[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Alex Gaynor

Changes by Alex Gaynor :


--
nosy: +alex

___
Python tracker 

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



[issue17858] Different documentation for identical methods

2013-04-27 Thread Georg Brandl

Georg Brandl added the comment:

This patch includes changes from #17851, please remove that (but you can remove 
the comma after "block").

--
nosy: +georg.brandl

___
Python tracker 

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



[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Ethan Furman

Ethan Furman added the comment:

Nick, thanks for the explanation.

Benjamin, I was referring to Nick taking 3.3 and 3.2 off the issue and leaving 
3.4, and you reversing it.  ;)

Sorry for the confusion -- I just reread my post and the words there didn't 
match the ideas in my head at the time very 
well.

--

___
Python tracker 

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



[issue15139] Speed up threading.Condition wakeup

2013-04-27 Thread Catalin Patulea

Changes by Catalin Patulea :


--
nosy: +Catalin.Patulea

___
Python tracker 

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



[issue17842] Add base64 module tests for a bytearray argument

2013-04-27 Thread Kushal Das

Kushal Das added the comment:

Bytearray encoding and decoding

--
Added file: http://bugs.python.org/file30041/issue17842_v2.patch

___
Python tracker 

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



[issue16177] IDLE Crash on Open Parens

2013-04-27 Thread Ned Deily

Ned Deily added the comment:

Something that comes to mind: the stack traces in both issues show similar 
crashes where Tk is calling into OS X AppKit to create or modify a window.  
Since a left paren is being typed, it seems to me the most likely scenario is 
that the left paren is completing a recognized token and IDLE is attempting to 
display a calltip (Lib/idlelib/CallTipWindow.py). That shouldn't be a problem, 
of course.  Also, note the exception class: NSInternalInconsistencyException.  
That sounds suspicious.  I've found a few other reports, all from 10.8, of 
other non-Tk, non-Python apps with similar crashes.  I'm still not able to 
reproduce it myself.  Both reports here were with 10.8.2 and with ActiveTcl 
8.5.11 or .12.  Can anyone reproduce the crash with the current 10.8.3 and 
ActiveTcl 8.5.13, which does contain some significant fixes for OS X?  And 
also, if so, verify that it is a calltip causing the problem?  To check that, 
in either an IDLE shell or edit window, typing ( at the beginning of a line sh
 ould not cause a calltip to be created so, if there is a connection, there 
should not be a crash.  But then typing something like "open(" should cause a 
calltip to be created.  A crash of this sort is almost certainly a problem in 
either OS X or in Tk and not Python.  In any case, if we can't find a way to 
reproduce the problem reliably, there isn't much we can do about it.

--

___
Python tracker 

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



[issue17396] modulefinder fails if module contains syntax error

2013-04-27 Thread Éric Araujo

Éric Araujo added the comment:

I would recommend that you base your patch on the default branch, i.e. what 
will become Python 3.4.  If we judge that this is not a new feature but 
actually a bug fix, the core developer who commits the patch will take care of 
backporting it to 2.7 and 3.3.

--
nosy: +brett.cannon, eric.snow, ncoghlan

___
Python tracker 

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



[issue17396] modulefinder fails if module contains syntax error

2013-04-27 Thread Éric Araujo

Éric Araujo added the comment:

Certainly: http://docs.python.org/devguide contains information to get the 
source code, describes the files layout and explains how to generate a patch.  
You’ll find existing unit tests in Lib/test/test_modulefinder.py

Feel free to ask any question you might have on this bug, or if you prefer on 
the friendly core-mentorship mailing list (where I am).

--

___
Python tracker 

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



[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Nick Coghlan

Nick Coghlan added the comment:

In this case, we won't fix it in a maintenance release because of the kind of 
change required to eliminate the bug. Adding a new opcode is likely to be the 
simplest fix and that is necessarily a backwards incompatible change (since 
older versions won't understand the new opcode).

Even if we find a solution that doesn't require a new opcode, fixing the 
problem is going to require changes to both the compiler and the eval loop, and 
we simply don't touch those in maintenance releases without a *really* 
compelling reason. Fixing an edge case related to the interaction between two 
features that are already somewhat obscure on their own doesn't qualify.

If anyone does decide to tackle this, I'll note that my examples in my previous 
post may be useful as inspiration for a test case - the final versions of both 
f() and g() should report "from metaclass" as the value of "outer" inside the 
class body, and it should be simple enough to replace the print statements with 
self.assertEqual() in a unit test.

--

___
Python tracker 

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



[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Benjamin Peterson

Benjamin Peterson added the comment:

There's no need for a discussion; the answer is no.

--

___
Python tracker 

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



[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Ethan Furman

Ethan Furman added the comment:

Perhaps you and Benjamin should discuss that.  :)

I just read a thread on core-mentors about when a bug is fixed or not -- 
considering that the behavior is plain wrong, 
that workarounds will still work even if the bug is fixed, why shouldn't we fix 
it even in a maintenance release?

--

___
Python tracker 

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



[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
nosy: +benjamin.peterson
versions: +Python 3.2, Python 3.3 -Python 3.4

___
Python tracker 

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



[issue15834] 2to3 benchmark not working under Python 3

2013-04-27 Thread Brett Cannon

Brett Cannon added the comment:

Since lib3 now exists we should probably take advantage and just keep a 
translated, patched copy of 2to3 there to avoid this problem while keeping 
performance on an even keel for comparison.

--

___
Python tracker 

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



[issue15834] 2to3 benchmark not working under Python 3

2013-04-27 Thread Brett Cannon

Changes by Brett Cannon :


--
keywords: +easy

___
Python tracker 

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



[issue17330] Stop checking for directory cache invalidation in importlib

2013-04-27 Thread Brett Cannon

Brett Cannon added the comment:

And I have decided to not bother removing the stat check.

--

___
Python tracker 

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



[issue17330] Stop checking for directory cache invalidation in importlib

2013-04-27 Thread Brett Cannon

Brett Cannon added the comment:

http://hg.python.org/cpython/rev/75e32a0bfd74 and 
http://hg.python.org/cpython/rev/5fac0ac46f54 have more stronger wording for 
importlib.invalidate_caches(). What's New already says to call the function 
without being wishy-washy, so I didn't touch it.

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

___
Python tracker 

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



[issue17853] Conflict between lexical scoping and name injection in __prepare__

2013-04-27 Thread Nick Coghlan

Nick Coghlan added the comment:

Just to clarify, the problem here isn't to do with referencing the class name 
in particular, it's referencing *any* lexically scoped name from the class 
body, when a metaclass wants to inject that as variable name in the class 
namespace. Here's a case where it silently looks up the wrong value:

>>> class Meta(type): pass
... 
>>> def f():
... outer = "lexically scoped"
... class inner(metaclass=Meta):
... print(outer)
... 
>>> f()
lexically scoped
>>> class Meta(type):
... def __prepare__(*args):
... return dict(outer="from metaclass")
... 
>>> f()
lexically scoped

That second one *should* say "from metaclass", but it doesn't because the 
LOAD_DEREF completely ignores the local namespace. You can get the same 
exception noted above by moving the assignment after the inner class definition:

>>> def g():
... class inner(metaclass=Meta):
... print(outer)
... outer = "This causes an exception"
... 
>>> g()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in g
  File "", line 3, in inner
NameError: free variable 'outer' referenced before assignment in enclosing 
scope  

We simply missed the fact that PEP 3115 and the __prepare__ method mean that 
using LOAD_DEREF to resolve lexically scoped names in a nested class is now 
wrong. Instead, we need a new opcode that first tries the class namespace and 
only if that fails does it fall back to looking it up in the lexically scoped 
cell reference.

(I changed the affected versions, as even though this *is* a bug in all current 
Python 3 versions, there's no way we're going to change the behaviour of name 
resolution in a maintenance release)

--
nosy: +ncoghlan
title: class construction name resolution broken in functions -> Conflict 
between lexical scoping and name injection in __prepare__
versions: +Python 3.4 -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



[issue17357] Add missing verbosity message to importlib

2013-04-27 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 75e32a0bfd74 by Brett Cannon in branch '3.3':
Issue #17357: Use more stern wording for
http://hg.python.org/cpython/rev/75e32a0bfd74

New changeset 5fac0ac46f54 by Brett Cannon in branch 'default':
merge for issue #17357
http://hg.python.org/cpython/rev/5fac0ac46f54

--

___
Python tracker 

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



[issue17857] sqlite modules doesn't build with 2.7.4 on Mac OS X 10.4

2013-04-27 Thread Ned Deily

Ned Deily added the comment:

Marc-Andre, can you elaborate on why you think Python 3 is not affected? The 
changes for Issue17073 also added sqlite3_int64 to 3.2, 3.3, and default and, 
for me on 10.4, _sqlite3.so currently fails to build in all three.  (I don't 
think 3.2 is worth worrying about but if Georg does spin a brown bag 3.2.5 he 
could cherry pick it.)

--
nosy: +georg.brandl

___
Python tracker 

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



[issue17115] __loader__ = None should be fine

2013-04-27 Thread Brett Cannon

Changes by Brett Cannon :


--
dependencies:  -xml.parsers.expat.(errors|model) don't set the __loader__ 
attribute

___
Python tracker 

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



[issue16104] Use multiprocessing in compileall script

2013-04-27 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee: brett.cannon -> 

___
Python tracker 

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



[issue13721] ssl.wrap_socket on a connected but failed connection succeeds and .peer_certificate gives AttributeError

2013-04-27 Thread Ben Darnell

Ben Darnell added the comment:

We found a related issue with Tornado: 
https://github.com/facebook/tornado/pull/750

We call wrap_socket with do_handshake_on_connect=False and then call 
do_handshake when the socket is ready.  If the getpeername call in wrap_socket 
fails with ENOTCONN because the connection was reset immediately after it was 
opened, then do_handshake will fail with an AttributeError (because 
self._sslobj is None).  do_handshake should fail with a clearer error (perhaps 
socket.error with ENOTCONN or ECONNABORTED?) if self._sslobj is None.

Also, Mac OS X appears to return EINVAL from getpeername in this case, instead 
of ENOTCONN.  wrap_socket should probably treat ENOTCONN and EINVAL from 
getpeername as equivalent.

--
nosy: +Ben.Darnell

___
Python tracker 

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



[issue15518] Provide test coverage for filecmp.dircmp.report methods.

2013-04-27 Thread Chris Calloway

Chris Calloway added the comment:

I'm uploading a new patch which gets rid of the temp_cwd calls as suggested in 
the review. The patch is not complete in that the explanatory comments 
suggested in the review and revising the pre-existing tests have not been 
completed yet. However, I want to upload the work I do have as it has been a 
couple of weeks since reivew and I won't have another opportunity to complete 
the review suggestions until PUG project nights on May 7th and 8th.

Also, I'm uploading this new patch because the previous patch had a serious 
problem that caused this delay. I happened to get a new laptop and used the 
previous patch to recreate the tests. I found that part of the new filecmpdata 
directory was missing when I did that and some of the tests failed as a result.

It turns out that hg add and hg diff were not detecting all of filecmpdata. 
There's a well known problem with hg no detecting empty directories. However, 
this was not the case in this patch. Because I was able to workaround the 
problem by recreating all the dir-same directories and all their 
subdirectories, I think the problem is with hg not detecting directories with 
identical contents if the creation dates are the same. It's something I'll need 
to investigate more when this issue has been completed.

--
Added file: http://bugs.python.org/file30040/issue-15518-1.patch

___
Python tracker 

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



[issue15518] Provide test coverage for filecmp.dircmp.report methods.

2013-04-27 Thread Chris Calloway

Changes by Chris Calloway :


Removed file: http://bugs.python.org/file29758/issue-15518-1.patch

___
Python tracker 

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



[issue17858] Different documentation for identical methods

2013-04-27 Thread Andriy Mysyk

Andriy Mysyk added the comment:

Issue 14823 indeed improved threading documentation. However, even with the 
improvement threading documentation makes acquire() appear to be more complex 
and harder to use than it actually is.

--

___
Python tracker 

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



[issue17858] Different documentation for identical methods

2013-04-27 Thread R. David Murray

R. David Murray added the comment:

For the record, both the _thread docs and the threading docs for acquire were 
updated in 01d1fd775d16 as part of issue 7316.  Some at least of the 
differences come from 6ab4128a (issue 14823).  That makes it likely that 
the threading docs are the better of the two.

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



[issue17858] Different documentation for identical methods

2013-04-27 Thread Andriy Mysyk

Andriy Mysyk added the comment:

I am attaching a patch that applies _thread.Lock.acquire() documentation to the 
functionally identical threading.Lock.acquire().

--
keywords: +patch
Added file: http://bugs.python.org/file30039/issue17858.patch

___
Python tracker 

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



[issue17858] Different documentation for identical methods

2013-04-27 Thread Andriy Mysyk

New submission from Andriy Mysyk:

Use _thread.Lock.acquire() documentation for threading.Lock.acquire().

threading.Lock inherits acquire() method from _thread.Lock.  The two acquire() 
methods are identical in their functionality yet have different documentation. 
Documentation for threading.Lock.acquire() creates the impression that the 
function is more complex or harder to use than it actually is. See 
http://docs.python.org/devguide/documenting.html#economy-of-expression for 
guidelines.

--
assignee: docs@python
components: Documentation
messages: 187945
nosy: amysyk, docs@python
priority: normal
severity: normal
status: open
title: Different documentation for identical methods
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



[issue17742] Add _PyBytesWriter API

2013-04-27 Thread STINNER Victor

Changes by STINNER Victor :


--
Removed message: http://bugs.python.org/msg187943

___
Python tracker 

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



[issue17742] Add _PyBytesWriter API

2013-04-27 Thread STINNER Victor

STINNER Victor added the comment:

Advantages of the patch.

* finer control on how the buffer is allocated: only overallocate if the 
replacement string (while handling an encoding error) is longer than 1 
byte/character. The "replace" error handler should never use overallocation for 
example. Overallocation (when misused, when it was not needed) has a cost at 
the end of the encoder, because the buffer must be resized (shrink)

* use a buffer allocated on the stack for short strings. I'm not really 
convinced of this optimization. The data is still copied when the result is 
converted to a bytes objects (PyBytes_FromStringAndSize). It may be interesting 
if the encoder has to handle one or more errors: no need to resize the buffer 
until we reach the size of the small buffer (ex: 512 bytes).

* handle correctly integer overflow: most encoders do not catch integer 
overflow errors and may fail to handle (very) long strings (ex: encoded string 
longer than PY_SSIZE_T_MAX).

I'm not convinced that the patch would permit to design faster code. According 
to the assembler, it is the opposite (when "*writer.str++" is used in a loop). 
I don't know if it's possible to design a more efficient _PyBytesWriter API (to 
help GCC to generate more efficient machine code), nor if the overhead is 
important in a "normal case" (bench_encoders.py tests border cases, text with 
many many errors).

--

___
Python tracker 

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



[issue17742] Add _PyBytesWriter API

2013-04-27 Thread STINNER Victor

STINNER Victor added the comment:

Advantages of the patch.

* finer control on how the buffer is allocated: only overallocate if the 
replacement string (while handling an encoding error) is longer than 1 
character. The "replace" error handler should never use overallocation for 
example. Overallocation has a cost at the end of the encoder, because the 
buffer must be resized (shrink)

* use a buffer allocated on the stack for short strings. I'm not really 
convinced of this optimization. The data is still copied when the result is 
converted to a bytes objects (PyBytes_FromStringAndSize). It may be interesting 
if the encoder has to handle one or more errors: no need to resize the buffer 
until we read the size of the small buffer (ex: 512 bytes).

* handle correctly integer overflow: most encoders do not catch integer 
overflow errors and may fail to handle (very) long strings (ex: encoded string 
longer than PY_SSIZE_T_MAX).

I'm not convinced that the patch would permit to design faster code. According 
to the assembler, it is the opposite (when "*writer.str++" is used in a loop). 
I don't know if it's possible to design a more efficient _PyBytesWriter API (to 
help GCC to generate more efficient machine code), nor if the overhead is 
important in a "normal case" (bench_encoders.py tests border cases, text with 
many many errors).

--

___
Python tracker 

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



[issue17851] Grammar errors in threading.Lock documentation

2013-04-27 Thread R. David Murray

R. David Murray added the comment:

I (as a native English speaker, FWIW) agree that the existing text is correct 
insofar as the reported problems go.  I, however, would remove the comma after 
'block'.  I don't know that it is wrong as written, but it reads strangely to 
my ear.

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



[issue17396] modulefinder fails if module contains syntax error

2013-04-27 Thread Florent Xicluna

Changes by Florent Xicluna :


--
nosy: +flox

___
Python tracker 

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



[issue17396] modulefinder fails if module contains syntax error

2013-04-27 Thread Jan Gosmann

Jan Gosmann added the comment:

Could you point me to some documentation on how to add a test? I have not been 
involved in Python development so far.

--

___
Python tracker 

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



[issue17857] sqlite modules doesn't build with 2.7.4 on Mac OS X 10.4

2013-04-27 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 27.04.2013 22:27, Serhiy Storchaka wrote:
> 
> Serhiy Storchaka added the comment:
> 
> Here is a patch for 2.7. Please test. Should it be fixed on 3.x?

Thanks, Serhiy.

I can confirm that the patch fixes the problem with 2.7.4 on
Mac OS X (and probably other platforms with old sqlite libs as
well).

Python 3.3 is not affected by this. It uses a Python type
for storing the values.

--

___
Python tracker 

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



[issue17396] modulefinder fails if module contains syntax error

2013-04-27 Thread Éric Araujo

Éric Araujo added the comment:

Thanks for the report and patch.  Could you add a test?

I’m not sure where this sits on the bug vs. feature line.

--
nosy: +eric.araujo, r.david.murray

___
Python tracker 

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



[issue17857] sqlite modules doesn't build with 2.7.4 on Mac OS X 10.4

2013-04-27 Thread Ned Deily

Ned Deily added the comment:

The patch does solve the build problem for 2.7 on 10.4 (Tiger).  The same 
problem exists for 3.3 and default as well.  I see the Tiger buildbots aren't 
failing with this problem; I suspect that's because there is a newer version of 
libsqlite3 being supplied in /usr/local/{include,lib}, like the OS X installer 
builds do since the Apple-supplied version of libsqlite3 in 10.4 is the ancient 
3.1.3.

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



[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman

Ethan Furman added the comment:

I guess the question is:

Because Python can no longer know if the name has been inserted via __prepare__ 
it has to go through the whole CLOSURE 
business, but will changing the LOAD_DEREF to a LOAD_GLOBAL (only for items 
inside a class def) do the trick?

--

___
Python tracker 

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



[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman

Ethan Furman added the comment:

On 04/27/2013 02:01 PM, Mark Dickinson wrote:
>
> Mark Dickinson added the comment:
>
> Isn't this just a consequence of Python's usual name-lookup rules?  In this 
> code:
>
>  def test():
>  class Season(Enum):
>  SPRING = Season()
>
> the class definition in 'test' amounts to a local assignment to the name 
> 'Season'.  So the occurrence of 'Season' in the class definition is bound to 
> that function local (at bytecode level, it's looked up using LOAD_DEREF 
> instead of LOAD_NAME).

The key point is that class construction should take place in its own namespace 
(it has its own locals(), after all), 
only looking to enclosing name spaces if it can't find the name in its locals() 
(which it won't know until it tries). 
Granted, this was never a problem before __prepare__ was available, but now 
that it is we need to have the name space 
look-up rules applied appropriately, and not have the enclosing function 
strong-arm its own values into the class namespace.

> I find it difficult to see how one could 'fix' this without significant 
> changes to the way that Python does name resolution.

I don't know if this helps, but here's the dis for three different runs:

--> def test1():
...   class WeekDay(Enum):
...  MONDAY = WeekDay(1)
...
--> dis.dis(test1)
   2   0 LOAD_BUILD_CLASS
   1 LOAD_CLOSURE 0 (WeekDay)
   4 BUILD_TUPLE  1
   7 LOAD_CONST   1 (", line 2>)
  10 MAKE_CLOSURE 0
  13 LOAD_CONST   2 ('WeekDay')
  16 LOAD_GLOBAL  0 (Enum)
  19 CALL_FUNCTION3
  22 STORE_DEREF  0 (WeekDay)
  25 LOAD_CONST   0 (None)
  28 RETURN_VALUE

--> def test2():
...   class WeekDay(Enum):
... MONDAY = enum(1)
...
--> dis.dis(test2)
   2   0 LOAD_BUILD_CLASS
   1 LOAD_CONST   1 (", line 2>)
   4 MAKE_FUNCTION0
   7 LOAD_CONST   2 ('WeekDay')
  10 LOAD_GLOBAL  0 (Enum)
  13 CALL_FUNCTION3
  16 STORE_FAST   0 (WeekDay)
  19 LOAD_CONST   0 (None)
  22 RETURN_VALUE

--> def test3():
...   class WeekDay(Enum):
... WeekDay = locals()['WeekDay']
... MONDAY = WeekDay(1)
...
--> dis.dis(test3)
   2   0 LOAD_BUILD_CLASS
   1 LOAD_CONST   1 (", line 2>)
   4 MAKE_FUNCTION0
   7 LOAD_CONST   2 ('WeekDay')
  10 LOAD_GLOBAL  0 (Enum)
  13 CALL_FUNCTION3
  16 STORE_FAST   0 (WeekDay)
  19 LOAD_CONST   0 (None)
  22 RETURN_VALUE

test1's dis should look more like test3's.  Also, I find it interesting that 
test2's dis is exactly the same as test3's.

--

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Florent Xicluna added the comment:

The previous patch fixes some cases where the caret was wrongly positioned.

However, there's probably stuff to fix in Python internals too.
See attached test cases (test_traceback_caret.py) which demonstrates other 
issues with non-ASCII chars or  in the source code.

--
Added file: http://bugs.python.org/file30038/test_traceback_caret.py

___
Python tracker 

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



[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Mark Dickinson

Mark Dickinson added the comment:

Isn't this just a consequence of Python's usual name-lookup rules?  In this 
code:

def test():
class Season(Enum):
SPRING = Season()

the class definition in 'test' amounts to a local assignment to the name 
'Season'.  So the occurrence of 'Season' in the class definition is bound to 
that function local (at bytecode level, it's looked up using LOAD_DEREF instead 
of LOAD_NAME).

I find it difficult to see how one could 'fix' this without significant changes 
to the way that Python does name resolution.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Your diff file looks broken.

I'm not sure it's the traceback module should be fixed and not Python 
internals. Georg, what you say?

--

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Changes by Florent Xicluna :


Added file: http://bugs.python.org/file30037/patch_indenterror_offset.diff

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Changes by Florent Xicluna :


Removed file: http://bugs.python.org/file30036/patch_indenterror_offset.diff

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Florent Xicluna added the comment:

The proposed patch deals with the case of the IndentationError in the traceback 
module.

--
keywords: +patch
resolution: works for me -> 
Added file: http://bugs.python.org/file30036/patch_indenterror_offset.diff

___
Python tracker 

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



[issue17857] sqlite modules doesn't build with 2.7.4 on Mac OS X 10.4

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch for 2.7. Please test. Should it be fixed on 3.x?

--
keywords: +patch
Added file: http://bugs.python.org/file30035/sqlite_int64.patch

___
Python tracker 

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



[issue17857] sqlite modules doesn't build with 2.7.4 on Mac OS X 10.4

2013-04-27 Thread Marc-Andre Lemburg

Changes by Marc-Andre Lemburg :


--
title: sqlite modules doesn't build on 2.7.4 with Mac OS X 10.4 -> sqlite 
modules doesn't build with 2.7.4 on Mac OS X 10.4

___
Python tracker 

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



[issue17857] sqlite modules doesn't build on 2.7.4 with Mac OS X 10.4

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The regression was introduced in issue17073.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue17806] Add keyword args support to str/bytes.expandtabs()

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Note that adding support of keyword arguments significant slowdown argument 
parsing. Please measure time of the function call with and without the patch.

I object to add support for keyword arguments in a quick built-in functions. 
Especially if it's the only argument.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Indeed, there is an inconsistence between the traceback module and builtin 
exception print function. Behavior of traceback is intentional as noted in 
format_exception_only() (if this comment is not misleading).

--
nosy: +georg.brandl, serhiy.storchaka
type: enhancement -> behavior

___
Python tracker 

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



[issue17806] Add keyword args support to str/bytes.expandtabs()

2013-04-27 Thread Éric Araujo

Éric Araujo added the comment:

Where is the “Approve patch” button :)

--

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Changes by Florent Xicluna :


--
status: closed -> open

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Florent Xicluna added the comment:

And this additional script (test_indenterror.py) demonstrates a different issue 
in the traceback module.

--
Added file: http://bugs.python.org/file30034/test_indenterror.py

___
Python tracker 

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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Florent Xicluna

Florent Xicluna added the comment:

Hello again,

actually, the attached script demonstrates some issues with the computation of 
the offset.

In rare cases, the computed offset does not match the position of the caret '^' 
in the traceback. It makes it difficult to reuse exc.offset to display the 
exact position.

--
Added file: http://bugs.python.org/file30033/issue17825_cases.py

___
Python tracker 

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



[issue17721] Help button on preference window doesn't work

2013-04-27 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Perhaps we should merely comment out the two blocks of text until we decide we 
don't ever want a help button. If the expanded doc in progress had a marked 
helpful doc on configure, the help button could open the doc to that section.

Guilherme, have you submitted a PSF Contributor License Agreement?
http://www.python.org/psf/contrib/contrib-form/
(Sorry if this a repeat question.)

--

___
Python tracker 

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



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

2013-04-27 Thread Armin Rigo

Armin Rigo added the comment:

It used to be a consistently reliable behavior in Python 2 (and we made it so 
in PyPy too), provided of course that the process exits normally; but it no 
longer is in Python 3.  Well I can see the reasons for not flushing files, if 
it's clearly documented somewhere as a change of behavior from Python 2.

However I'm complaining about the current behavior: files are flushed *most of 
the time*.  That's a behavior that is clearly misleading, or so I would think.  
I'm rather sure that there are many small scripts and large programs out there 
relying on automatic flushing, and then one day they'll hit a case where the 
file is not flushed and get the worst kind of error: a file unexpectedly 
truncated at 99% of its length, in a way that cannot be reproduced by small 
examples.

Feel free to close anyway as not-a-bug; I won't fight the Python 3 behavior, 
because Python 2 works as expected.

--

___
Python tracker 

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



[issue17857] sqlite modules doesn't build on 2.7.4 with Mac OS X 10.4

2013-04-27 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Adding the same people to the nosy list as on issue #14572.

--
nosy: +Joakim.Sernbrant, Marc.Abramowitz, dmalcolm, ned.deily, petri.lehtinen, 
python-dev
type:  -> compile error

___
Python tracker 

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



[issue17857] sqlite modules doesn't build on 2.7.4 with Mac OS X 10.4

2013-04-27 Thread Marc-Andre Lemburg

New submission from Marc-Andre Lemburg:

This is essentially the same issue as http://bugs.python.org/issue14572.

The following addition in Python 2.7.4 (compared to 2.7.3) reintroduced the 
same problem in a different place:

--- Python-2.7.3/Modules/_sqlite/util.h 2012-04-10 01:07:33.0 +0200
+++ Python-2.7.4/Modules/_sqlite//util.h2013-04-06 16:02:36.0 
+0200
@@ -33,6 +33,10 @@ int pysqlite_step(sqlite3_stmt* statemen
 /**
  * Checks the SQLite error code and sets the appropriate DB-API exception.
  * Returns the error code (0 means no error occurred).
  */
 int _pysqlite_seterror(sqlite3* db, sqlite3_stmt* st);
+
+PyObject * _pysqlite_long_from_int64(sqlite3_int64 value);
+sqlite3_int64 _pysqlite_long_as_int64(PyObject * value);
+
 #endif

The fix is the same as for the 2.7.3 issue: replace sqlite3_int64 with 
sqlite_int64

--
components: Extension Modules, Library (Lib)
messages: 187921
nosy: lemburg
priority: normal
severity: normal
status: open
title: sqlite modules doesn't build on 2.7.4 with Mac OS X 10.4
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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
resolution:  -> works for me
status: open -> closed
type: behavior -> enhancement

___
Python tracker 

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



[issue17818] aifc.Aifc_read/Aifc_write.getparams can return a namedtuple

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is a regression. The result of getparams() was pickable, but now it is 
not.

I have added other comments on Rietveld.

--

___
Python tracker 

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



[issue17839] base64 module should use memoryview

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Note that some functions use bytes/bytearray methods and an argument should 
converted to bytes for them. Other functions use C functions which supports the 
buffer protocol and do not required any conversion.

--

___
Python tracker 

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



[issue17810] Implement PEP 3154 (pickle protocol 4)

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> Padding makes it both less efficient and more annoying to handle, IMO.

Agree. But there is other application for NOPs. UTF-8 decoder (and some other 
decoders) works more fast (up to 4x) when input is aligned. By adding several 
NOPs before BINUNICODE so that start of encoded data is 4- or 8-bytes aligned 
relatively to start of frame, we can significan speedup unpickling long ASCII 
strings. I propose to add new NOP opcode and to use it to align some 
align-sensitive data.

> My framing proof-of-concept ends up quite simple in terms of code
> complexity. For example, the C version only adds 125 lines of code in 3
> additional functions.

I just looked in the code and saw that the unpickler already has a ready 
infrastructure for prefetching. Now your words have not appear to be so 
incredible. ;) It should work.

> No doublecopying is necessary (not in the C version, that is).

Agree, there is no doublecopying (except for large bytes objects).

--

___
Python tracker 

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



[issue17856] multiprocessing.Process.join does not block if timeout is lower than 1

2013-04-27 Thread Charles-François Natali

Charles-François Natali added the comment:

Thanks for the report, but it's a duplicate of #17707 (recently fixed).

--
nosy: +neologix
resolution:  -> duplicate
stage:  -> committed/rejected
status: open -> closed
superseder:  -> Multiprocessing queue get method does not block for short 
timeouts
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



[issue17841] Remove missing aliases from codecs documentation

2013-04-27 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



[issue17840] base64_codec uses assert for runtime validity checks

2013-04-27 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



[issue17856] multiprocessing.Process.join does not block if timeout is lower than 1

2013-04-27 Thread ProgVal

New submission from ProgVal:

In Python 3.3, multiprocessing.Process.join() is not blocking with floats lower 
than 1.0 (not included). It works as expected (ie. blocking for the specified 
timeout) in Python 2.6->3.2

As you can see in this example, calling join() with 0.99 returns immediately.

$ python3.3
Python 3.3.1 (default, Apr  6 2013, 13:58:40) 
[GCC 4.7.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import time
>>> import multiprocessing
>>> def foo():
...  time.sleep(1000)
... 
>>> p = multiprocessing.Process(target=foo)
>>> p.start()
>>> bar = time.time(); p.join(0.99); print(time.time()-bar)
0.015963315963745117
>>> p.is_alive()
True
>>> bar = time.time(); p.join(1.0); print(time.time()-bar)
1.0011239051818848
>>> p.is_alive()
True

--
components: Library (Lib)
messages: 187916
nosy: Valentin.Lorentz
priority: normal
severity: normal
status: open
title: multiprocessing.Process.join does not block if timeout is lower than 1
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



[issue17826] Setting a side_effect on mock from create_autospec doesn't work

2013-04-27 Thread Ezio Melotti

Changes by Ezio Melotti :


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



[issue17825] Indentation.offset and SyntaxError.offset mismatch

2013-04-27 Thread Ezio Melotti

Ezio Melotti added the comment:

I tried a few different lines that result in a syntax error and the position of 
the '^' always seems ok to me, so I'm not sure there's any bug here:

foo:bar
   ^
from import *
  ^
try:+
^
try+
   ^
1?
 ^
1+*1
  ^
1+-*1
   ^
[}]
 ^
foo)
   ^

--
nosy: +ezio.melotti
versions: +Python 3.4 -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



[issue17806] Add keyword args support to str/bytes.expandtabs()

2013-04-27 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +eric.araujo, mark.dickinson

___
Python tracker 

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



[issue17855] Implement introspection of logger hierarchy

2013-04-27 Thread Vinay Sajip

Vinay Sajip added the comment:

Added Brandon to nosy list, as his logging_tree is what set the ball rolling on 
this one. Brandon, your comments on the patch would be very welcome.

--
nosy: +brandon-rhodes
stage:  -> patch review

___
Python tracker 

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



[issue17855] Implement introspection of logger hierarchy

2013-04-27 Thread Vinay Sajip

Changes by Vinay Sajip :


--
keywords: +patch
Added file: http://bugs.python.org/file30032/64df448c183d.diff

___
Python tracker 

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



[issue17855] Implement introspection of logger hierarchy

2013-04-27 Thread Vinay Sajip

Changes by Vinay Sajip :


--
hgrepos: +186

___
Python tracker 

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



[issue17809] FAIL: test_expanduser when $HOME ends with /

2013-04-27 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
type:  -> behavior
versions:  -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



[issue17809] FAIL: test_expanduser when $HOME ends with /

2013-04-27 Thread koobs

koobs added the comment:

After some sleuthing with Ezio (thank you for the help) and some amateur 
debugging, all conditions in expanduser return the the home directory after 
stripping trailing slashes.

The assertion in Lib/test/test_posixpath.py:264 compares expanduser(path) with 
a path obtained directly from pwd.getpwuidpw_dir "without" submitting it to the 
same treatment,  and thus the test fails when $HOME ends in a "/".

The assertion was added in f11da6cecffd (2011-03-17) in order to show that 
expanduser() "does" infact derive a path from pw_dir, when $HOME is undefined, 
as the test indicates by deleting the environment variable

In so far as using exact path equivalence to make that assertion, the 'home' 
variable in the test either ought to be subjected to the same treatment as 
paths derived via expanduser(), or the assertion relaxed to use assertIsNotNone.

Given the comment in the test: "# expanduser should fall back to using the 
password database", my feeling is that the failure case is that no path is 
returned if a username is not provided in the path passed to expanduser, and as 
such assertIsNotNone is the more specific assertion, but I'll leave it in the 
hands of the experts to make the call.

--

___
Python tracker 

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



[issue17851] Grammar errors in threading.Lock documentation

2013-04-27 Thread Georg Brandl

Georg Brandl added the comment:

I see no problem with both points: "block" is the correct verb form in this 
context ("attempts" being plural), and the version including comma reads better 
to me.

--
nosy: +georg.brandl
resolution:  -> works for me
status: open -> closed

___
Python tracker 

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



[issue17839] base64 module should use memoryview

2013-04-27 Thread Nick Coghlan

Nick Coghlan added the comment:

As Serhiy and Antoine noted, what I had in mind here was to try to wrap the 
input in a memoryview if it wasn't an instance of str, bytes or bytearray.

An existing memoryview will be passed back unmodified, while something like 
array.array will provide a view into its raw data for encoding or decoding. The 
tests would then cover both memoryview and array.array to ensure it was all 
working as expected.

--

___
Python tracker 

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



[issue17827] Document codecs.encode and codecs.decode

2013-04-27 Thread Nick Coghlan

Nick Coghlan added the comment:

This is only the second case I'm aware of where a particularly interesting 
piece of functionality didn't get mentioned in the appropriate What's New doc. 
For the other case, the zipfile execution support, we just added it in to the 
2.6 What's New long after 2.6 had been released. To this day, most people don't 
know about that capability, which is why I suggest it's worth handling the 
current case (codecs.encode and codecs.decode) differently and noting their 
existence in the next What's New doc that people are likely to read :)

--

___
Python tracker 

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



[issue17851] Grammar errors in threading.Lock documentation

2013-04-27 Thread Andriy Mysyk

Andriy Mysyk added the comment:

Ramachandra, if I understand you correctly, I think what you are saying that 
both are grammar mistakes and the first one could addressed by adding "s" to 
block.

--

___
Python tracker 

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



[issue17851] Grammar errors in threading.Lock documentation

2013-04-27 Thread Ramchandra Apte

Ramchandra Apte added the comment:

oops, should be "the crowd blocks me"

--

___
Python tracker 

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



[issue17851] Grammar errors in threading.Lock documentation

2013-04-27 Thread Ramchandra Apte

Ramchandra Apte added the comment:

afaik they don't seem to be grammatical errors
"subsequent attempts to acquire it block" - block is the verb, don't see 
anything wrong
similar example: the crowd blocks me. (present tense)
"which one of the waiting threads proceeds is not defined, and may vary across 
implementations." - there is only one clause, so no comma needed.
If two separate clauses. are separated a coordinating conjunction (such as 
and), commas are required afaik.

--
nosy: +Ramchandra Apte

___
Python tracker 

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



[issue9682] socket.create_connection error message for domain subpart with invalid length is very confusing

2013-04-27 Thread Mike Milkin

Mike Milkin added the comment:

Dave, let me know what you think of the tests, ill fix the rest of your 
comments.

--

___
Python tracker 

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



[issue17846] Building Python on Windows - Supplementary info

2013-04-27 Thread Jeremy Kloth

Changes by Jeremy Kloth :


--
nosy: +jkloth

___
Python tracker 

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



[issue17652] Add skip_on_windows decorator to test.support

2013-04-27 Thread Berker Peksag

Berker Peksag added the comment:

> Could you also propose places in the test to use this?

Sure.

- Lib/test/test_py_compile.py
- Lib/test/test_cmd_line.py
- Lib/test/test_faulthandler.py
- Lib/test/test_subprocess.py
- Lib/test/test_fileio.py
- Lib/test/test_io.py
- Lib/test/test_logging.py
- Lib/test/test_uuid.py
- Lib/test/datetimetester.py
- Lib/test/test_glob.py
- Lib/test/test_import.py
- Lib/test/test_multiprocessing.py
- Lib/test/test_signal.py
- Lib/test/test_site.py
- Lib/test/test_sysconfig.py

Here's an alternative patch that adds an optional "reason" parameter.

--
Added file: http://bugs.python.org/file30031/issue17652_v2.diff

___
Python tracker 

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



[issue17855] Implement introspection of logger hierarchy

2013-04-27 Thread Vinay Sajip

New submission from Vinay Sajip:

Track implementation of logger hierarchy introspection as per

http://plumberjack.blogspot.co.uk/2012/04/introspecting-logger-hierarchy.html

--
assignee: vinay.sajip
components: Library (Lib)
messages: 187904
nosy: vinay.sajip
priority: normal
severity: normal
status: open
title: Implement introspection of logger hierarchy
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



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

2013-04-27 Thread Charles-François Natali

Charles-François Natali added the comment:

Code relying on garbage collection/shutdown hook to flush files is borked:
- it's never been guaranteed by the Python specification (neither does 
Java/C#...)
- even with an implementation based on C stdio streams, streams won't get 
flushed in case of _exit()/abort()/asynchronous signal

Furthermore, I think it's inherently unsafe: in a multi-threaded program, 
flushing requires locking, and doing this at shutdown is a recipe for 
deadlock/arbitrary delay (image you have a daemon thread currently holding the 
lock, e.g. for stdout).

In short, that's an application bug to me.

--
nosy: +neologix

___
Python tracker 

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



[issue17854] symmetric difference operation applicable to more than two sets

2013-04-27 Thread Amit Saha

Amit Saha added the comment:

I think the only change I am suggesting is the description of the ^ operator to 
be something like this:

set ^ other ^ ..
Return a new set with elements from the sets which are not present in more than 
one set

I do understand that this is not really what the operator and the corresponding 
operation symmetric_difference() allows semantically. But it does make it 
consistent with the description of operators such as the | or &, but then their 
operation allows multiple sets semantically.

Hmm may be it is fine as it is..

--

___
Python tracker 

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



[issue17854] symmetric difference operation applicable to more than two sets

2013-04-27 Thread Georg Brandl

Georg Brandl added the comment:

Can you suggest a change?  I don't see a problem here; giving multiple 
operators for the other operations does not imply that they are not treated as 
left-associative.

--
nosy: +georg.brandl

___
Python tracker 

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



[issue17854] symmetric difference operation applicable to more than two sets

2013-04-27 Thread Amit Saha

Amit Saha added the comment:

On some more thought, perhaps the description should be updated. Since s^t^u is 
effectively (s^t)^u and hence the implementation does not violate the 
definition.

--

___
Python tracker 

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



[issue17854] symmetric difference operation applicable to more than two sets

2013-04-27 Thread Amit Saha

New submission from Amit Saha:

The description of the symmetric difference operation implies that it cannot be 
applied to more than two sets 
(http://docs.python.org/3/library/stdtypes.html#set.symmetric_difference).

However, this is certainly possible:

>>> s={1,2}
>>> t={2,3}
>>> u={3,4}
>>> s^t^u
{1, 4}
>>> s.symmetric_difference(t).symmetric_difference(u)
{1, 4}

I am not sure how much of a "semantic" sense that makes, given that symmetric 
difference is by definition for two sets. 
(http://en.wikipedia.org/wiki/Symmetric_difference).

So, either the operator should be fixed to allow only two sets or the 
description be updated.

--
assignee: docs@python
components: Documentation
messages: 187899
nosy: Amit.Saha, docs@python
priority: normal
severity: normal
status: open
title: symmetric difference operation applicable to more than two sets
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



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

2013-04-27 Thread Antoine Pitrou

Antoine Pitrou added the comment:

There are actually several issues here:

* collection of globals at shutdown is wonky: you should add an explicit "del 
a,f; gc.collect()" at the end of the script

* order of tp_clear calls, or another issue with TextIOWrapper: if you open the 
file in binary mode ("f = open('...', 'wb'); f.write(b'bar')"), the data gets 
flushed during the GC run

--
nosy: +pitrou

___
Python tracker 

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



[issue17839] base64 module should use memoryview

2013-04-27 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Yes, this should probably be done the other way around: wrap the base64 
argument in a memoryview, and encode/decode from it.

--
nosy: +pitrou

___
Python tracker 

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



[issue17810] Implement PEP 3154 (pickle protocol 4)

2013-04-27 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> 1. Pack picked items in blocks of some predefined (or specified at the
> start with the BLOCKSIZE opcode) size. Only some large data (long
> strings, large integers) can cross the boundary between blocks. In all
> other cases the block should be padded with the NOP opcode.

Padding makes it both less efficient and more annoying to handle, IMO.
My framing proof-of-concept ends up quite simple in terms of code
complexity. For example, the C version only adds 125 lines of code in 3
additional functions.

> 2. A similar to your proposition, but frames should be declared with a
> special PREFETCH opcode (with 2- or 4-bytes argument). Large data
> pickled outside frames (this prevents doublecopying).

No doublecopying is necessary (not in the C version, that is). That
said, this is an interesting idea.

--

___
Python tracker 

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



[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Daniel Urban

Changes by Daniel Urban :


--
nosy: +daniel.urban

___
Python tracker 

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



[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman

Ethan Furman added the comment:

One more data point to truly demonstrate that something is wrong:


--> def test():
...   class Season(Enum):
... print(locals())
... Season = locals()['Season']
... print(locals())
...
--> test()
{'Season': , '__module__': '__main__', '__locals__': 
{...}}
{'Season': , '__module__': '__main__', '__locals__': 
{...}}


Notice the class name space *did not change in any way* before and after 
setting 'Season' manually.

--

___
Python tracker 

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



[issue17834] Add Heap (and DynamicHeap) classes to heapq module

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also rejected issue1162363.

--

___
Python tracker 

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



[issue17794] Add a key parameter to PriorityQueue

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Related issues: issue4356, issue13742.

See also issue1185383, issue1904 and issue1162363.

--
nosy: +serhiy.storchaka
title: Priority Queue -> Add a key parameter to PriorityQueue
type: behavior -> enhancement
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



[issue4424] Add support for a cmp, or key argument to heapq functions.

2013-04-27 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
superseder:  -> Add key argument to heapq functions
type:  -> enhancement

___
Python tracker 

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



[issue17853] class construction name resolution broken in functions

2013-04-27 Thread Ethan Furman

New submission from Ethan Furman:

In playing with metaclasses for the ongoing Enum saga, I tried having the 
metaclass insert an object into the custom dict (aka namespace) returned by 
__prepare__; this object has the same name as the to-be-created class.

An example:

class Season(Enum):
SPRING = Season()
SUMMER = Season()
AUTUMN = Season()
WINTER = Season()

When this executes as top level code it works beautifully.

However, if you have the exact same definition in a function, Bad Things happen:

---
--> def test():
...   class Season(Enum):
... SPRING = Season()
... 
--> test()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in test
  File "", line 3, in Season
NameError: free variable 'Season' referenced before assignment in enclosing 
scope
---

So I tried creating a dummy variable to see if it would be worked around:

---
--> def test():
...   Season = None
...   class Season(Enum):
... SPRING = Season()
... 
--> test()
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 3, in test
  File "", line 4, in Season
TypeError: 'NoneType' object is not callable
---

Finally I inserted the object using a different name, and also printed 
'locals()' just to see what was going on:

---
--> def test():
...   class Season(Enum):
... print(locals())
... SPRING = S()
... 
--> test()
{'S': , 'Season': , '__module__': 
'__main__', '__qualname__': 'test..Season', '__locals__': {...}}
---

and an actual (albeit extremely ugly) work around:

---
>>> def test():
...   class Season(Enum):
... Season = locals()['Season']
... SPRING = Season()
...   print(Season)
... 
>>> test()
Season(SPRING=1)
---

It seems that the function namespace is seriously messing with the class 
namespace.

--
components: Interpreter Core
messages: 187892
nosy: stoneleaf
priority: normal
severity: normal
status: open
title: class construction name resolution broken in functions
type: behavior
versions: Python 3.2, Python 3.3

___
Python tracker 

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



[issue17810] Implement PEP 3154 (pickle protocol 4)

2013-04-27 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I were thinking about framing before looking at your last changes to PEP 3154 
and I have two alternative propositions.

1. Pack picked items in blocks of some predefined (or specified at the start 
with the BLOCKSIZE opcode) size. Only some large data (long strings, large 
integers) can cross the boundary between blocks. In all other cases the block 
should be padded with the NOP opcode.

2. A similar to your proposition, but frames should be declared with a special 
PREFETCH opcode (with 2- or 4-bytes argument). Large data pickled outside 
frames (this prevents doublecopying). Opcode and size of large data object can 
(should?) be included in the previous frame.

--

___
Python tracker 

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



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

2013-04-27 Thread Armin Rigo

New submission from Armin Rigo:

In Python 2, a buffered file opened for writing is flushed by the C library 
when the process exit.  In Python 3, the _pyio and _io modules don't do it 
reliably.  They rely on __del__ being called, which is not neccesarily the 
case.  The attached example ends with the file 'foo' empty (tested with Python 
3.3 and the current trunk).  The same example in Python 2 using the built-in 
open() cannot end with 'foo' empty.

--
components: IO
files: y.py
messages: 187890
nosy: arigo
priority: normal
severity: normal
status: open
title: Built-in module _io can loose data from buffered files at exit
type: behavior
versions: Python 3.3, Python 3.4
Added file: http://bugs.python.org/file30030/y.py

___
Python tracker 

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



  1   2   >