[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2015-02-13 Thread STINNER Victor

STINNER Victor added the comment:

Note: bench_scandir2.py is a micro-benchmark. Ben's benchmark using walk() is 
more realistic, but I'm interested by micro-benchmark results.

scandir-2.patch is faster than scandir-6.patch, much fast on Windows.

Result of bench (cached): scandir-6.patch = scandir-2.patch

* Windows 7 VM using NTFS: 14.0x faster = 44.6x faster
* laptop using NFS share: 1.3x faster = 5.2x faster   *** warning: unstable 
results ***
* desktop PC using /tmp: 1.3x faster = 3.8x faster
* laptop using SSD and ext4: 1.3x faster = 2.8x faster
* desktop PC using HDD and ext4: 1.4x faster = 1.4x faster


Benchmark using scandir-2.patch
---


Benchmark results with the full C implementation, scandir-2.patch.

[ C implementation ] Results of bench_scandir2.py on my desktop PC using HDD 
and ext4:

- 110,100 entries (100,000 files, 100 symlinks, 10,000 directories)
- bench: 3.5x faster than listdir (scandir: 63.6 ms, listdir: 219.9 ms)
- bench_nostat: 0.8x faster than listdir (scandir: 52.8 ms, listdir: 42.4 ms)
- bench_nocache: 1.4x faster than listdir (scandir: 3745.2 ms, listdir: 5217.6 
ms)
- bench_nostat_nocache: 1.4x faster than listdir (scandir: 3834.1 ms, listdir: 
5380.7 ms)

[ C implementation ] Results of bench_scandir2.py on my desktop PC using /tmp 
(tmpfs):

- 110,100 entries (100,000 files, 100 symlinks, 10,000 directories)
- bench: 3.8x faster than listdir (scandir: 46.7 ms, listdir: 176.4 ms)
- bench_nostat: 0.7x faster than listdir (scandir: 38.6 ms, listdir: 28.6v)

[ C implementation ] Results of bench_scandir2.py on my Windows 7 VM using NTFS:

- 110,100 entries (100,000 files, 100 symlinks, 10,000 directories)
- bench: 44.6x faster than listdir (scandir: 125.0 ms, listdir: 5574.9 ms)
- bench_nostat: 0.8x faster than listdir (scandir: 92.4 ms, listdir: 74.7 ms)

[ C implementation ] Results of bench_scandir2.py on my laptop using SSD and 
ext4:

- 110,100 entries (100,000 files, 100 symlinks, 10,000 directories)
- bench: 3.6x faster (scandir: 59.4 ms, listdir: 213.3 ms)
- bench_nostat: 0.8x faster than listdir (scandir: 50.0 ms, listdir: 38.6)
- bench_nocache: 2.8x faster than listdir (scandir: 377.5 ms, listdir: 1073.1)
- bench_nostat_nocache: 2.8x faster than listdir (scandir: 370.9 ms, listdir: 
1055.0)

[ C implementation ] Results of bench_scandir2.py on my laptop using tmpfs:

- 110,100 entries (100,000 files, 100 symlinks, 10,000 directories)
- bench: 4.0x faster than listdir (scandir: 43.7 ms, listdir: 174.1)
- bench_nostat: 0.7x faster than listdir (scandir: 35.2 ms, listdir: 24.5)

[ C implementation ] Results of bench_scandir2.py on my laptop using NFS share 
and slow wifi:

- 11,010 entries (10,000 files, 10 symlinks, 1,000 directories)
- bench: 5.2x faster than listdir (scandir: 4.2 ms, listdir: 21.7 ms)
- bench_nostat: 0.6x faster than listdir (scandir: 3.3 ms, listdir: 1.9 ms)


*** Again, results with NFS are not reliable. Sometimes listing a directory 
conten takes 40 seconds. It's maybe a network issue. ***

It looks like d_type can be DT_UNKNOWN on NFS.


Benchmark using scandir-6.patch
---

I rerun benchmark with scandir-6.patch with more files to compare the two 
benchmarks.

[ C implementation ] Results of bench_scandir2.py on my Windows 7 VM using NTFS:

- 110,100 entries (100,000 files, 100 symlinks, 10,000 directories)
- bench: 14.0x faster than listdir (scandir: 399.0 ms, listdir: 5578.7 ms)
- bench_nostat: 0.3x faster than listdir (scandir: 279.2 ms, listdir: 76.1 ms)

[ C implementation ] Results of bench_scandir2.py on my laptop using NFS share 
and slow wifi:

- 11,010 entries (10,000 files, 10 symlinks, 1,000 directories)
- bench: 1.5x faster than listdir (scandir: 14.8 ms, listdir: 21.4 ms)
- bench_nostat: 0.2x faster than listdir (scandir: 10.6 ms, listdir: 2.2 ms)

--

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



[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2015-02-13 Thread STINNER Victor

STINNER Victor added the comment:

Hi Ben,

2015-02-13 4:51 GMT+01:00 Ben Hoyt rep...@bugs.python.org:
 Hi Victor, I thank you for your efforts here, especially your addition of 
 DirEntry.inode() and your work on the tests.

The addition of inode() should still be discussed on python-dev. The
remaining question is if the inode number (st_ino) is useful even if
st_dev is missing. I didn't added the inode() method yet to the PEP
because of that.

 However, I'm a bit frustrated that you just re-implemented the whole thing 
 without discussion:
(...)
 So it was a bit of a let down for a first-time Python contributor. Even a 
 simple question would have been helpful here: Ben, I really think this much 
 C code for a first version is bug-prone; what do you think about me 
 re-implementing it and comparing?

I'm really sorry, I didn't want to frustrate you :-( Sorry for not
being available, I also expected someone else to review your code, but
it didn't happen. And I *want* your opinon on design choices. Sorry if
I wasn't explicit about that in my last emails.

Sorry, I was very busy last months on other projects (like asyncio). I
want scandir() to be included in Python 3.5! The3.5 alpha 1 release
was a reminder for me.

I didn't reimplement everything. Almost all code comes from your work.
I just adapted it to Python 3.5.

 I've been behind scandir and written the first couple of implementations, and 
 I asked if you could review my code, but instead of reviewing it or 
 interacting with my fairly clear desire for the all-C version, you simply 
 turn up and say I've rewritten it, can you please review?

I'm not happy of the benchmark results of the C+Python implementation
(scandir-6.patch is supposed to be the fasted implementation of
C+Python).

I tried to produce as much benchmark results as possible to be able to
take a decision. I used:

* hardware: SSD, HDD and tmpfs (RAM)
* file system: ext4, tmpfs, NFS/ext4
* operating systems: Linux (Fedora 21), Windows 7

I will try to summarize benchmark results to write an email to
python-dev, to make a choice between the full C implementation vs
C+Python implementation. (ctypes is not an option, it's not reliable,
portability matters.)

 To continue the actual which implementation discussion: as I mentioned last 
 week in http://bugs.python.org/msg235458, I think the benchmarks above show 
 pretty clearly we should use the all-C version.

It's quite clear that the C implementation is always faster than C+Python.

My point is that we have to make a choice, C+Python is a nice
compromise because it uses less C code, and C code is more expensive
to *maintain*.

 For background: PEP 471 doesn't add any new functionality, and especially 
 with the new pathlib module, it doesn't make directory iteration syntax nicer 
 either: os.scandir() is all about letting the OS give you whatever info it 
 can *for performance*. Most of the Rationale for adding scandir given in PEP 
 471 is because it can be so so much faster than listdir + stat.

Good point :-)

In many setup (hardware, operating system, file system), I see a low
speedup (less than 2x faster). The whole purpose of the PEP 471
becomes unclear if the speedup is not at least 2x.

Quicky summary of benchmarks:

* using C+Python (scandir-6.patch), the benchmark (bench) is only
faster than 2x on Windows, in the other cases it's between 1.3x and
1.4x faster
* using C (scandir-2.patch), the benchmark (bench) is at least 3.5x
faster, it's between 3.5x and 44.6x faster, the most interesting
speedup is on Windows (44.6x faster!)

--

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



[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

2015-02-13 Thread STINNER Victor

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


--
versions: +Python 2.7 -Python 3.4, Python 3.5

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



[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2015-02-13 Thread Alexei Romanov

Changes by Alexei Romanov drednout...@gmail.com:


--
nosy: +alexei.romanov

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



[issue21840] Fix os.path in unicodeless build

2015-02-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8e2388b1e875 by Serhiy Storchaka in branch '2.7':
Issue #21840: Fixed expanding unicode variables of form $var in
https://hg.python.org/cpython/rev/8e2388b1e875

--
nosy: +python-dev

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



[issue21840] Fix os.path in unicodeless build

2015-02-13 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
assignee:  - serhiy.storchaka
dependencies:  -Fix unicodeless build of Python
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue21840] Fix os.path in unicodeless build

2015-02-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 544c5d4f4084 by Serhiy Storchaka in branch '2.7':
Issue #21840: Fixed a typo.
https://hg.python.org/cpython/rev/544c5d4f4084

--

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



[issue9674] make install DESTDIR=/home/blah fails when the prefix specified is /

2015-02-13 Thread Ivailo Monev

Ivailo Monev added the comment:

Can you please apply fix-root-prefix.patch? Or the updated version fof 
issue9674.patch that I've attached?

sysconfig tests will still fail and it will return bogus paths with double 
slash (e.g. //lib/python2.7) but at least Python will be installable with 
prefix=/ and will not mess up with files on root (/) when DESTDIR is set. That 
may not be complete solution but it's a step forward to that.

--
nosy: +Ivailo.Monev
Added file: http://bugs.python.org/file38129/issue9674-2.patch

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



[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

2015-02-13 Thread STINNER Victor

New submission from STINNER Victor:

Attached patch tries to make the private random file descriptor non-inheritable.

It should fix the following issue:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197376

I tried to write an unit test, but since the PEP 446 is not implemented, 
unexpected file descriptors are inherited. The test should maybe be run in a 
subprocess to not inherit all file descriptors created by other unit tests.

Note: I removed the stat.S_ISDOOR(st.st_mode) check from 
Lib/test/subprocessdata/fd_status.py, because stat.S_ISDOOR is not defined in 
Python 2.7.

--
components: Interpreter Core
files: pep446_random.patch
keywords: patch
messages: 235880
nosy: alex, haypo, pitrou
priority: normal
severity: normal
status: open
title: [2.7] random: make the file descriptor non-inheritable (on POSIX)
versions: Python 3.4, Python 3.5
Added file: http://bugs.python.org/file38126/pep446_random.patch

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



[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

2015-02-13 Thread STINNER Victor

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


Added file: http://bugs.python.org/file38127/test_fd_status.patch

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



[issue17711] Persistent id in pickle with protocol version 0

2015-02-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The patch is updated to current sources. Also optimized writing ASCII strings 
and fixed tests.

--
versions: +Python 3.5 -Python 3.3
Added file: http://bugs.python.org/file38128/fix_bad_persid_2.patch

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



[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

2015-02-13 Thread STINNER Victor

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


--
nosy: +koobs

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



[issue23435] installation with full path as prefix incomplete

2015-02-13 Thread Ned Deily

Ned Deily added the comment:

So the real problem here is configuring with --prefix=/ and then using make 
install DESTDIR to install to a temporary location.  This is a duplicate of 
Issue9674; the problem is that --prefix=/ results in build variable the start 
with '//', like '//lib', and that confuses os.path.join as used in Distutils.  
You might want to try the patch available there and comment on that issue.

--
resolution: works for me - duplicate
superseder:  - make install DESTDIR=/home/blah fails when the prefix specified 
is /

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



[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2015-02-13 Thread STINNER Victor

STINNER Victor added the comment:

 Result of bench (cached): scandir-6.patch = scandir-2.patch
 (...)
 laptop using SSD and ext4: 1.3x faster = 2.8x faster
 desktop PC using HDD and ext4: 1.4x faster = 1.4x faster

Oops, I copied the wrong numbers. scandir-2.patch is faster than that!

* laptop using SSD and ext4: 1.3x faster = 3.6x faster
* desktop PC using HDD and ext4: 1.4x faster = 3.5x faster

--

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



[issue23148] Missing the charset parameter in as_encoded_word()

2015-02-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--

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



[issue23147] Possible error in _header_value_parser.py

2015-02-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ping.

--

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



[issue21849] Fix multiprocessing for non-ascii data

2015-02-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a4a3a8b3f37f by Serhiy Storchaka in branch '2.7':
Issue #21849: Fixed xmlrpclib serialization of non-ASCII unicode strings in
https://hg.python.org/cpython/rev/a4a3a8b3f37f

New changeset 908533d5a427 by Serhiy Storchaka in branch '3.4':
Issue #21849: Ported from 2.7 tests for non-ASCII data.
https://hg.python.org/cpython/rev/908533d5a427

New changeset 1784c1901af6 by Serhiy Storchaka in branch 'default':
Issue #21849: Ported from 2.7 tests for non-ASCII data.
https://hg.python.org/cpython/rev/1784c1901af6

--
nosy: +python-dev

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



[issue23450] Possible loss of data warnings building 3.5 Visual Studio Windows 8.1 64 bit

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

int_overflows.patch looks good to me.

I really appreciate that these patches have been done properly too - I've seen 
far too much code where people just throw in casts to silence the warnings. 
This is why I like working on Python :)

--

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



[issue23452] Build errors using VS Express 2013 in win32 mode

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

I can't reproduce this easily. Could you delete the externals/tcltk folder and 
the Debug_VC12 folders under tk.../win, tix.../win and tcl-core.../win, rebuild 
and capture the output from the VS Output window? Apparently something in one 
of these external projects is not building properly.

--

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



[issue9566] Compilation warnings under x64 Windows

2015-02-13 Thread Steve Dower

Changes by Steve Dower steve.do...@microsoft.com:


--
nosy: +steve.dower

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



[issue21107] Add pgen.vcxproj to allow regenerating grammar files on Windows

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

I don't even know what pgen is or why I'd want to build it...

If running it updates a file that would trigger a rebuild, then I'd really like 
it to copy what _freeze_importlib currently does as far as writing to a 
temporary file and conditionally overwriting the actual one. That is the most 
reliable way to avoid unnecessary rebuilds.

--

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



[issue23350] Content-length is incorrect when request body is a list or tuple

2015-02-13 Thread Demian Brecht

Demian Brecht added the comment:

Thanks for the review Martin, I've addressed your comments.

 The length of an encoded Latin-1 string should equal the length of the 
 unencoded text string, since it is a one-to-one character-to-byte encoding.
Once in a while, I want to stop what I'm doing, put my head in my hands
and think to myself how did that escape me?! Of course you're right
and thanks for the catch. I've reverted the handling to how it was being
done in the previous patch.

 Though I’m not particularly excited by silently Latin-1 encoding text bodies 
 in the first place.
Truth be told, I'm more fond of only accepting pre-encoded byte strings
as input. However, that backwards incompatible change would likely break
many things. Request bodies can currently be strings, byte strings,
iterables or file objects. In the cases of string and file objects,
encoding is already supported. The change I made makes handling
iterables consistent with the other accepted data types.

I'm not sure why, but the auto-encoding of the raw string input object
was being done higher up in the general use case callstack
(Lib/http/client.py:1064). I've moved this handling to send() for
consistency with the auto-encoding of other input types. This also
ensures consistent behavior between calling request() with a string body
and calling send() directly.

--
Added file: http://bugs.python.org/file38130/list_content_length_3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue23350
___diff -r e548ab4ce71d Doc/library/http.client.rst
--- a/Doc/library/http.client.rst   Mon Feb 09 19:49:00 2015 +
+++ b/Doc/library/http.client.rst   Fri Feb 13 07:45:43 2015 -0800
@@ -212,8 +212,10 @@
contents of the file is sent; this file object should support ``fileno()``
and ``read()`` methods. The header Content-Length is automatically set to
the length of the file as reported by stat. The *body* argument may also be
-   an iterable and Content-Length header should be explicitly provided when the
-   body is an iterable.
+   an iterable. If the iterable is a tuple or list, the Content-Length will
+   automatically be set if not already supplied in the request headers.
+   In all other iterable cases, the Content-Length header should be explicitly
+   provided.
 
The *headers* argument should be a mapping of extra HTTP
headers to send with the request.
@@ -221,6 +223,10 @@
.. versionadded:: 3.2
   *body* can now be an iterable.
 
+   .. versionadded:: 3.5
+  The Content-Length header will be set when *body* is a list or tuple.
+
+
 .. method:: HTTPConnection.getresponse()
 
Should be called after a request is sent to get the response from the 
server.
diff -r e548ab4ce71d Lib/http/client.py
--- a/Lib/http/client.pyMon Feb 09 19:49:00 2015 +
+++ b/Lib/http/client.pyFri Feb 13 07:45:43 2015 -0800
@@ -836,11 +836,19 @@
 datablock = datablock.encode(iso-8859-1)
 self.sock.sendall(datablock)
 return
+
+if isinstance(data, str):
+# RFC 2616 Section 3.7.1 says that text default has a
+# default charset of iso-8859-1.
+data = data.encode('iso-8859-1')
+
 try:
 self.sock.sendall(data)
 except TypeError:
 if isinstance(data, collections.Iterable):
 for d in data:
+if hasattr(d, 'encode'):
+d = d.encode('iso-8859-1')
 self.sock.sendall(d)
 else:
 raise TypeError(data should be a bytes-like object 
@@ -1031,20 +1039,25 @@
 
 def _set_content_length(self, body):
 # Set the content-length based on the body.
-thelen = None
-try:
-thelen = str(len(body))
-except TypeError as te:
-# If this is a file-like object, try to
-# fstat its file descriptor
+size = None
+if isinstance(body, (list, tuple)):
+# the body will either be already encoded or will be latin-1
+# encoded when being sent. as latin-1 and ascii strings are of
+# equal size, there isn't a need to make a distinction here.
+size = sum(len(line) for line in body)
+else:
 try:
-thelen = str(os.fstat(body.fileno()).st_size)
-except (AttributeError, OSError):
-# Don't send a length if this failed
-if self.debuglevel  0: print(Cannot stat!!)
+size = len(body)
+except TypeError:
+try:
+size = os.fstat(body.fileno()).st_size
+except (AttributeError, OSError):
+if self.debuglevel  0:
+print(Cannot stat!!)
+size = None
 
-if thelen is not None:

[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

2015-02-13 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I'm not sure what the point is - there are many child descriptors which may 
inherited, why care about this one?

The right way to avoid this on 2.7 is to call subprocess.Popen(..., 
close_fds=True).

--

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



[issue23460] Decimals do not obey ':g' exponential notation formatting rules

2015-02-13 Thread Ian Kelly

New submission from Ian Kelly:

 '{:g}'.format(D('0.01'))
'0.01'

Formatted with '{:e}', the exponent would be -6, so per the formatting rules 
described under the 'g' specifier at 
https://docs.python.org/3/library/string.html#format-specification-mini-language
 the above should be formatted using exponential notation.

--
components: Library (Lib)
messages: 235904
nosy: ikelly
priority: normal
severity: normal
status: open
title: Decimals do not obey ':g' exponential notation formatting rules
type: behavior
versions: Python 3.4

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



[issue23458] [2.7] random: make the file descriptor non-inheritable (on POSIX)

2015-02-13 Thread STINNER Victor

STINNER Victor added the comment:

 I'm not sure what the point is - there are many child descriptors which may 
 inherited, why care about this one?

The bug report comes from FreeBSD, 
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=197376

They use os.system(), at least in the bug report.

The random file descriptor is a little suprising because it's not obvious than 
os.urandom() opens a file, nor that the file remains open.

It's also a change in a minor Python version.

--

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



[issue21568] Win32 pip doesn't use relative path to found site-packages.

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

Already reported at https://github.com/pypa/pip/issues/1889

--
resolution:  - third party
status: open - closed

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



[issue20523] global .pdbrc on windows 7 not reachable out of the box

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

expanduser() sounds like the better choice here.

--

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



[issue18295] Possible integer overflow in PyCode_New()

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

Other than my one query on the review, code_ssize_t_2.patch.patch looks good to 
me.

--
nosy: +steve.dower

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



[issue21107] Add pgen.vcxproj to allow regenerating grammar files on Windows

2015-02-13 Thread Zachary Ware

Zachary Ware added the comment:

 I don't even know what pgen is or why I'd want to build it...

pgen is the parser generator, taking Grammar/Grammar as input and generating 
Include/graminit.h and Python/graminit.c.  Only useful when you're changing 
Python's grammar, but without the ability to build pgen, it's hard for Windows 
developers to play with the grammar at all.

 If running it updates a file that would trigger a rebuild, then I'd
 really like it to copy what _freeze_importlib currently does as far as
 writing to a temporary file and conditionally overwriting the actual
 one. That is the most reliable way to avoid unnecessary rebuilds.

_freeze_importlib was what I used for a guide initially, and will be again when 
I get around to redoing the patch :)

--

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



[issue7200] multiprocessing deadlock on Mac OS X when queue collected before process terminates

2015-02-13 Thread Davin Potts

Davin Potts added the comment:

This issue was marked as not a bug by OP a while back but for whatever reason 
it did not also get marked as closed.  Going ahead with closing it now.

--
nosy: +davin
stage: needs patch - resolved
status: open - closed

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



[issue17229] unable to discover preferred HTTPConnection class

2015-02-13 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy:  -demian.brecht

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



[issue23425] Windows getlocale unix-like with french, german, portuguese, spanish

2015-02-13 Thread R. David Murray

R. David Murray added the comment:

This is either related to or effectively a duplicate of issue 10466, which 
contains a fair amount of discussion of the underlying problems.

--
nosy: +r.david.murray

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



[issue23440] Extend http.server.SimpleHTTPRequestHandler testing

2015-02-13 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +demian.brecht

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



[issue15914] multiprocessing.SyncManager connection hang

2015-02-13 Thread Brett Cannon

Brett Cannon added the comment:

Dead code deletion should be a separate issue, so I'm going to close this as 
fixed.

--
resolution:  - fixed
status: open - closed

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



[issue23410] Document more BaseHTTPRequestHandler attributes

2015-02-13 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +demian.brecht

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



[issue23447] Import fails when doing a circular import involving an `import *`

2015-02-13 Thread Brett Cannon

Brett Cannon added the comment:

If you want to take a stab at it, Steven, go for it and I will review the 
patch, but as you pointed out this is such an edge case that I'm personally not 
going to worry about fixing it and still don't consider it a bug.

--
title: Relative imports with __all__ attribute - Import fails when doing a 
circular import involving an `import *`

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



[issue23418] Keep http.server.__all__ up to date

2015-02-13 Thread Demian Brecht

Demian Brecht added the comment:

 LGTM.

+1

--
nosy: +demian.brecht

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



[issue23418] Keep http.server.__all__ up to date

2015-02-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d2dbec7d74d0 by Berker Peksag in branch '3.4':
Issue #23418: Add missing entries to http.server.__all__.
https://hg.python.org/cpython/rev/d2dbec7d74d0

New changeset 03e3e78014ea by Berker Peksag in branch 'default':
Issue #23418: Add missing entries to http.server.__all__.
https://hg.python.org/cpython/rev/03e3e78014ea

--
nosy: +python-dev

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



[issue23434] RFC6266 support (Content-Disposition for HTTP)

2015-02-13 Thread R. David Murray

R. David Murray added the comment:

Since that library is not part of the stdlib, this is not an appropriate patch 
for CPython.

Note that this issue is also relevant to the email library, which intends to 
support RFC2616 header parsing/generation, and therefore should also be 
enhanced to support RFC 6266.

--
components: +email
nosy: +barry, r.david.murray
versions:  -Python 2.7

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



[issue21717] Exclusive mode for ZipFile and TarFile

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the review, Serhiy. I'll take a look at the zipfile patch tomorrow.

--

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



[issue17527] PATCH as valid request method in wsgiref.validator

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

LGTM.

--
nosy: +berker.peksag
stage:  - commit review
versions: +Python 2.7, Python 3.5

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



[issue17349] wsgiref.simple_server.demo_app is not PEP-3333 compatible

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

I'm not sure this needs to be fixed in 2.7. I would only use demo_app to test 
WSGI servers. Otherwise, you need to create your own application. However, the 
code is correct in Python 3: 
https://hg.python.org/cpython/file/default/Lib/wsgiref/simple_server.py#l146

(Note: PEP  is for Python 3. In Python 2, the correct quote is When called 
by the server, the application object must return an iterable yielding zero or 
more strings. See PEP 333.)

--
nosy: +berker.peksag

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



[issue23425] Windows getlocale unix-like with french, german, portuguese, spanish

2015-02-13 Thread R. David Murray

R. David Murray added the comment:

Sorry, when I said effectively a duplicate I didn't mean *actually* a 
duplicate, I meant that fixing one will either result in or require fixing the 
other (same core cause: the disconnect between the Windows names and the unix 
names and the need for a *consistent* mapping between them).

But, I didn't fully reread that issue or the docs, so maybe I'm wrong about 
that.

--

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



[issue23418] Keep http.server.__all__ up to date

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

Fixed. Thanks Martin (also thanks to Demian for the review).

--
resolution:  - fixed
stage: commit review - resolved
status: open - closed

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



[issue21717] Exclusive mode for ZipFile and TarFile

2015-02-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ed9e9e6b3c1e by Berker Peksag in branch 'default':
Issue #21717: tarfile.open() now supports 'x' (exclusive creation) mode.
https://hg.python.org/cpython/rev/ed9e9e6b3c1e

--
nosy: +python-dev

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



[issue14652] Better error messages for wsgiref validator failures

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

Here is an updated patch. For InputWrapper.read(), see issue 18610.

--
nosy: +berker.peksag
stage:  - patch review
versions: +Python 3.4, Python 3.5 -Python 3.3
Added file: http://bugs.python.org/file38131/issue14652.diff

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



[issue17852] Built-in module _io can loose data from buffered files at exit

2015-02-13 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


--
nosy: +vadmium

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Eric Snow

Eric Snow added the comment:

This implies to me that someone didn't include importlib.h in their commit when 
they changed something that required it to be rebuilt.  However, if it's a 
Windows-only thing then perhaps there is something else afoot.  Steve?

--
nosy: +brett.cannon, eric.snow, steve.dower

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



[issue23425] Windows getlocale unix-like with french, german, portuguese, spanish

2015-02-13 Thread albertjan

albertjan added the comment:

I agree that the two issues are related, but I don't see how they could be 
duplicates. But maybe that's because I do not know the underlying code.

issue 10466 is mostly about getdefaultlocale() and whether it's desirable or 
not that its return value is always uniq-esque, including on windows. The 
failed call to locale.py*) as a script would demonstrate that the 
getdefaultlocale() return value ought to be platform-specific and ready for 
consumption by setlocale(). That's how I read that issue. I personally find it 
useful to have getdefaultlocale() --a nice, harmonized locale string.

With getlocale in Windows, however, the return value is sometimes unix-like, 
sometimes windows-specific. Until a couple of days ago I thought getlocale was 
entirely platform-specific. Why should locale.setlocale(locale.LC_ALL, 
..join(locale.getlocale())) succeed on my Dutch windows system, but fail on 
my neighbour's German windows system?

In my humble opinion:
-setlocale should return nothing. It's a setter
-getlocale should return a platform-specific locale specification, probably 
what is currently returned by setlocale. The output should be ready for 
consumption by setlocale.
-getdefaultlocale should ALWAYS return a harmonized/unix-like locale 
specification. In Unix, but not in Windows, it could be used as an argument for 
setlocale.

My two cents.

Best wishes,
Albert-Jan

*) which also fails on Python 2.7 and 3.4 on my Dutch Windows 7 64, btw.

--

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



[issue23452] Build errors using VS Express 2013 in win32 mode

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

Hmm, so maybe it only happens after you build the 64-bit version first. But 
apparently it's more complex than that, since that doesn't repro either. When I 
get some more time I'll run though and double check all the rebuild conditions, 
but it has worked fine for me every time I've done it across 8-10 machines and 
3-4 VS versions.

I think you've ended up in a very unlikely situation that is probably going to 
be fixed by hg purge --all  PCBuild\build -e -d  PCBuild\build -e -d -p 
x64.

--

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Zachary Ware

Zachary Ware added the comment:

What does the diff to importlib.h look like?  Does it look like a real change 
to importlib or is it something innocuous like a change in whitespace or the 
path separator in the heading?

--
components: +Build, Windows
nosy: +tim.golden, zach.ware

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Paul Moore

New submission from Paul Moore:

When building Python (cpython repository, tip revision on the default branch) 
using Visual Studio 2015 (version downloaded 12/02/2015) I get a message in the 
build:

C:\Work\Projects\cpython\PCbuild\_freeze_importlib.vcxproj(98,5): error : 
importlib.h has been updated. You will need to rebuild  pythoncore to see the 
changes.

This is using the command PCBuild\build.bat -p x64.

When I check hg status after the build, Python\importlib.h shows as modified.

(I have 2 changed files in the repo, one a documentation file and the other 
launcher.c. Neither change should affect importlib).

--
messages: 235922
nosy: pmoore
priority: normal
severity: normal
status: open
title: Building on windows modifies importlib.h
versions: Python 3.5

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



[issue14910] argparse: disable abbreviation

2015-02-13 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 99302634d756 by Berker Peksag in branch 'default':
Issue #14910: Add allow_abbrev parameter to argparse.ArgumentParser.
https://hg.python.org/cpython/rev/99302634d756

--
nosy: +python-dev

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

It looks like the C _io close() implementations delegate to the wrapped 
object’s undocumented _dealloc_warn() method to emit the warning if 
“self-finalizing” is set. For wrapped objects like BytesIO that do not have 
it, I guess the error due to the missing method is ignored.

There is no Python implementation of FileIO yet (see Issue 21859), so the 
Python file wrapper classes still use the C FileIO implementation, which emits 
a resource warning. However for the wrapper classes, _pyio.IOBase.__del__() 
explicitly invokes the wrapper’s close() method, which will invoke 
FileIO.close() method, which bypasses the warning.

Similarly, any object inheriting from the C implmentation’s _io.IOBase will 
also have close() explicitly invoked when being finalized, bypassing any 
warnings of the underlying wrapped object. The SocketIO instances returned by 
socket.makefile() are an example of this.

--

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

Windows is probably the only platform that detects when _freeze_importlib makes 
a change and aborts the build :)

I'd be interested to see what the diff is though. My guess is some of the 
recent marshal changes may have affected the output.

--

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



[issue23452] Build errors using VS Express 2013 in win32 mode

2015-02-13 Thread Mark Lawrence

Mark Lawrence added the comment:

I don't have externals/tcltk, only externals/tcltk64.  There is a Debug_VC12 
folder under tix.../win.  There is no Debug_VC12 folder under tk.../win, 
tcl-core.../win or for that matter tcl.../win, only Debug_AMD64_VC12.

--

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



[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2015-02-13 Thread Akira Li

Akira Li added the comment:

As I've mentioned in http://bugs.python.org/issue22524#msg231703

  os.walk size 7925376343, scandir.walk size 5534939617 -- NOT EQUAL!

os.walk and scandir.walk do a different work here.

I don't see that it is acknowledged so I assume the benchmark is not fixed.

If the fixed (same work) benchmark is used then there is no performance 
difference on Linux. See the attached file 
http://bugs.python.org/file37292/get_tree_size_listdir.diff 

Note: the performance improvements on Windows along should be enough to accept 
os.scandir() even if Linux version won't be improved (if the behavior is 
documented).

--

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



[issue23424] Unicode character ends interactive session

2015-02-13 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
resolution:  - duplicate
stage:  - resolved
status: open - closed
superseder:  - windows console doesn't print or input Unicode

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Paul Moore

Paul Moore added the comment:

Ah. It's 4K lines of everything changing. Looks like it might be an EOL issue. 
The build seems to be changing it from LF line endings to CRLF line endings.

--

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



[issue14910] argparse: disable abbreviation

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

Committed. Thank you all for patches and reviews :)

--
resolution:  - fixed
stage: patch review - resolved
status: open - closed

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



[issue23425] Windows getlocale unix-like with french, german, portuguese, spanish

2015-02-13 Thread eryksun

eryksun added the comment:

 -setlocale should return nothing. It's a setter
 -getlocale should return a platform-specific locale specification,
 probably what is currently returned by setlocale. The output 
 should be ready for consumption by setlocale.

These functions are well documented, so it's pointless to talk about major 
changes to the API. Per the docs, getlocale should return an RFC 1766 language 
code. If you want the platform result, use something like the following:

def getrawlocale(category=locale.LC_CTYPE):
return locale.setlocale(category)

 locale.setlocale(locale.LC_CTYPE, 'eng')   
'English_United Kingdom.1252'
 getrawlocale()  
'English_United Kingdom.1252'

 # the new CRT supports RFC1766
... locale.setlocale(locale.LC_CTYPE, 'en-GB')
'en-GB'
 getrawlocale()
'en-GB'

As I mentioned in issue 20088, the locale_alias dict is based on X11's 
locale.alias file. It doesn't handle most Windows locale strings of the form 
language_country.codepage. 

On Windows, the _locale extension module could enumerate the system locales at 
startup to build a mapping. Here's a rough prototype using ctypes (requires 
Vista or later for the new locale functions):

import locale
from ctypes import *
from ctypes.wintypes import *

LOCALE_WINDOWS = 1
LOCALE_SENGLISHLANGUAGENAME = 0x1001
LOCALE_SENGLISHCOUNTRYNAME = 0x1002
LOCALE_IDEFAULTANSICODEPAGE = 0x1004
LCTYPES = (LOCALE_SENGLISHLANGUAGENAME,
   LOCALE_SENGLISHCOUNTRYNAME,
   LOCALE_IDEFAULTANSICODEPAGE)

kernel32 = WinDLL('kernel32')
EnumSystemLocalesEx = kernel32.EnumSystemLocalesEx
GetLocaleInfoEx = kernel32.GetLocaleInfoEx

EnumLocalesProcEx = WINFUNCTYPE(BOOL, LPWSTR, DWORD, LPARAM)

def enum_system_locales():
alias = {}
codepage = {}
info = (WCHAR * 100)()

@EnumLocalesProcEx
def callback(locale, flags, param):
if '-' not in locale:
return True
parts = []
for lctype in LCTYPES:
if not GetLocaleInfoEx(locale, 
   lctype, 
   info, len(info)):
raise WinError()
parts.append(info.value)
lang, ctry, code = parts
if lang and ctry and code != '0':
locale = locale.replace('-', '_')
full = '{}_{}'.format(lang, ctry)
alias[full] = locale
codepage[locale] = 'cp' + code
return True

if not EnumSystemLocalesEx(callback, 
   LOCALE_WINDOWS, 
   None, None):
raise WinError()
return alias, codepage


 alias, codepage = enum_system_locales()

 alias[English_United Kingdom]
'en_GB'
 codepage['en_GB']  
'cp1252'
 alias[Spanish_United States] 
'es_US'
 codepage['es_US'] 
'cp1252'
 alias[Russian_Russia]
'ru_RU'
 codepage['ru_RU']
'cp1251'
 alias[Chinese (Simplified)_People's Republic of China]
'zh_CN'
 codepage['zh_CN']
'cp936'

--
nosy: +eryksun

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Zachary Ware

Zachary Ware added the comment:

Ah ha.  Do you have the hg eol extension enabled?  If not, you
probably should; it makes for far fewer headaches on Windows, and
should make this issue go away.

We should probably try to mitigate the problem anyway; Steve, how hard
would it be to change the 'see if the newly generated file actually
changed anything' logic to check line endings?

--

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



[issue13637] binascii.a2b_* functions could accept unicode strings

2015-02-13 Thread Berker Peksag

Berker Peksag added the comment:

The binascii documentation already says

   ``a2b_*`` functions accept Unicode strings containing only ASCII characters.
   [...]

   .. versionchanged:: 3.3
  ASCII-only unicode strings are now accepted by the ``a2b_*`` functions.

I think we can just remove versionchanged directives in 
fix_doc_binascii_unhexlify.v2.patch.

--
nosy: +berker.peksag

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Steve Dower

Steve Dower added the comment:

It's possible, but the eol extension is the best way to handle it.

Doing the comparison is relatively easy (we can just strip all '\r' and '\n' 
characters and compare), but if it has changed, it's much harder to update the 
new file to match whatever the old file had. With eol, it'll always be \r\n and 
it Just Works.

Leave this on me to update the check. If someone does try and push a change 
with EOL changes it'll be blocked anyway.

--

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Paul Moore

Paul Moore added the comment:

I'm just about finished for the night but I'll try the eol extension tomorrow. 
I don't really use it much, though, my practice is generally to make all my 
tools use LF. I certainly didn't do anything that would change that file, so 
something in the build must be writing it in CRLF line ending mode.

--

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



[issue13637] binascii.a2b_* functions could accept unicode strings

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

That’s another option. Someone might wonder why a2b_hex() and a2b_qp() actually 
accept text strings in Python 3.1 when the documentation says you need 3.3, but 
I guess that’s not such a big deal. Posting patch v3 which removes the 3.2 
notices.

--
Added file: http://bugs.python.org/file38132/fix_doc_binascii_unhexlify.v3.patch

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Zachary Ware

Zachary Ware added the comment:

The other option would be to change _freeze_importlib to force it to
use \n instead of \r\n; I'm not sure which change would be harder to
do.

Paul: fair enough; I've just found that keeping eol enabled reduces
headaches due to line endings to almost nothing, just because I never
have to think about them at all (except for the rare files that are
marked as 'BIN' in .hgeol).

--

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Mark Lawrence

Mark Lawrence added the comment:

I noticed a few days ago that this file had changed as I got a merge conflict 
using the tortoisehg sychronize command.  At the time I didn't think much of it 
and believe I simply let hg sort it out.  The changeset was 8ab6b404248c #21295.

--
nosy: +BreamoreBoy

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



[issue22928] HTTP header injection in urrlib2/urllib/httplib/http.client

2015-02-13 Thread Demian Brecht

Demian Brecht added the comment:

Here's a patch addressing the potential vulnerability as reported. The patch 
should also bring the implementation up to date with the most recent standards 
around header names and values.

 There could be potential for breaking compatibility if people are 
 intentionally sending values with folded lines (obsoleted by the new HTTP 
 RFC).

I think I'm okay with this given line folding seems to have been implemented by 
passing multiple value parameters (folding was automatically taken care of by 
the library).

I don't think that this should be merged into anything pre 3.5 as safeguarding 
/should/ be accounted for by the developer, so I don't think I'd regard this as 
a high risk security issue. I'm definitely open to debate on that though.

--
Added file: http://bugs.python.org/file38133/issue22928.patch

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



[issue22524] PEP 471 implementation: os.scandir() directory scanning function

2015-02-13 Thread Ben Hoyt

Ben Hoyt added the comment:

Akari: yes, I'm aware of this, and it's definitely a concern to me -- it may be 
that scandir has a bug with counting the size of certain non-file directory 
entries, or my implementation of os.walk() via scandir is not quite correct. 
I'll look at it before too long!

--

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



[issue23440] Extend http.server.SimpleHTTPRequestHandler testing

2015-02-13 Thread Demian Brecht

Demian Brecht added the comment:

LGTM

--
versions: +Python 3.5

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



[issue23410] Document more BaseHTTPRequestHandler attributes

2015-02-13 Thread Demian Brecht

Demian Brecht added the comment:

Minor comment in Rietveld, otherwise LGTM.

--

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



[issue23459] Linux: expose the new execveat() syscall

2015-02-13 Thread STINNER Victor

New submission from STINNER Victor:

execveat() was added to Linux in kernel 3.19:
http://man7.org/linux/man-pages/man2/execveat.2.html

It may be interesting to expose it in Python.

The primary aim of adding an execveat syscall is to allow an
implementation of fexecve(3) that does not rely on the /proc
filesystem.  The current glibc version of fexecve(3) is implemented
via /proc, which causes problems in sandboxed or otherwise restricted
environments.
http://lwn.net/Articles/600344/

--
components: Extension Modules
messages: 235889
nosy: haypo
priority: normal
severity: normal
status: open
title: Linux: expose the new execveat() syscall
versions: Python 3.5

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



[issue22351] NNTP constructor exception leaves socket for garbage collector

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

Posting a new patch which closes the file object, and also does the same for 
the SSL class.

--
Added file: http://bugs.python.org/file38137/issue22351_nntp_fail_3.patch

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



[issue23350] Content-length is incorrect when request body is a list or tuple

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

New patch looks good I think. Making the encoding code more consistent is nice.

--

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

One option would be for any wrapper-type class (e.g. BufferedReader, SocketIO) 
to override __del__(). Instead of calling close(), it should call detach() or 
equivalent, and delete the returned reference to the underlying wrapped object 
without explicitly closing it, to allow a warning to be generated. Maybe a 
WrappedIO mixin class could help with this.

I am posting del-detach.patch which roughly implements the above option. It 
only seems to break the test_override_destructor() tests for the 
TextIOWrapperTest and CommonBufferedTests classes, which expect close() to be 
called.

Another more radical option might be to make IOBase.__del__() only call 
flush(), not close(), except for the actual implementations that really should 
emit a warning, like FileIO. I will have a go at doing this option in another 
patch.

Both these options would change the behaviour in some cases that rely on the 
garbage collector to close objects. They would defer the automatic closing 
until all references of the underlying object are garbage collected, instead of 
just when the wrapped object is garbage collected. A third option would be to 
add explicit __del__() methods emitting a warning in each class, along with any 
exception supression needed due to Python interpreter finalization quirks.

--
keywords: +patch
Added file: http://bugs.python.org/file38134/del-detach.patch

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



[issue22351] NNTP constructor exception leaves socket for garbage collector

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

I believe this still leaves the socket open via the “file” object. Just that 
there is no ResourceWarning generated due to the way IOBase.__del__() works.

--

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2015-02-13 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


Removed file: http://bugs.python.org/file38135/del-flush.patch

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



[issue22928] HTTP header injection in urrlib2/urllib/httplib/http.client

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

If we’re in the realm of 3.5 only changes, it might make sense to remove the 
multi-argument mode of putheader() altogether, and document it only generates a 
single line. (Currently still says it generates multiple lines.)

--

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



[issue22928] HTTP header injection in urrlib2/urllib/httplib/http.client

2015-02-13 Thread Demian Brecht

Demian Brecht added the comment:

I think that keeping the public API as-is is the better way to go, at
least for the shorter term given it won't require users to have to make
code changes. Thanks for the catch on the docs though, will update that.

--

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



[issue22928] HTTP header injection in urrlib2/urllib/httplib/http.client

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

Good point. Maybe join them with tabs rather than spaces then, since it was 
previously \r\n\t. This way it is even closer to before.

--

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2015-02-13 Thread Martin Panter

Martin Panter added the comment:

Posting del-flush.patch, which only calls flush() instead of close() from 
__del__(), except for the FileIO class. Quick analysis of resulting test 
failures:

These tests fail because they are obviously written to test that __del__ calls 
close():
* IOTest.test_IOBase_destructor
* IOTest.test_RawIOBase_destructor
* IOTest.test_BufferedIOBase_destructor
* IOTest.test_TextIOBase_destructor
* test_override_destructor as mentioned above

CBufferedReader/Writer/RandomTest.test_garbage_collection() fail because they 
do not free the reference to the wrapped raw file object. Similarly, 
CTextIOWrapperTest.test_garbage_collection() holds references to both levels of 
wrapped object.

TextIOWrapperTest.test_destructor() fails because it assumes the wrapped 
close() will be called. The data is still written to the wrapped file though.

MiscIOTest.test_warn_on_dealloc/_fd() fail because the warning message only 
refers to the FileIO object rather than the wrapper object.

--
Added file: http://bugs.python.org/file38135/del-flush.patch

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



[issue19829] _pyio.BufferedReader and _pyio.TextIOWrapper destructor don't emit ResourceWarning if the file is not closed

2015-02-13 Thread Martin Panter

Changes by Martin Panter vadmium...@gmail.com:


Added file: http://bugs.python.org/file38136/del-flush.patch

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Paul Moore

Paul Moore added the comment:

No, enabling the eol extension didn't fix it :-(

--

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



[issue23461] Building on windows modifies importlib.h

2015-02-13 Thread Paul Moore

Paul Moore added the comment:

Correction. Looks like if I enable the eol extension, then hg revert 
importlib.h, then rebuild, the problem then goes away.

So basically you need the eol extension enabled *before* you update/clone your 
checkout.

--

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