[issue18283] shutil.which() should support bytes

2013-06-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What about bytearrays and other byte-like objects?

However I'm not sure this enhancement is worth to be accepted. Many other 
high-level functions in os and shutil modules do not support bytes paths. For 
shutil.which() there is no backward compatibility with Python 2 which we should 
support.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue18236] int() and float() do not accept strings with trailing separators

2013-06-23 Thread Martin v . Löwis

Martin v. Löwis added the comment:

I stand by that comment: IsWhiteSpace should use the Unicode White_Space 
property. Since FS/GS/RS/US are not in the White_Space property, it's correct 
that the int conversion fails. It's incorrect that .isspace() gives true.

There are really several bugs here:
- .isspace doesn't use the White_List property
- int conversion ultimately uses Py_ISSPACE, which conceptually could deviate 
from the Unicode properties (as it is byte-based). This is not really an issue, 
since they indeed match.

I propose to fix this by parsing PropList.txt, and generating 
_PyUnicode_IsWhitespace based on the White_Space property. For efficiency, it 
should also generate a fast-lookup array for the ASCII case, or just use 
_Py_ctype_table (with a comment that this table needs to match PropList 
White_Space). _Py_ascii_whitespace should go.

Contributions are welcome.

--

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread anatoly techtonik

anatoly techtonik added the comment:

..and still I miss:

with os.chdir(path):
  do_something()

--

___
Python tracker 

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



[issue18236] int() and float() do not accept strings with trailing separators

2013-06-23 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

I agree with Martin.

At the time Unicode was added to Python, there was no single Unicode property 
for white space, so I had to deduce this from the other available properties.

Now that we have a white space property in Unicode, we should start using it. 
Fortunately, the difference in Python's set of white space chars and the ones 
having the Unicode white space property are minimal.

--
nosy: +lemburg

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

The idea was discussed many times, and there are existing implementations:

http://mail.python.org/pipermail/python-ideas/2013-January/018756.html
http://www.astropython.org/snippet/2009/10/chdir-context-manager
http://stackoverflow.com/questions/169070/python-how-do-i-write-a-decorator-that-restores-the-cwd
...

The idea was rejected because it is "an anti-pattern" "encouraging a bad habit".

The current working directory is something global, as locales on UNIX: in a 
multithreaded application, all threads would be affected by such change. It's 
better to work only with absolute paths and never call os.chdir().

--
nosy: +haypo

___
Python tracker 

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



[issue18283] shutil.which() should support bytes

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

"What about bytearrays and other byte-like objects?

However I'm not sure this enhancement is worth to be accepted. Many other 
high-level functions in os and shutil modules do not support bytes paths. For 
shutil.which() there is no backward compatibility with Python 2 which we should 
support."

Bytes is the native type for path on all platforms... except Windows. So I 
fixed many functions of the os module to support bytes parameters. For example, 
functions of os.path support str and bytes types, but not bytearray. I also 
prefer to reject byte-like objects, to keep it simple.

The bytes type should be accepted for any kind of os function parameter: path, 
environment variable, command line argument, etc. It's not a question of being 
compatible with Python 2, an application can make the choice of only used bytes 
because bytes is the native type for OS data on UNIX.

Python 3 supports also "bytes stored in Unicode" thanks to the PEP 393, but 
it's not exactly the same: a path stored as str depends on the filesystem 
locale, whereas a bytes string is well defined (it's just an array of 8-bit 
unsigned numbers) and doesn't depend on any configuration variable.

--

___
Python tracker 

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



[issue18283] shutil.which() should support bytes

2013-06-23 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +loewis

___
Python tracker 

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



[issue18236] int() and float() do not accept strings with trailing separators

2013-06-23 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +haypo

___
Python tracker 

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



[issue11016] Re-implementation of the stat module in C

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

> And stat_filemode() should detect integer overflow.

Attached stat_mode_overflow.patch should fix this issue.

(I would also suggest to inline fileperm() into stat_filemode(), or pass buf 
instead of &buf[1]. But you may not agree, as you want :-))

--
Added file: http://bugs.python.org/file30675/stat_mode_overflow.patch

___
Python tracker 

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



[issue18137] format(float, str): integer overflow for huge precision

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ef5175d08e7e by Victor Stinner in branch '3.3':
Issue #18137: Detect integer overflow on precision in float.__format__() and
http://hg.python.org/cpython/rev/ef5175d08e7e

New changeset 81fef2666ebb by Victor Stinner in branch 'default':
(Merge 3.3) Issue #18137: Detect integer overflow on precision in
http://hg.python.org/cpython/rev/81fef2666ebb

New changeset d2b4f59943fa by Victor Stinner in branch '2.7':
Issue #18137: Detect integer overflow on precision in float.__format__()
http://hg.python.org/cpython/rev/d2b4f59943fa

--
nosy: +python-dev

___
Python tracker 

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



[issue18137] format(float, str): integer overflow for huge precision

2013-06-23 Thread STINNER Victor

Changes by STINNER Victor :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue18135] _ssl module: possible integer overflow for very long strings (+2^31 bytes)

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f0d934732ab1 by Victor Stinner in branch '3.3':
Issue #18135: Fix a possible integer overflow in ssl.SSLSocket.write()
http://hg.python.org/cpython/rev/f0d934732ab1

New changeset f90d82a75a43 by Victor Stinner in branch 'default':
(Merge 3.3) Issue #18135: Fix a possible integer overflow in
http://hg.python.org/cpython/rev/f90d82a75a43

New changeset d7e22acb2315 by Victor Stinner in branch '2.7':
Issue #18135: Fix a possible integer overflow in ssl.SSLSocket.write()
http://hg.python.org/cpython/rev/d7e22acb2315

--
nosy: +python-dev

___
Python tracker 

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



[issue18135] _ssl module: possible integer overflow for very long strings (+2^31 bytes)

2013-06-23 Thread STINNER Victor

Changes by STINNER Victor :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread anatoly techtonik

anatoly techtonik added the comment:

"an anti-pattern" and "encouraging a bad habit" are subjective non-arguments as 
long as they fail to answer why.

With or without the helper you still write this code:

prev = os.getcwd()
os.chdir(SDKPATH)
...
os.chdir(prev)

And because os.chdir() doesn't do anything high-level, there is no place for 
the multithreading warning.

--

___
Python tracker 

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



[issue18135] _ssl module: possible integer overflow for very long strings (+2^31 bytes)

2013-06-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'm sorry to chime in a bit late, but I think this isn't the correct solution. 
Right now partial writes are not possible on a SSL socket, but this commit 
makes them possible. See http://bugs.python.org/issue8240 and 
http://bugs.python.org/issue12197 for some background.

I think the right solution here would be to raise OverflowError, not truncate 
the output.

--
status: closed -> open

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

> "an anti-pattern" and "encouraging a bad habit" are subjective non-arguments 
> as long as they fail to answer why.

The reasons are explained in the python-idea thread. Please read it.

> With or without the helper you still write this code:

Adding more functions using os.chdir() would "encoure a bad habit".

--

___
Python tracker 

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



[issue11016] Re-implementation of the stat module in C

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

My changeset e5427b0b2bf7 is not enough: "import _stat" still fail on Windows. 
See for example:

http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.x/builds/2164/steps/test/logs/stdio

==
ERROR: test_directory (test.test_stat.TestFilemodeCStat)
--
Traceback (most recent call last):
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_stat.py", 
line 128, in test_directory
st_mode, modestr = self.get_mode()
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_stat.py", 
line 67, in get_mode
modestr = self.statmod.filemode(st_mode)
AttributeError: 'NoneType' object has no attribute 'filemode'

==
ERROR: test_mode (test.test_stat.TestFilemodeCStat)
--
Traceback (most recent call last):
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_stat.py", 
line 119, in test_mode
st_mode, modestr = self.get_mode()
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_stat.py", 
line 67, in get_mode
modestr = self.statmod.filemode(st_mode)
AttributeError: 'NoneType' object has no attribute 'filemode'

==
ERROR: test_module_attributes (test.test_stat.TestFilemodeCStat)
--
Traceback (most recent call last):
  File "C:\buildbot.python.org\3.x.kloth-win64\build\lib\test\test_stat.py", 
line 169, in test_module_attributes
modvalue = getattr(self.statmod, key)
AttributeError: 'NoneType' object has no attribute 'ST_DEV'

--

___
Python tracker 

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



[issue11016] Re-implementation of the stat module in C

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

test_stat.test_devices() fail on Solaris: it looks like os.devnull is a 
symlink. You should probably use os.stat() instead of os.lstat() for this 
specific test.

http://buildbot.python.org/all/builders/SPARC%20Solaris%2010%20%28cc%2C%2032b%29%20%5BSB%5D%203.x/builds/708/steps/test/logs/stdio

==
FAIL: test_devices (test.test_stat.TestFilemodeCStat)
--
Traceback (most recent call last):
  File 
"/home/cpython/buildslave/cc-32/3.x.snakebite-sol10-sparc-cc-32/build/Lib/test/test_stat.py",
 line 157, in test_devices
self.assertEqual(modestr[0], 'c')
AssertionError: 'l' != 'c'
- l
+ c

--

___
Python tracker 

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



[issue18135] _ssl module: possible integer overflow for very long strings (+2^31 bytes)

2013-06-23 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> > I think the right solution here would be to raise OverflowError, not 
> > truncate the output.
> 
> Do you mean always? Or only if the SSL_MODE_ENABLE_PARTIAL_WRITE option is 
> not set?

SSL_MODE_ENABLE_PARTIAL_WRITE is never set.

--

___
Python tracker 

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



[issue18236] int() and float() do not accept strings with trailing separators

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
hgrepos: +201

___
Python tracker 

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



[issue18135] _ssl module: possible integer overflow for very long strings (+2^31 bytes)

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

> Right now partial writes are not possible on a SSL socket, but this commit 
> makes them possible.

Oh, I didn't know (forgot) that SSL does allow partial write by default.

> I think the right solution here would be to raise OverflowError, not truncate 
> the output.

Do you mean always? Or only if the SSL_MODE_ENABLE_PARTIAL_WRITE option is not 
set?

--

___
Python tracker 

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



[issue18135] _ssl module: possible integer overflow for very long strings (+2^31 bytes)

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

> I think the right solution here would be to raise OverflowError, not truncate 
> the output.

Here is a new patch (for Python 3.3) always raising OverflowError if the string 
is longer than INT_MAX bytes.

--
Added file: http://bugs.python.org/file30676/ssl_overflow.patch

___
Python tracker 

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



[issue12520] spurious output in test_warnings

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

I cannot reproduce this isuse, was it fixed?

$ ./python -m test test_warnings
[1/1] test_warnings
1 test OK.

> Also, I don't understand how test_filename_none is supposed to check for 
> issue #12467 (it doesn't use a subprocess).

You don't need a subprocess to reproduce the issue, you just have to emit a 
warning with __file__=None. At shutdown, __file__ is set to None by 
Py_Finalize, whereas a warning is emitted because a file was not closed 
explicitly.

--

___
Python tracker 

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



[issue18236] int() and float() do not accept strings with trailing separators

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
keywords: +patch
Added file: http://bugs.python.org/file30677/5c934626d44d.diff

___
Python tracker 

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



[issue11016] Re-implementation of the stat module in C

2013-06-23 Thread Christian Heimes

Christian Heimes added the comment:

I have addressed the Windows build issue in 
http://hg.python.org/cpython/rev/838f04e5a690 and the failing test on Solaris 
in http://hg.python.org/cpython/rev/6c23ca1982b3 (also 2.7 and default).

--

___
Python tracker 

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



[issue7267] format method: c presentation type broken

2013-06-23 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
stage: test needed -> needs patch

___
Python tracker 

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



[issue18287] PyType_Ready() should sanity-check the tp_name field

2013-06-23 Thread Niklas Koep

New submission from Niklas Koep:

I noticed that defining a new type where the tp_name field is NULL causes 
segfaults, for instance, when calling pydoc on the extension module. This 
particular segfault traces back to type_module() in Objects/typeobject.c where 
tp_name is passed to strrchr(). Raising an appropriate exception from 
PyType_Ready() seems sensible to avoid this kind of issue. The field is also 
used in two calls to PyErr_Format() in PyType_Ready() itself where it'll cause 
segfaults if not handled properly.

While we're on the subject, pydoc doesn't list the type documentation  if the 
tp_name string does not have a dot in it. I didn't research this any further as 
omitting dots seems to be valid according to the docs. However, at the very 
least it seems like this side effect should be mentioned in the documentation 
to avoid confusion when someone omits/forgets the 
package..module.type hierarchy in the field definition.

I attached a tiny patch which just jumps to PyType_Ready()'s error label if the 
field is NULL. I also added a comment about pydoc in the two places of the 
documentation I could think of where tp_name is mentioned.

--
components: Interpreter Core
files: patch
messages: 191705
nosy: nkoep
priority: normal
severity: normal
status: open
title: PyType_Ready() should sanity-check the tp_name field
type: crash
versions: Python 3.5
Added file: http://bugs.python.org/file30678/patch

___
Python tracker 

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



[issue18236] str.isspace should use the Unicode White_Space property

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I have updated the title to focus this issue on the behavior of str.isspace().  
I'll pick up remaining int/float issues in #10581.

--
assignee:  -> belopolsky
title: int() and float() do not accept strings with trailing separators -> 
str.isspace should use the Unicode White_Space property

___
Python tracker 

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



[issue18236] str.isspace should use the Unicode White_Space property

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


Added file: http://bugs.python.org/file30679/3ed5bb7fcee9.diff

___
Python tracker 

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



[issue18236] str.isspace should use the Unicode White_Space property

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


Removed file: http://bugs.python.org/file30677/5c934626d44d.diff

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread Brian Curtin

Changes by Brian Curtin :


--
nosy:  -brian.curtin

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread anatoly techtonik

anatoly techtonik added the comment:

On Sun, Jun 23, 2013 at 4:32 PM, STINNER Victor wrote:

>
> STINNER Victor added the comment:
>
> > "an anti-pattern" and "encouraging a bad habit" are subjective
> non-arguments as long as they fail to answer why.
>
> The reasons are explained in the python-idea thread. Please read it.
>

This operation is time consuming. I counted +5 votes for the idea and then
it turned into some complicated reading.
If you know the reasons, why can't you do good for other people and
summarize them here?

--

___
Python tracker 

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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread R. David Murray

R. David Murray added the comment:

I would prefer that Haypo spend his time contributing code to Python.  If 
someone else wants to summarize the arguments in the thread for this issue, 
that would be great.  Absent that, the link to the discussion is sufficient for 
the curious.

In any case, the arguments already in this issue are sufficient.

--
resolution:  -> rejected
stage:  -> committed/rejected

___
Python tracker 

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



[issue10581] Review and document string format accepted in numeric data type constructors

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Martin v. Löwis wrote at #18236 (msg191687):
> int conversion ultimately uses Py_ISSPACE, which conceptually could
> deviate from the Unicode properties (as it is byte-based). This is not
> really an issue, since they indeed match.

Py_ISSPACE matches Unicode White_Space property in the ASII range (first 128 
code points) it differs for byte (code point) values from 128 through 255.  
This leads to the following discrepancy:

>>> int('123\xa0')
123

but

>>> int(b'123\xa0')
Traceback (most recent call last):
  File "", line 1, in 
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 3: invalid 
start byte
>>> int('123\xa0'.encode())
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: '123\xa0'

--

___
Python tracker 

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



[issue10581] Review and document string format accepted in numeric data type constructors

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +loewis

___
Python tracker 

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



[issue18184] Add range check for %c in PyUnicode_FromFormat

2013-06-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

No, I don't feel motivated right now (and this is a case when even never is 
better than right now).

I checked other format methods and found a bug only in PyUnicode_FromFormatV(). 
I had added test for 3.3+ because 3.3+ already have a test for 
PyUnicode_FromFormatV(). I hadn't add test for 2.7 because there is no test for 
PyUnicode_FromFormatV() on 2.7.

--
assignee:  -> serhiy.storchaka

___
Python tracker 

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



[issue18260] configparser: TypeError occurs when handling errors in files with binary names

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 56c1227f21f5 by Łukasz Langa in branch '3.3':
Fixed issue #18260: configparser TypeError on source name specified as bytes
http://hg.python.org/cpython/rev/56c1227f21f5

New changeset 06e70937364b by Łukasz Langa in branch 'default':
Merged fix for issue #18260 from 3.3
http://hg.python.org/cpython/rev/06e70937364b

--
nosy: +python-dev

___
Python tracker 

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



[issue18260] configparser: TypeError occurs when handling errors in files with binary names

2013-06-23 Thread Łukasz Langa

Łukasz Langa added the comment:

1. Duplicate sections and options are consciously reported as errors now. This 
is a documented backwards-incompatible change [1]_. If you wish to revert to 
previous behaviour, you can set strict=False on parser creation.

2. It's really just a coincidence that specifying the filename as bytes worked 
in this case before on Python 3. That being said, it is indeed an unfortunate 
regression and was fixed in 56c1227f21f5 for 3.3 and 06e70937364b for 3.4. As a 
workaround for Python versions < 3.3.3 you can specify the source name as a 
Unicode string (e.g. `read_file(f, source=path_str)`.


.. [1] 
http://docs.python.org/3/library/configparser.html#customizing-parser-behaviour

--
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



[issue18184] Add range check for %c in PyUnicode_FromFormat

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f8ede55cf92b by Serhiy Storchaka in branch '3.3':
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
http://hg.python.org/cpython/rev/f8ede55cf92b

New changeset 42def600210e by Serhiy Storchaka in branch 'default':
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
http://hg.python.org/cpython/rev/42def600210e

New changeset 2f1e8b7fa534 by Serhiy Storchaka in branch '2.7':
Issue #18184: PyUnicode_FromFormat() and PyUnicode_FromFormatV() now raise
http://hg.python.org/cpython/rev/2f1e8b7fa534

--
nosy: +python-dev

___
Python tracker 

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



[issue12641] Remove -mno-cygwin from distutils

2013-06-23 Thread frattaroli.nicolas

frattaroli.nicolas added the comment:

It's cool that you guys are discussing semantics of who said what and how, but 
that still doesn't fix this very simple issue that breaks compiling for 
everyone on Windows who uses MinGW.
-mno-cygwin, was, as far as I know, only ever required to build from cygwin as 
host to mingw as target.
It is very unlikely that anyone who'd upgrade python still needs this option 
and is running a gcc cygwin 3.x version. And if it breaks for them it's still 
better than the current state, which is "broken for everyone else".

Sorry if this sounds snarky, but the fact that this issue has been open for 
almost 2 years is quite ridiculous.

--
nosy: +fratti

___
Python tracker 

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



[issue18234] Unicodedata module should provide access to codepoint aliases

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Rather than adding a new method to unicodedata, what do you think about adding 
a type keyword argument to unicodedata.name()?  It can default to "canonical" 
and have possible values "control", "abbreviation", etc.

See also #12753.

--

___
Python tracker 

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



[issue11390] doctest: add cmdline parameters

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ae802dc4dcd4 by R David Murray in branch 'default':
#11390: convert doctest CLI to argparse and add -o and -f options.
http://hg.python.org/cpython/rev/ae802dc4dcd4

--
nosy: +python-dev

___
Python tracker 

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



[issue11390] doctest: add cmdline parameters

2013-06-23 Thread R. David Murray

R. David Murray added the comment:

Committed.  Thanks for the review, Barry.

--
resolution:  -> fixed
stage: patch review -> 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



[issue18184] Add range check for %c in PyUnicode_FromFormat

2013-06-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I agree, a ValueError may be better than OverflowError, but all other 
formattings raise OverflowError, and we should support them consistent.

--
resolution:  -> fixed
stage: patch review -> 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



[issue18234] Unicodedata module should provide access to codepoint aliases

2013-06-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Can a character or sequence have multiple aliases? What will be a result type 
of unicodedata.name() with "abbreviation" keyword value?

--

___
Python tracker 

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



[issue10581] Review and document string format accepted in numeric data type constructors

2013-06-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

For the last discrepancy see issue16741. It have a patch which should fix this.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue18288] Idle 2.7: Run Module does not set __file__

2013-06-23 Thread Terry J. Reedy

New submission from Terry J. Reedy:

This is a 2.7 only bug.

F:\Python\mypy\tem2.py

print (__file__)

__file__ should be set to relative or absolute path.

>From command line:

F:\Python\mypy> c:/programs/python27/python.exe tem2.py
tem2.py

F:\Python\mypy> c:/programs/python27/python.exe -m tem2
F:\Python\mypy\tem2.py

3.3 gives same results.

>From Idle editor window with Run Module (F5):

3.3: >>>
F:\Python\mypy\tem2.py
# same as python -m above, and same as when file is imported.

2.7: >>>
Traceback (most recent call last):
  File "F:\Python\mypy\tem2.py", line 1, in 
print (__file__)
NameError: name '__file__' is not defined

This is the bug to be fixed, if reasonably possible.

Both 2.7 and 3.3 set __file__ on regular import (or rather, Idle does not 
disable this).

>>> import tem2
F:\Python\mypy\tem2.py

I think the first step should be to try this on non-Windows systems.

--
components: IDLE
messages: 191721
nosy: Todd.Rovito, roger.serwy, terry.reedy
priority: normal
severity: normal
stage: test needed
status: open
title: Idle 2.7: Run Module does not set __file__
type: behavior
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



[issue14264] Comparison bug in distutils2.version

2013-06-23 Thread Francisco Martín Brugué

Francisco Martín Brugué added the comment:

What the status of this issue?:
the changeset http://hg.python.org/distutils2/rev/1e0ca4594a2a mentioned in 
msg155480 seems to add tests (but it hasn't been add to the issue explicitly).

Can the issue be closed?

--
nosy: +francismb

___
Python tracker 

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



[issue18288] Idle 2.7: Run Module does not set __file__

2013-06-23 Thread Francisco Martín Brugué

Francisco Martín Brugué added the comment:

On Debian:

* Command line 2.7.3
~/Prog/mypy$ python2.7 tem2.py 
tem2.py

~/Prog/mypy$ python2.7 -m tem2
/home/ci/Prog/mypy/tem2.py

* IDLE 2.7.3

>>> print(__file__)

Traceback (most recent call last):
  File "", line 1, in 
print(__file__)
NameError: name '__file__' is not defined
>>>
>>> import tem2
tem2.pyc
>>>

--
nosy: +francismb

___
Python tracker 

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



[issue18234] Unicodedata module should provide access to codepoint aliases

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

> Can a character or sequence have multiple aliases?

Yes, for example, most control characters have two aliases (and no name).

;NULL;control
;NUL;abbreviation
0001;START OF HEADING;control
0001;SOH;abbreviation
0002;START OF TEXT;control
0002;STX;abbreviation

(See )

> What will be a result type of unicodedata.name() with "abbreviation" keyword 
> value?

Under my proposal:

>>> unicodedata.name('\N{ESCAPE}', type='abbreviation')
'ESC'

I would also like to consider changing the default slightly.  I find the 
following behavior rather unhelpful:

>>> unicodedata.name('\N{ESC}')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: no such name

I think most users would expect 'ESCAPE' instead.

The following is more of a curiosity rather than a genuine problem, but is a 
good illustration for a general point:

>>> unicodedata.name('\N{PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR 
>>> BRACKET}')
'PRESENTATION FORM FOR VERTICAL RIGHT WHITE LENTICULAR BRAKCET'

(Note misspelled word "BRACKET" in the output.)

Since "correction" alias is the official method of publishing corrections to 
unicode names, I think unicodedata.name() should return correct name by default.

--

___
Python tracker 

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



[issue18288] Idle 2.7: Run Module does not set __file__

2013-06-23 Thread Francisco Martín Brugué

Francisco Martín Brugué added the comment:

>From Idle editor window (F5): 
>>> 
Traceback (most recent call last):
  File "/home/ci/Prog/mypy/tem2.py", line 1, in 
print(__file__)
NameError: name '__file__' is not defined
>>>

--

___
Python tracker 

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



[issue18179] SMTP.local_hostname is undocumented

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3685d8074203 by R David Murray in branch '3.3':
#18179: document the local_hostname parameter.
http://hg.python.org/cpython/rev/3685d8074203

New changeset b10fae8c185c by R David Murray in branch 'default':
Merge #18179: document the local_hostname parameter.
http://hg.python.org/cpython/rev/b10fae8c185c

New changeset c8914dbe6ead by R David Murray in branch '2.7':
#18179: document the local_hostname parameter.
http://hg.python.org/cpython/rev/c8914dbe6ead

New changeset ffcf46316e1f by R David Murray in branch '3.3':
#18179: reflow paragraphs.
http://hg.python.org/cpython/rev/ffcf46316e1f

New changeset 627e3096340e by R David Murray in branch 'default':
Merge #18179: reflow paragraphs.
http://hg.python.org/cpython/rev/627e3096340e

New changeset 9f1f83d23ec4 by R David Murray in branch '2.7':
#18179: reflow paragraphs.
http://hg.python.org/cpython/rev/9f1f83d23ec4

--
nosy: +python-dev

___
Python tracker 

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



[issue18179] SMTP.local_hostname is undocumented

2013-06-23 Thread R. David Murray

R. David Murray added the comment:

Thanks Berker.  I edited your patch to (a) use 'Otherwise' instead of 'By 
default', which is a change from the original docstring that I think makes it 
clearer, (b) add words about what the local_hostname is used for (the HELO/EHLO 
commands) and (c) in SMTP_SSL and LMTP, just refer to the SMTP class (like LMTP 
already did).  I also updated the docstrings similarly.

--
resolution:  -> fixed
stage: patch review -> 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



[issue9097] os.chdir(path) to return current dir

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

> anatoly techtonik added the comment:
>> The reasons are explained in the python-idea thread. Please read it.
>
> This operation is time consuming. I counted +5 votes for the idea and then
> it turned into some complicated reading.
> If you know the reasons, why can't you do good for other people and
> summarize them here?

I'm sure that other core developers already explained you how Python
is developed. It's not because someone proposed an idea and he/she has
5 supporters that the idea will be implemented. If you want to change
Python, you have to explain your usecase, others will ask you
questions, you will have to answer to answer to questions and propose
technical solutions. For this issue, many questions have no answer.
(Just one example, the fact that os.chdir() is process-wide.)

I don't know why I'm repeating myself, I already told you something
like that at least once on another topic. It's just a lack of respect
of answering "This operation is time consuming." If you don't respect
the rules (understand how Python is developed), we cannot work
together.

--

___
Python tracker 

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



[issue18234] Unicodedata module should provide access to codepoint aliases

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

unicodedata.name() was discussed in #12353 (msg144739) where MvL argued that 
misspelled names are better than corrected because they are more likely to 
appear misspelled in other sources.  I am not sure I buy this argument.  
Someone googling for 'BYZANTINE MUSICAL SYMBOL FHTORA SKLIRON CHROMA VASIS' 
will probably just enter BYZANTINE VASIS and find what he or she needs.  A more 
likely scenario is someone trying to get all FTHORA symbols using a naive code 
like this: [hex(i) for i in range(1114112) if 'FTHORA' in ud.name(chr(i), '')].

Even more likely scenario is someone seeing a fancy symbol on the web and 
wanting to use it in a python program.  Such programmer would copy the symbol 
to python prompt, call unicode.name() and copy the result in the program.  Do 
we want to encourage people to perpetuate the mistake that Unicode has 
corrected?

I don't think the issue of control codes names was discussed in #12353.  I see 
no downside with returning the first alias in case no name is present.

--

___
Python tracker 

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



[issue11016] Re-implementation of the stat module in C

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 44c8a9d80595 by Victor Stinner in branch 'default':
Issue #11016: Detect integer conversion on conversion from Python int to C 
mode_t
http://hg.python.org/cpython/rev/44c8a9d80595

--

___
Python tracker 

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



[issue17206] Py_XDECREF() expands its argument multiple times

2013-06-23 Thread STINNER Victor

STINNER Victor added the comment:

> I've attached an updated patch that reuses the _py_tmp variable for those 
> temporary assignments thus keeping the required stack size down.

I don't understand how it would change the size of the C stack, could you 
please explain? object.patch looks like refactoring to simplify the work of the 
C preprocessor.

--

___
Python tracker 

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



[issue18267] xmlrpc.client documentation multicall example missleading for division behaviour of python3

2013-06-23 Thread Bernhard Reiter

Bernhard Reiter added the comment:

Andrew,
thanks for caring!

Seeing your fix 2a3bc6eb2e13 I believe it does not fully resolv the issue.
Now the code reads
 "return x // y"
  "multicall.divide(7,3)"
and the client prints
 "7/3=2"

I think you probably should change "7/3=" to "7//3=" in the client code as well
to be instructive to learners.

By the way: your change also introduced whitespace around the operator. Now it 
is the only one out of the four. I guess they should be consistent.

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue18234] Unicodedata module should provide access to codepoint aliases

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I mistyped issue reference above it should be #12753, not 12353.

--

___
Python tracker 

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



[issue13276] bdist_wininst-created installer does not run the postinstallation script when uninstalling

2013-06-23 Thread anatoly techtonik

Changes by anatoly techtonik :


--
nosy: +techtonik

___
Python tracker 

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



[issue13276] bdist_wininst-created installer does not run the postinstallation script when uninstalling

2013-06-23 Thread anatoly techtonik

anatoly techtonik added the comment:

@Pierre.Raybaut: Looking at the stage of this ticker, I believe you need to 
write unittest. Then attach a patch. If patch is attached, the issue is more 
visible among developers.

--

___
Python tracker 

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



[issue12641] Remove -mno-cygwin from distutils

2013-06-23 Thread Jeffrey Armstrong

Jeffrey Armstrong added the comment:

> ...the fact that this issue has been open for almost 2 years is quite 
> ridiculous.

I thought that I'd add a little statistic for everyone that might put this bug 
into perspective.  Since this bug was opened, the MinGW installer has been 
downloaded about 32,000,000 (32 million) times per sf.net:

http://sourceforge.net/projects/mingw/files/Installer/stats/timeline?dates=2011-07-26+to+2013-06-23

If we take a naive approach, that's 32 million compiler installations that 
can't build Python extensions without manually modifying distutils first.  

That statistic doesn't include the multitude of people installing other builds 
of GCC for Windows (including MinGW-W64, a whole other unsupported version of 
GCC, but that's a different bug).

--

___
Python tracker 

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



[issue11723] Add support for mingw64 compiler

2013-06-23 Thread Jeffrey Armstrong

Changes by Jeffrey Armstrong :


--
nosy: +Jeffrey.Armstrong

___
Python tracker 

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



[issue11016] Re-implementation of the stat module in C

2013-06-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 75bc0ae02bcd by Christian Heimes in branch 'default':
Issue #11016: Don't define macros and constants that are already set by pyport.h
http://hg.python.org/cpython/rev/75bc0ae02bcd

--

___
Python tracker 

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



[issue12753] \N{...} neglects formal aliases and named sequences from Unicode charnames namespace

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

> about the problems you mentioned in msg144836, can you report
> it in a new issue or, if there are already issues about them,
> add a message there?

I believe that would be #4610.

--
nosy: +belopolsky
superseder:  -> Unicode case mappings are incorrect

___
Python tracker 

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



[issue4610] Unicode case mappings are incorrect

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

There has been a relatively recent discussion of case mappings under #12753 
(msg144836).

I personally agree with Martin: str.upper/lower should remain the way it is - a 
simplistic 1-to-1 mapping using UnicodeData.txt fields.  More sophisticated 
case mapping algorithms belong to a specialized library module not python core.

The behavior of .title() and .capitalize() is harder to defend, so if someone 
can point out to a python library (PyICU?) that gets it right we can reference 
it in the documentation.

--
versions: +Python 3.4 -Python 2.6, Python 3.0

___
Python tracker 

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



[issue18236] str.isspace should use the Unicode White_Space property

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


Added file: http://bugs.python.org/file30680/42973dfea391.diff

___
Python tracker 

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



[issue18236] str.isspace should use the Unicode White_Space property

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


Removed file: http://bugs.python.org/file30679/3ed5bb7fcee9.diff

___
Python tracker 

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



[issue18236] str.isspace should use the Unicode White_Space property

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I would like someone review this change:

https://bitbucket.org/alexander_belopolsky/cpython/commits/92c187025d0a8a989d9f81f2cb4c96f4eecb81cb?at=issue-18236

The patch can go in without this optimization, but I think this is the right 
first step towards removing _Py_ascii_whitespace.

I don't think there is a need to generate ASCII optimization in 
makeunicodedata.  While technically Unicode stability policy only guarantees 
that White_Space property will not be removed from code point s that have it, I 
think there is little chance that they will ever add White_Space property to 
another code point in the ASCII range and if they do, I am not sure Python will 
have to follow.

--
components: +Interpreter Core, Unicode
keywords: +needs review
stage:  -> commit review

___
Python tracker 

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



[issue4610] Unicode case mappings are incorrect

2013-06-23 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

It looks like at least the OP issue has been fixed in #12736:

>>> 'ß'.upper()
'SS'

--
resolution:  -> out of date
status: open -> closed
superseder:  -> Request for python casemapping functions to use full not simple 
casemaps per Unicode's recommendation

___
Python tracker 

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



[issue15223] datetime instances lack __module__ attribute

2013-06-23 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue18289] Segmentation Fault using round()

2013-06-23 Thread Max Kaye

New submission from Max Kaye:

Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:52:43) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print round(1.123456, 3)
1.123
>>> print round(1.123756, 3)
Segmentation fault: 11

This doesn't happen if you just do the second round, only if you do both.
`python -c "print round(1.123456, 3); print round(1.123756, 3)"` doesn't 
segfault.

Doesn't segfault on brew's python:
Python 2.7.3 (default, May 19 2013, 04:22:38) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.51)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print round(1.123456, 3)
1.123
>>> print round(1.123756, 3)
1.124
>>> 

Doesn't segfault on another box:
Python 2.7.2+ (default, Jul 20 2012, 22:12:53) 
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print round(1.123456, 3)
1.123
>>> print round(1.123756, 3)
1.124
>>> 

OSX Log File: (goes to EOF)

Process: Python [5423]
Path:
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Identifier:  Python
Version: 2.7.3 (2.7.3)
Code Type:   X86-64 (Native)
Parent Process:  bash [1219]
Responsible: iTerm [442]
User ID: 501

Date/Time:   2013-06-24 13:55:56.871 +1000
OS Version:  Mac OS X 10.9 (13A476u)
Report Version:  11
Anonymous UUID:  D8CE5653-35DD-5963-C8C9-E5012E41FDEE

Sleep/Wake UUID: 9C40804C-F025-4E16-A61A-D1E9D9F68DD3

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x

VM Regions Near 0:
--> 
__TEXT 0001-00011000 [4K] r-x/rwx 
SM=COW  
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   readline.so 0x0001002eff97 call_readline + 647
1   org.python.python   0x00018852 PyOS_Readline + 274
2   org.python.python   0x0001a0a8 tok_nextc + 104
3   org.python.python   0x0001a853 PyTokenizer_Get + 147
4   org.python.python   0x0001544a parsetok + 218
5   org.python.python   0x0001000e7722 PyParser_ASTFromFile 
+ 146
6   org.python.python   0x0001000e8983 
PyRun_InteractiveOneFlags + 243
7   org.python.python   0x0001000e8c6e 
PyRun_InteractiveLoopFlags + 78
8   org.python.python   0x0001000e9451 PyRun_AnyFileExFlags 
+ 161
9   org.python.python   0x00010010006d Py_Main + 3085
10  org.python.python   0x00010f14 0x1 + 3860

Thread 0 crashed with X86 Thread State (64-bit):
  rax: 0x  rbx: 0x00010060  rcx: 0x00010060  
rdx: 0x2800
  rdi: 0x  rsi: 0x0001002f0254  rbp: 0x7fff5fbff620  
rsp: 0x7fff5fbff550
   r8: 0x00010060   r9: 0x  r10: 0x0007  
r11: 0x0001
  r12: 0x0001  r13: 0x0018  r14: 0x7fff5fbff5e0  
r15: 0x7fff5fbff560
  rip: 0x0001002eff97  rfl: 0x00010206  cr2: 0x
  
Logical CPU: 4
Error Code:  0x0004
Trap Number: 14


Binary Images:
   0x1 -0x10fff +org.python.python (2.7.3 - 2.7.3) 
 
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
   0x13000 -0x10016dff7 +org.python.python (2.7.3, [c] 
2004-2012 Python Software Foundation. - 2.7.3) 
<4F9EF48A-7D0C-0C1A-670B-3BF4E72C8696> 
/Library/Frameworks/Python.framework/Versions/2.7/Python
   0x1002ee000 -0x1002f0fff +readline.so (???) 
 
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/readline.so
   0x1004f -0x10050effb  libedit.2.dylib (39) 
<24343EDB-E64F-34DC-8632-68C9E44E0FF7> /usr/lib/libedit.2.dylib
0x7fff66a19000 - 0x7fff66a4c987  dyld (236) 
 /usr/lib/dyld
0x7fff8201f000 - 0x7fff82026ff3  libcopyfile.dylib (103) 
<7925E83E-6C96-38AD-9E53-AA9AE7C9E406> /usr/lib/system/libcopyfile.dylib
0x7fff82062000 - 0x7fff82063ff7  libsystem_blocks.dylib (63) 
 /usr/lib/system/libsystem_blocks.dylib
0x7fff823cd000 - 0x7fff823f4ff3  libsystem_info.dylib (449) 
<6080681C-A561-3458-AA51-4DBE6D4E36B2> /usr/lib/system/libsystem_info.dylib
0x7fff8246 - 0x7fff82466fef  libsystem_platform.dylib (20.0.0.0.1) 
 /usr/lib/system/libsystem_platform.dylib
0x7fff82514000 - 0x7fff8251bff7  liblaunch.dylib (841) 
<0554A59B-30EE-3E01-A5F6-3676F4B060B2> /usr/lib/system/liblaunch.dylib
0x7fff826d3000 - 0x7fff826d3ff7  libkeymgr.dylib (28) 
 /usr/lib/system/libkeymgr.dylib
0x7fff8

[issue18290] json encoder does not support JSONP/JavaScript safe escaping

2013-06-23 Thread Antti Haapala

New submission from Antti Haapala:

JSON is not a strict superset of JavaScript 
(http://timelessrepo.com/json-isnt-a-javascript-subset). However, certain web 
technologies use JSON values as a part of JavaScript code (JSONP, inline 
 tags)... The Python json module, however, by default does not escape 
\u2028 or \u2029 when ensure_ascii is false. Furthermore, the / -> \/ escape is 
not supported by any switch.

Strictly speaking, json specification only requires that " be escaped to \" and 
\ to \\ - all other escaping is optional. The whitespace escapes only exist to 
aid handwriting and embedding values in HTML/code. Thus it can be argued that 
the choice of escapes used by json encoder is ill-adviced.

In an inline HTML