[issue17636] Modify IMPORT_FROM to fallback on sys.modules

2014-10-09 Thread Nick Coghlan

Nick Coghlan added the comment:

The language reference - at least the section on the import statement, and 
potentially the section on the overall operation of the import system.

I don't *think* it would affect anywhere in the tutorial or the importlib docs, 
but they may be worth skimming to see if anything leaps out.

--

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



[issue19494] urllib2.HTTPBasicAuthHandler (or urllib.request.HTTPBasicAuthHandler) doesn't work with GitHub API v3 and similar

2014-10-09 Thread Armin Rigo

Armin Rigo added the comment:

In my own case I use os.popen(wget ...) instead of urllib2 just because some 
version long ago failed on some web site.  I can trust that this external tool 
works all the time.  It would be great if urllib2 worked as well nowadays.

So my opinion on this issue, as a mere user, is that it is purely a bug which 
Python 2.7 should fix it, and it should do so in a transparent way.  Adding 
some new class that can only be found by careful reading of the latest version 
of the docs is useless: people will instead blame urllib2 as a whole and switch 
to something else.

Can someone confirm how common browser (one is enough) deal with it?  If they 
also send the authorization headers in the initial request, then I really, 
really don't see why urllib2 shouldn't by default.

--
nosy: +arigo

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



[issue21049] Warning at interpreter exit triggers flood of “ImportWarning: sys.meta_path is empty”

2014-10-09 Thread Quentin Pradet

Quentin Pradet added the comment:

Martin, yes, I'd be glad to see a fix if it's not too complicated.

--

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



[issue22584] Get rid of SRE character tables

2014-10-09 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Currently the SRE regular expression engine uses internal tables to implement 
ASCII-only character predicates and converting. Proposed patch get rid of these 
tables and reuse standard Python macros Py_ISSPACE, Py_TOLOWER, etc.

--
components: Extension Modules, Regular Expressions
files: sre_tables.patch
keywords: patch
messages: 228836
nosy: ezio.melotti, mrabarnett, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Get rid of SRE character tables
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file36841/sre_tables.patch

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



[issue17381] IGNORECASE breaks unicode literal range matching

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Updated patch for 3.5 addresses Antoine's comments.

Note that 3.4 and 3.5 use different solutions of this issue.

--
dependencies: +Get rid of SRE character tables
Added file: http://bugs.python.org/file36842/re_ignore_case_range-3.5_3.patch

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



[issue19380] Optimize parsing of regular expressions

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Updated patch implements Antoine's suggestions.

--
Added file: http://bugs.python.org/file36843/re_parse_5.patch

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



[issue22389] Generalize contextlib.redirect_stdout

2014-10-09 Thread Berker Peksag

Berker Peksag added the comment:

Here's an updated patch.

--
Added file: http://bugs.python.org/file36844/issue22389_v2.diff

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



[issue22389] Add contextlib.redirect_stderr()

2014-10-09 Thread STINNER Victor

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


--
title: Generalize contextlib.redirect_stdout - Add contextlib.redirect_stderr()

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



[issue22389] Add contextlib.redirect_stderr()

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

issue22389_v2.diff:

 .. function:: redirect_stdout(new_target)
+  redirect_stderr(new_target)

I would prefer to have two distinct entries in the documentation. The 
redirect_stderr() doc can be after redirect_stdout() and just say Similar to 
redirect_stdout() but redirects sys.stderr.

--

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



[issue22493] Deprecate the use of flags not at the start of regular expression

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is alternative, much simpler, patch. It deprecates only flags in nested 
subpatterns. No changes needed in tests and other stdlib modules. It is very 
unlikely that it is used in third party code.

--
Added file: http://bugs.python.org/file36845/re_deprecate_nested_flags.patch

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



[issue16254] Make PyUnicode_AsWideCharString() increase temporary

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

I proposed to change PyUnicode_AsWideCharString() to not cache the result: see 
my issue #22323 Rewrite PyUnicode_AsWideChar() and 
PyUnicode_AsWideCharString(): don't cache the result.

See also my issues #22271 Deprecate PyUnicode_AsUnicode(): emit a 
DeprecationWarning and #22324 Use PyUnicode_AsWideCharString() instead of 
PyUnicode_AsUnicode().

--

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



[issue22323] Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(): don't cache the result

2014-10-09 Thread STINNER Victor

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


--
title: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() - 
Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(): don't cache 
the result

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



[issue22580] PyUnicode_Tailmatch documentation does not match signature

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4aba14bb6b1e by Victor Stinner in branch '3.4':
Closes #22580: Fix documentation of PyUnicode_Tailmatch()
https://hg.python.org/cpython/rev/4aba14bb6b1e

New changeset 335d16d864e1 by Victor Stinner in branch 'default':
(Merge 3.4) Closes #22580: Fix documentation of PyUnicode_Tailmatch()
https://hg.python.org/cpython/rev/335d16d864e1

--
nosy: +python-dev
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue22580] PyUnicode_Tailmatch documentation does not match signature

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset de4ffe20 by Victor Stinner in branch '2.7':
Closes #22580: Fix documentation of PyUnicode_Tailmatch()
https://hg.python.org/cpython/rev/de4ffe20

--

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



[issue22580] PyUnicode_Tailmatch documentation does not match signature

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 The documentation for PyUnicode_Tailmatch says it returns an int

It's an old bug (since Python 2.7 or older) and it is now fixed. Thanks for the 
report Josh.

--

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



[issue22542] Use arc4random under OpenBSD for os.urandom() if /dev/urandom is not present

2014-10-09 Thread STINNER Victor

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


--
title: Use arc4random under OpenBSD for os.urandom() - Use arc4random under 
OpenBSD for os.urandom() if /dev/urandom is not present

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



[issue22181] os.urandom() should use Linux 3.17 getrandom() syscall

2014-10-09 Thread STINNER Victor

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


--
type: enhancement - security

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



[issue22585] os.urandom() should use getentropy() of OpenBSD 5.6

2014-10-09 Thread STINNER Victor

New submission from STINNER Victor:

The future OpenBSD 5.6 (scheduled in november 2014) will have a new 
getentropy() syscall and a new getentropy() in their C library which avoid the 
need of a file descriptor:
http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/getentropy.2?query=getentropysec=2

Note: The maximum buffer size permitted is 256 bytes. If buflen exceeds this, 
an error of EIO will be indicated.

The file descriptor of os.urandom() causes perfomance issues and surprising 
bugs: #18756, #21207.

For Python 2.7, see also the PEP 466 and the issue #21305.

See also issues:

- #22181: os.urandom() should use Linux 3.17 getrandom() syscall
- #22542: Use arc4random under OpenBSD for os.urandom() if /dev/urandom is not 
present

--
messages: 228846
nosy: haypo
priority: normal
severity: normal
status: open
title: os.urandom() should use getentropy() of OpenBSD 5.6
type: security
versions: Python 3.5

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



[issue22585] os.urandom() should use getentropy() of OpenBSD 5.6

2014-10-09 Thread STINNER Victor

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


--
nosy: +700eb415, rpointel

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



[issue22181] os.urandom() should use Linux 3.17 getrandom() syscall

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

This issue is specific to Linux: it depends on the Linux kernel version and we 
are waiting until the new syscall is available in the C library (especially the 
glibc). For these reasons, I prefer to open a new specific issue for OpenBSD, 
since they release the kernel and C library at the same time (different release 
process): issue #22585. OpenBSD 5.6 scheduled in one month will get the new 
getentropy() syscall and a new getentropy() function at the same time.

--

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



[issue21459] DragonFlyBSD support

2014-10-09 Thread Thomas Klausner

Thomas Klausner added the comment:

The diff got even smaller -- one of the two chunks was applied in 3.4.2 without 
a reference to this bug report. Please apply the last chunk, it's completely 
straightforward.

--
Added file: http://bugs.python.org/file36846/dragonfly.diff

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



[issue21459] DragonFlyBSD support

2014-10-09 Thread Thomas Klausner

Changes by Thomas Klausner t...@giga.or.at:


Removed file: http://bugs.python.org/file35433/dragonfly.diff

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



[issue22585] os.urandom() should use getentropy() of OpenBSD 5.6

2014-10-09 Thread STINNER Victor

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


--
nosy: +alex

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



[issue22542] Use arc4random under OpenBSD for os.urandom() if /dev/urandom is not present

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 title: Use syscall (eg. arc4random or getentropy) rather than /dev/urandom 
 when possible - Use arc4random under OpenBSD for os.urandom()

For the usage getentropy(), I created a dedicated issue: #22585.

 arc4random() should be avoided IMO, on many systems (including OS X) it 
 really is still arc4

RC4 has known weaknesses since 1995, the most severe was reported the last year:
https://en.wikipedia.org/wiki/RC4#Royal_Holloway_attack

http://www.theregister.co.uk/2013/11/14/ms_moves_off_rc4/
Microsoft, Cisco: RC4 encryption considered harmful, avoid at all costs
and
RC4 is broken in real-time by the ‪NSA‬ – stop using it.

FYI On OpenBSD 5.5 and newer, arc4random() now uses ChaCha20:
http://www.openbsd.org/cgi-bin/man.cgi?query=arc4randomsektion=3arch=manpath=OpenBSD+Current

If I understand correctly, arc4random() uses the ARC4 algorithm on all 
platforms except OpenBSD 5.5 and newer.

OpenBSD 5.6 with its getentropy() will be available when Python 3.5 will be 
released (PEP 478): OpenBSD 5.6 is scheduled for one month (november 2014), 
whereas Python 3.5 is scheduled for September 2015.

I don't think that we need to add a very specific code in Python 3.5 only for 
the exact platform OpenBSD 5.5, for a very specific case: chroot without 
/dev/urandom. What's the point of a chroot without /dev/urandom? Other 
applications will also have security issues if /dev/urandom is not available.

Current before of Python 3.5 if /dev/urandom is not available:

$ ~haypo/prog/python/default/python
Fatal Python error: Failed to open /dev/urandom
Abandon (core dumped)

The error is reported immediatly at startup. So you can immediatly detect the 
issue with your chroot.

I don't trust a function from the user space.

os.urandom() is documented as providing entropy from the OS:
Return a string of n random bytes suitable for cryptographic use. This 
function returns random bytes from an OS-specific randomness source.
https://docs.python.org/dev/library/os.html#os.urandom

I'm not sure that arc4random() can be considered as coming from the OS.

If you really want arc4random(), IMO you should add a *new* function, but it 
would not be portable: only available on OpenBSD (and maybe other BSD including 
Mac OS X), not available on Windows nor Linux. I'm not sure that it fits Python 
portability policy, even if we have many functions which are only available on 
some recent platforms, like many Linux-specific functions (in the os module).

--
nosy: +haypo

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



[issue22181] os.urandom() should use Linux 3.17 getrandom() syscall

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 Since this is a Linux-specific issue (see the title), you should create a 
 separate issue for OpenBSD support.

700eb415 opened the issue #22542 for arc4random().

--

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



[issue22542] Use arc4random under OpenBSD for os.urandom() if /dev/urandom is not present

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 Hopefully this could then be used as a template for getrandom() when 
 implemented on Linux.

Sorry, what is getrandom()?

Linux 3.17 has a new getrandom() syscall, but the C API is not defined yet (see 
the issue #22181). OpenBSD 5.6 will have a getentropy() syscall and a 
gentropy() function in the C libray.

If if you are discussing about an hypothetical function in the C library, it's 
out of the scope if this bug tracker. Python don't call directly syscalls (ok, 
there is only one place in _posixsubprocess to avoid a race condition).

--

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



[issue22583] Segmentation fault with string concatenation

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 Then, on Ubuntu 14.04, 32-bit:
 $ python mega_concat.py 
 Segmentation fault (core dumped)

What is your Python version? It looks like Ubuntu Trusty provides Python 2.7.6. 
I'm unable to reproduce the issue on ArchLinux 32-bit with Python 2.7.8. The 
issue was maybe fixed between 2.7.6 and 2.7.8.

[haypo@arch32 ~]$ cat megaconcat.py 

N = 2**17
my_array = []
for i in range(N):
  my_array.append(\\)
print('+'.join(my_array))

[haypo@arch32 ~]$ python2 -V
Python 2.7.8

[haypo@arch32 ~]$ ulimit -v 8000
[haypo@arch32 ~]$ python2 megaconcat.py 
Traceback (most recent call last):
  File megaconcat.py, line 5, in module
my_array.append(\\)
MemoryError

--
nosy: +haypo

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



[issue5843] Normalization error in urlunparse

2014-10-09 Thread Aaron Hill

Aaron Hill added the comment:

In order to fix this, I think ParseResult needs to have two additional fields, 
indicating with an empty prefix or query string are used.

Both ParseResult.fragment and ParseResult.query omit the leading '#' or '?' 
from their value. This makes it impossible to determine if the fragment/query 
string is entirely absent, or has no value.

--
nosy: +Aaron1011

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5843
___
___
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

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

I cloned https://github.com/benhoyt/scandir. I understand that the --scandir 
command line option of benchmark.py are these choices:

- generic = call listdir() and then use yield GenericDirEntry which caches 
os.stat() and os.lstat() results
- python = ctypes implemented calling opendir/readdir and yields PosixDirEntry 
objects which uses d_type field from readdir() in is_dir(), is_file() and 
is_symlink(). Cache the result of os.stat() and os.lstat()
- c = scandir_helper (iterator) implemented in C (Python C API) yielding 
PosixDirEntry objects (same class than the python benchmark)


I checked with an assertion: d_type of readdir() is never DT_UNKNOWN on my 
Linux Fedora 20. Statistics of PosixDirEntry on my /usr/share tree:

- 155544 PosixDirEntry instances
- fast-path (use d_type) taken 466632 times in is_dir/is_symlink
- slow-path (need to call os.stat or os.lstat) taken 7828 times in 
is_dir/is_symlink
- os.stat called 7832 times
- os.stat called 0 times

7832 is the number of symbolic links in my /usr/share tree. 95% of entries 
don't need stat() in scandir.walk() when using readdir().

So is_dir() and is_symlink() are approximatively called 3 times per entry: 
scandir.walk() calls is_dir() and is_symlink() on each entry, but is_dir() also 
calls is_symlink() by default (because the default value of the follow_symlinks 
parameter is True).


I ran benchmark.py on my Linux Fedora 20 (Linux kernel 3.14). I have two HDD 
configured as RAID0. I don't think that my disk config is revelant: I also have 
12 GB of memory, I hope that /usr/share tree is fully cached. For example, 
free -m tells me that 8.8 GB are cached.

The generic implementation looks inefficient: it is 2 times slower. Is there a 
bug? GenericDirEntry caches os.stat() and os.lstat() result, it should be as 
fast or faster than os.walk(), no? Or is it the cost of a generator?

The c implementation is 35% faster than the python implementation 
(python=1.170 sec, c=0.762 sec).


Result of benchmark:

haypo@smithers$ python3 setup.py build  for scandir in generic python c; do 
echo; echo === $scandir ===; PYTHONPATH=build/lib.linux-x86_64-3.3/ python3 
benchmark.py /usr/share -c $scandir || break; done
running build
running build_py
running build_ext

=== generic ===
Using very slow generic version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 1.340s, scandir.walk took 2.471s -- 0.5x as fast

=== python ===
Using slower ctypes version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 1.318s, scandir.walk took 1.170s -- 1.1x as fast

=== c ===
Using fast C version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 1.317s, scandir.walk took 0.762s -- 1.7x as fast

--

___
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

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

I also ran the benchmark without cache on disk. It looks like my hard drive is 
too slow to see a real speedup of scandir(). The maximum speedup is 2.7 seconds 
lesser when testing the c scandir (24.089 = 21.374 seconds): 1.1x as fast.

I modified the benchmark to flush all caches, I added the following line into 
do_scandir_walk():

   os.system(sudo bash -c 'echo 3  /proc/sys/vm/drop_caches')

I also commented the first call to do_scandir_walk() (Priming the system's 
cache...), just to make the benchmark faster.

(See attached clear_system_cache.patch for all changes.)

Result of the modified benchmark without cache:

haypo@smithers$ python3 setup.py build  for scandir in generic python c; do 
echo; echo === $scandir ===; PYTHONPATH=build/lib.linux-x86_64-3.3/ python3 
benchmark.py /usr/share -c $scandir || break; done
running build
running build_py
running build_ext

=== generic ===
Using very slow generic version of scandir
Comparing against builtin version of os.walk()
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 24.324s, scandir.walk took 24.215s -- 1.0x as fast

=== python ===
Using slower ctypes version of scandir
Comparing against builtin version of os.walk()
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 24.089s, scandir.walk took 21.374s -- 1.1x as fast

=== c ===
Using fast C version of scandir
Comparing against builtin version of os.walk()
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 24.225s, scandir.walk took 21.390s -- 1.1x as fast

--
Added file: http://bugs.python.org/file36847/clear_system_cache.patch

___
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



[issue22583] Segmentation fault with string concatenation

2014-10-09 Thread Josh Rosenberg

Josh Rosenberg added the comment:

You're supposed to use that code to create a file (the output file is just 
+...+).

If you want something that won't MemoryError generating the file, this is a 
memory free version of the code to generate the file:

import itertools, sys
sys.stdout.writelines(itertools.repeat('+', 2**17))
print('')

Run that code (saved as whatever file name you like) and pipe the output to 
mega_concat.py, then run mega_concat.py to repro.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22583
___
___
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

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

My previous benchmark runs were with the system Python 3.3.

New benchmark with a Python 3.5 patched with scandir-1.patch (compiled in 
release mode: ./configure  make).

os (os.scandir) is 2 times faster than c (_scandir.scandir_helper): c=0.533 
sec, os=0.268 sec.

On all implementations, scandir.walk() is only much faster than os.walk() when 
os (os.scandir) is used: 3.2x as fast (860 ms = 268 ms).

I guess that on Linux the speedup highly depends on the number of symbolic 
links.

It would help if benchmark.py created the tree to have more reliable numbers, 
and being able to compare trees without symlinks, with a few symlinks (ex: 
10%), and with a lot of symlinks (ex: 99%).

Benchmark results:

haypo@smithers$ ~/prog/python/default/python setup.py build  for scandir in 
generic python c os; do echo; echo === $scandir ===; 
PYTHONPATH=build/lib.linux-x86_64-3.5/ ~/prog/python/default/python 
benchmark.py /usr/share -c $scandir || break; done
running build
running build_py
copying scandir.py - build/lib.linux-x86_64-3.5
running build_ext

=== generic ===
Using very slow generic version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 0.857s, scandir.walk took 1.627s -- 0.5x as fast

=== python ===
Using slower ctypes version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 0.856s, scandir.walk took 0.915s -- 0.9x as fast

=== c ===
Using fast C version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 0.857s, scandir.walk took 0.533s -- 1.6x as fast

=== os ===
Using Python 3.5's builtin os.scandir()
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk took 0.860s, scandir.walk took 0.268s -- 3.2x as fast

--

___
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

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

On Windows, I guess that benchmark.py --size is faster with scandir() than 
with os.walk(), because os.stat() is never called.

benchmark.py has a bug in do_os_walk() when the --size option is used: attached 
do_os_walk_getsize.patch is needed.

Sizes returned by os.walk() and scandir.walk() are different. I guess that the 
behaviour of symbolic links to directory is different. Because of that, I'm not 
sure that benchmark timings are reliable, but well, it should give us an idea 
of performances.

To compute the size of a tree, scandir() is twice faster (2.1x as fast) than 
os.walk(): os.walk=1.435 sec, scandir.walk=0.675 sec.

os is 41% faster than c: c=1150 ms, os=675 ms.


Results of benchmark.py --size on my Linux Fedora 20:

haypo@smithers$ ~/prog/python/default/python setup.py build  for scandir in 
generic python c os; do echo; echo === $scandir ===; 
PYTHONPATH=build/lib.linux-x86_64-3.5/ ~/prog/python/default/python 
benchmark.py -s /usr/share -c $scandir || break; done
running build
running build_py
running build_ext

=== generic ===
Using very slow generic version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk size 3064748475, scandir.walk size 2924332540 -- NOT EQUAL!
os.walk took 1.425s, scandir.walk took 1.147s -- 1.2x as fast

=== python ===
Using slower ctypes version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk size 3064748475, scandir.walk size 2924332540 -- NOT EQUAL!
os.walk took 1.421s, scandir.walk took 1.651s -- 0.9x as fast

=== c ===
Using fast C version of scandir
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk size 3064748475, scandir.walk size 2924332540 -- NOT EQUAL!
os.walk took 1.426s, scandir.walk took 1.150s -- 1.2x as fast

=== os ===
Using Python 3.5's builtin os.scandir()
Comparing against builtin version of os.walk()
Priming the system's cache...
Benchmarking walks on /usr/share, repeat 1/3...
Benchmarking walks on /usr/share, repeat 2/3...
Benchmarking walks on /usr/share, repeat 3/3...
os.walk size 3064748475, scandir.walk size 2924332540 -- NOT EQUAL!
os.walk took 1.435s, scandir.walk took 0.675s -- 2.1x as fast

--
Added file: http://bugs.python.org/file36848/do_os_walk_getsize.patch

___
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



[issue22583] C stack overflow in the Python 2.7 compiler

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 You're supposed to use that code to create a file (the output file is just 
 +...+).

Oh ok, the bug is in Python compiler. It's probably an overflow of the C stack.

The bug was fixed in Python 3.3 by the issue #5765: see changeset ab02cd145f56. 
See also the issue #19098 (sys.setrecursionlimit(2**30) breaks interactive 
shell) and the changeset c3df31cbcd0a.

Nick Coghlan wrote in the issue #5765: However, agreed on the won't fix for 
3.2 and 2.7, although I'd consider it at least for 2.7 if someone went through 
and worked out a patch that applies cleanly.


$ python2
Python 2.7.5 (default, Sep 25 2014, 13:57:38) 
[GCC 4.8.3 20140911 (Red Hat 4.8.3-7)] on linux2 compile('1' + '+1'*10**5, 
'string', 'exec')
code object module at 0x7f8c5ba2c1b0, file string, line 1
 compile('1' + '+1'*10**6, 'string', 'exec')
Erreur de segmentation (core dumped)

$ python3
Python 3.3.2 (default, Jun 30 2014, 17:20:03) 
[GCC 4.8.3 20140624 (Red Hat 4.8.3-1)] on linux
 compile('1' + '+1'*10**3, 'string', 'exec')
code object module at 0x7f7298d479c0, file string, line 1
 compile('1' + '+1'*10**4, 'string', 'exec')
Traceback (most recent call last):
  File stdin, line 1, in module
RuntimeError: maximum recursion depth exceeded during compilation

--
nosy: +ncoghlan
title: Segmentation fault with string concatenation - C stack overflow in the 
Python 2.7 compiler

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



[issue22327] test_gdb failures on Ubuntu 14.10

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

Is it only a warning or python-gdb.py doesn't work at all? If it's a warning, 
attached test_gdb.patch should fix it.

--
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file36849/test_gdb.patch

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



[issue22579] Posix module init function name should not be compiler-dependent

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

The patch looks good to me, but I would prefer that someone else double check.

--
components: +Windows
nosy: +haypo, loewis, pitrou
versions: +Python 3.5 -Python 3.4

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 58601c36a357 by Victor Stinner in branch '3.4':
Issue #22568: Fix compilation of posixmodule.c with Open Watcom: rename utime
https://hg.python.org/cpython/rev/58601c36a357

New changeset 588657f910ac by Victor Stinner in branch 'default':
(Merge 3.4) Issue #22568: Fix compilation of posixmodule.c with Open Watcom:
https://hg.python.org/cpython/rev/588657f910ac

--
nosy: +python-dev

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 Patch LGTM.

The patch is safe. Even if I don't care of the Open Watcom compiler, the patch 
is simple enough to be accepted. (It doesn't add crazy #ifdef WATCOM).

I commited your change, thanks Jeffrey for your contribution.

--

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



[issue22327] test_gdb failures on Ubuntu 14.10

2014-10-09 Thread Matěj Stuchlík

Matěj Stuchlík added the comment:

While with Python3.5's test_gdb does fail when building in Koji [0], it seems 
to pass fine in our other build system - Copr [1]. Comparing the two [2][3], it 
seems the only big difference is the kernel version - 2.6.32 in Copr and 3.16.3 
in Koji. Not sure how relevant this is, just something I noticed.

[0] https://kojipkgs.fedoraproject.org//work/tasks/700/7810700/build.log
[1] 
http://copr-be.cloud.fedoraproject.org/results/churchyard/python3-nightly/fedora-21-i386/python3-3.5.0-0.117.20141009hgf7124c167603.fc20/build.log
[2] https://kojipkgs.fedoraproject.org//work/tasks/700/7810700/root.log
[3] 
http://copr-be.cloud.fedoraproject.org/results/churchyard/python3-nightly/fedora-21-i386/python3-3.5.0-0.117.20141009hgf7124c167603.fc20/root.log

--

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



[issue22198] Odd floor-division corner case

2014-10-09 Thread Petr Viktorin

Petr Viktorin added the comment:

Apologies for the delay; I missed/did not get a notification.

Alexander, I don't disagree, but I'd like my first patch to Python to not be a 
refactoring. As I said, I'd like to keep this patch focused. After that I'd 
like to provide tests the rest of float_divmod; and then perhaps use an 
entirely different implementation.

If that's not a good course of action, and you suggest a different one or just 
tell me to improve everything at once, I will certainly try. But, I think that 
this patch is an improvement, and that it does fix this bug.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22198
___
___
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

2014-10-09 Thread Ben Hoyt

Ben Hoyt added the comment:

Thanks, Victor and Antone. I'm somewhat surprised at the 2-3x numbers you're 
seeing, as I was consistently getting 4-5x in the Linux tests I did. But it 
does depend quite a bit on what file system you're running, what hardware, 
whether you're running in a VM, etc. Still, 2-3x faster is a good speedup!

The numbers are significantly better on Windows, as you can see. Even the 
smallest numbers I've seen with --scandir os are around 12x range on Windows.

In any case, Victor's last tests are right -- I presume we'll have *some* C, 
so what we want to be comparing is benchmark.py --scandir c versus 
benchmark.py --scandir os: the some C version versus the all C version in the 
attached CPython 3.5 patch.

BTW, Victor, Generic isn't really useful. I just used it as a test case that 
calls listdir() and os.stat() to implement the scandir/DirEntry interface. So 
it's going to be strictly slower than listdir + stat due to using listdir and 
creating all those DirEntry objects.

Anyway, where to from here? Are we agreed given the numbers that -- especially 
on Linux -- it makes good performance sense to use an all-C approach?

--

___
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

2014-10-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le 09/10/2014 14:35, Ben Hoyt a écrit :
 
 Anyway, where to from here? Are we agreed given the numbers that --
especially on Linux -- it makes good performance sense to use an all-C
approach?

I think so, yes.

--

___
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



[issue16177] Typing left parenthesis in IDLE causes intermittent Cocoa Tk crash on OS X

2014-10-09 Thread Brian Keegan

Brian Keegan added the comment:

I was also using a dual-screen setup: laptop + external display.

On Thu, Oct 9, 2014 at 1:07 AM, Ned Deily rep...@bugs.python.org wrote:


 Ned Deily added the comment:

 Thanks, Tom, nice writeup!  If any of the other people who have seen this
 crash are still around, it would be interesting to know if they also were
 using more than one monitor.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue16177
 ___


--

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



[issue22564] ssl: post-commit review of the new memory BIO API

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

Here is a first patch for SSL documentation. If the patch looks fine, I will 
first apply revelant parts to Python 3.4 documentation.

--
keywords: +patch
Added file: http://bugs.python.org/file36850/ssl_doc.patch

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



[issue557704] netrc module can't handle all passwords

2014-10-09 Thread Martin Dengler

Martin Dengler added the comment:

I know this is ancient, but the below patch handles spaces in passwords in 
2.7.8 and 3.4 for me.  If this is worth making into a new bug / proper patch 
I'm happy to do it.

$ diff -uw /c/Python278/Lib/netrc.py{-orig,}
--- /c/Python278/Lib/netrc.py-orig  2014-10-09 13:52:36.995286000 +0100
+++ /c/Python278/Lib/netrc.py   2014-10-09 13:53:05.041286000 +0100
@@ -111,7 +111,23 @@
~/.netrc access too permissive: access
 permissions must restrict access to only
 the owner, file, lexer.lineno)
+# handle passwords with quoted spaces
+quote_chars = lexer.quotes
+removed_chars = []
+for quote_char in quote_chars:
+if quote_char in lexer.wordchars:
+lexer.wordchars = 
lexer.wordchars.replace(quote_char, '')
+removed_chars.append(quote_char)
+try:
+
 password = lexer.get_token()
+
+for quote_char in quote_chars:
+if password.startswith(quote_char) and 
password.endswith(quote_char):
+password = password[1:-1]
+finally:
+for removed_char in removed_chars:
+lexer.wordchars += removed_char
 else:
 raise NetrcParseError(bad follower token %r % tt,
   file, lexer.lineno)

--
nosy: +mdengler

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



[issue557704] netrc module can't handle all passwords

2014-10-09 Thread Martin Dengler

Martin Dengler added the comment:

Sorry for the whitespace-unaware diff.  The attached patch is the real one, 
with the obvious extra level of indentation around the critical password = 
lexer.get_token() line.

--
keywords: +patch
Added file: 
http://bugs.python.org/file36851/python-netrc-password-spaces-bug-557704.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue557704
___
___
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

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 I'm somewhat surprised at the 2-3x numbers you're seeing, as I was 
 consistently getting 4-5x in the Linux tests I did. But it does depend quite 
 a bit on what file system you're running, what hardware, whether you're 
 running in a VM, etc. Still, 2-3x faster is a good speedup!

I don't think that hardware matters. As I wrote, I expect the whole /usr/share 
tree to fit in memory. It's sounds more like optimizations in the Linux kernel. 
I ran benchmarks on Fedora 20 with the Linux kernel 3.14.

 Anyway, where to from here? Are we agreed given the numbers that -- 
 especially on Linux -- it makes good performance sense to use an all-C 
 approach?

We didn't try yet to call readdir() multiple times in the C iterator and use a 
small cache (ex: between 10 and 1000 items, I don't know which size is the best 
yet) to also limit the number of readdir() calls. The cache would be an array 
of dirent on Linux.

scandir_helper() can return an array of items instead of a single item for 
example.

I can try to implement it if you want.

--

___
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

2014-10-09 Thread Ben Hoyt

Ben Hoyt added the comment:

I dunno, I'd be happy if you implement this, but it does mean *more* C code, 
not less. :-) I feel this would be a nice-to-have, but we should get the thing 
working first, and then do the multiple-OS-calls-in-one optimization.

In any case, if you implement this, I think you should do so against the 
CPython 3.5 patch, not the _scandir.c/scandir_helper code.

--

___
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



[issue22578] Add additional attributes to re.error

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Matthew for your suggestions. Here is updated patch.

--
Added file: http://bugs.python.org/file36852/re_error_attrs3.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue22578
___diff -r 8b1ac1a3d007 Doc/library/re.rst
--- a/Doc/library/re.rstWed Oct 08 22:32:50 2014 +0300
+++ b/Doc/library/re.rstThu Oct 09 16:29:25 2014 +0300
@@ -726,13 +726,36 @@ form.
Clear the regular expression cache.
 
 
-.. exception:: error
+.. exception:: error(msg, pattern=None, pos=None)
 
Exception raised when a string passed to one of the functions here is not a
valid regular expression (for example, it might contain unmatched 
parentheses)
or when some other error occurs during compilation or matching.  It is 
never an
-   error if a string contains no match for a pattern.
+   error if a string contains no match for a pattern.  The error instance has
+   the following additional attributes:
 
+   .. attribute:: msg
+
+  The unformatted error message.
+
+   .. attribute:: pattern
+
+  The regular expression pattern.
+
+   .. attribute:: pos
+
+  The index of *pattern* where compilation failed.
+
+   .. attribute:: lineno
+
+  The line corresponding to *pos*.
+
+   .. attribute:: colno
+
+  The column corresponding to *pos*.
+
+   .. versionchanged:: 3.5
+  Added additional attributes.
 
 .. _re-objects:
 
diff -r 8b1ac1a3d007 Lib/sre_constants.py
--- a/Lib/sre_constants.py  Wed Oct 08 22:32:50 2014 +0300
+++ b/Lib/sre_constants.py  Thu Oct 09 16:29:25 2014 +0300
@@ -21,8 +21,35 @@ from _sre import MAXREPEAT, MAXGROUPS
 # should this really be here?
 
 class error(Exception):
-pass
+def __init__(self, msg, pattern=None, pos=None):
+self.msg = msg
+self.pattern = pattern
+self.pos = pos
+if pattern is not None and pos is not None:
+msg = '%s at position %d' % (msg, pos)
+if isinstance(pattern, str):
+newline = '\n'
+else:
+newline = b'\n'
+self.lineno = pattern.count(newline, 0, pos) + 1
+self.colno = pos - pattern.rfind(newline, 0, pos)
+if newline in pattern:
+msg = '%s (line %d, column %d)' % (msg, self.lineno, 
self.colno)
+else:
+self.lineno = self.colno = None
+super().__init__(msg)
 
+def linecol(doc, pos):
+if isinstance(pattern, str):
+newline = '\n'
+else:
+newline = b'\n'
+lineno = pattern.count(newline, 0, pos) + 1
+if lineno == 1:
+colno = pos + 1
+else:
+colno = pos - doc.rindex(newline, 0, pos)
+return lineno, colno
 # operators
 
 FAILURE = failure
diff -r 8b1ac1a3d007 Lib/sre_parse.py
--- a/Lib/sre_parse.py  Wed Oct 08 22:32:50 2014 +0300
+++ b/Lib/sre_parse.py  Thu Oct 09 16:29:25 2014 +0300
@@ -207,7 +207,8 @@ class Tokenizer:
 try:
 c = self.string[self.index + 1]
 except IndexError:
-raise error(bogus escape (end of line))
+self.next = None
+raise self.error(bogus escape (end of line), 0)
 if not self.istext:
 c = chr(c)
 char = char + c
@@ -233,9 +234,13 @@ class Tokenizer:
 self.__next()
 return result
 def tell(self):
-return self.index, self.next
+return self.index - len(self.next or '')
 def seek(self, index):
-self.index, self.next = index
+self.index = index
+self.__next()
+
+def error(self, msg, offset):
+return error(msg, self.string, self.tell() - offset)
 
 # The following three functions are not used in this module anymore, but we 
keep
 # them here (with DeprecationWarnings) for backwards compatibility.
@@ -299,8 +304,8 @@ def _class_escape(source, escape):
 escape += source.getwhile(2, OCTDIGITS)
 c = int(escape[1:], 8)
 if c  0o377:
-raise error('octal escape value %r outside of '
-'range 0-0o377' % escape)
+raise source.error('octal escape value %r outside of '
+   'range 0-0o377' % escape, len(escape))
 return LITERAL, c
 elif c in DIGITS:
 raise ValueError
@@ -308,7 +313,7 @@ def _class_escape(source, escape):
 return LITERAL, ord(escape[1])
 except ValueError:
 pass
-raise error(bogus escape: %s % repr(escape))
+raise source.error(bogus escape: %s % repr(escape), len(escape))
 
 def _escape(source, escape, state):
 # handle escape code in expression
@@ -354,21 +359,23 @@ def _escape(source, escape, state):
 escape = escape + source.get()
 c = int(escape[1:], 8)
 if c  0o377:
-  

[issue21049] Warning at interpreter exit triggers flood of “ImportWarning: sys.meta_path is empty”

2014-10-09 Thread Brett Cannon

Brett Cannon added the comment:

I'm already planning to look into this problem in issue #21052 so feel free to 
follow over there.

--
superseder:  - Consider dropping ImportWarning for empty sys.path_hooks and 
sys.meta_path

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



[issue22407] re.LOCALE is nonsensical for Unicode

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is simple patch which just deprecate using of the re.LOCALE flag with str 
patterns. It also deprecates using of the re.LOCALE flag with the re.ASCII flag 
(with bytes patterns) and adds some re.LOCALE related tests.

--
versions:  -Python 2.7, Python 3.4
Added file: http://bugs.python.org/file36853/re_deprecate_unicode_locale.patch

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



[issue22586] urljoin allow_fragments doesn't work

2014-10-09 Thread Alex Parrill

New submission from Alex Parrill:

Passing False to the allow_fragments argument to urljoin doesn't remove 
fragments.

Is this a bug, or am I misunderstanding the allow_fragments parameter? It's not 
perfectly clear what fragment identifiers are not allowed means (strips them 
out? throws an error?)

I'm running this on XUbuntu 14.04.01.

$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type help, copyright, credits or license for more information.
 from urllib.parse import urljoin
 urljoin(http://localhost:8000/foo.html;, bar.html#baz, 
 allow_fragments=False)
'http://localhost:8000/bar.html#baz'

--
components: Library (Lib)
messages: 228877
nosy: ColonelThirtyTwo
priority: normal
severity: normal
status: open
title: urljoin allow_fragments doesn't work
versions: Python 3.4

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



[issue22389] Add contextlib.redirect_stderr()

2014-10-09 Thread Yury Selivanov

Yury Selivanov added the comment:

I think that Victor is right, it would be better to have two distinct entries 
in the docs. Besides that - LGTM.

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Georg Brandl

Georg Brandl added the comment:

UTIME_TO_UTIMBUF actually still looks dodgy and UTIME_TO_TIME_T is completely 
broken.

* There should be only one utimbuf structure, because it already contains 
both times (see man 2 utime).

* UTIME_TO_TIME_T uses a type called struct timet which I don't think exists, 
it should be time_t *.  The  operator is wrong.

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Jeffrey Armstrong

Jeffrey Armstrong added the comment:

My patch merely fixes broken code that wasn't being used by Python's 
supported compilers under most common configurations.  It's really 
independent of compiler.  I realize nobody here cares about Open Watcom as a 
supported compiler; the Python community has made that *abundantly* clear.

--

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



[issue22586] urljoin allow_fragments doesn't work

2014-10-09 Thread Georg Brandl

Georg Brandl added the comment:

The not allowed should be clarified.  What is meant is that if 
allow_fragments is false, a fragment is parsed as part of the path.

This doesn't make a difference for urljoin if the fragment is part of the 
second part.  It does make a difference for the first part:

 urljoin('http://www.example.com/#frag/', 'foo#bar', allow_fragments=True)
'http://www.example.com/foo#bar'

 urljoin('http://www.example.com/#frag/', 'foo#bar', allow_fragments=False)
'http://www.example.com/#frag/foo#bar'

For reference, the urlparse() results:

 urlparse('http://www.example.com/#frag/', allow_fragments=True)
ParseResult(scheme='http', netloc='www.example.com', path='/', params='', 
query='', fragment='frag/')

 urlparse('http://www.example.com/#frag/', allow_fragments=False)
ParseResult(scheme='http', netloc='www.example.com', path='/#frag/', params='', 
query='', fragment='')

--
assignee:  - docs@python
components: +Documentation -Library (Lib)
nosy: +docs@python, georg.brandl, orsenthil
versions: +Python 2.7, Python 3.5

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Georg Brandl

Georg Brandl added the comment:

Jeffrey: I did not mean to devalue your patch, I just wanted to bring even more 
issues to Victor's attention.

--

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



[issue22587] os.path.abspath(None) behavior is inconsistent between platforms

2014-10-09 Thread Kevin Keating

New submission from Kevin Keating:

On Windows, os.path.abspath() treats None as if it were an empty string, so 
os.path.abspath(None) returns the current working directory.  On Linux, 
os.path.abspath(None) raises an AttributeError.  With macpath, abspath(None) 
raises a TypeError.  I've seen this behavior with Python 2.7.3, 2.7.8, 3.2.5, 
and 3.4.2.

Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit 
(Intel)] on win32
Type help, copyright, credits or license for more information.
 import ntpath, posixpath, macpath
 ntpath.abspath(None)
'C:\\Users\\Keating\\Documents'
 posixpath.abspath(None)
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\programs\Python34\lib\posixpath.py, line 357, in abspath
if not isabs(path):
  File C:\programs\Python34\lib\posixpath.py, line 63, in isabs
return s.startswith(sep)
AttributeError: 'NoneType' object has no attribute 'startswith'
 macpath.abspath(None)
Traceback (most recent call last):
  File stdin, line 1, in module
  File C:\programs\Python34\lib\macpath.py, line 177, in abspath
if not isabs(path):
  File C:\programs\Python34\lib\macpath.py, line 49, in isabs
return colon in s and s[:1] != colon
TypeError: argument of type 'NoneType' is not iterable

This case seems very closely related to http://bugs.python.org/issue9018, which 
noted a platform inconsistency in os.path.normcase.

--
components: Library (Lib)
messages: 228883
nosy: KevKeating
priority: normal
severity: normal
status: open
title: os.path.abspath(None) behavior is inconsistent between platforms
versions: Python 2.7, Python 3.2, Python 3.4

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Jeffrey Armstrong

Jeffrey Armstrong added the comment:

Georg: Sorry, that wasn't directed at you.  Your comment snuck in before mine.  
It was more general frustration.

--

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



[issue22587] os.path.abspath(None) behavior is inconsistent between platforms

2014-10-09 Thread Kevin Keating

Kevin Keating added the comment:

I just realized that even the behavior of ntpath.abspath() is inconsistent 
across platforms.  On Windows, ntpath.abspath(None) returns the current working 
directory.  On other OSs, ntpath.abspath(None) raises a TypeError.  There are 
two different abspath definitions in ntpath, one that uses the native Windows 
method (used on Windows) and one that doesn't (used everywhere else).  The two 
methods behave differently if the input value isn't a string.  I've tested this 
on OS X using Python 2.7.8 and 3.4.1:

Python 2.7.8 |Anaconda 2.1.0 (x86_64)| (default, Aug 21 2014, 15:21:46) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type help, copyright, credits or license for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
 import ntpath
 ntpath.abspath(None)
Traceback (most recent call last):
File stdin, line 1, in module
File /Users/young/anaconda/envs/py278/lib/python2.7/ntpath.py, line 473, in 
abspath
if not isabs(path):
  File /Users/young/anaconda/envs/py278/lib/python2.7/ntpath.py, line 57, in 
isabs
s = splitdrive(s)[1]
  File /Users/young/anaconda/envs/py278/lib/python2.7/ntpath.py, line 114, in 
splitdrive
if len(p)  1:
TypeError: object of type 'NoneType' has no len()


Python 3.4.1 |Anaconda 2.1.0 (x86_64)| (default, Sep 10 2014, 17:24:09) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type help, copyright, credits or license for more information.
 import ntpath
 ntpath.abspath(None)
Traceback (most recent call last):
File stdin, line 1, in module
File /Users/young/anaconda/envs/py34/lib/python3.4/ntpath.py, line 533, in 
abspath
if not isabs(path):
File /Users/young/anaconda/envs/py34/lib/python3.4/ntpath.py, line 99, in 
isabs
s = splitdrive(s)[1]
File /Users/young/anaconda/envs/py34/lib/python3.4/ntpath.py, line 159, in 
splitdrive
if len(p)  1:
TypeError: object of type 'NoneType' has no len()

--

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



[issue22588] memory corrupted in test_capi refleaks test

2014-10-09 Thread Xavier de Gaye

New submission from Xavier de Gaye:

This does not happen on tests run with '-R 22:22' or a lower run count, but 
occur systematically with '-R 23:23' or a greater run count.

$ ./python
Python 3.5.0a0 (default:1e1c6e306eb4, Oct  9 2014, 19:52:59)
[GCC 4.9.1 20140903 (prerelease)] on linux
Type help, copyright, credits or license for more information.
 import platform; platform.uname()
uname_result(system='Linux', node='bilboquet', release='3.16.3-1-ARCH', 
version='#1 SMP PREEMPT Wed Sep 17 21:54:13 CEST 2014', machine='x86_64', 
processor='')
 

$ ./python -m test -R 23:23 test_capi
[1/1] test_capi
beginning 46 repetitions
1234567890123456789012345678901234567890123456
..
1 test OK.
Debug memory block at address p=0x982570: API ''
18446744073709551615 bytes originally requested
The 7 pad bytes at p-7 are not all FORBIDDENBYTE (0xfb):
at p-7: 0x00 *** OUCH
at p-6: 0x00 *** OUCH
at p-5: 0x00 *** OUCH
at p-4: 0x00 *** OUCH
at p-3: 0x00 *** OUCH
at p-2: 0x00 *** OUCH
at p-1: 0x00 *** OUCH
Because memory is corrupted at the start, the count of bytes requested
   may be bogus, and checking the trailing pad bytes may segfault.
The 8 pad bytes at tail=0x98256f are not all FORBIDDENBYTE (0xfb):
at tail+0: 0x00 *** OUCH
at tail+1: 0x00 *** OUCH
at tail+2: 0x00 *** OUCH
at tail+3: 0x00 *** OUCH
at tail+4: 0x00 *** OUCH
at tail+5: 0x00 *** OUCH
at tail+6: 0x00 *** OUCH
at tail+7: 0x00 *** OUCH
The block was made by call #0 to debug malloc/realloc.
Data at p:
Fatal Python error: bad ID: Allocated using API '', verified using API 'o'

Current thread 0x7f525bcf2700 (most recent call first):
Aborted (core dumped)

--
components: Library (Lib)
messages: 228886
nosy: xdegaye
priority: normal
severity: normal
status: open
title: memory corrupted in test_capi refleaks test
type: crash
versions: Python 3.5

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



[issue18615] sndhdr.whathdr could return a namedtuple

2014-10-09 Thread Claudiu Popa

Changes by Claudiu Popa pcmantic...@gmail.com:


--
stage: patch review - commit review

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



[issue21986] Pickleability of code objects is inconsistent

2014-10-09 Thread Claudiu Popa

Claudiu Popa added the comment:

Terry, can I do something to move this issue forward?

--

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



[issue21052] Consider dropping ImportWarning for empty sys.path_hooks and sys.meta_path

2014-10-09 Thread Quentin Pradet

Changes by Quentin Pradet quentin.pra...@gmail.com:


--
nosy: +Quentin.Pradet

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



[issue16177] Typing left parenthesis in IDLE causes intermittent Cocoa Tk crash on OS X

2014-10-09 Thread Ned Deily

Ned Deily added the comment:

Thanks for the confirmation, Brian.  I certainly would not have thought to ask 
about multiple monitors.

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Larry Hastings

Larry Hastings added the comment:

Georg, you want to take a swing at it, be my guest.  The current mess is my 
doing, and I claim this is an *improvement* over what came before.

--

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



[issue3068] IDLE - Add an extension configuration dialog

2014-10-09 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I think we should give each extension with options other than 'enablexx' a 
single 'option-help' option that gives the 'signature' of the extension.  I 
suggest 'option-help', rather than just 'help', as the new 'reserved' option 
name as being more descriptive and less likely to already be in use in 
3rd-party extension. Example (that indicates my ignorance of what the options 
mean ;-):

option-help=ParenMatch options
  bell-bool: Ring bell on failure(??)
  flash-delay-int: Milliseconds delay before ??
  style-choice: expression, statement??

Parse by splitting on '\n', ':', and '-'.
-bool would cause the current value to be read as a bool and True/False button 
to be displayed.
-int would cause current value to be read as int and entered value to be 
checked as int
-choice would cause radiobuttons to be displayed.
-float should also be recognized

The Help button at the bottom should display information about enablexx options.

--

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



[issue22522] sys.excepthook doesn't receive the traceback when called from code.InteractiveInterpreter

2014-10-09 Thread Claudiu Popa

Changes by Claudiu Popa pcmantic...@gmail.com:


--
stage:  - patch review

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Georg Brandl

Georg Brandl added the comment:

I'm sure you've improved the code. Without looking at the hg history, you've 
likely just inherited the broken C code from the previous version and made it 
prettier :)

Since this breakage has not been reported so far, the last two #elses appear to 
be a combination of #defines that is very rare.

--

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



[issue22589] mimetypes uses image/x-ms-bmp as the type for bmp files

2014-10-09 Thread Brian Matthews

New submission from Brian Matthews:

In the file mimetypes.py the mime type for bmp files should be image/bmp for 
IE8 and later. the problem is that if the content header for 'nosniff' is set, 
then the bmp file fails to display due to the incorrect mime type.

--
components: IO
messages: 228892
nosy: brma
priority: normal
severity: normal
status: open
title: mimetypes uses image/x-ms-bmp as the type for bmp files
type: behavior
versions: Python 2.7

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



[issue11694] xdrlib raises ConversionError in inconsistent way

2014-10-09 Thread Claudiu Popa

Claudiu Popa added the comment:

Here's a refreshed patch:

- raising_conversion_error is now raise_conversion_error
- the decorator uses functools.wraps
- the ConversionError is instantiated with the first argument of the caught 
expression
- the reraising of ConversionError has the exception context supressed.

--
versions: +Python 3.4, Python 3.5 -Python 3.2, Python 3.3
Added file: http://bugs.python.org/file36854/issue11694.patch

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Z:\c:\Python27\python.exe
Python 2.7.8 (default, Jun 30 2014, 16:03:49) [MSC v.1500 32 bit (Intel)] on 
win32
Type help, copyright, credits or license for more information.

 import math
 math.copysign(0.0, float(nan))
-0.0
 ^Z

Z:\c:\Python34\python.exe
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:24:06) [MSC v.1600 32 bit 
(Intel)] on win32
Type help, copyright, credits or license for more information.
 import math
 math.copysign(0.0, float(nan))
0.0
 ^Z

--
components: Library (Lib), Windows
messages: 228894
nosy: mark.dickinson, pitrou, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: math.copysign buggy with nan under Windows
type: behavior
versions: Python 2.7

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Mark Dickinson

Mark Dickinson added the comment:

Why do you consider this a bug?

--

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Mark Dickinson

Mark Dickinson added the comment:

More info: the reason for the difference is that in Python 3.4, float(nan) 
and float(inf) create the float directly from the appropriate bit-pattern, 
rather than deferring to the platform's definition of nan.  This change was 
introduced to avoid obscure problems on platforms where the Py_NAN macros were 
causing compile-time errors.  There should be a (resolved, fixed) issue about 
this somewhere on the tracker, but I don't have the number handy right now.

I don't consider this a bug.

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 I realize nobody here cares about Open Watcom as a supported compiler; the 
 Python community has made that *abundantly* clear.

I only heard once about Open Watcom, maybe 1 or 2 years ago. I see on 
http://www.openwatcom.org/ that the latest release is 4 years old.

Open Watcom is not packaged in my Linux Fedora 20. I downloaded the source code 
of the release 1.9 and I tried to compile it with build.sh. I had to modify 
build.sh to use bash instead of sh. Than the compilation of c/mglob.c failed 
with Unknown CPU architecture, it looks like x86_64 CPU is not supported :-(

On which platform are you working? Dummy question, why not using a different 
compiler like GCC or Clang?

It was discussed recently to define rules to support a platform (ex: OpenBSD). 
For example, a requirement to have a buildbot and someone able to fix issues. 
I'm trying to help to support AIX even if I don't consider the platform 
important enough and I don't like proprietary software :) There is a buildbot 
and a developer proposing regulary patches.

If you want an official and full support of OpenWatcom, it's better to discuss 
it on the python-dev mailing list.

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 UTIME_TO_UTIMBUF actually still looks dodgy and UTIME_TO_TIME_T is completely 
 broken.

Agreed. It looks like dead code which was never used nor tested.

@Jeffrey: Is your patch enough to compile posixmodule.c with OpenWatcom?

If it's enough, I will close the issue.

--

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ah, apparently it was already reported as issue14521...

Well, it's bug in as much as it shows different behaviour across platforms... 
AFAICT, we try to provide consistent math behaviour despite possible platform 
variations.

--

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Also, the fact that we support float('nan') and float('-nan') as producing 
different bit patterns means we should perhaps produce the right sign bit for 
each (it seems that's the problem here).

 import struct
 struct.pack(d, float(nan))
'\x00\x00\x00\x00\x00\x00\xf8\xff'
 struct.pack(d, float(-nan))
'\x00\x00\x00\x00\x00\x00\xf8\x7f'

--

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Mark Dickinson

Mark Dickinson added the comment:

 we should perhaps produce the right sign bit for each

Perhaps.  But given that signs of NaNs are pretty much meaningless anyway (the 
IEEE 754 standard explicitly refuses to attach any meaning to NaN sign bits, 
and the sign bit of a NaN result is not specified for most operations), and 
that a change *could* conceivably break existing code, I don't see much of a 
case for changing the behaviour in 2.7.  I'm not particularly *opposed* to such 
a change; I just don't really see the point.

BTW, I'd expect this report to apply to other platforms in addition to Windows; 
Intel's default NaN has its sign bit set, so a platform that just does the 
lazy thing and lets the FPU NaN propagate will tend to see an inverted sign bit 
here.

It's only the 2.7 behaviour you're complaining about, right?  Are things 
working as expected on 3.4 and Windows?

--

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



[issue22588] memory corrupted in test_capi refleaks test

2014-10-09 Thread Stefan Krah

Stefan Krah added the comment:

I cannot reproduce this here. Did you run make distclean before compiling?

--
nosy: +skrah

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



[issue22590] math.copysign buggy with nan under Windows

2014-10-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Yes, things are ok under 3.x. We'll probably disable our NaN tests under 
Windows anyway, since they aren't very useful as you point out.

--

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



[issue22588] memory corrupted in test_capi refleaks test

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5d87a6b38422 by Victor Stinner in branch '3.4':
Issue #22588: Fix typo in _testcapi.test_incref_decref_API()
https://hg.python.org/cpython/rev/5d87a6b38422

--
nosy: +python-dev

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



[issue22588] memory corrupted in test_capi refleaks test

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 but occur systematically with '-R 23:23' or a greater run count.

I was able to reproduce the issue. I found that the error came from 
test_incref_decref_API(). After my change, it looks like test_capi doesn't 
crash anymore.

$ ./python -m test -R 23:23 test_capi
[1/1] test_capi
beginning 46 repetitions
1234567890123456789012345678901234567890123456
..
1 test OK.

Can you confirm Xavier?

--
nosy: +haypo

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



[issue21986] Pickleability of code objects is inconsistent

2014-10-09 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Here are the issues for me.

1. Except for your interest, this is a lower priority for me that most all of 
the other 125 Idle issues.

2. I am not familiar with pickling and wonder about the following in the patch. 
It deletes a statememt
copyreg.pickle(types.CodeType, pickle_code, unpickle_code)
that registers two functions.  But the new code only registers pickle_code.  
Will
 message = pickle.loads(packet)
then work?  Maybe, since pickle_code has this.
 return unpickle_code, (ms,)
Is this normal?  Is registring unpickle_code not needed?  Would it make any 
sense to wrap code objects in a CodePickler class with __getstate__ and 
__setstate__ methods?

3. The interprocess communication implemented in rpc.py is central to Idle's 
execution of user code.  So I would want to be confident that a patch does not 
break it.  What I would like is a test script (executed by hand is ok) that 
works now, fails with the deletion of the copyreg statement, and works again 
with the rest of the patch.

4. I have no idea if or from where a code object is sent.  One way to search 
would be to grep idlelib for rpc calls.  Another would be to add a print 
statement to pickle_code, start Idle from the console with 'python -m idlelib', 
and run through all the menu options that involve the user process while 
watching the console for messages.

So you could try one of the searches methods to find a test.  Or you can wait 
for someone who currently understands pickle well enough to review and apply 
the patches without a test.

--

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



[issue22568] Use of utime as variable name in Modules/posixmodule.c causes errors

2014-10-09 Thread Jeffrey Armstrong

Jeffrey Armstrong added the comment:

The last official Open Watcom release (1.9) is indeed quite dated.  The 
codebase was forked for a variety of reasons where development continues: 

https://github.com/open-watcom/open-watcom-v2

The current development release does indeed build on x86_64 (the build system 
is quite complicated).  I'm running Open Watcom nightly builds on Debian Wheezy 
x86 myself.  I've mentioned supporting OW in Python, most notably in a PyCon 
lightning talk last year, but there really seems to be no interest even if 
there are some benefits.  OW allows building the full interpreter and standard 
library on Windows, for example, without any MS tooling.

I was using it in this particular case as a benchmark for compile times for a 
presentation in a few weeks.  OW is able to build the interpreter in ~25sec 
whereas GCC is taking 1min 10sec on my desktop.  I don't have any plans to 
pursue Python support for OW any further, although I'm open to the idea.

This patch is enough to compile *this portion* of Modules/posixmodule.c with 
OW, but, no, it is not sufficient to compile the whole file.  There are two 
more places where some preprocessor definitions cause issues.  One is 
OW-specific, and I don't plan on filing a bug against it.  The other is #22579. 
 I only filed this bug because the code was broken.

--

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



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Terry J. Reedy

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


--
title: Pickleability of code objects is inconsistent - Idle: disable 
pickleability of user code objects

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



[issue22579] Posix module init function name should not be compiler-dependent

2014-10-09 Thread Georg Brandl

Georg Brandl added the comment:

There is also

#if !defined(__QNX__)
#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || 
defined(__DJGPP__)
#define SEP L'\\'
#define ALTSEP L'/'
#define MAXPATHLEN 256
#define DELIM L';'
#endif
#endif

in Include/osdefs.h

--
nosy: +georg.brandl

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



[issue18615] sndhdr.whathdr could return a namedtuple

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ef72142eb8a2 by R David Murray in branch 'default':
#18615: Make sndhdr return namedtuples.
https://hg.python.org/cpython/rev/ef72142eb8a2

--
nosy: +python-dev

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



[issue18615] sndhdr.whathdr could return a namedtuple

2014-10-09 Thread R. David Murray

R. David Murray added the comment:

Committed.  Thanks, Claudiu.

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

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



[issue22579] Posix module init function name should not be compiler-dependent

2014-10-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I would remove the || defined(__BORLANDC__) || defined(__WATCOMC__) || 
defined(__DJGPP__) part, since it's probably for MSDOS variants of those 
compilers.

--

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



[issue21986] Pickleability of code objects is inconsistent

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

2. It is normal. The third argument of copyreg.pickle() is not used now.

The patch LGTM.

--
title: Idle: disable pickleability of user code objects - Pickleability of 
code objects is inconsistent

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



[issue22591] Drop support of MS-DOS

2014-10-09 Thread STINNER Victor

New submission from STINNER Victor:

In the C code of Python 3.5, there are still preprocessor commands checking for 
defines:

- __BORLANDC__: Borland C compiler
- __WATCOMC__: Watcom C compiler
- __DJGPP__: MS-DOS port of GCC

In 2014, it's time to drop this old code. OS/2 support was already removed in 
Python 3.4 (see the PEP 11).

I'm quite sure that Python 3.5 cannot be compiled on MS-DOS and/or will not 
work on MS-DOS. I don't think that anyone tried Python 3 on MS-DOS. The MS-DOS 
support was simply inherited from Python 2, Python 3 source code is based on 
Python 2.

I don't want to drop support of custom compilers, only removing code specific 
to MS-DOS, see:
http://bugs.python.org/issue22579#msg228908

--
messages: 228913
nosy: haypo
priority: normal
severity: normal
status: open
title: Drop support of MS-DOS
versions: Python 3.5

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



[issue22579] Posix module init function name should not be compiler-dependent

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 I would remove the || defined(__BORLANDC__) || defined(__WATCOMC__) || 
 defined(__DJGPP__) part, since it's probably for MSDOS variants of those 
 compilers.

I agree, but IMO it is unrelated to this issue. Jeffrey wants to support a new 
C compiler (OpenWatcom) on Windows, not drop support of MS-DOS or old C 
compiler.

I created the issue #22591 to drop support of MS-DOS specific code.

--

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



[issue17636] Modify IMPORT_FROM to fallback on sys.modules

2014-10-09 Thread Antoine Pitrou

Antoine Pitrou added the comment:

By the way, my patch is currently using the package's __name__ attribute to 
build the fully-qualified name. Should it use the package's __package__ 
attribute instead?

--

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



[issue22591] Drop support of MS-DOS

2014-10-09 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

AFAIK Borland and Watcom compilers supported Windows.

--
nosy: +serhiy.storchaka

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



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Serhiy Storchaka

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


--
title: Pickleability of code objects is inconsistent - Idle: disable 
pickleability of user code objects

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



[issue21986] Idle: disable pickleability of user code objects

2014-10-09 Thread Claudiu Popa

Claudiu Popa added the comment:

Thank you for your feedback, Terry.

1. IDLE is behaving differently than the builtin interpreter. It should be 
higher priority, because it
leads beginners into believing that code objects are picklable.

2. No, wrapping code objects in a CodePickler with __getstate__ et al will not 
work. What is important in my implementation of CodePickler is that the 
dispatch_table is private, so it will not leak private reduction function, as 
it happens right now.

3. That doesn't make sense. What works now is pickling of code objects, 
removing the copyreg call, without my patch, will break the rpc as well. To 
test this, comment the copyreg.pickle call in idlelib.rpc and just define a 
function in IDLE, you'll get a PicklingError. I added a small test file, which 
can be used to test what happens now and what happens after my patch.

4. Better, here's a traceback which can explain from where codes are sent. The 
traceback is from inside pickle_code, using code.InteractiveInterpreter.

 File C:\Python34\lib\idlelib\PyShell.py, line 1602, in main
   root.mainloop()
 File C:\Python34\lib\tkinter\__init__.py, line 1069, in mainloop
   self.tk.mainloop(n)
 File C:\Python34\lib\tkinter\__init__.py, line 1487, in __call__
   return self.func(*args)
 File C:\Python34\lib\idlelib\MultiCall.py, line 179, in handler
   r = l[i](event)
 File C:\Python34\lib\idlelib\PyShell.py, line 1188, in enter_callback
   self.runit()
 File C:\Python34\lib\idlelib\PyShell.py, line 1229, in runit
   more = self.interp.runsource(line)
 File C:\Python34\lib\idlelib\PyShell.py, line 671, in runsource
   return InteractiveInterpreter.runsource(self, source, filename)
 File C:\Python34\lib\code.py, line 74, in runsource
   self.runcode(code)
 File C:\Python34\lib\idlelib\PyShell.py, line 762, in runcode
   (code,), {})
 File C:\Python34\lib\idlelib\rpc.py, line 256, in asyncqueue
   self.putmessage((seq, request))
 File C:\Python34\lib\idlelib\rpc.py, line 348, in putmessage
   s = pickle.dumps(message)

--
Added file: http://bugs.python.org/file36855/test.py

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



[issue18176] Builtins documentation refers to old version of UCD.

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fd7994909c2d by R David Murray in branch '3.4':
#18176: updated stdtypes UCD link, added reminder to makeunicodedata.
https://hg.python.org/cpython/rev/fd7994909c2d

New changeset 2551bdfff335 by R David Murray in branch 'default':
Merge: #18176: updated stdtypes UCD link, added reminder to makeunicodedata.
https://hg.python.org/cpython/rev/2551bdfff335

--
nosy: +python-dev

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



[issue18176] Builtins documentation refers to old version of UCD.

2014-10-09 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 303861ce9ead by R David Murray in branch '3.4':
#18176: fix another reference and add it to the makeunicodedata comment.
https://hg.python.org/cpython/rev/303861ce9ead

New changeset e9ec8d622a30 by R David Murray in branch 'default':
Merge: #18176: fix another reference and add it to the makeunicodedata comment.
https://hg.python.org/cpython/rev/e9ec8d622a30

--

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



[issue22591] Drop support of MS-DOS

2014-10-09 Thread STINNER Victor

STINNER Victor added the comment:

 AFAIK Borland and Watcom compilers supported Windows.

It looks like Borland C++ Builder 5.5 was released in 2000, 14 years ago. Yes, 
it supports Windows and MS-DOS, but do we really want to support this very old 
proprietary compiler?

For Watcom, it's a different story. The compiler was released under an open 
source license. It's now hosted at github and the project is actively developed 
(last commit a few hours ago):
https://github.com/open-watcom/open-watcom-v2/

It would be interesting to support OpenWatcom compiler on Windows to not depend 
on the proprietary Microsoft compiler.

--

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



  1   2   >