[issue17414] timeit.timeit not in __all__ even though documented

2013-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset dda8a6b8a351 by Terry Jan Reedy in branch 'default':
Issue #17414: Add timeit, repeat, and default_timer to timeit.__all__.
http://hg.python.org/cpython/rev/dda8a6b8a351

--
nosy: +python-dev

___
Python tracker 

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



[issue17414] timeit.timeit not in __all__ even though documented

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Fred Drake, Eli Bendersky, and in particular, Guido ("I do see that it 
shouldn't be backported, but I don't see any worries about doing it in 3.4.") 
said that this is a 3.4-only enhancement.

Anuj, ACKS are alphabetical. Åstrand is at the end because that is where Å 
sorts. Thanks for the patch. We hope to see more.

--
versions:  -Python 2.6, Python 2.7, Python 3.2, Python 3.3

___
Python tracker 

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



[issue17414] timeit.timeit not in __all__ even though documented

2013-03-15 Thread Terry J. Reedy

Changes by Terry J. Reedy :


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

___
Python tracker 

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



[issue17415] Clarify docs of os.path.normpath()

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The question is what is the 'this' that may change the patch meaning. It does 
not seem to me that changing '/' to '\' would do that. So I suspect 'this' 
refers to 'collapsing'. If so, I suggest the entry be:

Normalize a pathname (but not the case -- use normcase for that). This 
collapses redundant separators and up-level references so that A//B, A/B/, 
A/./B and A/foo/../B all become A/B. This collapsing may change the meaning of 
the path if it contains symbolic links!  On Windows, normpath also converts 
forward slashes to backward slashes.

--
nosy: +loewis, pitrou

___
Python tracker 

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



[issue17047] Fix double double words words

2013-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4b28a6a3eda6 by Terry Jan Reedy in branch '3.2':
Issue #17047: Add news entry
http://hg.python.org/cpython/rev/4b28a6a3eda6

New changeset 937989570b42 by Terry Jan Reedy in branch '3.3':
Merge with 3.2: issue #17047 news entry
http://hg.python.org/cpython/rev/937989570b42

New changeset f0a3c2006adb by Terry Jan Reedy in branch 'default':
Merge with 3.2: closes issue #17047
http://hg.python.org/cpython/rev/f0a3c2006adb

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread Ezio Melotti

Ezio Melotti added the comment:

PERL uses $& for the whole match rather than $0.  That would explain why \0 is 
not supported.  For .group() it probably made sense to access the whole match 
using 0 rather than passing something else, and that was likely reflected in 
the \g<...> form, but not in the \X form.

--

___
Python tracker 

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



[issue17047] Fix double double words words

2013-03-15 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed
type: enhancement -> behavior

___
Python tracker 

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



[issue17047] Fix double double words words

2013-03-15 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
assignee: docs@python -> terry.reedy

___
Python tracker 

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



[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Rock Li

New submission from Rock Li:

When I'm how glob module is implemented. I found in file posixmodule.c, the 
function posix_listdir is using readdir to get all the entries under one 
directory and the context is setted to allow multi threads. But the function 
readdir is not thread-safe, so I changed this call to use readdir_r instead. 

I'm using the lastest codes in the repo.

--
components: Extension Modules
files: mywork.patch
keywords: patch
messages: 184224
nosy: Rock
priority: normal
severity: normal
status: open
title: replace readdir to readdir_r in function posix_listdir
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file29413/mywork.patch

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread anatoly techtonik

anatoly techtonik added the comment:

The perl syntax supported $0 according to this doc 
http://turtle.ee.ncku.edu.tw/docs/perl/manual/pod/perlre.html but was removed 
for unknown reason. Using the fact that support is removed without knowing the 
true reason is "cargo cult argument", which I hope is not acceptable for Python 
development.

Among the possible reason can be binding of $0 to the __file__ analogue 
according to this doc - 
http://www.cs.cmu.edu/afs/cs/usr/rgs/mosaic/pl-predef.html

--

___
Python tracker 

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



[issue13918] locale.atof documentation is missing func argument

2013-03-15 Thread Cédric Krier

Cédric Krier added the comment:

Here is a patch for the documentation.

--
keywords: +patch
resolution: wont fix -> 
Added file: http://bugs.python.org/file29414/doc_atof.patch

___
Python tracker 

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



[issue17053] pydoc should use inspect.signature instead of inspect.getfullargspec

2013-03-15 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The attached patch appears to work correctly and includes a test for pydoc 
(text output). There could be more testing (HTML output, annotations, 
positional-only arguments).

With this patch I can get usable documentation for Cocoa classes with a patched 
version of PyObjC that includes an __signature__ property on ObjC method 
objects.

As mentioned before I'm not sure about the 'render' method added to 
inspect.Signature and inspect.Parameter. These methods were needed to generate 
output that's compatible with the current pydoc output, in particular to emit 
better HTML output.

--
keywords: +patch
stage: test needed -> patch review
Added file: http://bugs.python.org/file29415/issue17053.txt

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread Matthew Barnett

Matthew Barnett added the comment:

The regex behaves the same as re.

The reason it isn't supported is that \0 starts an octal escape sequence.

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread Guido van Rossum

Guido van Rossum added the comment:

Anatoly, your argument for consistency with other languages is ridiculous.

--

___
Python tracker 

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



[issue1291] test_resource fails on recent linux systems

2013-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 59292f366b53 by Senthil Kumaran in branch 'default':
#1291 http.server's send_error takes an optional explain argument
http://hg.python.org/cpython/rev/59292f366b53

--
nosy: +python-dev

___
Python tracker 

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



[issue12921] http.server.BaseHTTPRequestHandler.send_error , ability send a detailed response

2013-03-15 Thread Senthil Kumaran

Senthil Kumaran added the comment:

I have added explain argument in 3.4, committed changeset 82669:59292f366b53

I think the short message no trailing line assertion should be taken by next. 
Either a new issue it if already open or create one just for the purpose.

Thanks Karl for the patch.

--
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed
title: http.server.BaseHTTPRequestHandler.send_error and trailing newline -> 
http.server.BaseHTTPRequestHandler.send_error , ability send a detailed response

___
Python tracker 

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



[issue12921] http.server.BaseHTTPRequestHandler.send_error , ability send a detailed response

2013-03-15 Thread karl

karl added the comment:

Thanks! Yes we should open a separate issue. I will look at the current patch 
and see what I can propose for the next step.

--

___
Python tracker 

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



[issue12921] http.server.BaseHTTPRequestHandler.send_error , ability send a detailed response

2013-03-15 Thread karl

karl added the comment:

just a minor issue you made a mistake in the commit message. The issue number 
is 12921

--

___
Python tracker 

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



[issue17429] platform.platform() can throw Unicode error

2013-03-15 Thread Toshio Kuratomi

New submission from Toshio Kuratomi:

Tested on python-3.2 and python-3.3.  platform.platform() looks for a file in 
/etc/ that looks like it will contain the name of the Linux distribution that 
python3 is running on.  Once found, it reads the contents of the file to have a 
name for the Linux distribution.  Most Linux distributions do create files 
inside of /etc/ with a single line which is the distribution name so this is a 
good heuristic.  However, these files are created by the operating system 
vendor and so they can have a different encoding than the encoding of the 
locale the user uses.  This means that if there are non-ascii characters inside 
the file, user code that invokes platform.platform() may throw a traceback.

Test:

$ LC_ALL=en_US.utf8 sudo echo ' Café' >> /etc/fedora-release
$ LC_ALL=C python3
>>> import platform
>>> platform.platform()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python3.2/platform.py", line 1538, in platform
distname,distversion,distid = dist('')
  File "/usr/lib64/python3.2/platform.py", line 358, in dist
full_distribution_name=0)
  File "/usr/lib64/python3.2/platform.py", line 329, in linux_distribution
firstline = f.readline()
  File "/usr/lib64/python3.2/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 22: 
ordinal not in range(128)

It seems that the standard method of fixing these that we're promoting in 
python3 is to use surrogateescape.  I'll provide a patch that does that.

--
messages: 184234
nosy: a.badger
priority: normal
severity: normal
status: open
title: platform.platform() can throw Unicode error
versions: Python 3.2, Python 3.3

___
Python tracker 

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



[issue17429] platform.platform() can throw Unicode error

2013-03-15 Thread Toshio Kuratomi

Changes by Toshio Kuratomi :


--
keywords: +patch
Added file: http://bugs.python.org/file29416/00175-platform-unicode.patch

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread anatoly techtonik

anatoly techtonik added the comment:

Matthew, finally the right answer. Thanks!


Looking further, there is a bug in processing backslashes in raw literal 
replacement strings. re.sub ignores raw strings as replacements. This can be 
even more confusing for people who look for more advanced equivalent for string 
replace().


  patt = "aaa"
  repl = r"zed \0 org"

  print(" aaa ".replace(patt, repl))

  import re
  print(re.sub(patt, repl, " aaa "))

This gives:

 zed \0 org
 zed   org

With `repl = "zed \0 org"`, the output matches:

  zed   org
  zed   org

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread Guido van Rossum

Guido van Rossum added the comment:

Anatoly, your question belongs on python-list or stack overflow, not in the
tracker.

--Guido van Rossum (sent from Android phone)
On Mar 15, 2013 9:28 AM, "anatoly techtonik"  wrote:

>
> anatoly techtonik added the comment:
>
> Matthew, finally the right answer. Thanks!
>
>
> Looking further, there is a bug in processing backslashes in raw literal
> replacement strings. re.sub ignores raw strings as replacements. This can
> be even more confusing for people who look for more advanced equivalent for
> string replace().
>
>
>   patt = "aaa"
>   repl = r"zed \0 org"
>
>   print(" aaa ".replace(patt, repl))
>
>   import re
>   print(re.sub(patt, repl, " aaa "))
>
> This gives:
>
>  zed \0 org
>  zed   org
>
> With `repl = "zed \0 org"`, the output matches:
>
>   zed   org
>   zed   org
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue17386] Bring Doc/make.bat as close to Doc/Makefile as possible

2013-03-15 Thread Zachary Ware

Zachary Ware added the comment:

Applying the minipatch makes the big patch fail to apply, so here's an update.  
Also changed in this version of the patch:

- README.txt is updated.  Not all the changes directly relate to this patch, 
but there were some needed updates in there anyway.  If desired, I can split 
those into a separate issue, but all the changes are fairly minor.

- Added *VERSION variables for each of the tools for easy overriding and 
easier-to-find, single place to update.

Terry, you're right about make.bat being very similar between versions.  About 
the only other difference I saw was the removal of the line that prints the 
Python version in use, and the version of Pygments used.  I'd be happy to make 
patches for backporting this as far as desired (assuming, of course, that it is 
accepted and is desirable to backport :-).

--
Added file: http://bugs.python.org/file29417/win_doc_make.v2.diff

___
Python tracker 

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



[issue17386] Bring Doc/make.bat as close to Doc/Makefile as possible

2013-03-15 Thread Zachary Ware

Changes by Zachary Ware :


Removed file: http://bugs.python.org/file29417/win_doc_make.v2.diff

___
Python tracker 

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



[issue17386] Bring Doc/make.bat as close to Doc/Makefile as possible

2013-03-15 Thread Zachary Ware

Changes by Zachary Ware :


Added file: http://bugs.python.org/file29418/win_doc_make.v2.diff

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread anatoly techtonik

anatoly techtonik added the comment:

I thought that trackers are used to track the sources of the bugs. Aren't they?

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread anatoly techtonik

anatoly techtonik added the comment:

Users list the effect. Then a research is made to find the source. Then a 
decision is made to find the right cause for the source of the bug, and then a 
decision about if the fix is possible.

The bug is closed, but that doesn't mean we can not dedicate some time trying 
to research the cause. This research can be used to develop other language and 
explain the mechanism why this feature works like it does. If people are not 
interested, they can opt-out.

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Anatoly, your last question about re.sub is covered by the documentation:
re.sub will process the replacement string, and interpret the sequence \ 0 as 
the NUL character. So you get the NUL character in the returned string.

This is unrelated to raw literal strings.

And yes, sometimes you need 4 backslashes to get one in the output:

>>> print(re.sub("b", "", "abc"))
a\c

--
nosy: +amaury.forgeotdarc

___
Python tracker 

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



[issue17429] platform.platform() can throw Unicode error

2013-03-15 Thread Martin v . Löwis

Martin v. Löwis added the comment:

What's the most likely encoding? UTF-8? I suggest we assume UTF-8, and use the 
surrogate-escape error handler to deal with the cases when it isn't.

--
nosy: +loewis

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread anatoly techtonik

anatoly techtonik added the comment:

Amaury, the documentation could make it more clear that it is a double 
replacement. Of course I payed attention to the repeated instructions about 
string substitution, but I thought that it is just a reminder, not an extra 
processing layer on top of standard string processing logic. Currently it reads 
like:

...if it is a string, any backslash escapes in it are processed. That is, \n 
is...

The correct text would be like:

...if it is a string, any backslash escapes in it are processed in addition to 
standard string escapes. That is, \n is... ... Note that re.sub backslash 
processing for replacement string occurs even if the raw strings.

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread anatoly techtonik

anatoly techtonik added the comment:

FWIW, I reimplemented substitution logic in my wikify [1] engine some time ago. 
I was kind of disappointed that I have to reinvent the bicycle, but now I see 
that this was for good. Thanks to people in this report I now understand the 
whole stuff much better and this will definitely make wikify more useful and 
easier to use.

1. https://bitbucket.org/techtonik/wikify

--

___
Python tracker 

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



[issue17426] \0 in re.sub substitutes to space

2013-03-15 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

It's not a double replacement: chr(92)+chr(0) is processed only once.
And the second paragraph of the re documentation already contains such a 
warning.

--

___
Python tracker 

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



[issue17423] libffi on 32bit is broken on linux

2013-03-15 Thread Simon Cross

Changes by Simon Cross :


--
nosy: +hodgestar

___
Python tracker 

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



[issue17430] missed peephole optimization

2013-03-15 Thread Neal Norwitz

New submission from Neal Norwitz:

>>> def fo():
...   if a:
... if b:
...  if c:
...print
... 
>>> dis.dis(fo)
  2   0 LOAD_GLOBAL  0 (a)
  3 POP_JUMP_IF_FALSE   28

  3   6 LOAD_GLOBAL  1 (b)
  9 POP_JUMP_IF_FALSE   28

  4  12 LOAD_GLOBAL  2 (c)
 15 POP_JUMP_IF_FALSE   25

  5  18 PRINT_NEWLINE   
 19 JUMP_ABSOLUTE   25
 22 JUMP_ABSOLUTE   28
>>   25 JUMP_FORWARD 0 (to 28)
>>   28 LOAD_CONST   0 (None)
 31 RETURN_VALUE

The 2 JUMP_ABSOLUTEs should be optimized away since the code is equivalent to: 
if a and b and c: as in:

>>> dis.dis(fo)
  2   0 LOAD_GLOBAL  0 (a)
  3 POP_JUMP_IF_FALSE   22
  6 LOAD_GLOBAL  1 (b)
  9 POP_JUMP_IF_FALSE   22
 12 LOAD_GLOBAL  2 (c)
 15 POP_JUMP_IF_FALSE   22

  3  18 PRINT_NEWLINE   
 19 JUMP_FORWARD 0 (to 22)
>>   22 LOAD_CONST   0 (None)
 25 RETURN_VALUE

--
messages: 184245
nosy: Neal.Norwitz
priority: normal
severity: normal
status: open
title: missed peephole optimization
type: performance
versions: Python 2.7

___
Python tracker 

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



[issue17337] input() and raw_input() do not work correctly with colored prompts

2013-03-15 Thread Michael Enßlin

Michael Enßlin added the comment:

Terry, i guess you are right; it is indeed not the job of python to know how 
its terminal will print characters; there is a whole lot of issues to consider, 
such as terminal unicode support, control characters, ansi escape sequences, 
terminal-specific escape sequences such as terminal title, etc.
I guess that on UNIX, a lot of that information could be taken from terminfo, 
to provide a method that guesses the length of a text on the terminal that is 
referenced in the $TERM environment variable.

In fact, I think this is a design problem of readline; readline should print 
the prompt, and then try to determine its length via the dedicated escape 
sequence (if it really needs to know the prompt length). In that case, there 
would be no way to fix this in python - apart from re-implementing. In 
conclusion, no, I don't believe the python readline code should be modified, 
maybe an additional, os- and $TERM-dependent method for adding prompt escapes 
should be added.

However, the issue should definitely be documented in the readline 
documentation:
importing readline _will_ break input() if the prompt contains non-printable 
characters that are not escaped by '\x01' and '\x02' characters.

Hence I have changed the bug components to 'Documentation'.

--
assignee:  -> docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python

___
Python tracker 

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



[issue17431] email.parser module has no attribute BytesFeedParser

2013-03-15 Thread Forest Wilkinson

New submission from Forest Wilkinson:

The docs claim that email.parser.BytesFeedParser exists, but it doesn't.  Looks 
like email.feedparser.FeedParser is imported into the email.parser module, but 
someone forgot to do the same for BytesFeedParser.

--
components: email
messages: 184247
nosy: barry, forest, r.david.murray
priority: normal
severity: normal
status: open
title: email.parser module has no attribute BytesFeedParser
versions: Python 3.2, Python 3.3

___
Python tracker 

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



[issue17431] email.parser module has no attribute BytesFeedParser

2013-03-15 Thread R. David Murray

R. David Murray added the comment:

Thanks for the report.

--
keywords: +easy
stage:  -> needs patch
versions: +Python 3.4

___
Python tracker 

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



[issue17400] ipaddress.is_private needs to take into account of rfc6598

2013-03-15 Thread pmoody

pmoody added the comment:

Is the request that is_private should return true for all reserved/non-routable 
addresses? The docstrings refer to specific rfcs which don't cover most of the 
addresses listed in the wikipedia page. I haven't done a lot of network 
programming in the last couple of years, so what do folks think the least 
surprising result here would be?

--

___
Python tracker 

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



[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Ross Lagerwall

Ross Lagerwall added the comment:

Hi,

There shouldn't be a problem with the existing implementation since, according 
to posix:
"""
The pointer returned by readdir() points to data which may be overwritten by 
another call to readdir() on the same directory stream. This data is not 
overwritten by another call to readdir() on a different directory stream.
"""

Since each call to listdir() opens a different directory stream, this shouldn't 
be a problem.

Also, when using readdir_r(), struct dirent should not be allocated on the 
stack since the last field may be an unspecified size.
See the following for further reading about this:
http://elliotth.blogspot.co.uk/2012/10/how-not-to-use-readdirr3.html
http://womble.decadent.org.uk/readdir_r-advisory.html

Regards

--
nosy: +rosslagerwall

___
Python tracker 

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



[issue13918] locale.atof documentation is missing func argument

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I find the idea of intentionally not documenting a public parameter and the 
full signature of a function somewhat strange, especially when it is already 
automatically partially-documented.

>>> import locale
>>> help(locale.atof)
Help on function atof in module locale:

atof(string, func=)
Parses a string as a float according to the locale settings.
# 2.7, 3.2, 3.3

Not documenting the full signature of a function seems to me contrary to proper 
policy. That aside, the func parameter is, to me, a useful feature, not just an 
implementation detail

The way to have factored out the common normalization without a func parameter 
is obvious: define a private normalization function.

def _anormalize(string):
"remove thousands separators, make decimal dot"
ts = localeconv()['thousands_sep']
if ts:
string = string.replace(ts, '')
#next, replace the decimal point with a dot
dd = localeconv()['decimal_point']
if dd:
string = string.replace(dd, '.')
return string

def atof(string):
"Parses a string as a float according to the locale settings."
return float(_anormalize(string))

def atoi(string):  # changed from str
"Converts a string to an integer according to the locale settings."
return int(_anormalize(string))

But Martin von Loewis, the original author did not do this. I would not assume 
that he "thought that copying 3 lines from atof into atoi was a bad idea." 
without asking him.  Whatever his conscious intention, the func parameter 
*does* have the advantage of allowing alternate float string to number 
converters.  We now have another one in the stdlib besides decimal.Decimal: 
fractions.Fractions.

>>> locale.atof('99,999.99', F)
Fraction(999, 100)
# versus
>>> F(locale.atof('99,999.99'))
Fraction(6871946986405233, 68719476736)

There are also 3rd party float implementations, such as indefinite precision 
binary floats. Does anyone still object to properly documenting this useful 
feature? I am willing to do the commits.

As to the patch and atof docstring, I thinks 'converts' (used in atoi 
docstring) is better than 'parses'.  So I would change both.

--
nosy: +terry.reedy
versions: +Python 2.7, Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue14468] Update cloning guidelines in devguide

2013-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7a707540391e by Ezio Melotti in branch 'default':
#14468: add FAQs about merge conflicts, null merges, and heads merges.
http://hg.python.org/devguide/rev/7a707540391e

--

___
Python tracker 

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



[issue10652] test___all_ + test_tcl fails (Windows installed binary)

2013-03-15 Thread Zachary Ware

Zachary Ware added the comment:

I was recently bitten by this issue.  I've reviewed Terry's patch on Rietveld, 
and have tested it myself some.  It seems to get the job done without getting 
in the way.

--
nosy: +zach.ware

___
Python tracker 

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



[issue17398] document url argument of RobotFileParser

2013-03-15 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
assignee: docs@python -> terry.reedy
nosy: +terry.reedy

___
Python tracker 

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



[issue17398] document url argument of RobotFileParser

2013-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 274e68e2a5a6 by Terry Jan Reedy in branch '2.7':
Issue #17398: document url argument of RobotFileParser
http://hg.python.org/cpython/rev/274e68e2a5a6

New changeset 4be7f8da7adf by Terry Jan Reedy in branch '3.2':
Issue #17398: document url argument of RobotFileParser
http://hg.python.org/cpython/rev/4be7f8da7adf

--
nosy: +python-dev

___
Python tracker 

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



[issue10652] test___all_ + test_tcl fails (Windows installed binary)

2013-03-15 Thread Ezio Melotti

Ezio Melotti added the comment:

Would using import_fresh_module() in test_tcl (and others) work?

--
versions: +Python 3.4

___
Python tracker 

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



[issue17398] document url argument of RobotFileParser

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Agreed.

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

___
Python tracker 

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



[issue17337] input() and raw_input() do not work correctly with colored prompts

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Please suggest the specific change in a specific place that you would like to 
see. Message is ok, patch even better.

--

___
Python tracker 

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



[issue17400] ipaddress.is_private needs to take into account of rfc6598

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Peter, 'Assigned To' is a developer who intends to push (or has pushed) a 
patch. Anyone can write and attach one. And it is nice to give notice that you 
intend to.

--
nosy: +ncoghlan, terry.reedy

___
Python tracker 

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



[issue1159051] Handle corrupted gzip files with unexpected EOF

2013-03-15 Thread Matthias Klose

Matthias Klose added the comment:

this change breaks a test case in the bzr testsuite; will try to get to it next 
week. See https://launchpad.net/bugs/1116079

--
nosy: +doko, larry
priority: normal -> release blocker

___
Python tracker 

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



[issue17400] ipaddress.is_private needs to take into account of rfc6598

2013-03-15 Thread Lei Miao

Lei Miao added the comment:

is_private should return true for all prefixes that are intended for
*private* use, hence it should include rfc1918 and rfc6598. rfc6598
stipulates 100.64.0.0/10

On 16 March 2013 06:34, pmoody  wrote:

>
> pmoody added the comment:
>
> Is the request that is_private should return true for all
> reserved/non-routable addresses? The docstrings refer to specific rfcs
> which don't cover most of the addresses listed in the wikipedia page. I
> haven't done a lot of network programming in the last couple of years, so
> what do folks think the least surprising result here would be?
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue17408] second python execution fails when embedding

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Can you tell if the relevant 3.2 to 3.3 change is in Py_Initialize, 
Py_Finalize(), or typeobject.c?

--
nosy: +ncoghlan, terry.reedy

___
Python tracker 

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



[issue10652] test___all_ + test_tcl fails (Windows installed binary)

2013-03-15 Thread Zachary Ware

Zachary Ware added the comment:

It does, in fact.  Here's a patch.

--
Added file: http://bugs.python.org/file29419/issue10652.v2.diff

___
Python tracker 

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



[issue17409] resource.setrlimit doesn't respect -1

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Module 'resource' is unix only.  What happens on 3.x or linux?

Given that the doc invites input of -1, it seems to me that raising an 
exception is wrong; -1 should be interpreted as a valid value.

--
nosy: +terry.reedy

___
Python tracker 

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



[issue17411] Build failures with non-NDEBUG, non-Py_DEBUG builds.

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The patch changes unicodeobject.c and obmalloc.c
Thomas, is the problem new to 3.3 (and the new unicode implementation)?

--
nosy: +benjamin.peterson, ezio.melotti, haypo, pitrou, terry.reedy

___
Python tracker 

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



[issue17411] Build failures with non-NDEBUG, non-Py_DEBUG builds.

2013-03-15 Thread Thomas Wouters

Thomas Wouters added the comment:

Yes, I already had the same kinds of failures fixed for 3.2, before; this only 
affects 3.3 and later.

--

___
Python tracker 

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



[issue17416] Clarify docs of os.walk()

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The unambiguous title of your first report was better, so I copied it with a 
new method name.

Changing a parameter name will break code, so it is essentially never done. In 
any case, directory trees are considered to grow 'down' from the root 
directory, and tree walkers recurse 'down' to leaves, even though biological 
trees usually grow 'up'. You just have to get used to the standard inverted 
metaphor.

I read the doc entry and I do not see any need to change, so I am closing this.

--
nosy: +terry.reedy
resolution:  -> works for me
stage:  -> committed/rejected
status: open -> closed
title: Documentation Ambiguity 2 -> Clarify docs of os.walk()

___
Python tracker 

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



[issue17429] platform.platform() can throw Unicode error

2013-03-15 Thread Toshio Kuratomi

Toshio Kuratomi added the comment:

I agree.  In my experience, utf-8 is the most common encoding.  Updated patch 
that defaults to utf-8 instead of the user's locale is attached.

--
Added file: http://bugs.python.org/file29420/00175-platform-unicode.patch

___
Python tracker 

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



[issue17432] PyUnicode_ functions not accessible in Limited API on Windows

2013-03-15 Thread Bill Dirks

New submission from Bill Dirks:

This issue was discovered in 3.3.0 on Windows. Haven't looked at other versions.
Using the Limited API, the PyUnicode_Xxxx() functions are not accessible. A 
simple demonstration of the problem:

   HMODULE p3 = ::LoadLibraryA("C:\\Python33\\DLLs\\python3.dll");
   FARPROC f;
   f = GetProcAddress(p3, "Py_IsInitialized"); // works
   f = GetProcAddress(p3, "PyImport_AppendInittab"); // works, and so on
   f = GetProcAddress(p3, "PyUnicode_FromString"); // fails
   f = GetProcAddress(p3, "PyUnicode_FromFormat"); // fails
   f = GetProcAddress(p3, "PyUnicode_FromStringAndSize"); // fails, and so on
   ::FreeLibrary(p3);

After some digging I found that python3.dll refers all of its exports on to 
python33.dll, and the problem exports all have the form:
  PyUnicode_Xxxx -> python33.PyUnicodeUCS2_Xxxx
but python33.dll does not export any PyUnicodeUCS2_ symbols, confirmed by the 
Dependency Walker tool.

Any Limited API extension using PyUnicode_ functions will compile and link, but 
fail at runtime. If I understand the problem, the fix is just to correct the 
.def file.

--
components: Windows
messages: 184268
nosy: bdirks
priority: normal
severity: normal
status: open
title: PyUnicode_ functions not accessible in Limited API on Windows
type: behavior
versions: Python 3.3

___
Python tracker 

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



[issue17417] Documentation Modification Suggestion: os.walk, fwalk

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Our standard is to start function doc entries with verbs. In any case, it is 
irrelevant whether os.walk is a generator function or iterator class. Which is 
to say, it is not part of the language definition that the object returned by 
os.walk() is specifically a generator, as opposed to an instance of some other 
iterator class. Indeed, other implementations might do differently and if we 
decided to recode os.walk in C to make it faster, it would be an iterator class 
and not a generator function (which are only written in Python). So 'generate' 
is being used in a generic sense. 

Ideas like this, and the one about changing 'topdown', would be better floated 
on python-list.

--
nosy: +terry.reedy
resolution:  -> works for me
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue17411] Build failures with non-NDEBUG, non-Py_DEBUG builds.

2013-03-15 Thread STINNER Victor

STINNER Victor added the comment:

I added _PyUnicode_CheckConsistency() to Python 3.3 to check the implementation 
of the PEP 393, this function should not be called in release mode, that's just 
it is not defined in release mode.

--

___
Python tracker 

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



[issue17411] Build failures with non-NDEBUG, non-Py_DEBUG builds.

2013-03-15 Thread STINNER Victor

STINNER Victor added the comment:

> that's just it is not defined in release mode.

that's *why*

2013/3/15 STINNER Victor :
>
> STINNER Victor added the comment:
>
> I added _PyUnicode_CheckConsistency() to Python 3.3 to check the 
> implementation of the PEP 393, this function should not be called in release 
> mode, that's just it is not defined in release mode.
>
> --
>
> ___
> Python tracker 
> 
> ___

--

___
Python tracker 

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



[issue17411] Build failures with non-NDEBUG, non-Py_DEBUG builds.

2013-03-15 Thread Thomas Wouters

Thomas Wouters added the comment:

Unfortunately there is no "release mode". There's Py_DEBUG mode, and the 
absence of Py_DEBUG. And there's NDEBUG, and the absence of NDEBUG, which 
controls the assert macro. Py_DEBUG unsets NDEBUG, but *not* setting Py_DEBUG 
doesn't *set* NDEBUG (nor should it.)

In the Google build environment, where we occasionally embed Python and also 
build extensions that use Python and Python itself in slightly different ways, 
we have build modes that don't set Py_DEBUG but don't set NDEBUG -- so we keep 
the asserts, but don't set Py_DEBUG (which would change the ABI.) I suggest 
that this is a valid expectation :) If something is used in assert statements 
(and _PyUnicode_CheckConsistency is, quite a lot) it needs to be defined 
whenever NDEBUG is not defined, not just when Py_DEBUG is defined. The patch 
makes it a macro that calls PyUnicode_Check() in that case, because that's what 
unicodeobject.c itself does.

In the case of obmalloc, the asserts are calling functions that are only 
defined when PYMALLOC_DEBUG is set, so it seems obvious that that's the guard 
that should surround their use.

--

___
Python tracker 

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



[issue17433] stdlib generator-like iterators don't forward send/throw

2013-03-15 Thread Thomas Wouters

New submission from Thomas Wouters:

In response to a question asked at Brett Cannon's Python 3.3 talk at PyCon, it 
occurs to me the iterators in the itertools module should participate in 
generator sending, so that you can do this:

def report_first_ten(g):
s = itertools.islice(g, 10)
yield from s
print("First 10 done.")
yield from g

and then send (or throw) into the report_first_ten() generator, it fails 
(because itertools.islice() has no send method.) Similarly, perhaps 
itertools.izip() should gain a send method that sends into the iterators it's 
zipping, etc.

--
components: Library (Lib)
messages: 184273
nosy: twouters
priority: normal
severity: normal
status: open
title: stdlib generator-like iterators don't forward send/throw
versions: Python 3.4

___
Python tracker 

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



[issue17431] email.parser module has no attribute BytesFeedParser

2013-03-15 Thread Edmond Burnett

Edmond Burnett added the comment:

Working on a patch for this.

--
nosy: +edmond.burnett

___
Python tracker 

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



[issue17432] PyUnicode_ functions not accessible in Limited API on Windows

2013-03-15 Thread Martin v . Löwis

Martin v. Löwis added the comment:

The Unicode functions were left out of the limited API precisely because of the 
UCS2/UCS4 issue. If you have an extension module on a narrow Python build using 
the limited API, it should work without recompilation on a wide build as well.

Now, with Python 3.3, this issue is gone, so it might be reasonable to add  
some of the functions to the limited API. Can you propose a list of functions 
that you think should be there?

--
nosy: +loewis

___
Python tracker 

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



[issue17418] Documentation for os.open and io.open

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

This is really two issues:

io.open: Your statement about *buffering* not correct is not helpful. Quote the 
sentence you think is wrong. I am guessing it is "Pass ... an integer > 1 to 
indicate the size of a fixed-size chunk buffer". Then quote some code from the 
module or code that uses the module that acts differently from the doc. Then 
suggest an alternative wording supported by the evidence presented.

os.open:
For *flags*, there already is a link to
http://docs.python.org/3/library/os.html#open-flag-constants
That says "consult the open(2) manual page on Unix or the MSDN on Windows."

I believe mode is ignored on Windows. (Martin, true?)
Any Unix system should document the various bits, but we could say where, as 
with flags (open(2) also)?

I agree that "see the C run-time documentation" (for flags and mode) is pretty 
useless as is. This must refer to the C-API manual.  If you can find a specific 
link for info about flags or mode, it can be added. I do not see anything in 
the index. It is possible that the sentence is obsolete and should be deleted.

Do note that the note "This function is intended for low-level I/O. For normal 
usage, use the built-in function open()," strongly implies that one should only 
use this function with some understanding of the os function that it wraps. 
This is true for much of the os module.

--
nosy: +loewis, terry.reedy
stage:  -> needs patch
title: Documentation Bug -> Documentation for os.open and io.open

___
Python tracker 

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



[issue17431] email.parser module has no attribute BytesFeedParser

2013-03-15 Thread Edmond Burnett

Changes by Edmond Burnett :


--
keywords: +patch
Added file: http://bugs.python.org/file29421/issue17431_3.4.patch

___
Python tracker 

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



[issue17434] str literals, which are not docstrings, should not be allowed between __future__ imports

2013-03-15 Thread Arfrever Frehtes Taifersar Arahesis

New submission from Arfrever Frehtes Taifersar Arahesis:

test1.py shows that a str literal before first import from __future__ is a 
docstring.
test2.py shows that a str literal after first import from __future__ is not a 
docstring.
test2.py shows that if docstring is absent, then a single str literal between 
imports from __future__ does not cause SyntaxError, while it should.
test3.py shows that if docstring is present, then a str literal between imports 
from __future__ causes SyntaxError.
test4.py shows that if docstring is absent, then >=2 str literals between 
imports from __future__ cause SyntaxError.

$ cat test1.py
"some text"
from __future__ import absolute_import
print(__doc__)
$ cat test2.py
from __future__ import absolute_import
"some text"
from __future__ import print_function
print(__doc__)
$ cat test3.py
"some text 1"
from __future__ import absolute_import
"some text 2"
from __future__ import print_function
$ cat test4.py
from __future__ import absolute_import
"some text 1"
"some text 2"
from __future__ import print_function
$ python3.4 test1.py
some text
$ python3.4 test2.py
None
$ python3.4 test3.py
  File "test3.py", line 4
from __future__ import print_function
^
SyntaxError: from __future__ imports must occur at the beginning of the file
$ python3.4 test4.py
  File "test4.py", line 4
from __future__ import print_function
^
SyntaxError: from __future__ imports must occur at the beginning of the file
$

--
components: Interpreter Core
messages: 184277
nosy: Arfrever
priority: normal
severity: normal
status: open
title: str literals, which are not docstrings, should not be allowed between 
__future__ imports
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue17435] threading.Timer.__init__() should use immutable argument defaults for args and kwargs

2013-03-15 Thread Denver Coneybeare

New submission from Denver Coneybeare:

The __init__() method of threading.Timer uses *mutable* default values for the 
"args" and "kwargs" arguments.  Since the default argument objects are created 
once and re-used for each instance, this means that changing the args list or 
kwargs dict of a Timer object that used the argument defaults will specify 
those arguments to all future Timer objects that use the defaults too.

def __init__(self, interval, function, args=[], kwargs={}):

A fully backwards-compatible way to fix this is to instead use None as the 
default value for args and kwargs and just create a new list and/or dict inside 
__init__() if they are None.  That way each new instance of Timer will get its 
very own args list and kwargs dict object.

def __init__(self, interval, function, args=None, kwargs=None):
...
self.args = args if args is not None else []
self.kwargs = kwargs if kwargs is not None else {}

Here is a sample script that reproduces the issue:

import threading

event = threading.Event()
def func(*args, **kwargs):
print("args={!r} kwargs={!r}".format(args, kwargs))
event.set()

timer1 = threading.Timer(1, func)
timer1.args.append("blah")
timer1.kwargs["foo"] = "bar"

timer2 = threading.Timer(1, func)
timer2.start()
event.wait()

Here is the example output when run before the fix:

c:\dev\cpython>PCbuild\python_d.exe ThreadingTimerInitDefaultArgsIssueDemo.py
args=('blah',) kwargs={'foo': 'bar'}
[44758 refs, 17198 blocks]

And after the fix:

c:\dev\cpython>PCbuild\python_d.exe ThreadingTimerInitDefaultArgsIssueDemo.py
args=() kwargs={}
[47189 refs, 18460 blocks]

As you can see, in the version without the fix, the elements added to timer1's 
args and kwargs were also given to timer2, which is almost certainly not what a 
user would expect.

A proposed patch, ThreadingTimerInitDefaultArgsIssueDemo.01.patch, is attached. 
 This fixes the issue, updates the docs, and adds a unit test.

--
components: Library (Lib)
files: ThreadingTimerInitDefaultArgsIssueDemo.01.patch
keywords: patch
messages: 184278
nosy: denversc
priority: normal
severity: normal
status: open
title: threading.Timer.__init__() should use immutable argument defaults for 
args and kwargs
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: 
http://bugs.python.org/file29422/ThreadingTimerInitDefaultArgsIssueDemo.01.patch

___
Python tracker 

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



[issue15806] Add context manager for the "try: ... except: pass" pattern

2013-03-15 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue15805] Add stdout redirection tool to contextlib

2013-03-15 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue17431] email.parser module has no attribute BytesFeedParser

2013-03-15 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4e6cf15e55c1 by R David Murray in branch '3.2':
#17431: Fix missing import of BytesFeedParser in email.parser.
http://hg.python.org/cpython/rev/4e6cf15e55c1

New changeset 45f6925906bf by R David Murray in branch '3.3':
Merge: #17431: Fix missing import of BytesFeedParser in email.parser.
http://hg.python.org/cpython/rev/45f6925906bf

New changeset b7c1ed5ce714 by R David Murray in branch 'default':
Merge: #17431: Fix missing import of BytesFeedParser in email.parser.
http://hg.python.org/cpython/rev/b7c1ed5ce714

--
nosy: +python-dev

___
Python tracker 

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



[issue17431] email.parser module has no attribute BytesFeedParser

2013-03-15 Thread R. David Murray

R. David Murray added the comment:

Thanks, Edmond.

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

___
Python tracker 

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



[issue16057] Subclasses of JSONEncoder should not be insturcted to call JSONEncoder.decode

2013-03-15 Thread Éric Araujo

Changes by Éric Araujo :


--
keywords: +needs review
stage: needs patch -> patch review
versions: +Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



[issue11420] Make testsuite pass with -B/DONTWRITEBYTECODE set.

2013-03-15 Thread Éric Araujo

Éric Araujo added the comment:

Looks fine.

Can this go into 2.7 too?

--
nosy: +eric.araujo

___
Python tracker 

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



[issue17420] bdist_wininst does not play well with unicode descriptions

2013-03-15 Thread Éric Araujo

Changes by Éric Araujo :


--
assignee:  -> eric.araujo
components: +Distutils
nosy: +eric.araujo, tarek

___
Python tracker 

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



[issue17435] threading.Timer.__init__() should use immutable argument defaults for args and kwargs

2013-03-15 Thread R. David Murray

R. David Murray added the comment:

Hmm.  This wasn't an issue before 3.3 because previously one couldn't subclass 
Timer.  So yeah, this needs to be fixed, but only in 3.3 and tip.

Thanks for the patch.

--
nosy: +r.david.murray
stage:  -> patch review
versions:  -Python 2.7, Python 3.1, Python 3.2

___
Python tracker 

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



[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Rock Li

Rock Li added the comment:

Hi Ross, 

What about if one implementation of posix use the global variable to store 
something. From `man readdir`, I didn't see the sentence "This data is not 
overwritten by another call to readdir() on a different directory stream.".

And from the link you gived, 
""
Background

The POSIX readdir_r function is a thread-safe version of the readdir function 
used to read directory entries. Whereas readdir returns a pointer to a 
system-allocated buffer and may use global state without mutual exclusion, 
readdir_r uses a user-supplied buffer and is guaranteed to be reentrant. Its 
use is therefore preferable or even essential in portable multithreaded 
programs.
""

Actually readdir_r is guaranteed to be reentrant. By using readdir, I think 
just like to use errno in a multi thread programs, we can't always think it 
will work as the right way. But readdir_r, we can. 

And another question, you say 
"struct dirent should not be allocated on the stack since the last field may be 
an unspecified size."

What does this mean? Can you explain detail to me?
Thx.

--

___
Python tracker 

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



[issue10652] test___all_ + test_tcl fails (Windows installed binary)

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Once I worked around the example.bat problems so repository _tkinter will run 
for one python version (3.2), Zach's patch seems to solve the test problem as 
well as mine, and it is better self-contained. In other words,
python -m test -ugui test___all__ test_tcl test_tk test_ttk_guionly 
test_ttk_textonly
runs all five tests with os.environ change the only problem noted.

If Ezio or someone else who knows testing better than me agrees that it is the 
right patch, I am willing to apply it.

--
stage: patch review -> commit review

___
Python tracker 

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



[issue17239] XML vulnerabilities in Python

2013-03-15 Thread Benjamin Peterson

Benjamin Peterson added the comment:

Since this has dragged on for quite a while, I'm probably just going to release 
2.7.4 with a pointer to defusedxml in the release notes. (docs, though, perhaps)

--

___
Python tracker 

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



[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread R. David Murray

R. David Murray added the comment:

My man page says "The  data  returned by readdir() may be overwritten by 
subsequent calls to readdir() for the same directory stream."  Ross I believe 
was quoting from the posix *spec*, so that is a more complete explanation.  If 
an implementation is doing what you said, it would be out of compliance with 
posix.

Python opens a new directory stream inside listdir, and that directory stream 
is not exposed to the Python code, so there is no way for another Python thread 
to cause a problem here.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue17434] str literals, which are not docstrings, should not be allowed between __future__ imports

2013-03-15 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis added the comment:

Jython and PyPy properly raise SyntaxError for test2.py.

--

___
Python tracker 

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



[issue16310] zipfile: allow surrogates in filenames

2013-03-15 Thread Toshio Kuratomi

Toshio Kuratomi added the comment:

I found some "standards" docs that could bear on this:

http://www.pkware.com/documents/casestudies/APPNOTE.TXT

Appendix D:
"D.1 The ZIP format has historically supported only the original IBM PC 
character encoding set, commonly referred to as IBM Code Page 437."
[..]
"D.2 If general purpose bit 11 is unset, the file name and comment should 
conform to the original ZIP character encoding.  If general purpose bit 11 is 
set, the filename and comment must support The Unicode Standard, Version 4.1.0 
or greater using the character encoding form defined by the UTF-8 storage 
specification."
[..]

So there's two choices for a filename in a zipfile:

* bytes that make valid UTF-8 strings
* bytes that make valid strings in code page 437

http://en.wikipedia.org/wiki/Code_page_437#Standard_code_page

Code Page 437 takes up all 256 possible bit patterns available in a byte.

These two factors mean that if a filename in a zipfile is considered from the 
POV of a sequence of bytes, it can (according to the zipfile standard) contain 
any possible sequence of bytes.  If a filename is considered from the POV of a 
sequence of human characters, it can contain any possible sequence of unicode 
code points encoded as utf-8.  

The tricky bit: if the bytes are not valid utf-8 then officially the characters 
should be limited to the 256 characters of Code Page 437.   However, the client 
tools I've looked at exploit the fact that all bytes are possible to simply 
save the bytes that make up the filename into the zip file.

--
nosy: +a.badger

___
Python tracker 

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



[issue17239] XML vulnerabilities in Python

2013-03-15 Thread Raymond Hettinger

Raymond Hettinger added the comment:

> Since this has dragged on for quite a while, I'm probably 
> just going to release 2.7.4 with a pointer to defusedxml
> in the release notes. (docs, though, perhaps)

+1

--
nosy: +rhettinger

___
Python tracker 

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



[issue15805] Add stdout redirection tool to contextlib

2013-03-15 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: ncoghlan -> rhettinger

___
Python tracker 

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



[issue10652] test___all_ + test_tcl fails (Windows installed binary)

2013-03-15 Thread Ezio Melotti

Ezio Melotti added the comment:

LGTM.

The changes on os.environ should be unrelated.  I've seen a few other tests 
(e.g. test_distutils) that change it on Windows, and started writing a patch 
for it, but I never finished it.

--
assignee:  -> terry.reedy
stage: commit review -> patch review

___
Python tracker 

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



[issue17415] Clarify docs of os.path.normpath()

2013-03-15 Thread Ezio Melotti

Ezio Melotti added the comment:

Your suggestion -- assuming it's accurate -- looks good to me, however I would 
get rid of the exclamation mark and move the link to normcase at the end:
"""
Normalize a pathname by collapsing redundant separators and up-level references 
so that A//B, A/B/, A/./B and A/foo/../B all become A/B. This collapsing may 
change the meaning of the path if it contains symbolic links.  On Windows, 
normpath also converts forward slashes to backward slashes.  normpath doesn't 
normalize the case -- use normcase for that.
"""

--

___
Python tracker 

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



[issue13918] locale.atof documentation is missing func argument

2013-03-15 Thread Ezio Melotti

Ezio Melotti added the comment:

The function was introduced by Guido in f5b55311e79d.

I think it would have been better if atof had another name (e.g. _atof) and 
that atof and atoi were implemented as:

def atof(str):
return _atof(str, float)
def atoi(str):
return _atof(str, int)

Even better would have been to have _atof return the string without applying 
any function, and let e.g. atoi return int(_atof(str)).  This could have been 
documented publicly and used to build other functions.
However it's probably too late for such refactoring.

--

___
Python tracker 

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



[issue17432] PyUnicode_ functions not accessible in Limited API on Windows

2013-03-15 Thread Bill Dirks

Bill Dirks added the comment:

A great number of PyUnicode functions are already added to the Limited API. 
That is, the declarations are outside of #ifndef Py_LIMITED_API guards in the 
header files, and the symbols are included in python3.lib and exported from 
python3.dll. (in 3.3.0)

Can't those functions link to the functions of the same name in python33.dll?

In other words, for example, PyUnicode_FromString in the python3.dll should 
link to PyUnicode_FromString in python33.dll, not PyUnicodeUCS2_FromString 
(which doesn't exist in python33.dll). Right?

--

___
Python tracker 

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



[issue10652] test___all_ + test_tcl fails (Windows installed binary)

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

After editing 2.7 files to match Zach's patch, and also after adding the 
changes in my patch, and also deleting tcltk directory and rerunning 
external.bat to rebuild tcltk/ for 2.7 with tcl/tk 8.5.2,
the tests still do not all work right.

--
F:\Python\dev\py27\PCbuild> python_d -m test.regrtest -ugui test___all__ 
test_tcl test_tk test_ttk_guionly test_ttk_text
only

test___all__
Warning -- os.environ was modified by test___all__

test_tcl
test test_tcl failed -- multiple errors occurred; run in verbose mode for 
details

test_tk
test_tk skipped -- tk not available: Can't find a usable init.tcl in the 
following directories:
F:/Python/dev/py27/lib/tcl8.5 F:/Python/dev/py27/lib/tcl8.5 
F:/Python/dev/lib/tcl8.5 F:/Python/dev/py27/library F:/P
ython/dev/library F:/Python/dev/tcl8.5.2/library F:/Python/tcl8.5.2/library
This probably means that Tcl wasn't installed properly.

--
If test_tcl is run first, it works, test_ttk_guionly gives the same message as 
test_tk, test_ttk_testonly is OK. So the attached patch, 10652_tkfix_27.diff is 
an improvement, but not a complete fix.

I am going to concentrate on 3.x (which means manually delete tcltk and 
re-compile) and apply if all goes well.

--
Added file: http://bugs.python.org/file29423/10652_tkfix_27.diff

___
Python tracker 

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



[issue13918] locale.atof documentation is missing func argument

2013-03-15 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The refactoring could be done if we were willing to give the normalize function 
a public name, so people could write Decimal(delocalize()) or if we were willing to add atod and atofr (fraction). However, 
simply adding a few words to the doc is a lot easier.

--

___
Python tracker 

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



[issue17428] replace readdir to readdir_r in function posix_listdir

2013-03-15 Thread Ross Lagerwall

Ross Lagerwall added the comment:

That text was from the POSIX 2008 spec:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/readdir.html

The following text from my copy of the readdir manpage gives an indication of 
how you *should* allocate struct dirent when using readdir_r:
"""
Since  POSIX.1 does not specify the size of the d_name field, and other 
nonstandard fields may precede that field within the dirent structure, portable 
applications that use readdir_r() should allocate the buffer whose address is 
passed in entry as follows:

   name_max = pathconf(dirpath, _PC_NAME_MAX);
   if (name_max == -1) /* Limit not defined, or error */
   name_max = 255; /* Take a guess */
   len = offsetof(struct dirent, d_name) + name_max + 1;
   entryp = malloc(len);

(POSIX.1 requires that d_name is the last field in a struct dirent.)
"""

I hope that helps

--

___
Python tracker 

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