Re: Could you verify this, Oh Great Unicode Experts of the Python-List?

2013-08-12 Thread Gregory Ewing

Michael Torrie wrote:

I've always wondered if the 160 character limit or whatever it is is a
hard limit in their system, or if it's just a variable they could tweak
if they felt like it.


Isn't it for compatibility with SMS? Twitter could
probably change it, but persuading all the cell phone
networks to change at the same time might be rather
difficult.

--
Greg
--
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
darn i was hoping i could put off learning classes for a bit, but it seems that 
is not the case. i have tested it a bit and it seems to be working correctly 
now.


import random

class player():
hp = 10
speed = 5
attack = random.randint(0,5)

print (player.attack)

+++

i know it's not nearly as complicated as your examples but it seems to work. 
the self part of it always eluded me and continues to do so. and just so you 
know im learning through codecademy.com , it's based on python 2.7 and im 
trying to code in 3.3. but thanks for your help again and classes are starting 
(i think) to make some sort of sense.i'll have to reread both replies over and 
over again but it looks like a lot of useful info is there. but is the example 
i posted sorta right? i know i left the self part out but i think im on the 
right track.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
import random

class player():
hp = 10
attack = random.randint(0,5)

class monster():
hp = 10
attack = random.randint(0,4)


def battle():
print (a wild mosnter appered!)
print (would you like to battle?)
answer = input()
if answer == (yes):
while monster.hp =0:
print (you do, player.attack, damage)
monster.hp -= player.attack
print (monster.hp)
elif answer == (no):
print (you run away)
else:
print(you stand there)



battle()




Hello! just wanted to show you guys how its coming together, im starting to 
understand it abit more (hopefully it's right) at the moment it seems to only 
roll the attack once and uses that value but that's another issue all together 
that i bother you with (yet anyway).

thanks again guys you are awesome
-- 
http://mail.python.org/mailman/listinfo/python-list


[ANN] New article:

2013-08-12 Thread mauricel...@acm.org
Dear all

The following article had been peer-reviewed and accepted by The Python Papers.

Title: A Python Module for FITS Files with full C Level Programming 
Functionality

Abstract: A Python module for manipulating files in the FITS format is 
described. The module was constructed using the capabilites of ctypes to 
dynamically create foreign function interfaces from a C library. Here this was 
used to import the CFITSIO library into Python. I describe how this module can 
be used to call the functions from the C library in their near native form, and 
how one to manipulate FITS files in a style that Python programmers are 
accustomed. The ctypes and ctypeslib modules allows one to import all routines 
and data structures from the C library and avoids the need to manually write 
language bindings for each routine. Moreover, these modules allow the Python 
programmer to enjoy the full functionality of the the underlying C library.

http://ojs.pythonpapers.org/index.php/tpp/article/view/250

Maurice Ling
Co-EIC, The Python Papers
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Dave Angel
Kris Mesenbrink wrote:

 darn i was hoping i could put off learning classes for a bit, but it seems 
 that is not the case. i have tested it a bit and it seems to be working 
 correctly now.

 
 import random

 class player():
 hp = 10
 speed = 5
 attack = random.randint(0,5)

 print (player.attack)

 +++

 i know it's not nearly as complicated as your examples but it seems to work. 
 the self part of it always eluded me and continues to do so. and just so you 
 know im learning through codecademy.com , it's based on python 2.7 and im 
 trying to code in 3.3. but thanks for your help again and classes are 
 starting (i think) to make some sort of sense.i'll have to reread both 
 replies over and over again but it looks like a lot of useful info is there. 
 but is the example i posted sorta right? i know i left the self part out but 
 i think im on the right track.

The complication was there for good reason.

If you are sure you'll never have more than one player, this could work.
 i don't see the advantage over (ugh) global variables, however.

But what happens when you have four monsters instead of one?  A class
provides you a way to store data for each instance, not just for the
class as a whole.  And the self convention is kind of analogous to the
English myself.  If you're inside an ordinary method, you refer to
yourself as self.

By the way, by convention, class names are capitalized.  That's why i
called it Player.
-- 
DaveA


-- 
http://mail.python.org/mailman/listinfo/python-list


Calling Python macro from ctypes

2013-08-12 Thread Steven D'Aprano
Is it possible to call a Python macro from ctypes? For example, Python 
3.3 introduces some new macros for querying the internal representation 
of strings:

http://www.python.org/dev/peps/pep-0393/#new-api


So I try this in 3.3:

py import ctypes
py ctypes.pythonapi.PyUnicode_MAX_CHAR_VALUE
Traceback (most recent call last):
  File stdin, line 1, in module
  File /usr/local/lib/python3.3/ctypes/__init__.py, line 366, in 
__getattr__
func = self.__getitem__(name)
  File /usr/local/lib/python3.3/ctypes/__init__.py, line 371, in 
__getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: python3.3: undefined symbol: PyUnicode_MAX_CHAR_VALUE





-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling Python macro from ctypes

2013-08-12 Thread Peter Otten
Steven D'Aprano wrote:

 Is it possible to call a Python macro from ctypes? For example, Python
 3.3 introduces some new macros for querying the internal representation
 of strings:
 
 http://www.python.org/dev/peps/pep-0393/#new-api
 
 
 So I try this in 3.3:
 
 py import ctypes
 py ctypes.pythonapi.PyUnicode_MAX_CHAR_VALUE
 Traceback (most recent call last):
   File stdin, line 1, in module
   File /usr/local/lib/python3.3/ctypes/__init__.py, line 366, in
 __getattr__
 func = self.__getitem__(name)
   File /usr/local/lib/python3.3/ctypes/__init__.py, line 371, in
 __getitem__
 func = self._FuncPtr((name_or_ordinal, self))
 AttributeError: python3.3: undefined symbol: PyUnicode_MAX_CHAR_VALUE

That's not possible. It may look like a function, but a preprocessor 
replaces the C macro in the C source before compilation. An example of very 
bad usage of macros, just to drive the point home:

$ cat macro.c 
#define IF(expr) if (expr) {
#define ENDIF ;}

main()
{
  IF(10)
printf(It worked\n)
  ENDIF
}

And here's what the compiler sees:

$ gcc -E -P macro.c



main()
{
  if (10) {
printf(It worked\n)
  ;}
}


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Devyn Collier Johnson


On 08/10/2013 10:47 PM, Chris Angelico wrote:

On Sun, Aug 11, 2013 at 3:43 AM, Roy Smith r...@panix.com wrote:

In article mailman.452.1376188442.1251.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:


When you get a syntax error you can't understand, look at the previous
line of code. Perhaps something there is incomplete; maybe you have
mismatched parentheses, so this line is considered to be part of the
same expression.

Next thing to do is split it into more lines. Why is all that in a single
line?

Also, try reformatting the code in a tool like emacs or eclipse which
does syntax coloring and auto indenting.  Often, if you're missing some
piece of punctuation, it will become obvious when your tool tries to
indent things in some unexpected way.  Or suddenly starts coloring all
of your program text as if it were a string literal :-)

Agreed. Though I've had some odd issues with SciTE in that way; I
think its Python handling may have bugs in it here and there. But 95%
of the time it's helpful.

ChrisA


Thanks everyone. Unfortunately, I have not found the problem yet. I use 
the Geany IDE which has syntax highlighting, but nothing wrong is seen. 
None of the suggestions helped. The lines before this one set variables. 
The lines further up appear fine. I will keep looking. If I ever 
figure it out, I will share with all of you.


As for the code being one line, my style of coding is very different 
from others. I try to keep similar or related tasks on one line. 
Programming like that is called trolling. A programmer that uses 
trolling is called a troll. A troll can also refer to such a line of 
code itself. My scripts contain a lot of trolls. It is easier for me to 
read trolls than typical coding styles. (Yes, I am a weird troll (^u^))


Mahalo,

devyncjohn...@gmail.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Zachary Ware
On Mon, Aug 12, 2013 at 7:33 AM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:

 On 08/10/2013 10:47 PM, Chris Angelico wrote:

 On Sun, Aug 11, 2013 at 3:43 AM, Roy Smith r...@panix.com wrote:

 In article mailman.452.1376188442.1251.python-l...@python.org,
   Chris Angelico ros...@gmail.com wrote:

 When you get a syntax error you can't understand, look at the previous
 line of code. Perhaps something there is incomplete; maybe you have
 mismatched parentheses, so this line is considered to be part of the
 same expression.

 Next thing to do is split it into more lines. Why is all that in a
 single
 line?

 Also, try reformatting the code in a tool like emacs or eclipse which
 does syntax coloring and auto indenting.  Often, if you're missing some
 piece of punctuation, it will become obvious when your tool tries to
 indent things in some unexpected way.  Or suddenly starts coloring all
 of your program text as if it were a string literal :-)

 Agreed. Though I've had some odd issues with SciTE in that way; I
 think its Python handling may have bugs in it here and there. But 95%
 of the time it's helpful.

 ChrisA


 Thanks everyone. Unfortunately, I have not found the problem yet. I use the
 Geany IDE which has syntax highlighting, but nothing wrong is seen. None of
 the suggestions helped. The lines before this one set variables. The lines
 further up appear fine. I will keep looking. If I ever figure it out, I
 will share with all of you.

 As for the code being one line, my style of coding is very different from
 others. I try to keep similar or related tasks on one line. Programming like
 that is called trolling. A programmer that uses trolling is called a troll.
 A troll can also refer to such a line of code itself. My scripts contain a
 lot of trolls. It is easier for me to read trolls than typical coding
 styles.

Obviously not, since you can't find the syntax error.  If you replace
each semicolon in that line with a newline, the syntax error will be
immediately obvious.  I'll even give you a hint: it's on the third
line.

-- 
Zach
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Ned Batchelder


On 8/12/13 8:33 AM, Devyn Collier Johnson wrote:


On 08/10/2013 10:47 PM, Chris Angelico wrote:

On Sun, Aug 11, 2013 at 3:43 AM, Roy Smith r...@panix.com wrote:

In article mailman.452.1376188442.1251.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:


When you get a syntax error you can't understand, look at the previous
line of code. Perhaps something there is incomplete; maybe you have
mismatched parentheses, so this line is considered to be part of the
same expression.

Next thing to do is split it into more lines. Why is all that in a 
single

line?

Also, try reformatting the code in a tool like emacs or eclipse which
does syntax coloring and auto indenting.  Often, if you're missing some
piece of punctuation, it will become obvious when your tool tries to
indent things in some unexpected way.  Or suddenly starts coloring all
of your program text as if it were a string literal :-)

Agreed. Though I've had some odd issues with SciTE in that way; I
think its Python handling may have bugs in it here and there. But 95%
of the time it's helpful.

ChrisA


Thanks everyone. Unfortunately, I have not found the problem yet. I 
use the Geany IDE which has syntax highlighting, but nothing wrong is 
seen. None of the suggestions helped. The lines before this one set 
variables. The lines further up appear fine. I will keep looking. If 
I ever figure it out, I will share with all of you.


As Terry Reedy pointed out, you have semicolons separating arguments in 
a function call.  This is your line of code:


JOB_WRITEURGFILES = 
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID); 
write2file(SENTEMPPATH, ''); write2file(INPUTMEM, '')); 
JOB_WRITEURGFILES.start()


Replacing names with shorter ones to see the structure, it's like this:

J = m.P( w('', E); w(S, ''); w(I, '') ); J.s()

You have three semicolons in that line.  Two are inside a call, though 
I'm not sure that's what you intended.  One is separating statements.  
You might be a little too attached to your more readable style.  
Putting things on different lines really does help you see what is going on.


--Ned.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Devyn Collier Johnson


On 08/12/2013 09:20 AM, Zachary Ware wrote:

On Mon, Aug 12, 2013 at 7:33 AM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:

On 08/10/2013 10:47 PM, Chris Angelico wrote:

On Sun, Aug 11, 2013 at 3:43 AM, Roy Smith r...@panix.com wrote:

In article mailman.452.1376188442.1251.python-l...@python.org,
   Chris Angelico ros...@gmail.com wrote:


When you get a syntax error you can't understand, look at the previous
line of code. Perhaps something there is incomplete; maybe you have
mismatched parentheses, so this line is considered to be part of the
same expression.

Next thing to do is split it into more lines. Why is all that in a
single
line?

Also, try reformatting the code in a tool like emacs or eclipse which
does syntax coloring and auto indenting.  Often, if you're missing some
piece of punctuation, it will become obvious when your tool tries to
indent things in some unexpected way.  Or suddenly starts coloring all
of your program text as if it were a string literal :-)

Agreed. Though I've had some odd issues with SciTE in that way; I
think its Python handling may have bugs in it here and there. But 95%
of the time it's helpful.

ChrisA


Thanks everyone. Unfortunately, I have not found the problem yet. I use the
Geany IDE which has syntax highlighting, but nothing wrong is seen. None of
the suggestions helped. The lines before this one set variables. The lines
further up appear fine. I will keep looking. If I ever figure it out, I
will share with all of you.

As for the code being one line, my style of coding is very different from
others. I try to keep similar or related tasks on one line. Programming like
that is called trolling. A programmer that uses trolling is called a troll.
A troll can also refer to such a line of code itself. My scripts contain a
lot of trolls. It is easier for me to read trolls than typical coding
styles.

Obviously not, since you can't find the syntax error.  If you replace
each semicolon in that line with a newline, the syntax error will be
immediately obvious.  I'll even give you a hint: it's on the third
line.


Zachary, are you, Ned, and Terry trying to say the syntax should be

job = multiprocessing.Process(func1(), func2())

not

job = multiprocessing.Process(func1(); func2())

DCJ

--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread John Gordon
In mailman.451.1376187574.1251.python-l...@python.org Devyn Collier Johnson 
devyncjohn...@gmail.com writes:

 I am checking my 1292-line script for syntax errors. I ran the following 
 commands in a terminal to check for errors, but I do not see the error.

File ./beta_engine, line 344
  JOB_WRITEURGFILES = 
 multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID); 

You have too many ('s this line.

 write2file(SENTEMPPATH, ''); write2file(INPUTMEM, '')); 

And too many )'s on this one.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Rotwang

On 12/08/2013 06:54, Dave Angel wrote:

[...]

This function makes no sense to me.  A function should have three
well-defined pieces:  what are its parameters, what does it do, what are
its side-effects, and what does it return.


No! A function should have *four* well-defined pieces: what are its 
parameters, what does it do, what are its side-effects, what does it 
return, and an almost fanatical devotion to the Pope [etc.]

--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Zachary Ware
On Mon, Aug 12, 2013 at 9:04 AM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:

 Zachary, are you, Ned, and Terry trying to say the syntax should be

 job = multiprocessing.Process(func1(), func2())

 not

 job = multiprocessing.Process(func1(); func2())


Basically, yes.  The first option there is equivalent to this:

func_returns = (func1(), func2())

job = multiprocessing.Process(*func_returns)

The second option is equivalent to this:

job = multiprocessing.Process(func1()

func2())

...which is actually several different syntax errors, depending on how
you look at it.  Semi-colon is only ever used in Python as a
substitute for \n-plus-some-spaces.  And, since in your original
example, your semi-colons are inside parenthesis, they really have no
effect at all due to implicit line continuation within parens.  So
your original line:

JOB_WRITEURGFILES =
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID);
write2file(SENTEMPPATH, ''); write2file(INPUTMEM, ''));
JOB_WRITEURGFILES.start()

is really:

JOB_WRITEURGFILES =
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID)
write2file(SENTEMPPATH, '') write2file(INPUTMEM, ''))

JOB_WRITEURGFILES.start()

It should be obvious now that the syntax error comes from not
separating the arguments to Process.

Trying to read between the lines a little here, I don't think you have
quite figured out how multiprocessing.Process works; that first option
above will only work if func1 returns None and func2 returns a
callable object and the second has no hope.  I think this is more
along the lines of what you're really after:

def process_func():
func1()
func2()

if __name__ == '__main__':
job = multiprocessing.Process(target=process_func) # note: no
() after process_func!
job.start()

I'd suggest giving the multiprocessing.Process docs [0] a good
read-through.  Keep in mind that Process is just a type like any other
(str, int, list, etc.), and calling its constructor is subject to the
same rules as any other function call.


-- 
Zach

[0] http://docs.python.org/3/library/multiprocessing#the-process-class
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Zachary Ware
On Mon, Aug 12, 2013 at 10:37 AM, Zachary Ware
zachary.ware+pyl...@gmail.com wrote:
 [snip my last reply with a few code samples]

My apologies for Gmail's mangling of my samples.  Any code that is not
indented should be on the previous line.

-- 
Zach
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Roy Smith
I can't quite sort out the multiple quoting levels, but somebody said:

 Programming like that is called trolling. A programmer that uses 
 trolling is called a troll. A troll can also refer to such a line 
 of code itself. My scripts contain a lot of trolls. It is easier 
 for me to read trolls than typical coding styles.

Please tell me this is all just an elaborate joke.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Joel Goldstick
On Mon, Aug 12, 2013 at 11:47 AM, Roy Smith r...@panix.com wrote:
 I can't quite sort out the multiple quoting levels, but somebody said:

 Programming like that is called trolling. A programmer that uses
 trolling is called a troll. A troll can also refer to such a line
 of code itself. My scripts contain a lot of trolls. It is easier
 for me to read trolls than typical coding styles.

 Please tell me this is all just an elaborate joke.

I was thinking something similar Roy.  Devyn, you may think you code
differently, but you don't.  You have a half of dozen people trying to
show you how your style causes confusion between what you think you
are writing and what you actually coded.  There is plenty of room in
coding for personal expression, but what you call 'trolling' is not
that.  If you like semicolons, use another language that needs them.
I think you think it is some version of premature optimization.  Since
you are a novice at the language, stick with the standards, and learn
to embrace them.  Ultimately standard coding styles has nothing to do
with code optimization.  It has to do with readability.  Although this
is a small example, you can see that if several people get involved
debugging it, the first thing that gets in the way is your
non-standard coding style.  If you want to code alone your whole life,
do as you like.  But the time spent reading and fixing code in the
lifetime of any useful software system is greater than the time spent
creating the original code.
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Calling Python macro from ctypes

2013-08-12 Thread Dave Angel
Peter Otten wrote:

 Steven D'Aprano wrote:

 Is it possible to call a Python macro from ctypes? For example, Python
 3.3 introduces some new macros for querying the internal representation
 of strings:
 
 http://www.python.org/dev/peps/pep-0393/#new-api
 
 
 So I try this in 3.3:
 
 py import ctypes
 py ctypes.pythonapi.PyUnicode_MAX_CHAR_VALUE
 Traceback (most recent call last):
   File stdin, line 1, in module
   File /usr/local/lib/python3.3/ctypes/__init__.py, line 366, in
 __getattr__
 func = self.__getitem__(name)
   File /usr/local/lib/python3.3/ctypes/__init__.py, line 371, in
 __getitem__
 func = self._FuncPtr((name_or_ordinal, self))
 AttributeError: python3.3: undefined symbol: PyUnicode_MAX_CHAR_VALUE

 That's not possible. It may look like a function, but a preprocessor 
 replaces the C macro in the C source before compilation. An example of very 
 bad usage of macros, just to drive the point home:

 $ cat macro.c 
 #define IF(expr) if (expr) {
 #define ENDIF ;}

 main()
 {
   IF(10)
 printf(It worked\n)
   ENDIF
 }

 And here's what the compiler sees:

 $ gcc -E -P macro.c



 main()
 {
   if (10) {
 printf(It worked\n)
   ;}
 }


To elaborate a bit more, Python can only see those symbols that are put
into the shared library  They can be functions, and they can be
values, but they don't include macros, which are processed by the
preprocessor, before the real C compiler even starts.  C Macros are
actually text-substitution rules.  They can look like functions, but
those functions do not end up in the shared library.

In Windows, you can use dumpbin to examine a DLL and see what symbols it
exports.  I don't remember the syntax; it's been years.

I assume there's a similar tool for Linux to examine a shared library
(typically an .so file).  Perhaps readelf and/or nm is such a tool,
but I don't really know. Although I've been using Python and C++ in
Linux in recent years, I haven't used them together, and neither have
I had to examine a shared library.

The following link looks interesting, but I haven't read it yet.

http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

-- 
DaveA


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Chris Angelico
On Mon, Aug 12, 2013 at 5:56 PM, Joel Goldstick
joel.goldst...@gmail.com wrote:
 If you like semicolons, use another language that needs them.
 I think you think it is some version of premature optimization.  Since
 you are a novice at the language, stick with the standards, and learn
 to embrace them.

I'm a C programmer who really likes his semicolons, and I often write
long lines. But I still was right up there early on saying split this
line. It definitely wants to be split. And when *I* say that, it must
be pretty notably splittable. :)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


SSL issues in Python stdlib and 3rd party code

2013-08-12 Thread Christian Heimes
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA512

Hello,

(re-post from the Python developer list)

last week Ryan Sleevi of the Google Chrome Security Team has informed
us about about two issues in Python's SSL module. I already new about
the cause of the first bug and suspected that our SSL module suffers
from the second bug but I was unable to prove it.

Both issues are security issues but their impact is limited if you
trust only trustworthy root certification authorities. Any decent root
CA would should not sign a malicious cert with NULL bytes in a
subjectAltName dNSName field or with wildcards like *.*.com.

By the way if you are using the cacert.pem from curl, please update
your bundle ASAP. I have found a bug in its Mozilla certdata parser, too.


bug #1: ssl.match_hostname() wildcard matching
- --

ssl.match_hostname() doesn't implement RFC 6125 wildcard matching rules.

Affected versions:

- - Python 3.2 ( 3.2.5)
- - Python 3.3 ( 3.3.3)
- - Python 3.4a1
- - requests  1.2.3
  https://pypi.python.org/pypi/requests
- - backports.ssl_match_hostname (3.2a3)
  https://pypi.python.org/pypi/backports.ssl_match_hostname/
- - urllib3  1.6
  https://github.com/shazow/urllib3

Bug reports:

  http://bugs.python.org/issue17997
  https://github.com/kennethreitz/requests/issues/1528

https://bitbucket.org/brandon/backports.ssl_match_hostname/issue/2/match_hostname-doesnt-implement-rfc-6125

Patch:

  http://bugs.python.org/issue17997 has a preliminary patch. The
  handling of IDN A-labels is still a bit controversial, though.


bug #2 failure to handle NULL bytes in subjectAltName
- -

It's basically the same issue as CVE-2013-4073. Python uses
GENERAL_NAME_print() to turn a GERNAL_NAME entry into a C string. But
GENERAL_NAME_print() doesn't handle embedded NULL bytes in
ASN1_STRINGs correctly. You can read more about the issue at
http://www.ruby-lang.org/en/news/2013/06/27/hostname-check-bypassing-vulnerability-in-openssl-client-cve-2013-4073/

Affected versions:

- - Python 2.6 ( 2.6.8)
- - Python 2.7 ( 2.7.5)
- - Python 3.2 ( 3.2.5)
- - Python 3.3 ( 3.3.3)
- - Python 3.4a1
- - PyOpenSSL  0.13
  https://pypi.python.org/pypi/pyOpenSSL
- - eGenix.com pyOpenSSL Distribution with PyOpenSSL  0.13
  https://pypi.python.org/pypi/M2Crypto
- - M2Crypto  0.21.1
  http://www.egenix.com/products/python/pyOpenSSL/

Bug report:

  http://bugs.python.org/issue18709

Patches:

  http://bugs.python.org/issue18709 has patches for 2.7, 3.3 and default
  https://code.launchpad.net/~heimes/pyopenssl/pyopenssl/+merge/179673


Jean-Paul Calderone is going to release 0.13.1 soonish. It's going to
contain just my fix for the issue. Marc-Andre Lemburg will build a new
version of eGenix.com pyOpenSSL Distribution shortly after.

I'm not going to work on a patch for M2Crypto as I don't understand
SWIG. I have contacted Heikki Toivonen for M2Crypto but haven't heard
back from him yet.


related issue: Mozilla's certdata.txt and CKT_NSS_MUST_VERIFY_TRUST
- ---

Recently I found bugs in curl's mk-ca-bundle.pl script, its cacert.pem
and in the CA bundle of eGenix.com pyOpenSSL Distribution. Both failed
to handle a new option in Mozilla's certdata.txt database correctly.
As a consequence the root CA bundles contained additionally and
untrustworthy root certificates. I'm not sure about the severity of
the issue.

Curl has already fixed its script week ago. Marc-Andre Lemburg is
going to release a new distribution very soon.

  https://github.com/bagder/curl/commit/51f0b798fa
  http://curl.haxx.se/docs/caextract.html

Background information:

  https://www.imperialviolet.org/2012/01/30/mozillaroots.html
  http://lists.debian.org/debian-release/2012/11/msg00411.html

http://p11-glue.freedesktop.org/doc/storing-trust-policy/storing-trust-existing.html



I like to thank Ryan Sleevi (Google), Chris Palmer (Google),
Marc-Andre Lemburg (eGenix.com, Python core dev), Jean-Paul Calderone
(PyOpenSSL), Antoine Pitrou (Python core dev), Daniel Stenberg (curl),
Günter Knauf (curl) and everybody else who was involved in reporting
and fixing these issues.


Regards,
Christian
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQIcBAEBCgAGBQJSCRlqAAoJEMeIxMHUVQ1Fmq0QAJoKFK3V1iiB+3hhvPfJGnLn
pSMzm9CpIineF7KRSI50GYls7gwO5Nggqol2V7qcEzpRCPFxkV9E2t75Q8OnBW0+
ZHOoTjpLD086HeQ4oIcGN6byQcHwIbIVh74hRFu7ZW4jqLQwvyPrGwRonRv5a6nG
0tRqp/Swqyqvo4KTpxV26MdZNwD+c+ASO0gmQzW6SURS5/gUKv0fDWjUwqC9COdZ
Xz9wsLZaul+e6ewH7N5c7EWRXEs8l8cVk68Jw+/Jshct4kfWUnnw67qPjcoDgHLI
tZzjVy7aCp2V9vjKvAcM2OUz0Q5h1rIFc5Roh5yH8OxuOn+Zn6zs3M6DKHJI9n12
JTTyi4yBu5hBRFqOWYSicytQpHAT604zpaGY7g4Hd0J98tG0kuT0BC7tozdi+MUW
eXuBML7uYOBlI/VCIv/baZAaRj1txPZl5Vf9a75N2lb2seavUJDu8HqOzh+zxSTC
9agPuGAJOrU5mljkBKCCVy6/4njktjOBDmQsf9OHZ0/FolBjQuiJyXp4hLMQMqzY

Re: connection change

2013-08-12 Thread Joel Goldstick
On Sun, Aug 11, 2013 at 7:50 PM, Inna Belakhova
inna.belakh...@melbourne.vic.gov.au wrote:
 Hi,

 I don't know much about Python code. Where is the connection made, eg
 config file - where can I find it?

 Our SQLITe database is currently 9GB and we have a table that contains
 7GB of BLOB type. I think the table cannot handle any more insert of
 BLOB hence I want to change it to SQL database - which has no
 restriction on database size.

 Any suggestions?

use google: python mssql





 Cheers,
 Inna


-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread random832
On Mon, Aug 12, 2013, at 10:56, Rotwang wrote:
 No! A function should have *four* well-defined pieces: what are its 
 parameters, what does it do, what are its side-effects, what does it 
 return, and an almost fanatical devotion to the Pope [etc.]

To be fair, I can't think of what what does it do includes other than
the side-effects and the return.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Devyn Collier Johnson


On 08/12/2013 12:56 PM, Joel Goldstick wrote:

On Mon, Aug 12, 2013 at 11:47 AM, Roy Smith r...@panix.com wrote:

I can't quite sort out the multiple quoting levels, but somebody said:


Programming like that is called trolling. A programmer that uses
trolling is called a troll. A troll can also refer to such a line
of code itself. My scripts contain a lot of trolls. It is easier
for me to read trolls than typical coding styles.

Please tell me this is all just an elaborate joke.

I was thinking something similar Roy.  Devyn, you may think you code
differently, but you don't.  You have a half of dozen people trying to
show you how your style causes confusion between what you think you
are writing and what you actually coded.  There is plenty of room in
coding for personal expression, but what you call 'trolling' is not
that.  If you like semicolons, use another language that needs them.
I think you think it is some version of premature optimization.  Since
you are a novice at the language, stick with the standards, and learn
to embrace them.  Ultimately standard coding styles has nothing to do
with code optimization.  It has to do with readability.  Although this
is a small example, you can see that if several people get involved
debugging it, the first thing that gets in the way is your
non-standard coding style.  If you want to code alone your whole life,
do as you like.  But the time spent reading and fixing code in the
lifetime of any useful software system is greater than the time spent
creating the original code.

--
http://mail.python.org/mailman/listinfo/python-list





I know using semicolons will not optimize the code, but it is actually 
easier for me to read. I can handle such code better than spacing it out.


DCJ
--
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Joel Goldstick
On Mon, Aug 12, 2013 at 4:16 PM, Devyn Collier Johnson
devyncjohn...@gmail.com wrote:

 On 08/12/2013 12:56 PM, Joel Goldstick wrote:

 On Mon, Aug 12, 2013 at 11:47 AM, Roy Smith r...@panix.com wrote:

 I can't quite sort out the multiple quoting levels, but somebody said:

 Programming like that is called trolling. A programmer that uses
 trolling is called a troll. A troll can also refer to such a line
 of code itself. My scripts contain a lot of trolls. It is easier
 for me to read trolls than typical coding styles.

 Please tell me this is all just an elaborate joke.

 I was thinking something similar Roy.  Devyn, you may think you code
 differently, but you don't.  You have a half of dozen people trying to
 show you how your style causes confusion between what you think you
 are writing and what you actually coded.  There is plenty of room in
 coding for personal expression, but what you call 'trolling' is not
 that.  If you like semicolons, use another language that needs them.
 I think you think it is some version of premature optimization.  Since
 you are a novice at the language, stick with the standards, and learn
 to embrace them.  Ultimately standard coding styles has nothing to do
 with code optimization.  It has to do with readability.  Although this
 is a small example, you can see that if several people get involved
 debugging it, the first thing that gets in the way is your
 non-standard coding style.  If you want to code alone your whole life,
 do as you like.  But the time spent reading and fixing code in the
 lifetime of any useful software system is greater than the time spent
 creating the original code.

 --
 http://mail.python.org/mailman/listinfo/python-list




 I know using semicolons will not optimize the code, but it is actually
 easier for me to read. I can handle such code better than spacing it out.

Except it doesn't make it easier to read.


JOB_WRITEURGFILES =
multiprocessing.Process(write2file('./mem/ENGINE_PID', ENGINEPID);
write2file(SENTEMPPATH, ''); write2file(INPUTMEM, ''));
JOB_WRITEURGFILES.start()

As I understand it the above line of code caused you problems.  I
don't know what muliprocessing.Process() is supposed to have as
arguments, but I don't think is can have arguments with semicolons,
unless they appeared in a string.

So your semicolons, that you insist make your code easier to read,
have made code that doesn't work, and you don't know why.  All I am
saying is you are stating a fact not in evidence.  You only think the
semicolons are useful because you haven't taken the time to read and
write enough python code to appreciate that they are not only not
helpful, but they serve no useful purpose.  Sure, they allow you to
put several statements on a single line.  But that isn't what you were
doing.

good luck.  I can see you are interested.  keep at it.





 DCJ
 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
Joel Goldstick
http://joelgoldstick.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Am I not seeing the Error?

2013-08-12 Thread Ned Batchelder


On 8/12/13 4:16 PM, Devyn Collier Johnson wrote:


On 08/12/2013 12:56 PM, Joel Goldstick wrote:

On Mon, Aug 12, 2013 at 11:47 AM, Roy Smith r...@panix.com wrote:

I can't quite sort out the multiple quoting levels, but somebody said:


Programming like that is called trolling. A programmer that uses
trolling is called a troll. A troll can also refer to such a line
of code itself. My scripts contain a lot of trolls. It is easier
for me to read trolls than typical coding styles.

Please tell me this is all just an elaborate joke.

I was thinking something similar Roy.  Devyn, you may think you code
differently, but you don't.  You have a half of dozen people trying to
show you how your style causes confusion between what you think you
are writing and what you actually coded.  There is plenty of room in
coding for personal expression, but what you call 'trolling' is not
that.  If you like semicolons, use another language that needs them.
I think you think it is some version of premature optimization. Since
you are a novice at the language, stick with the standards, and learn
to embrace them.  Ultimately standard coding styles has nothing to do
with code optimization.  It has to do with readability. Although this
is a small example, you can see that if several people get involved
debugging it, the first thing that gets in the way is your
non-standard coding style.  If you want to code alone your whole life,
do as you like.  But the time spent reading and fixing code in the
lifetime of any useful software system is greater than the time spent
creating the original code.

--
http://mail.python.org/mailman/listinfo/python-list





I know using semicolons will not optimize the code, but it is actually 
easier for me to read. I can handle such code better than spacing it out.
There's no point debating the readability of code that doesn't work.  
Get it functioning first, then let's talk about how best to format it.


--Ned.



DCJ


--
http://mail.python.org/mailman/listinfo/python-list


Digging into multiprocessing

2013-08-12 Thread Demian Brecht
Hi all,

Some work that I'm doing atm is in some serious need of
parallelization. As such, I've been digging into the multiprocessing
module more than I've had to before and I had a few questions come up
as a result:

(Running 2.7.5+ on OSX)

1. From what I've read, a new Python interpreter instance is kicked
off for every worker. My immediate assumption was that the file that
the code was in would be reloaded for every instance. After some
digging, this is obviously not the case (print __name__ at the top of
the file only yield a single output line). So, I'm assuming that
there's some optimization that passes of the bytecode within the
interpreter? How, exactly does this work? (I couldn't really find much
in the docs about it, or am I just not looking in the right place?)

2. For cases using methods such as map_async/wait, once the bytecode
has been passed into the child process, `target` is called `n` times
until the current queue is empty. Is this correct?

3. Because __main__ is only run when the root process imports, if
using global, READ-ONLY objects, such as, say, a database connection,
then it might be better from a performance standpoint to initialize
that at main, relying on the interpreter references to be passed
around correctly. I've read some blogs and such that suggest that you
should create a new database connection within your child process
targets (or code called into by the targets). This seems to be less
than optimal to me if my assumption is correct.

4. Related to 3, read-only objects that are initialized prior to being
passed into a sub-process are safe to reuse as long as they are
treated as being immutable. Any other objects should use one of the
shared memory features.

Is this more or less correct, or am I just off my rocker?

Thanks,

-- 

Demian Brecht
http://demianbrecht.github.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Could you verify this, Oh Great Unicode Experts of the Python-List?

2013-08-12 Thread Michael Torrie
On 08/11/2013 11:54 PM, Gregory Ewing wrote:
 Michael Torrie wrote:
 I've always wondered if the 160 character limit or whatever it is is a
 hard limit in their system, or if it's just a variable they could tweak
 if they felt like it.
 
 Isn't it for compatibility with SMS? Twitter could
 probably change it, but persuading all the cell phone
 networks to change at the same time might be rather
 difficult.

Yes I think you're correct about it being limited for SMS.

However I know of no phone or network that won't let you use longer
messages; multiple SMS packets are used and most phone paste them back
together.  So no there's nothing that anyone needs to change to use
longer messages if they so chose.  It's now just an arbitrary limit,
part of the twitter culture.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Could you verify this, Oh Great Unicode Experts of the Python-List?

2013-08-12 Thread Chris Angelico
On Tue, Aug 13, 2013 at 2:48 AM, Michael Torrie torr...@gmail.com wrote:
 On 08/11/2013 11:54 PM, Gregory Ewing wrote:
 Michael Torrie wrote:
 I've always wondered if the 160 character limit or whatever it is is a
 hard limit in their system, or if it's just a variable they could tweak
 if they felt like it.

 Isn't it for compatibility with SMS? Twitter could
 probably change it, but persuading all the cell phone
 networks to change at the same time might be rather
 difficult.

 Yes I think you're correct about it being limited for SMS.

 However I know of no phone or network that won't let you use longer
 messages; multiple SMS packets are used and most phone paste them back
 together.  So no there's nothing that anyone needs to change to use
 longer messages if they so chose.  It's now just an arbitrary limit,
 part of the twitter culture.

It's unlikely to be changed; the limit demands brevity. 160 may be
arbitrary now, but without strong argument for another cutoff, there's
no reason to alter it.

And that's my response, in 160 characters. :)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread Kris Mesenbrink
the Classes and __init__ still don't make much sense actually. i have tried and 
tried again to make it generate numbers between 0 and 5 in a while statement 
but it just doesn't seem to be working. 

import random


class Player():
hp = 10
def __init__(self, patt):
self.att = random.randint(0,5)



while Player.hp == 10:
print (Player.__init__)

atm it seems to be printing function Player.__init__ at 0x02954EA0 
over and over again, i don't mind the repetition but from my understanding 
there should be numbers there. numbers that change. crazy frustrating that i 
just don't understand how this works.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Could you verify this, Oh Great Unicode Experts of the Python-List?

2013-08-12 Thread Jason Friedman
 I've always wondered if the 160 character limit or whatever it is is a
 hard limit in their system, or if it's just a variable they could tweak
 if they felt like it.

I thought it was 140 characters?
https://twitter.com/about
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: back with more issues

2013-08-12 Thread MRAB

On 13/08/2013 04:13, Kris Mesenbrink wrote:

the Classes and __init__ still don't make much sense actually. i have tried and 
tried again to make it generate numbers between 0 and 5 in a while statement 
but it just doesn't seem to be working.

import random


class Player():


This sets an attribute of the class:


 hp = 10


This method will be called to initialise an instance of the class when
one is created:


 def __init__(self, patt):


This sets an attribute of the instance:


 self.att = random.randint(0,5)



while Player.hp == 10:


This prints the __init__ method of the class:


 print (Player.__init__)

atm it seems to be printing function Player.__init__ at 0x02954EA0 
over and over again, i don't mind the repetition but from my understanding there should be 
numbers there. numbers that change. crazy frustrating that i just don't understand how this 
works.


At no point does it create an instance of the class, so the __init__
method is never called.

You can't return anything from the __init__ method because it's called
just to initialise the instance.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Could you verify this, Oh Great Unicode Experts of the Python-List?

2013-08-12 Thread MRAB

On 13/08/2013 04:20, Jason Friedman wrote:

I've always wondered if the 160 character limit or whatever it is is a
hard limit in their system, or if it's just a variable they could tweak
if they felt like it.


I thought it was 140 characters?
https://twitter.com/about


He did say or whatever. :-)
--
http://mail.python.org/mailman/listinfo/python-list


[issue18693] help() not helpful with enum

2013-08-12 Thread Ethan Furman

Ethan Furman added the comment:

Huh.  I just checked `help(Color)` on my proposed __dir__ and got the two-line, 
rather useless, response.  Perhaps help() is broken with all custom __dir__s.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-12 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Thanks, Benjamin, for reviewing my patch.

Attached the fourth patch to wrap the business part inside the try ... 
finally.

--
Added file: 
http://bugs.python.org/file31237/formatter_fix_resource_warning_v4.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18644
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-12 Thread Benjamin Peterson

Benjamin Peterson added the comment:

That will fail if fp is not assigned before an exception is raised. I mostly 
mean the part starting with the for loop.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18644
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-12 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Ah, sorry about that.

Attached the fifth patch to only wrap for loop section inside the try... 
finally.

--
Added file: 
http://bugs.python.org/file31238/formatter_fix_resource_warning_v5.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18644
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18606] Add statistics module to standard library

2013-08-12 Thread Mark Dickinson

Mark Dickinson added the comment:

About the implementation of sum: it's worth noting that the algorithm you're 
using for floats depends on correct rounding of addition and subtraction, and 
that that's not guaranteed.  See the existing test (testFsum) in test_math for 
more information, and note that that test is skipped on machines that don't do 
correct rounding.

This isn't an uncommon problem:  last time I looked, most 32-bit Linux systems 
had problems with double rounding, thanks to evaluating first to 64-bit 
precision using the x87 FPU, and then rounding to 53-bit precision as usual.  
(Python builds on 64-bit Linux tend to use the SSE2 instructions in preference 
to the x87, so don't suffer from this problem.)

Steven: any thoughts about how to deal with this?  Options are (1) just ignore 
the problem and hope no-one runs into it, (2) document it / warn about it, (3) 
try to fix it.  Fixing it would be reasonably easy for a C implementation (with 
access to the FPU control word, in the same way that our float-string 
conversion already does), but not so easy in Python without switching algorithm 
altogether.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18606
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18702] Report skipped tests as skipped

2013-08-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 Which one is the preferred way to go? requires or test needs or needs? 
 Or it does not matter?

I used the wording which used in other skips in the same file or in similar 
skips in other files. If it matters I will correct messages.

 Which one is the preferred way to go? With or without parentheses? Or it does 
 not matter?

Thank you for note. I will add missed parentheses to function names.

There are existing skip messages which uses function names without parentheses. 
I left them untouched (the patch already is a large enough).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18702
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16799] start using argparse.Namespace in regrtest

2013-08-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also issue17974.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16799
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16038] ftplib: unlimited readline() from connection

2013-08-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Error message got more than %d bytes is misleading because in most cases 
(except storlines()) we read not bytes but a text string.

There are 4 changes in the ftplib module but only one of them covered by test.

--
nosy: +serhiy.storchaka

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16038
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18606] Add statistics module to standard library

2013-08-12 Thread Mark Dickinson

Mark Dickinson added the comment:

From the code:

# Also, like all dunder methods, we should call
# __float__ on the class, not the instance.

Why?  I've never encountered this recommendation before.  x.__float__() would 
be clearer, IMO.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18606
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18606] Add statistics module to standard library

2013-08-12 Thread Mark Dickinson

Mark Dickinson added the comment:

 Why?  I've never encountered this recommendation before.  x.__float__()  
 would be clearer, IMO.

Hmm;  it would be better if I engaged by brain before commenting.  I guess the 
point is that type(x).__float__(x) better matches the behaviour of the builtin 
float:


 class A:
... def __float__(self): return 42.0
... 
 a = A()
 a.__float__ = lambda: 1729.0
 
 float(a)
42.0
 a.__float__()
1729.0
 type(a).__float__(a)
42.0


When you get around to tests, it would be nice to have a test for this 
behaviour, just so that someone who comes along and wonders the code is written 
this way gets an immediate test failure when they try to incorrectly simplify 
it.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18606
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18606] Add statistics module to standard library

2013-08-12 Thread Mark Dickinson

Mark Dickinson added the comment:

(We don't seem to care too much about the distinction in general, though:  
there are a good few places in the std. lib. where obj.__index__() is used 
instead of the more correct type(obj).__index__(obj).)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18606
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3526] Customized malloc implementation on SunOS and AIX

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

PEP 445 allows you to customize the Python memory allocators, which is a better 
solution than shipping several ones with Python ;-)

--
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18394] cgi.FieldStorage triggers ResourceWarning sometimes

2013-08-12 Thread Vajrasky Kok

Vajrasky Kok added the comment:

It happens because if the length of data is more than 1000:

def __write(self, line):
line is always bytes, not string
if self.__file is not None:
if self.__file.tell() + len(line)  1000:
self.file = self.make_file()
data = self.__file.getvalue()
self.file.write(data)
self.__file = None
..

it will create a temporary file.

Attached the patch to close the temporary file in the destructor method.

About the 1000 number, should we put it in constant? Why 1000? This number is 
so random. For now, I just leave it as it is.

--
keywords: +patch
nosy: +vajrasky
Added file: 
http://bugs.python.org/file31239/fix_resource_warning_in_test_cgi.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18394
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18700] test_cgi raises ResourceWarning

2013-08-12 Thread Vajrasky Kok

Vajrasky Kok added the comment:

Superseded by bug #18394.

Should we close this one by marking it as duplicate?

--
nosy: +vajrasky

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18700
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12075] python3.2 memory leak when reloading class with attributes

2013-08-12 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
resolution: wont fix - out of date

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12075
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12075] python3.2 memory leak when reloading class with attributes

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Yes, __del__ will interfere with garbage collection before Python 3.4. This is 
pretty much expected (and is fixed in Python 3.4, but won't be backported).

--
nosy: +pitrou
resolution:  - wont fix
stage:  - committed/rejected
status: open - closed
versions:  -Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12075
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1565525] tracebacks eat up memory by holding references to locals and globals when they are not wanted

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 We need maybe an helper to clear all frames referenced by a traceback?

Yes. Something in the traceback module would be fine.

--
components: +Library (Lib) -Interpreter Core
versions: +Python 3.4 -Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1565525
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Christian Heimes

New submission from Christian Heimes:

Ryan Sleevi of the Google Chrome Security Team has informed us that Python's 
SSL module doesn't handle NULL bytes inside subjectAltNames general names. It's 
related to Ruby's CVE-2013-4073 
http://www.ruby-lang.org/en/news/2013/06/27/hostname-check-bypassing-vulnerability-in-openssl-client-cve-2013-4073/

Although Python uses a slightly different OpenSSL API to parse a X.509 
certificate and turn its fields into a dictionary, our implementation 
eventually uses an OpenSSL function that fails to handle NULL bytes. This could 
lead to a breach when an application uses ssl.match_hostname() to match the 
hostname againt the certificate's subjectAltName's dNSName general names.

When the Ruby issues was announced publicly I already suspected that our code 
may suffer from the same issue. But I was unable to generate a X.509 
certificate with a NULL byte in its X509v3 subjectAltName extension, only in 
subject and issuer. OpenSSL's config file format just didn't support NULL 
bytes. But Our code handled the NULL byte in subject in issuer just fine so I 
gave up. In the light of the bug report I went a different path and eventually 
I came up with a malicious certificate that showed the reported bug.

--
components: Extension Modules
messages: 194944
nosy: christian.heimes
priority: critical
severity: normal
stage: patch review
status: open
title: SSL module fails to handle NULL bytes inside subjectAltNames general 
names (CVE-2013-4073)
type: security
versions: Python 2.6, Python 2.7, Python 3.2, Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


Added file: http://bugs.python.org/file31242/CVE-2013-4073_py33.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


--
keywords: +patch
Added file: http://bugs.python.org/file31241/CVE-2013-4073_py34.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Christian Heimes

Changes by Christian Heimes li...@cheimes.de:


Added file: http://bugs.python.org/file31243/CVE-2013-4073_py27.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Christian Heimes

Christian Heimes added the comment:

Demo certificate:

Certificate:
Data:
Version: 3 (0x2)
Serial Number: 0 (0x0)
Signature Algorithm: sha1WithRSAEncryption
Issuer: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, 
OU=Python Core Development, 
CN=null.python.org\x00example.org/emailAddress=python-...@python.org
Validity
Not Before: Aug  7 13:11:52 2013 GMT
Not After : Aug  7 13:12:52 2013 GMT
Subject: C=US, ST=Oregon, L=Beaverton, O=Python Software Foundation, 
OU=Python Core Development, 
CN=null.python.org\x00example.org/emailAddress=python-...@python.org
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:b5:ea:ed:c9:fb:46:7d:6f:3b:76:80:dd:3a:f3:
03:94:0b:a7:a6:db:ec:1d:df:ff:23:74:08:9d:97:
16:3f:a3:a4:7b:3e:1b:0e:96:59:25:03:a7:26:e2:
88:a9:cf:79:cd:f7:04:56:b0:ab:79:32:6e:59:c1:
32:30:54:eb:58:a8:cb:91:f0:42:a5:64:27:cb:d4:
56:31:88:52:ad:cf:bd:7f:f0:06:64:1f:cc:27:b8:
a3:8b:8c:f3:d8:29:1f:25:0b:f5:46:06:1b:ca:02:
45:ad:7b:76:0a:9c:bf:bb:b9:ae:0d:16:ab:60:75:
ae:06:3e:9c:7c:31:dc:92:2f:29:1a:e0:4b:0c:91:
90:6c:e9:37:c5:90:d7:2a:d7:97:15:a3:80:8f:5d:
7b:49:8f:54:30:d4:97:2c:1c:5b:37:b5:ab:69:30:
68:43:d3:33:78:4b:02:60:f5:3c:44:80:a1:8f:e7:
f0:0f:d1:5e:87:9e:46:cf:62:fc:f9:bf:0c:65:12:
f1:93:c8:35:79:3f:c8:ec:ec:47:f5:ef:be:44:d5:
ae:82:1e:2d:9a:9f:98:5a:67:65:e1:74:70:7c:cb:
d3:c2:ce:0e:45:49:27:dc:e3:2d:d4:fb:48:0e:2f:
9e:77:b8:14:46:c0:c4:36:ca:02:ae:6a:91:8c:da:
2f:85
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Basic Constraints: critical
CA:FALSE
X509v3 Subject Key Identifier:
88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C
X509v3 Key Usage:
Digital Signature, Non Repudiation, Key Encipherment
X509v3 Subject Alternative Name:
*
WARNING: The values for DNS, email and URI are WRONG. OpenSSL
 doesn't print the text after a NULL byte.
*
DNS:altnull.python.org, email:n...@python.org, 
URI:http://null.python.org, IP Address:192.0.2.1, IP 
Address:2001:DB8:0:0:0:0:0:1
Signature Algorithm: sha1WithRSAEncryption
 ac:4f:45:ef:7d:49:a8:21:70:8e:88:59:3e:d4:36:42:70:f5:
 a3:bd:8b:d7:a8:d0:58:f6:31:4a:b1:a4:a6:dd:6f:d9:e8:44:
 3c:b6:0a:71:d6:7f:b1:08:61:9d:60:ce:75:cf:77:0c:d2:37:
 86:02:8d:5e:5d:f9:0f:71:b4:16:a8:c1:3d:23:1c:f1:11:b3:
 56:6e:ca:d0:8d:34:94:e6:87:2a:99:f2:ae:ae:cc:c2:e8:86:
 de:08:a8:7f:c5:05:fa:6f:81:a7:82:e6:d0:53:9d:34:f4:ac:
 3e:40:fe:89:57:7a:29:a4:91:7e:0b:c6:51:31:e5:10:2f:a4:
 60:76:cd:95:51:1a:be:8b:a1:b0:fd:ad:52:bd:d7:1b:87:60:
 d2:31:c7:17:c4:18:4f:2d:08:25:a3:a7:4f:b7:92:ca:e2:f5:
 25:f1:54:75:81:9d:b3:3d:61:a2:f7:da:ed:e1:c6:6f:2c:60:
 1f:d8:6f:c5:92:05:ab:c9:09:62:49:a9:14:ad:55:11:cc:d6:
 4a:19:94:99:97:37:1d:81:5f:8b:cf:a3:a8:96:44:51:08:3d:
 0b:05:65:12:eb:b6:70:80:88:48:72:4f:c6:c2:da:cf:cd:8e:
 5b:ba:97:2f:60:b4:96:56:49:5e:3a:43:76:63:04:be:2a:f6:
 c1:ca:a9:94

The correct values are:

(('DNS', 'altnull.python.org\x00example.com'),
 ('email', 'n...@python.org\x00u...@example.org'),
 ('URI', 'http://null.python.org\x00http://example.org'),
 ('IP Address', '192.0.2.1'),
 ('IP Address', '2001:DB8:0:0:0:0:0:1\n'))

--
Added file: http://bugs.python.org/file31240/nullbytecert.pem

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-12 Thread Martijn Pieters

Martijn Pieters added the comment:

 The formatter module was deprecated? When?

It wasn't, that's the point I am raising. The `formatter` module was 
exclusively used by the `htmllib` module, I am surprised the `formatter` module 
wasn't part of that deprecation.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18644
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18644] Got ResourceWarning: unclosed file when using test function from formatter module

2013-08-12 Thread R. David Murray

R. David Murray added the comment:

Pydoc uses DumbWriter.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18644
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16396] Importing ctypes.wintypes on Linux gives a traceback

2013-08-12 Thread Ezio Melotti

Ezio Melotti added the comment:

Even if the patch is applied only on 3.4, I would still like to see the 
ValueError turned into ImportError for 2.7/3.3.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue16396
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Attached patch adds PyState_GetModuleAttr() and converts the _csv module to use 
it (as an example).

As you can see, the _csv module grows a little but it now has proper error 
handling (previously, it didn't check for PyState_FindModule() returning NULL).

(A few lines would be removed if we added PyErr_FormatV as well...)

--
components: Extension Modules, Interpreter Core
files: getmodattr.patch
keywords: patch
messages: 194949
nosy: eli.bendersky, loewis, ncoghlan, pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: Add PyState_GetModuleAttr
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31244/getmodattr.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17997] ssl.match_hostname(): sub string wildcard should not match IDNA prefix

2013-08-12 Thread Christian Heimes

Christian Heimes added the comment:

Ryan Sleevi of the Google Chrome Security Team has informed us about another 
issue that is caused by our failure to implement RFC 6125 wildcard matching 
rules. RFC 6125 allows only one wildcard in the left-most fragment of a 
hostname. For security reasons matching rules like *.*.com should be not 
supported.

For wildcards in internationalized domain names I have followed the 
piece of advice In the face of ambiguity, refuse the temptation to guess.. A 
substring wildcard does no longer match an IDN A-label fragment. '*' still 
matches a full punycode fragment but 'x*' no longer matches 'xn--foo'. I copied 
the idea from Chrome's matching code:

http://src.chromium.org/viewvc/chrome/trunk/src/net/cert/x509_certificate.cc?revision=212341#l640

// * must not match a substring of an IDN A label; just a whole 
fragment.
if (reference_host.starts_with(xn--) 
!(pattern_begin.empty()  pattern_end.empty()))
continue;

The relevant RFC section for the patch are

  http://tools.ietf.org/html/rfc6125#section-6.4.3
  http://tools.ietf.org/html/rfc2818#section-3.1
  http://tools.ietf.org/html/rfc2459#section-4.2.1.7
  http://tools.ietf.org/html/rfc5280#section-7

--
keywords: +patch
stage: needs patch - patch review
versions: +Python 3.2
Added file: http://bugs.python.org/file31245/match_hostname_RFC6125.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18693] help() not helpful with enum

2013-08-12 Thread Eli Bendersky

Eli Bendersky added the comment:

Ethan, please revert your commit first. I liked the previous dir. The current 
one is useless.

I think you may be right about help, but I didn't dig deep enough to be sure.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18711] Add PyErr_FormatV

2013-08-12 Thread Antoine Pitrou

New submission from Antoine Pitrou:

PyErr_FormatV can be useful to write third-party helper functions. Patch 
attached.

--
components: Interpreter Core
files: pyerr_formatv.patch
keywords: patch
messages: 194952
nosy: pitrou
priority: low
severity: normal
stage: patch review
status: open
title: Add PyErr_FormatV
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31246/pyerr_formatv.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread STINNER Victor

STINNER Victor added the comment:

I don't understand your change. Why do we need to change the _csv module and 
why storing module global variables in the module dict is better than storing 
them in a simple C structure?

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18693] help() not helpful with enum

2013-08-12 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


--
nosy: +ronaldoussoren

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 I don't understand your change. Why do we need to change the _csv
 module and why storing module global variables in the module dict is
 better than storing them in a simple C structure?

I won't repeat what was already said in the python-dev thread:
http://mail.python.org/pipermail/python-dev/2013-August/127862.html

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18711] Add PyErr_FormatV

2013-08-12 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@gmail.com:


--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18711
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Christian Heimes

Christian Heimes added the comment:

The patch contains the new function and a patch for the CSV module. How about 
you split it up across two patches: one for the new feature and one for the CSV 
module? It makes review easier.

--
nosy: +christian.heimes

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Bundling the two was aimed at showcasing the effect the new function can have. 
The function itself is trivial, there's not much point in reviewing it alone.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread STINNER Victor

STINNER Victor added the comment:

+PyObject *
+PyState_GetModuleAttr(struct PyModuleDef *def,
+  const char *name,
+  PyObject *restrict_type)

When the char* type is used, the function has usually the suffix String. I 
prefer the PyIdentifier API because it avoids to create a temporary Python 
Unicode object.

It's the first type that I see a function getting an attribute which also 
checks for its type. I don't know if the check should be done in 
PyState_GetModuleAttr() or in the _csv module.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread STINNER Victor

STINNER Victor added the comment:

Does it really make sense to allow to open a certificate containing a NUL byte 
in its name? How does OpenSSL and other projects handle this case?

--
nosy: +haypo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18709] SSL module fails to handle NULL bytes inside subjectAltNames general names (CVE-2013-4073)

2013-08-12 Thread Christian Heimes

Christian Heimes added the comment:

OpenSSL's print() functions fail to handle the NULL byte in subjectAltName 
(SAN) general names as they use strlen() or printf() functions with %s format 
char. The subject and issuer elements with NULL bytes are handled correctly by 
OpenSSL.

wget and curl combine CN / SAN parsing and hostname matching in one function. 
Both report an error when they see a NULL byte in a dNSName (strlen(dNSName) != 
lengtt of ASN1_STRING).

Python has separate functions for retrieving the X.509 information and matching 
a hostname against CN / SAN. I like to keep it that way and just for our 
parsing code in this bug. Latter ssl.match_hostname() can check for NULL bytes 
and raise an exception, but that's a different issue.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18709
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue17997] ssl.match_hostname(): sub string wildcard should not match IDNA prefix

2013-08-12 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue17997
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 When the char* type is used, the function has usually the suffix
 String. I prefer the PyIdentifier API because it avoids to create a
 temporary Python Unicode object.

This is a convenience API, not a performance optimization.

 It's the first type that I see a function getting an attribute which
 also checks for its type. I don't know if the check should be done
 in PyState_GetModuleAttr() or in the _csv module.

The aim is to help writing extension modules, which is why the type
check is done inside the helper function.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18693] help() not helpful with enum

2013-08-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 39697dcd97e3 by Ethan Furman in branch 'default':
Issue 18693: Put custom __dir__ back in place.  Will instead look at fixing 
`help()`.
http://hg.python.org/cpython/rev/39697dcd97e3

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18693
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Eli Bendersky

Eli Bendersky added the comment:

The patched code looks better than the original one in several respects, but I 
think it raises some questions.

I agree with Victor that the type-checking API is unnatural, but I also think 
there may be a deeper issue hiding behind. You felt compelled to add the 
type-checking to provide some level of safety to the C code - but is it enough? 
Previously, the only way to add a dialect was through register_dialect that 
does type checking to make sure it gets a legit dialect object. Now, the 
_dialects dict is directly accessible to Python code and it can add arbitrary 
objects to it (both as keys and as values). Does this mean that the C code now 
has to do type checking in all internal code that accesses _dialects? I haven't 
had time to find a crasher example, but it's plausible that it's possible to 
crash the interpreter now by assigning un-expected stuff to members of 
_dialects.

Maybe it's not a problem in practice for _csv but something worth thinking 
about if we're going to switch other methods to this approach.

Also, the problem with 
http://mail.python.org/pipermail/python-dev/2013-August/127862.html does not go 
away with this patch, as expected. However, it's a step in the right direction 
in case we do have multiple instances of the extension module alive at the same 
time in the future. Although then it would be interesting to consider how to 
find the actually correct module instance from internal functions.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Previously, the only way to add a dialect was through register_dialect that 
 does
 type checking to make sure it gets a legit dialect object. Now, the _dialects 
 dict is 
 directly accessible to Python code and it can add arbitrary objects to it 
 (both as
 keys and as values). Does this mean that the C code now has to do type 
 checking in all 
 internal code that accesses _dialects?

You are right, I forgot about that part. That will make the patch significantly 
more complicated.

 However, it's a step in the right direction in case we do have multiple 
 instances of
 the extension module alive at the same time in the future. Although then it 
 would be
 interesting to consider how to find the actually correct module instance from 
 internal 
 functions.

This sounds basically impossible (which is why we *can't* have multiple 
instances of an extension module alive in a single interpreter :-)).

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18712] Pure Python operator.index doesn't match the C version.

2013-08-12 Thread Mark Dickinson

New submission from Mark Dickinson:

Nitpick: the pure Python version of operator.index (new in Python 3.4, 
introduced in issue #16694) doesn't match the C version, in that it looks up 
__index__ on the object rather than the class.


iwasawa:cpython mdickinson$ ./python.exe
Python 3.4.0a1+ (default:9e61563edb67+, Aug 12 2013, 14:45:12) 
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type help, copyright, credits or license for more information.
 from test import support
 py_operator = support.import_fresh_module('operator', blocked=['_operator'])
 c_operator = support.import_fresh_module('operator', fresh=['_operator'])
 class A(int): pass
... 
 a = A(42); a.__index__ = lambda: 1729
 
 py_operator.index(a)
1729
 c_operator.index(a)
42

--
components: Extension Modules
messages: 194966
nosy: mark.dickinson, zach.ware
priority: normal
severity: normal
status: open
title: Pure Python operator.index doesn't match the C version.
type: behavior
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18712
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Nick Coghlan

Nick Coghlan added the comment:

Breaking the 1:1 interpreter - extension module mapping involves
adding custom types to sys.modules rather than module objects. Making
that work sensibly will involve larger changes to the extension
initialisation APIs. import-sig already has plans for this :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18710] Add PyState_GetModuleAttr

2013-08-12 Thread Eli Bendersky

Eli Bendersky added the comment:

 Previously, the only way to add a dialect was through register_dialect
that does

   type checking to make sure it gets a legit dialect object. Now, the
 _dialects dict is
  directly accessible to Python code and it can add arbitrary objects to
 it (both as
  keys and as values). Does this mean that the C code now has to do type
 checking in all
  internal code that accesses _dialects?

 You are right, I forgot about that part. That will make the patch
 significantly more complicated.


:-/

Turns out there's real merit in having a clear dividing line between the
safe world of Python and unsafe world of C. Within the C code, some
invariants are assumed to be correct (and can be efficiently assert()-ed) -
this makes the code simpler and more performant.

  However, it's a step in the right direction in case we do have multiple
 instances of
  the extension module alive at the same time in the future. Although then
 it would be
  interesting to consider how to find the actually correct module instance
 from internal
  functions.

 This sounds basically impossible (which is why we *can't* have multiple
 instances of an extension module alive in a single interpreter :-)).


Well, it surely isn't possible without significant code rewriting. But I
can envision carrying such state around in extension-specific objects.
Although it's not entirely clear whether the memory cost is justified.

But without it, it's not clear to me how we plan to have multiple living
extension modules at all. Perhaps this is a discussion outside this
specific issue though (maybe for the PEP Stefan writes)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18710
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18660] os.read behavior on Linux

2013-08-12 Thread Louis Riviere

Louis Riviere added the comment:

Thanks Benjamin !
I should have known that Python doesn't break things :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18660
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18713] Enable surrogateescape on stdin and stdout when appropriate

2013-08-12 Thread Nick Coghlan

New submission from Nick Coghlan:

One problem with Unicode in 3.x is that surrogateescape isn't normally enabled 
on stdin and stdout. This means the following code will fail with 
UnicodeEncodeError in the presence of invalid filesystem metadata:

print(os.listdir())

We don't really want to enable surrogateescape on sys.stdin or sys.stdout 
unilaterally, as it increases the chance of data corruption errors when the 
filesystem encoding and the IO encodings don't match.

Last night, Toshio and I thought of a possible solution: enable surrogateescape 
by default for sys.stdin and sys.stdout on non-Windows systems if (and only if) 
they're using the same codec as that returned by sys.getfilesystemencoding() 
(allowing for codec aliases rather than doing a simple string comparison)

This means that for full UTF-8 systems (which includes most modern Linux 
installations), roundtripping will be enabled by default between the standard 
streams and OS facing APIs, while systems where the encodings don't match will 
still fail noisily.

A more general alternative is also possible: default to errors='surrogatescape' 
for *any* text stream that uses the filesystem encoding. It's primarily the 
standard streams we're interested in fixing, though.

--
messages: 194968
nosy: abadger1999, benjamin.peterson, ezio.melotti, haypo, lemburg, ncoghlan, 
pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: Enable surrogateescape on stdin and stdout when appropriate
type: enhancement
versions: Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18713
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18713] Enable surrogateescape on stdin and stdout when appropriate

2013-08-12 Thread R. David Murray

R. David Murray added the comment:

My gut reaction to this is that it feels dangerous.  That doesn't mean my gut 
is right, I'm just reporting my reaction :)

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18713
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18713] Enable surrogateescape on stdin and stdout when appropriate

2013-08-12 Thread Nick Coghlan

Nick Coghlan added the comment:

Everything about surrogateescape is dangerous - we're trying to work
around the presence of bad data by at least allowing it to be
tunnelled through Python code without corrupting it further :)

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18713
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18367] See if a venv setup can be used for devinabox for coverage

2013-08-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - fixed
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18367
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18451] Omit test files in devinabox coverage run

2013-08-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - wont fix
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18451
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18689] add argument for formatter to logging.Handler and subclasses in logging module

2013-08-12 Thread Derek Wilson

Derek Wilson added the comment:

dictConfig and fileConfig are nice for static needs, but when I want to quickly 
enable a complex (but not complicated) logging flow I find it just as tedious 
as the current situation with the direct API.

 ... as at the very least every handler would need to be changed to 
 accommodate the new kwarg

Adding a keyword only argument to the base handler and the other handler 
classes is a nearly trivial change in terms of lines and complexity of the code.

 Also, this isn't going to work for third-party handlers which are out there 
 already, since they won't necessarily recognise a new kwarg.

I don't see that as a problem. If 3rd party handlers are intelligent then they 
will include **kargs in their __init__ and pass that forward to the 
initialization of their parent. If they haven't done so then nothing changes 
for them and they just support exactly the same features they supported 
previously.

--
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18689
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18578] Rename and document test.bytecode_helper as test.support.bytecode_helper

2013-08-12 Thread Seydou Dia

Seydou Dia added the comment:

I have a hard time figuring out what exactly BytecodeTestCase methods actually 
do. Thus the documentation is not probably accurate.

--
keywords: +patch
Added file: http://bugs.python.org/file31247/issue-18578.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18578
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18598] Importlib, more verbosity please

2013-08-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 2294594fbe6c by Brett Cannon in branch 'default':
Closes issue #18598: Have the exception message for
http://hg.python.org/cpython/rev/2294594fbe6c

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18598
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18598] Importlib, more verbosity please

2013-08-12 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18598
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12837] Patch for issue #12810 removed a valid check on socket ancillary data

2013-08-12 Thread Brett Cannon

Brett Cannon added the comment:

This is still a warning and so I'm still looking for a solution.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12837
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18667] missing HAVE_FCHOWNAT

2013-08-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a89226508a04 by Larry Hastings in branch '3.3':
Issue #18667: Add missing HAVE_FCHOWNAT symbol to posix._have_functions.
http://hg.python.org/cpython/rev/a89226508a04

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18667
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18667] missing HAVE_FCHOWNAT

2013-08-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 92de1a5dc3ea by Larry Hastings in branch 'default':
Issue #18667: Add missing HAVE_FCHOWNAT symbol to posix._have_functions.
http://hg.python.org/cpython/rev/92de1a5dc3ea

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18667
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18667] missing HAVE_FCHOWNAT

2013-08-12 Thread Larry Hastings

Larry Hastings added the comment:

Fixed in 3.3 and trunk.  Thanks for the report!

--
assignee:  - larry
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
type:  - behavior

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18667
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18416] Move to absolute file paths for module.__file__

2013-08-12 Thread Madison May

Madison May added the comment:

Here's a minor revision to that patch removing an unnecessary 
@skip_if_dont_write_bytecode decorator from the test I added to test_import.py. 
 

No docs changes are included in the current patch -- I'm guessing this should 
probably wait until we have all the other details ironed out.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18416
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18416] Move to absolute file paths for module.__file__

2013-08-12 Thread Madison May

Changes by Madison May madison@students.olin.edu:


Added file: http://bugs.python.org/file31248/Issue18416_v2.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18416
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18700] test_cgi raises ResourceWarning

2013-08-12 Thread Madison May

Madison May added the comment:

Good catch, Vajrasky.  I'll close the issue and add my brief report to bug 
#18394.

--
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18700
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18394] cgi.FieldStorage triggers ResourceWarning sometimes

2013-08-12 Thread Madison May

Madison May added the comment:

I ran into a similar issue (see #18700) with test_cgi.

``/home/mmay/cpython/Lib/test/test_cgi.py:276: ResourceWarning: unclosed file 
_io.BufferedRandom name=3``

--
nosy: +madison.may

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18394
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1666318] shutil.copytree doesn't give control over directory permissions

2013-08-12 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hey Catherine,
Do you want to update your patch to include Vajrasky's suggestion?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1666318
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18694] getxattr on Linux ZFS native filesystem happily returns partial values

2013-08-12 Thread Larry Hastings

Larry Hastings added the comment:

Attached is an updated patch, this time for 3.3.  (So I'm guessing we won't get 
a review link.)  It incorporates Benjamin's two comments.

--
Added file: http://bugs.python.org/file31249/larry.setxattr.zfs.3.3.patch.1.txt

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18694] getxattr on Linux ZFS native filesystem happily returns partial values

2013-08-12 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Okay. Hopefully, we can kill that thing one day...

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18694
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >