[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-08 Thread Larry Hastings

Larry Hastings added the comment:

Now fixed in trunk.  I am waiting to hear from Georg and the 
only-recently-pinged Benjamin to see if they want these fixes in 3.3 or 2.7.

--

___
Python tracker 

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



[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f871f8662509 by Larry Hastings in branch 'default':
Issue #15301: Parsing fd, uid, and gid parameters for builtins
http://hg.python.org/cpython/rev/f871f8662509

--

___
Python tracker 

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



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

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Embedding JSON inside 

[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-08 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I think we should leave 2.7 at rest for the moment.

--

___
Python tracker 

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



[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The original issue was fixed in issue4591. Larry's patch only adds support of 
PyNumber_Index() and refactors already existing uid/gid converters.

--

___
Python tracker 

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



[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-08 Thread Ned Deily

Ned Deily added the comment:

Richard, can you say what failed on the OS X 10.4 (Tiger) buildbot?  FWIW, I 
tested b3620777f54c.diff (and commented out the darwin skip of 
test_multiprocessing_forkserver) on OS X 10.4, 10.5, and 10.8.  There were no 
failures on any of them. The only vaguely suspicious message when running with 
-v was:

./python -m test -v test_multiprocessing_forkserver
[...]
test_semaphore_tracker 
(test.test_multiprocessing_forkserver.TestSemaphoreTracker) ... 
[semaphore_tracker] '/mp18203-0': [Errno 22] Invalid argument
[semaphore_tracker] '/mp18203-1': successfully unlinked
ok
[...]
--
Ran 233 tests in 97.162s

OK (skipped=5)  # on 32-bit 'largest assignable fd number is too small'
OK (skipped=4)  # on 64-bit

1 test OK.

--

___
Python tracker 

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



[issue18682] [PATCH] remove bogus codepath from pprint._safe_repr

2013-08-08 Thread Michal Vyskocil

New submission from Michal Vyskocil:

pprint._safe_repr for type str uses much slower codepath by default, which does 
not makes a sense in Python3 context. Instead of simply using repr, it check 
the existence of 'locale' in sys.modules and if found, it goes one-by-one-char 
call str.isalpha() on each and apply the quoting for non-alpha chars. This is 
extremely slow, but as locale is usually in sys.modules, it's used by default.

The point of such code was because in python2, str.isalpha() depends on locale, 
so for locale-aware Python builds, there was a different path needed. But this 
does not apply for Python3, where all strings are unicode, so .isaplha() is not 
locale sensitive anymore.

--
components: Library (Lib)
files: pprint-remove-bogus-code.patch
keywords: patch
messages: 194652
nosy: mvyskocil
priority: normal
severity: normal
status: open
title: [PATCH] remove bogus codepath from pprint._safe_repr
type: performance
Added file: http://bugs.python.org/file31193/pprint-remove-bogus-code.patch

___
Python tracker 

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



[issue18682] [PATCH] remove bogus codepath from pprint._safe_repr

2013-08-08 Thread Michal Vyskocil

Michal Vyskocil added the comment:

This is simple code checks if .isalnum is or is not locale sensitive and a 
small measurement of how much is the repr faster, compared to old codepath.

BTW: python3 test_pprint.py on patched version have succeeded

OK (expected failures=1)

--

___
Python tracker 

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



[issue18682] [PATCH] remove bogus codepath from pprint._safe_repr

2013-08-08 Thread Michal Vyskocil

Changes by Michal Vyskocil :


Added file: http://bugs.python.org/file31194/check.py

___
Python tracker 

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



[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-08 Thread Georg Brandl

Georg Brandl added the comment:

Looks like an unnecessary change for the maintenance releases then.

--

___
Python tracker 

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



[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-08 Thread Larry Hastings

Larry Hastings added the comment:

Okay then, closing.

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

___
Python tracker 

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



[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-08 Thread Richard Oudkerk

Richard Oudkerk added the comment:

> Richard, can you say what failed on the OS X 10.4 (Tiger) buildbot?

There seems to be a problem which depends on the order in which you run 
the test, and it happens on Linux also.  For example if I do

   ./python -m test -v \
   test_multiprocessing_fork \
   test_multiprocessing_forkserver

Then I get lots of failures when forkserver runs.  I have tracked down 
the changeset which caused the problem, but I have not had time to look 
in to it.

 > The only vaguely suspicious message when running with -v was:
 > [...]
 > [semaphore_tracker] '/mp18203-0': [Errno 22] Invalid argument
 > [semaphore_tracker] '/mp18203-1': successfully unlinked
 > [...]

That is expected and it shows the semaphore tracker is working as 
expected.  Maybe I should print a note to stderr to expect this.

--

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-08 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

I've modified the patch.  The problem that nested_delayed was trying to solve 
are "hybrid" context managers, ones that allocate resources during __init__ and 
release them at exit.  A proper context manager should allocate resources 
during __enter__, and thus a number of them can be created upfront with 
impunity.

Added contextlib.proper to turn a hybrid context manager into a proper one by 
instantiating the hybrid in a delayed fashion.
added contextlib.opened() as a special case that does open() properly.

With this change, and the ability to nest error handling of exceptions stemming 
from __enter__(), nested now works as intended.

--
Added file: http://bugs.python.org/file31195/contextmanagerexit.patch

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-08 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Thanks, Eric.
I read that bit and I can't say that I disagree.
And I'm not necessarily advocating that "skipping the body" become a standard 
feature of context managers.  But it is a necessary functionality if you want 
to be able to dynamically nest one or more context managers, something I think 
Python should be able to do, for completeness, if not only for aesthetic beauty.

Having said that, optionally skipping the body is a far cry from the more 
esoteric constructs achievable with pep 340.

And python _already_ silently skips the body of managed code, if you nest two 
managers:

@contextmanager errordude:
1 // 0
yield
@contextmanager handler:
try:
yield
except ZeroDivisionError:
pass

with handler, errordude:
do_stuff()

These context managers will skip the execution of f.  It will be Python's 
internal decision to do so, of course.  But the "with" statement already has 
the potential to have the body silently skipped.

What I'm adding here, the ContextManagerExit, is the ability for the context 
manager itself to make the decision, so that the two context managers above can 
be coalesced into one:

with nested(handler, errordude):
do_stuff()

The fact that do_stuff can be silently skipped in the first case, where we 
explicitly have two nested calls, invalidates IMHO the argument that context 
managers should not affect control flow.  why shouldn't it also be skippable in 
the case of a single context manager?

--

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-08 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Using my latest patch, the ExitStack inline example can be rewritten:

with ExitStack() as stack:
files = [stack.enter_context(open(fname)) for fname in filenames]
# All opened files will automatically be closed at the end of
# the with statement, even if attempts to open files later
# in the list raise an exception

becomes:
with nested(opened(fname) for fname in filenames) as files:
do_stuff_with_files(files)

--

___
Python tracker 

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



[issue18683] Core dumps on CentOS

2013-08-08 Thread Marc Schlaich

New submission from Marc Schlaich:

I'm running unittests on a CentOS 6.4 Virtual Box slave via Jenkins on a 
Windows host. Randomly I get core dumps for no obvious reason. I don't
use any C extension in my code and don't use ctypes. The (proprietary)
software is plain Python with a multi-threaded architecture.

There might be a threading race condition in the code but according
to http://stackoverflow.com/a/13654489/851737 this shouldn't result
in a segfault. So it might be a bug in Python.

I appended one log (I have various others if you wish to see them) with 
faulthandler enabled by https://pypi.python.org/pypi/nose-faulthandler.

--
files: crash.log
messages: 194660
nosy: schlamar
priority: normal
severity: normal
status: open
title: Core dumps on CentOS
type: crash
versions: Python 2.6
Added file: http://bugs.python.org/file31196/crash.log

___
Python tracker 

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



[issue18684] Pointers point out of array bound in _sre.c

2013-08-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

In _sre.c pointers can point out of boundaries of array. This is an undefined 
behavior and is one of causes of a bug in issue17998 (end-ptr can be negative). 
The proposed patch change code to check if pointers will point out of 
boundaries before their changing.

--
components: Regular Expressions
files: sre_ptr_out_of_bounds.patch
keywords: patch
messages: 194661
nosy: ezio.melotti, mrabarnett, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Pointers point out of array bound in _sre.c
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31197/sre_ptr_out_of_bounds.patch

___
Python tracker 

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



[issue18683] Core dumps on CentOS

2013-08-08 Thread R. David Murray

R. David Murray added the comment:

Can you reproduce this using 2.7?  2.6 only gets security fixes.

--
nosy: +r.david.murray

___
Python tracker 

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



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

2013-08-08 Thread Brett Cannon

Brett Cannon added the comment:

So this is bringing up a sticky situation that I ran across when initially 
implementing all of this: what should sys.path_importer_cache use as a key? '' 
would be what happens with Madison's option 3, and with option 1 it would be 
os.getcwd(). Now if you iterate through sys.path you won't find what '' 
connects to. Then again, it won't be accurate if you change the directory 
either.

So the question becomes should sys.path_importer_cache reflect exactly what is 
in sys.path or what should be cached for a finder based on what import should 
do (i.e. the full path and change based on the cwd)?

--

___
Python tracker 

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



[issue18273] Simplify calling and discovery of json test package

2013-08-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 95cf8640b271 by Ezio Melotti in branch '3.3':
#18273: move the tests in Lib/test/json_tests to Lib/test/test_json and make 
them discoverable by unittest.  Patch by Zachary Ware.
http://hg.python.org/cpython/rev/95cf8640b271

New changeset f7ed301e7199 by Ezio Melotti in branch 'default':
#18273: merge with 3.3.
http://hg.python.org/cpython/rev/f7ed301e7199

--
nosy: +python-dev

___
Python tracker 

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



[issue18273] Simplify calling and discovery of json test package

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the patch!
(Thanks Ned too!)

--
assignee:  -> ezio.melotti
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

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



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

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the report!

--
assignee: docs@python -> ezio.melotti
nosy: +ezio.melotti
resolution:  -> fixed
status: open -> closed
type:  -> enhancement
versions:  -Python 3.1, Python 3.2

___
Python tracker 

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



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

2013-08-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 38d341ef28b3 by Ezio Melotti in branch '3.3':
#18267: make whitespace consistent and fix an operator.
http://hg.python.org/cpython/rev/38d341ef28b3

New changeset 9875410ed390 by Ezio Melotti in branch 'default':
#18267: merge with 3.3.
http://hg.python.org/cpython/rev/9875410ed390

--

___
Python tracker 

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



[issue18301] In itertools.chain.from_iterable() there is no cls argument

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

> I would just remove the decorator.

+1

--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18313] In itertools recipes repeatfunc() defines a non-keyword argument as keyword

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

> it should be: "def repeatfunc(func, times, *args):"
> and None for times described in the docstring

This would require you to provide at least two elements, whereas now it's 
possible to pass just the function (e.g. repeatfunc(random.random)).

The problem with the current signature is that you are "forced" to specify the 
"times" (positionally) whenever you want to pass args to the function -- even 
if you want an endless repetition (i.e. times=None).

--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18685] Restore re performance to pre-PEP393 level

2013-08-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Before PEP 393 the regex functions scanned an array of char or Py_UNICODE and 
character testing was cheap. After PEP 393 they checks a kind of an unicode 
string for every tested character and processing of unicode strings becomes 
slower. _sre.c already generates two sets of functions from one source -- for 
byte and unicode strings. The proposed patch uses same technique to generate 
three sets of functions -- for byte/UCS1, UCS2 and UCS4 strings. This 
simplifies the code (now it more similar to pre-PEP393 version) and makes 
characters testing faster.

Benchmark example:

Python 3.2:
$ python3.2 -m timeit -s "import re; f = re.compile(b'abc').search; x = 
b'x'*10"  "f(x)"
1000 loops, best of 3: 613 usec per loop
$ python3.2 -m timeit -s "import re; f = re.compile('abc').search; x = 
'x'*10"  "f(x)"
1000 loops, best of 3: 232 usec per loop
$ python3.2 -m timeit -s "import re; f = re.compile('abc').search; x = 
'\u20ac'*10"  "f(x)"
1000 loops, best of 3: 217 usec per loop

Python 3.4.0a1+ unpatched:
$ ./python -m timeit -s "import re; f = re.compile(b'abc').search; x = 
b'x'*10"  "f(x)"
1000 loops, best of 3: 485 usec per loop
$ ./python -m timeit -s "import re; f = re.compile('abc').search; x = 
'x'*10"  "f(x)"
1000 loops, best of 3: 790 usec per loop
$ ./python -m timeit -s "import re; f = re.compile('abc').search; x = 
'\u20ac'*10"  "f(x)"
1000 loops, best of 3: 1.09 msec per loop

Python 3.4.0a1+ patched:
$ ./python -m timeit -s "import re; f = re.compile(b'abc').search; x = 
b'x'*10"  "f(x)"
1000 loops, best of 3: 250 usec per loop
$ ./python -m timeit -s "import re; f = re.compile('abc').search; x = 
'x'*10"  "f(x)"
1000 loops, best of 3: 250 usec per loop
$ ./python -m timeit -s "import re; f = re.compile('abc').search; x = 
'\u20ac'*10"  "f(x)"
1000 loops, best of 3: 256 usec per loop

I also propose for simplicity extract a template part of _sre.c to separated 
file (i.e. srelib.h) and get rid of recursion.

--
assignee: serhiy.storchaka
components: Regular Expressions, Unicode
files: sre_optimize.patch
keywords: patch
messages: 194669
nosy: ezio.melotti, mrabarnett, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Restore re performance to pre-PEP393 level
type: performance
versions: Python 3.4
Added file: http://bugs.python.org/file31198/sre_optimize.patch

___
Python tracker 

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



[issue18572] Remove redundant note about surrogates in string escape doc

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

I think it's OK to remove the sentence.

Converting a surrogate pair to a non-BMP char is something that works only 
while decoding a UTF-16 byte sequence.  Surrogates are invalid in UTF-8/32, and 
while dealing with Unicode strings, surrogates have no special meaning and are 
no different from any other codepoint, whether they are lone or paired.

--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18668] Properly document setting m_size in PyModuleDef

2013-08-08 Thread Eli Bendersky

Eli Bendersky added the comment:

Nick, you're right - m_size=0 is a valid value. How about the attached patch?

--
Added file: http://bugs.python.org/file31199/issue18668.msize-fix.patch

___
Python tracker 

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



[issue18576] Rename and document test.script_helper as test.support.script_helper

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
stage:  -> needs patch

___
Python tracker 

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



[issue18588] timeit examples should be consistent

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

IIRC those were the actual values I got.  I think I investigated why they were 
different, but right now I don't remember if I found out why.

--
assignee: docs@python -> ezio.melotti
nosy: +ezio.melotti
versions:  -Python 2.6, Python 3.1, Python 3.2, Python 3.3

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-08 Thread Eli Bendersky

Eli Bendersky added the comment:

Thanks Antoine. I think I understand the patch better now. Just a couple small 
questions and otherwise LGTM

This code in the beginning in PyInit__elementtree:

m = PyState_FindModule(&elementtreemodule);
if (m) {
Py_INCREF(m);
return m;
}

Can you explain what use case it tries to cover? I couldn't find similar code 
in other modules we have that implement PEP 3121 (_csv, readline, io, etc.)

This code has at least one adverse effect, for testing. The problem with 
re-importing _elementtree I raised in 
http://mail.python.org/pipermail/python-dev/2013-August/127766.html is solved 
by moving to PEP 3121, but this piece of code above ruins it. This is because I 
want to set sys.modules['pyexpat'] = None and re-import _elementtree (this is 
what support.import_fresh_module does). But with this code in place, if 
_elementtree was imported any time in the past (say, in a previous test), I'll 
just get the instance back without attempting to do the full module 
initialization.


>> I don't see a call to PyState_AddModule. What am I missing?
>It is called implicitly when an extension module is imported.

Do you think this should be documented in the C API docs? The way they read 
now, it seems that calling PyState_AddModule is needed manually by extension 
writers.

--

___
Python tracker 

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



[issue18592] IDLE: Unit test for SearchDialogBase.py

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-08 Thread Eli Bendersky

Eli Bendersky added the comment:

> Can you explain what use case it tries to cover?

What I'm trying to say is that although I think I understand its effect (if the 
same sub-interpreter re-imports _elementtree bypassing the Python module cache, 
this is an additional level of caching), I'm not sure what *real* use cases it 
aims for.

--

___
Python tracker 

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



[issue18602] "_io" module names itself "io"

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

Have you tried to change it and run the test suite?  Maybe it breaks pickling 
or something similar?

--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18602] "_io" module names itself "io"

2013-08-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> Have you tried to change it and run the test suite?  Maybe it breaks
> pickling or something similar?

Yeah, it came to me that it may break pickle. The test suite may not
pick it, though.

--

___
Python tracker 

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



[issue18604] Consolidate gui available checks in test.support

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> This code in the beginning in PyInit__elementtree:
> 
> m = PyState_FindModule(&elementtreemodule);
> if (m) {
> Py_INCREF(m);
> return m;
> }
> 
> Can you explain what use case it tries to cover? I couldn't find
> similar code in other modules we have that implement PEP 3121 (_csv,
> readline, io, etc.)

I don't know :-) I just re-used Robin's original patch.

> >> I don't see a call to PyState_AddModule. What am I missing?
> >It is called implicitly when an extension module is imported.
> 
> Do you think this should be documented in the C API docs? The way
> they read now, it seems that calling PyState_AddModule is needed
> manually by extension writers.

Well, how to deal with module state should probably be better
documented. Not sure how, though.

--

___
Python tracker 

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



[issue18673] Add and use O_TMPFILE for Linux 3.11

2013-08-08 Thread Jesús Cea Avión

Changes by Jesús Cea Avión :


--
nosy: +jcea

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-08 Thread Eli Bendersky

Eli Bendersky added the comment:

On Thu, Aug 8, 2013 at 7:00 AM, Antoine Pitrou wrote:

>
> Antoine Pitrou added the comment:
>
> > This code in the beginning in PyInit__elementtree:
> >
> > m = PyState_FindModule(&elementtreemodule);
> > if (m) {
> > Py_INCREF(m);
> > return m;
> > }
> >
> > Can you explain what use case it tries to cover? I couldn't find
> > similar code in other modules we have that implement PEP 3121 (_csv,
> > readline, io, etc.)
>
> I don't know :-) I just re-used Robin's original patch.
>

Would you mind removing it from the patch, due to the case described above?
ISTM that in real scenarios the sys.modules cache kicks in anyway. It
should not be really bypassed for any given sub-interpreter in sane code.

>
> > >> I don't see a call to PyState_AddModule. What am I missing?
> > >It is called implicitly when an extension module is imported.
> >
> > Do you think this should be documented in the C API docs? The way
> > they read now, it seems that calling PyState_AddModule is needed
> > manually by extension writers.
>
> Well, how to deal with module state should probably be better
> documented. Not sure how, though.
>

I'll think about it some more and will try to propose a documentation
patch. This can be done incrementally; we don't have to go to perfect docs
on the first try ;-)

--

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-08 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> Would you mind removing it from the patch, due to the case described
> above?
> ISTM that in real scenarios the sys.modules cache kicks in anyway. It
> should not be really bypassed for any given sub-interpreter in sane
> code.

Yeah, I think you're right. I'll submit an updated patch or, if it's
the only issue with it, perhaps you can simply remove the 3 offending
lines?

--

___
Python tracker 

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



[issue18588] timeit examples should be consistent

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In command-line invocation the gc is disabled. And timit.repeat() is used 
instead of timit.timit().

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue17974] Migrate unittest to argparse

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Is the patch good?

--
assignee:  -> serhiy.storchaka
keywords: +needs review

___
Python tracker 

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



[issue18685] Restore re performance to pre-PEP393 level

2013-08-08 Thread Matthew Barnett

Matthew Barnett added the comment:

It appears that in your tests Python 3.2 is faster with Unicode than 
bytestrings and that unpatched Python 3.4 is a lot slower.

I get somewhat different results (Windows XP Pro, 32-bit):

C:\Python32\python.exe -m timeit -s "import re; f = re.compile(b'abc').search; 
x = b'x'*10" "f(x)"
1000 loops, best of 3: 449 usec per loop

C:\Python32\python.exe -m timeit -s "import re; f = re.compile('abc').search; x 
= 'x'*10" "f(x)"
1000 loops, best of 3: 506 usec per loop

C:\Python32\python.exe -m timeit -s "import re; f = re.compile('abc').search; x 
= '\u20ac'*10" "f(x)"
1000 loops, best of 3: 506 usec per loop


C:\Python34\python.exe -m timeit -s "import re; f = re.compile(b'abc').search; 
x = b'x'*10" "f(x)"
1000 loops, best of 3: 227 usec per loop

C:\Python34\python.exe -m timeit -s "import re; f = re.compile('abc').search; x 
= 'x'*10" "f(x)"
1000 loops, best of 3: 339 usec per loop

C:\Python34\python.exe -m timeit -s "import re; f = re.compile('abc').search; x 
= '\u20ac'*10" "f(x)"
1000 loops, best of 3: 504 usec per loop

For comparison, in the regex module I don't duplicate whole sections of code, 
but instead have a pointer to one of 3 functions (for UCS1, UCS2 and UCS4) that 
gets the codepoint, except for some tight loops. Doing that might be too much 
of a change for re.

However, the speed appears to be a lot more consistent:

C:\Python32\python.exe -m timeit -s "import regex; f = 
regex.compile(b'abc').search; x = b'x'*10" "f(x)"
1 loops, best of 3: 113 usec per loop

C:\Python32\python.exe -m timeit -s "import regex; f = 
regex.compile('abc').search; x = 'x'*10" "f(x)"
1 loops, best of 3: 113 usec per loop

C:\Python32\python.exe -m timeit -s "import regex; f = 
regex.compile('abc').search; x = '\u20ac'*10" "f(x)"
1 loops, best of 3: 113 usec per loop


C:\Python34\python.exe -m timeit -s "import regex; f = 
regex.compile(b'abc').search; x = b'x'*10" "f(x)"
1 loops, best of 3: 113 usec per loop

C:\Python34\python.exe -m timeit -s "import regex; f = 
regex.compile('abc').search; x = 'x'*10" "f(x)"
1 loops, best of 3: 113 usec per loop

C:\Python34\python.exe -m timeit -s "import regex; f = 
regex.compile('abc').search; x = '\u20ac'*10" "f(x)"
1 loops, best of 3: 113 usec per loop

--

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-08 Thread Eli Bendersky

Eli Bendersky added the comment:

On Thu, Aug 8, 2013 at 7:14 AM, Antoine Pitrou wrote:

>
> Antoine Pitrou added the comment:
>
> > Would you mind removing it from the patch, due to the case described
> > above?
> > ISTM that in real scenarios the sys.modules cache kicks in anyway. It
> > should not be really bypassed for any given sub-interpreter in sane
> > code.
>
> Yeah, I think you're right. I'll submit an updated patch or, if it's
> the only issue with it, perhaps you can simply remove the 3 offending
> lines?
>

Sure, I'll do that. Thanks.

--

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-08 Thread Derek Wilson

Derek Wilson added the comment:

using repr(x)[1:-1] is not safe for my use case as i need this for encoding and 
decoding data. the "deserialization" of repr would be eval, and aside from the 
security issues with that, if I strip the quotes off I can't reliably eval the 
result and get back the original. On top of that, quote escape handling makes 
this non-portable to other languages/tools that do understand control character 
escapes. Consider:

>>> s = """Α""\t'''Ω"""
>>> print(s)
Α"" '''Ω
>>> e = repr(s)[1:-1]
>>> print(e)
Α""\t\'\'\'Ω

how do i know what to quote e with before I eval it to get back the value? I 
can't even try all the quoting options and stop when i don't get a syntax error 
because more than one could work and give me a bad result:

>>> d = eval('"{}"'.format(e))
>>> d == s
False
>>> print(d)
Α   '''Ω

Aside from python not being able to handle the repr(x)[1:-1] case itself, the 
goal is to use output generated in common tools from cut to hadoop where tab is 
a field separator (aside: wouldn't adoption of ascii 0x1f as a common unit 
separator be great). Sometimes it is useful to separate newlines in data from a 
literal new line in formats (again like hadoop or unix utilities) that treat 
lines as records (and here again ascii 0x1e would have been a nice solution).

But we have to work with what we've got and there are many tools that care 
about tab separated fields and per line records. In these cases, the right tool 
for the interoperability job is a codec that simply backslash escapes control 
characters and nothing else.

--

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-08 Thread Nick Coghlan

Nick Coghlan added the comment:

Allowing a context manager to skip the statement body isn't a new proposal,
and I previously argued your side. However, with multiple context managers,
there is no invisible flow control. Two context managers are locally
visible, which means the outer one completely encloses the inner one and
can suppress exceptions it throws. Guido explicitly made the decision to
require two managers at the point of use to achieve that behaviour when I
proposed making the change - he doesn't care about allowing a single
context manager to provide that functionality.

For the other question, how does your version of nested keep people from
doing "nested(open(fname) for name in names)"? That was the core problem
with that style of API: it made it far too easy to introduce a latent
defect when combined with file like objects that eagerly acquire their
resource. It wasn't that it couldn't be used correctly, but that the
natural and obvious way of combining it with open() is silently wrong.

--

___
Python tracker 

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



[issue18668] Properly document setting m_size in PyModuleDef

2013-08-08 Thread Nick Coghlan

Nick Coghlan added the comment:

Looks good to me.

--

___
Python tracker 

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



[issue18588] timeit examples should be consistent

2013-08-08 Thread Clay McClure

Clay McClure added the comment:

There's a 68% difference in running time between the command-line and 
programmatic invocations shown in the current documentation, and a 1% 
difference between the runtimes shown in the patch. I can't speak for why that 
is the case, but I did find it somewhat confusing when trying to interpret the 
timeit documentation.

Being a somewhat pedantic and trivial patch, I'm fine if you want to close it 
wontfix.

--

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

ast.literal_eval("'%s'" % e)
e.encode().decode('unicode-escape').encode('latin1').decode()
e.encode('latin1', 'backslashescape').decode('unicode-escape')

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-08 Thread Derek Wilson

Derek Wilson added the comment:

> ast.literal_eval("'%s'" % e)

this doesn't work if you use the wrong quote. without introspecting the data in 
e you can't reliably choose whether to use "'%s'" '"%s"' '"""%s"""' or 
"'''%s'''". which ones break (and break siliently) depend on the data.


> e.encode().decode('unicode-escape').encode('latin1').decode()

so ... encode the repr()[1:-1] string in utf-8 bytes, decode backslash escape 
sequences and individual bytes as if they are latin1, encode as latin1 (which 
is just byte for byte serialization), then decode the byte representation as if 
it is utf-8 encoded to recombine the characters that were broken with the 
'unicode-escape' decode earlier? 

this may work for my example, but this looks and feels very hacky for something 
that should be simple and straight forward. and again tools other than python 
will run into escaped quotes in the data which may cause problems.

> e.encode('latin1', 'backslashescape').decode('unicode-escape')

when i execute this i get a traceback

LookupError: unknown error handler name 'backslashescape'

--

___
Python tracker 

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



[issue18581] Duplicate test and missing class test in test_abc.py

2013-08-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e8f8f81c5af6 by Ezio Melotti in branch '3.3':
#18581: remove duplicate test and run a test class that was skipped.  Initial 
patch by Vajrasky Kok.
http://hg.python.org/cpython/rev/e8f8f81c5af6

New changeset 328b1a29102c by Ezio Melotti in branch 'default':
#18581: merge with 3.3.
http://hg.python.org/cpython/rev/328b1a29102c

--
nosy: +python-dev

___
Python tracker 

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



[issue18581] Duplicate test and missing class test in test_abc.py

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the report and the patch!

--
assignee:  -> ezio.melotti
nosy: +ezio.melotti
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed
type:  -> behavior
versions: +Python 3.3

___
Python tracker 

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



[issue18626] Make "python -m inspect " dump the source of a module

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18628] Better index entry for encoding declarations

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti
type:  -> enhancement

___
Python tracker 

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



[issue18686] Tkinter focus_get on menu causes crash

2013-08-08 Thread Jeffrey Goeders

New submission from Jeffrey Goeders:

I am experiencing a crash when calling focus_get() when a Tk Menu has focus.  
Here is sample code, just click the menu and it will crash.


import Tkinter as tk

class App(tk.Tk):
def __init__(self, *args, **kw):
tk.Tk.__init__(self, *args, **kw)

self.entry = tk.Entry(self)
self.entry.grid(padx=20, pady=20)
self.entry.focus_set()
self.entry.bind("", self.entry_focus_lost)

self.menubar = tk.Menu(self)
self["menu"] = self.menubar

self.menufile = tk.Menu(self.menubar, tearoff=False)
self.menubar.add_cascade(menu=self.menufile, label="File")

def entry_focus_lost(self, event):
widget_with_focus = self.focus_get()


app = App()
app.mainloop()


Here is the error stack:
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
return self.func(*args)
  File "/home/jgoeders/workspace/tester/test_menu_focus.py", line 19, in 
entry_focus_lost
widget_with_focus = self.focus_get()
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 446, in focus_get
return self._nametowidget(name)
  File "/usr/lib64/python2.7/lib-tk/Tkinter.py", line 1079, in nametowidget
w = w.children[n]
KeyError: '#140030874747536'

--
components: Tkinter
messages: 194693
nosy: jgoeders
priority: normal
severity: normal
status: open
title: Tkinter focus_get on menu causes crash
type: crash
versions: Python 2.7

___
Python tracker 

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



[issue18326] Mention 'keyword only' for list.sort, improve glossary.

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

"keyword-only" is a well-established term, and I think it's better to use it 
and possibly make it a link to the "parameter" entry of the glossary.

--
nosy: +ezio.melotti
stage: needs patch -> patch review

___
Python tracker 

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



[issue18335] Add textwrap.dedent, .indent, as str methods.

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18357] add tests for dictview set difference operations

2013-08-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 0152152b09d0 by Ezio Melotti in branch '2.7':
#18357: add tests for dictview set difference.  Patch by Fraser Tweedale.
http://hg.python.org/cpython/rev/0152152b09d0

New changeset 8b557ef46d7c by Ezio Melotti in branch '3.3':
#18357: add tests for dictview set difference.  Patch by Fraser Tweedale.
http://hg.python.org/cpython/rev/8b557ef46d7c

New changeset 4db3d3d5815c by Ezio Melotti in branch 'default':
#18357: merge with 3.3.
http://hg.python.org/cpython/rev/4db3d3d5815c

--
nosy: +python-dev

___
Python tracker 

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



[issue18357] add tests for dictview set difference operations

2013-08-08 Thread Ezio Melotti

Ezio Melotti added the comment:

Fixed, thanks for the report and the patch!

--
assignee:  -> ezio.melotti
nosy: +ezio.melotti
resolution:  -> fixed
stage: patch review -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue18381] unittest warnings counter

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
stage:  -> patch review
type:  -> enhancement

___
Python tracker 

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



[issue18375] python -m test --randseed 1234 does not randomize tests

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
status: open -> pending

___
Python tracker 

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



[issue18313] In itertools recipes repeatfunc() defines a non-keyword argument as keyword

2013-08-08 Thread py.user

py.user added the comment:

> This would require you to provide at least two elements
I see
how about "def repeatfunc(func, *args, times=None):" ?


>>> from itertools import starmap, repeat
>>> 
>>> def repeatfunc(func, *args, times=None):
... """Repeat calls to func with specified arguments.
... 
... Example:  repeatfunc(random.random)
... """
... if times is None:
... return starmap(func, repeat(args))
... return starmap(func, repeat(args, times))
... 
>>> def f(*args):
... print(args)
... 
>>> r = repeatfunc(f, 1, 2)
>>> next(r)
(1, 2)
>>> next(r)
(1, 2)
>>> next(r)
(1, 2)
>>> r = repeatfunc(f, 1, 2, times=1)
>>> next(r)
(1, 2)
>>> next(r)
Traceback (most recent call last):
  File "", line 1, in 
StopIteration
>>>

--

___
Python tracker 

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



[issue18409] IDLE Improvements: Unit test for AutoComplete.py

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18423] Document limitations on -m

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
type:  -> enhancement
versions: +Python 3.4

___
Python tracker 

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



[issue18410] IDLE Improvements: Unit test for SearchDialog.py

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18671] enhance formatting in logging package

2013-08-08 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a206f952668e by Vinay Sajip in branch 'default':
Closes #18671: Output more information when logging exceptions occur.
http://hg.python.org/cpython/rev/a206f952668e

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue18425] IDLE Unit test for IdleHistory.py

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18626] Make "python -m inspect " dump the source of a module

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I agree that it will be better to output a formalized report about a module and 
it's contents using inspect.getmoduleinfo() and inspect.getmembers().

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-08 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> this doesn't work if you use the wrong quote. without introspecting the data 
> in e you can't reliably choose whether to use "'%s'" '"%s"' '"""%s"""' or 
> "'''%s'''".

Indeed.

> and again tools other than python will run into escaped quotes in the data 
> which may cause problems.

Then use s.translate() or re.sub() for encoding.

> when i execute this i get a traceback

Sorry, it should be

e.encode('latin1', 'backslashreplace').decode('unicode-escape').

--

___
Python tracker 

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



[issue18436] Add mapping of symbol to function to operator module

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18445] Tools/Script/Readme is outdated

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
keywords: +easy
nosy: +ezio.melotti

___
Python tracker 

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



[issue18301] In itertools.chain.from_iterable() there is no cls argument

2013-08-08 Thread py.user

py.user added the comment:

>>> import itertools
>>> 
>>> class A(itertools.chain):
... def from_iter(arg):
... return A(iter(arg))
... 
>>> class B(A):
... pass
... 
>>> B('a', 'b')
<__main__.B object at 0x7f40116d7730>
>>> B.from_iter(['a', 'b'])
<__main__.A object at 0x7f40116d7780>
>>>

it should be B

--

___
Python tracker 

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



[issue18456] Documentation for PyDict_Update is incorrect

2013-08-08 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti

___
Python tracker 

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



[issue18680] JSONDecoder should document that it raises a ValueError for malformed data

2013-08-08 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
keywords: +easy
stage:  -> needs patch
versions:  -Python 2.6, Python 3.1, Python 3.2, Python 3.5

___
Python tracker 

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



[issue18686] Tkinter focus_get on menu results in KeyError

2013-08-08 Thread R. David Murray

Changes by R. David Murray :


--
title: Tkinter focus_get on menu causes crash -> Tkinter focus_get on menu 
results in KeyError

___
Python tracker 

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



[issue18686] Tkinter focus_get on menu causes crash

2013-08-08 Thread R. David Murray

R. David Murray added the comment:

We use the 'crash' type for interpreter crashes (segfaults).  So goes under the 
'behavior' type.

--
nosy: +r.david.murray
type: crash -> behavior

___
Python tracker 

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



[issue18687] Lib/test/leakers/test_ctypes.py still mentions the need to update Misc/build.sh

2013-08-08 Thread Févry Thibault

New submission from Févry Thibault:

"# When this leak is fixed, remember to remove from Misc/build.sh LEAKY_TESTS." 
-> Misc/build.sh got removed 19 months ago, this should be updated.

--
assignee: docs@python
components: Documentation
files: patch.diff
keywords: patch
messages: 194703
nosy: docs@python, iwontbecreative
priority: normal
severity: normal
status: open
title: Lib/test/leakers/test_ctypes.py still mentions the need to update 
Misc/build.sh
versions: Python 3.4
Added file: http://bugs.python.org/file31200/patch.diff

___
Python tracker 

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



[issue1424152] urllib/urllib2: HTTPS over (Squid) Proxy fails

2013-08-08 Thread Lukas Wunner

Lukas Wunner added the comment:

Unfortunately this bug was only fixed in urllib2.py but never in urllib.py. 
This keeps biting people in the butt to this very day. Example: 
https://chromiumcodereview.appspot.com/10825107/

The attached patch remedies that and also fixes some more issues:

(1) proxy_bypass handling:
URLopener.open() will route the request to one of the open_*() methods based on 
the type of the *request* url. However, if a proxy is defined, it instead 
routes the request based on the type of the *proxy* url. So far so good. But: 
In open_http(), the code checks if proxy_bypass(realhost) is true and if so it 
modifies the Host header of the outgoing request. This code only works properly 
if the request url is by chance of type "http". If the request url type is e.g. 
"ftp" and the proxy url type is "http" and there's a proxy_bypass defined for 
realhost, things will go awry since the program will try to speak HTTP with 
realhost while it should really speak FTP. (In other words, open_ftp() should 
be used instead of open_http(), the program is stuck in the wrong codepath.) 
Also, proxy_bypass handling is currently only implemented for the proxy url 
type "http" (and not, for instance, "https"). The patch solves this by moving 
the proxy_bypass check to URLopener.open(): If a proxy_bypass is
  defined for realhost, the request is routed based on the request url type and 
not based on the proxy url type.

(2) addinfourl construction:
Upon successful retrieval of the URL, open_http() and open_https() will 
construct an addinfourl object and return that to the caller. The object is 
constructed with hard coded url type "http" / "https". So if for instance the 
request url type is "ftp" and the proxy url type is "http", the addinfourl 
object will contain a url whose type will have magically changed from "ftp" to 
"http".

(3) Superfluous code:
At the beginning of open_http() and open_https(), the program sets "user_passwd 
= None". Directly below is an if-else statement. At the beginning of the else 
block the program again sets "user_passwd = None".

The patch also works with Python 2.6 save for set_tunnel() in httplib.py, which 
was called _set_tunnel() in 2.6.

--
nosy: +l
Added file: http://bugs.python.org/file31201/issue1424152-py27-urllib.diff

___
Python tracker 

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



[issue18688] Document undocumented Unicode object API

2013-08-08 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Include/unicodeobject.h contains followed names which are declared as public 
but are not documented in Doc/c-api/unicode.rst.

PyUnicodeIter_Type
Py_UNICODE_REPLACEMENT_CHARACTER
PyUnicode_Resize
PyUnicode_InternImmortal
PyUnicode_CHECK_INTERNED
PyUnicode_FromOrdinal
PyUnicode_GetDefaultEncoding
PyUnicode_AsDecodedObject
PyUnicode_AsDecodedUnicode
PyUnicode_AsEncodedObject
PyUnicode_AsEncodedUnicode
PyUnicode_BuildEncodingMap
PyUnicode_DecodeCodePageStateful
PyUnicode_Append
PyUnicode_AppendAndDel
PyUnicode_Partition
PyUnicode_RPartition
PyUnicode_RSplit
PyUnicode_IsIdentifier
_PyUnicode_FromId
_PyUnicode_ClearStaticStrings

They should be either documented or declared as private.

PyUnicode_AsEncodedObject only mentioned in Doc/whatsnew/3.3.rst as recomended 
replacement of PyUnicode_Encode.

--
assignee: docs@python
components: Documentation, Unicode
messages: 194705
nosy: docs@python, ezio.melotti, serhiy.storchaka
priority: normal
severity: normal
stage: needs patch
status: open
title: Document undocumented Unicode object API
type: behavior
versions: Python 3.3, Python 3.4

___
Python tracker 

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



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

2013-08-08 Thread Derek Wilson

New submission from Derek Wilson:

It is common when setting up a logger to create both a handler and a formatter. 
Nice format strings make logging better. Like this:

>>> fmt_string = "%(asctime)s [%(levelname)-9s] %(name)s: %(message)s"

We would use it like so: 

>>> from logging import getLogger, StreamHandler, Formatter
>>> logger = getLogger('mypackage.mymodule')
>>> handler = StreamHandler()
>>> formatter = Formatter(fmt_string)
>>> handler.setFormatter(formatter)
>>> logger.addHandler(handler)
>>> logger.warning('she called out a warning...')

But its nice to separate adding handlers from using loggers. so in mymodule I 
might do:

>>> logger = getLogger('mypackage.mymodule')
>>> logger.warning('do not pass go...')

and in whatever entry point cares about logging from mypackage (like a cli or 
another module importing my package that wants log data) I would do:

>>> base_logger = getLogger('mypackage')
>>> handler = StreamHandler()
>>> formatter = Formatter(fmt_string)
>>> handler.setFormatter(formatter)
>>> base_logger.addHandler(handler)

but usually, at this point, i don't care about this base_logger at all and i've 
got a bunch of refs to things i don't need anymore - the only purpose of all 
this code is to handle any logging that may be done elsewhere in the package.

If handlers allowed passing in a formatter into __init__, then we could reduce 
the above to something like this:

>>> getLogger('mypackage').addHandler(StreamHandler(
fmt=Formatter(fmt_string)))

Using a kwarg would make it so we don't need to worry about existing argument 
order so that should be completely backward compatible.

It'd be extra friendly if Handler could introspect fmt and see if it is an 
instance str and if so create a Formatter in itself ... that way we could do:

>>> getLogger('mypackage').addHandler(StreamHandler(fmt=fmt_string))

This would reduce the barrier to entry to customizing logging functionality and 
might go a long way toward increasing effective use of the same.

--
components: Library (Lib)
messages: 194706
nosy: underrun
priority: normal
severity: normal
status: open
title: add argument for formatter to logging.Handler and subclasses in logging 
module
type: enhancement
versions: Python 3.4

___
Python tracker 

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



[issue18690] memoryview not considered a sequence

2013-08-08 Thread Simon Feltman

New submission from Simon Feltman:

This was a bit unexpected as memoryviews support all the methods of the 
Sequence abstract base class:

>>> import collections
>>> b = bytearray(b'asdf')
>>> isinstance(b, collections.Sequence)
True
>>> m = memoryview(b)
>>> isinstance(m, collections.Sequence)
False

It would be nice if memoryview was registered with the Sequence ABC and 
MutableSequence for writeable memoryviews.

--
components: Library (Lib)
messages: 194707
nosy: sfeltman
priority: normal
severity: normal
status: open
title: memoryview not considered a sequence
type: behavior
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-08 Thread Derek Wilson

Derek Wilson added the comment:

> e.encode('latin1', 'backslashreplace').decode('unicode-escape')

this works, but still the quotes are backslash escaped. 

translate will do what i need for my use case, but it doesn't support streaming 
for larger chunks of data.

it is nice that there is a workaround but i do still think this is a valuable 
enough feature that there should be a builtin codec for it.

--

___
Python tracker 

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



[issue14019] Unify tests for str.format and string.Formatter

2013-08-08 Thread Francisco Freire

Francisco Freire added the comment:

I increased the coverage of formatter module to 40%. I added a new file 
"test_formatter.py" including some unit tests.

--
keywords: +patch
nosy: +francisco.freire
Added file: http://bugs.python.org/file31202/mywork.patch

___
Python tracker 

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



[issue18691] sqlite3.Cursor.execute expects sequence as second argument.

2013-08-08 Thread Andrew Myers

New submission from Andrew Myers:

Sorry if this isn't the place for this, it is my first python bug report.

In PEP 249 Python database API specifiction 2.0 the Cursor execute method[1] is 
described as taking a variable number of arguments for substitution of '?' in 
the SQL string.  In the documentation of the sqlite3 module the Cursor execute 
method is also described this way[2].

However, the actual method requires a sequence, in the same way that the 
executemany method does.  This does not match the execute method in (for 
instance) pyodbc and means one cannot write code that is (fully) agnostic to 
the connection type.

[1]: http://www.python.org/dev/peps/pep-0249/#id15
[2]: http://docs.python.org/2/library/sqlite3.html#sqlite3.Cursor.execute

Pasted below is an example of this from python 3.3

In [1]: import sqlite3
In [2]: con = sqlite3.connect(":memory:")
In [4]: con.execute('create table foo (bar int, baz int)')
Out[4]: 

In [5]: con.execute('insert into foo values (?, ?)', 4, 5)
---
TypeError Traceback (most recent call last)
 in ()
> 1 con.execute('insert into foo values (?, ?)', 4, 5)

TypeError: function takes at most 2 arguments (3 given)

In [6]: con.execute('insert into foo values (?, ?)', (4, 5))
Out[6]: 

In [7]:

--
components: Library (Lib)
messages: 194710
nosy: Andrew.Myers
priority: normal
severity: normal
status: open
title: sqlite3.Cursor.execute expects sequence as second argument.
versions: Python 2.7, Python 3.3

___
Python tracker 

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



[issue18691] sqlite3.Cursor.execute expects sequence as second argument.

2013-08-08 Thread R. David Murray

Changes by R. David Murray :


--
nosy: +r.david.murray

___
Python tracker 

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



[issue18692] Connection change in compiled code

2013-08-08 Thread INNA

New submission from INNA:

Hi,

I have a compiled code, which currently uses SQLITE connection (datastore). I 
was wondering if it is possible to change the connection string to use SQL 
Server database.

I would like to export the datastore to SQL server database, as we are having 
issues with the limit.

Thank you.
Inna

--
components: Windows
messages: 194711
nosy: INNESSA
priority: normal
severity: normal
status: open
title: Connection change in compiled code
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue18301] In itertools.chain.from_iterable() there is no cls argument

2013-08-08 Thread py.user

py.user added the comment:

changed iter(arg) to *arg


>>> import itertools
>>> 
>>> class A(itertools.chain):
... @classmethod
... def from_iter(cls, arg):
... return cls(*arg)
... 
>>> class B(A):
... pass
... 
>>> B('ab', 'cd')
<__main__.B object at 0x7fc280e93cd0>
>>> b = B.from_iter(['ab', 'cd'])
>>> b
<__main__.B object at 0x7fc280e93d20>
>>> next(b)
'a'
>>> next(b)
'b'
>>> next(b)
'c'
>>> next(b)
'd'
>>> next(b)
Traceback (most recent call last):
  File "", line 1, in 
StopIteration
>>>

--

___
Python tracker 

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



[issue18692] Connection change in compiled code

2013-08-08 Thread R. David Murray

R. David Murray added the comment:

This issue tracker is for reporting bugs in Python and its standard library.  
Your submission looks like a request for help.  You are much more likely to get 
the answer to your question on the python-list mailing list.  Please submit 
your question there.

--
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue18693] help() not helpful with enum

2013-08-08 Thread Ethan Furman

New submission from Ethan Furman:

help(), when used on an enum member or class, returns almost nothing.  I 
suspect the custom __dir__ is at fault, but whatever is causing the problem 
needs fixing.

--
assignee: ethan.furman
messages: 194714
nosy: barry, eli.bendersky, ethan.furman
priority: normal
severity: normal
status: open
title: help() not helpful with enum
versions: Python 3.4

___
Python tracker 

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



[issue18606] Add statistics module to standard library

2013-08-08 Thread Stephen J. Turnbull

Stephen J. Turnbull added the comment:

A few small comments and nits.

1. I'm with the author on the question of a sum function in this module.  The 
arguments that builtin sum isn't accurate enough, and neither is math.fsum for 
cases where all data is of infinite precision, are enough for me.

2. A general percentile function should be high on the list of next additions.

A substantive question:

3. Can't add_partial be used in the one-pass algorithms?

Several typos and suggested style tweaks:

4. I would find the summary more readable if grouped by function:
add_partial, sum, StatisticsError; mean, median, mode; pstdev, pvariance, 
stdev, variance.  Maybe I'd like it better if the utilities came last.  IMO 
YMMV, of course.

5. In the big comment in add_partial, "the inner loop" is mentioned.  Indeed 
this is the inner loop in statistics.sum, but there's only one loop in 
add_partial.

6. In the Limitations section of sum's docstring it says "these limitations may 
change".  Is "these limitations may be relaxed" what is meant?  I would hope 
so, but the current phrasing makes me nervous.

7. In sum, there are two comments referring to the construct 
"type(total).__float__(total)", with the first being a forward reference to the 
second.  I would find a single comment above the "isinstance(total, float)" 
test more readable.  Eg,

"""
First, accumulate a non-float sum. Until we find a float, we keep adding.
If we find a float, we exit this loop, convert the partial sum to float, and 
continue with the float code below. Non-floats are converted to float with 
'type(x).__float__(x)'. Don't call float() directly, as that converts strings 
and we don't want that. Also, like all dunder methods, we should call __float__ 
on the class, not the instance.
"""

8. The docstrings for mean and variance say they are unbiased.  This depends on 
the strong assumption of a representative (typically i.i.d.) sample.  I think 
this should be mentioned.

9. Several docstrings say "this function should be used when ...".  In fact the 
choice of which function to use is somewhat delicate.  My personal preference 
would be to use "may" rather than "should."

10. In several of the mode functions, the value is a sorted sequence.  The sort 
key should be specified, because it could be the data value or the score.

--
nosy: +sjt

___
Python tracker 

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



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

2013-08-08 Thread Larry Hastings

New submission from Larry Hastings:

The getxattr() system call retrieves an "extended attribute" on a file.  When 
you call it you pass in a buffer and a size.  The expected behavior is, if you 
pass in a buffer that's too small, the function returns -1 and sets errno to 
ERANGE.

On a ZFS filesystem on Linux, using the "ZFS On Linux" port:
http://zfsonlinux.org/

getxattr() does not behave this way.  Instead, it fills the buffer with the 
first buffer-size bytes of data (without a zero terminator).

Python's implementation of getxattr() interprets this as success.  Which means 
that, the way it's implemented, if you call getxattr() to retrieve a value 
that's > 128 bytes in length, you only get the first 128 bytes.  (Happily, we 
already have a regression test that finds this!)

Attached is a patch fixing this behavior.  It checks the return value of 
getxattr() to see if the buffer was filled to 100%.  If so, it retries with a 
larger buffer.

--
assignee: larry
components: Library (Lib)
files: larry.setxattr.zfs.patch.1.txt
messages: 194716
nosy: larry
priority: normal
severity: normal
stage: patch review
status: open
title: getxattr on Linux ZFS native filesystem happily returns partial values
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file31203/larry.setxattr.zfs.patch.1.txt

___
Python tracker 

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



[issue18693] help() not helpful with enum

2013-08-08 Thread Ethan Furman

Ethan Furman added the comment:

With custom __dir__:

Help on class Enum in module enum:

Enum = 



Without custom __dir__:

Help on class Enum in module enum:

class Enum(builtins.object)
 |  Generic enumeration.
 |  
 |  Derive from this class to define new enumerations.
 |  
 |  Methods defined here:
 |  
 |  __eq__(self, other)
 |  
 |  __getnewargs__(self)
 |  
 |  __hash__(self)
 |  
 |  __repr__(self)
 |  
 |  __str__(self)
 |  
 |  --
 |  Static methods defined here:
 |  
 |  __new__(cls, value)
 |  
 |  --
 |  Data descriptors defined here:
 |  
 |  __dict__
 |  dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |  list of weak references to the object (if defined)
 |  
 |  name
 |  Route attribute access on a class to __getattr__.
 |  
 |  This is a descriptor, used to define attributes that act differently 
when
 |  accessed through an instance and through a class.  Instance access 
remains
 |  normal, but access to an attribute through a class will be routed to the
 |  class's __getattr__ method; this is done by raising AttributeError.
 |  
 |  value
 |  Route attribute access on a class to __getattr__.
 |  
 |  This is a descriptor, used to define attributes that act differently 
when
 |  accessed through an instance and through a class.  Instance access 
remains
 |  normal, but access to an attribute through a class will be routed to the
 |  class's __getattr__ method; this is done by raising AttributeError.

---

I'm thinking we should drop the custom __dir__.  help() is far more important 
than not seeing some things with dir().

--

___
Python tracker 

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



[issue12806] argparse: Hybrid help text formatter

2013-08-08 Thread paul j3

Changes by paul j3 :


--
nosy: +paul.j3

___
Python tracker 

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



[issue13280] argparse should use the new Formatter class

2013-08-08 Thread paul j3

Changes by paul j3 :


--
nosy: +paul.j3

___
Python tracker 

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



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

2013-08-08 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +benjamin.peterson

___
Python tracker 

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