[issue4356] Add "key" argument to "bisect" module functions

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Fixed in r84383.

--
resolution: duplicate -> 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



[issue9730] base64 docs refers to strings instead of bytes

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

The example can be fixed by placing a "b" before the two string literals.

However, pretty much the whole document refers to "strings" and should refer to 
"byte sequences" or the "bytes" type.

I thought there were automated tests that exercised the documentation examples. 
 Am I wrong about that?

--
nosy: +stutzbach
resolution:  -> accepted
stage:  -> needs patch
title: base64 encoding takes in bytes rather than string. -> base64 docs refers 
to strings instead of bytes
versions: +Python 3.2

___
Python tracker 

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



[issue7877] Iterators over _winreg EnumKey and EnumValue results

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

As most of the code in this patch was copied from EnumValue and EnumKey, it 
includes bugs from those functions that have since been fixed.  I'm thinking of 
Issue #2810, although there might have been other changes.

Instead of duplicating code, it would be better to abstract out some of the 
common elements so that in the future changes only need to be made in one place.

While winreg isn't very Pythonic, I imagine most users write a simple wrapper 
around the functions to give it a more Pythonic feel.  I have been using a 
home-brewed class that implements the MutableMapping ABC.  I just posted it as 
a recipe on ActiveState:

http://code.activestate.com/recipes/577381-collectionsmutablemapping-wrapper-around-_winreg/

--
nosy: +stutzbach

___
Python tracker 

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



[issue8743] set() operators don't work with collections.Set instances

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Raymond, do you agree with Ray's analysis?

--

___
Python tracker 

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



[issue9729] Unconnected SSLSocket.{send, recv} raises TypeError: 'member_descriptor' object is not callable

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Note that 3.x will give you the expected error message:
>>> s = socket.socket()
>>> wrapped = ssl.wrap_socket(s)
>>> wrapped.recv(1)
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/antoine/py3k/__svn__/Lib/ssl.py", line 292, in recv
return socket.recv(self, buflen, flags)
socket.error: [Errno 107] Transport endpoint is not connected

Do you have any idea how to solve it for 2.7? Do you want to provide a patch?

--
components: +Library (Lib)
nosy: +pitrou
stage:  -> needs patch
versions:  -Python 2.6

___
Python tracker 

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



[issue9731] ABCMeta.register should verify that methods are present

2010-09-01 Thread Daniel Stutzbach

New submission from Daniel Stutzbach :

In Issue 9212, I mused:

> I sort of wonder if .register() should verify that the concrete class
> provides all of the methods of the ABC.

Éric Araujo suggested I open that as an issue for consideration.  

I have found a few bugs in the standard library where a concrete class did not 
actually implement all of the methods of the ABC that it purported to 
implement.  Specifically:

dict's keys view claims to implement the Set ABC but doesn't provide the 
is_disjoint method (Issue 9212)

range objects claims to support the Sequence ABC but don't provide the count 
and index methods (Issue 9213)

Should ABCMeta.register verify that the type implements all of the appropriate 
methods?

On the one hand, that would prevent similar bugs from sneaking by.  On the 
other hand, it's extra code that would get executed every time Python started 
(site.py imports os.py which imports _abcoll.py).

Thoughts?

--
components: Library (Lib)
messages: 115293
nosy: benjamin.peterson, eric.araujo, gvanrossum, stutzbach
priority: normal
severity: normal
status: open
title: ABCMeta.register should verify that methods are present
type: feature request
versions: Python 3.2

___
Python tracker 

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



[issue3101] global function _add_one_to_index_C

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I've added a "_Py" prefix in r84391, and also made the `shape` argument const. 
If numpy people want this to be an official public API, they'll have to 
contribute. Thanks.

--
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed
versions: +Python 2.7, Python 3.1, Python 3.2 -Python 3.0

___
Python tracker 

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



[issue8685] set(range(100000)).difference(set()) is slow

2010-09-01 Thread Jean-Paul Calderone

Jean-Paul Calderone  added the comment:

> I'll be looking at it shortly.  Py3.2 is still aways from release so there is 
> no hurry.

I would consider reviewing and possibly apply this change, but I don't want to 
invade anyone's territory.

--
nosy: +exarkun

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

New submission from Michael Foord :

As discussed on python-dev, a version of getattr that does static lookups - 
bypassing the descriptor protocol, __getattr__, and __getattribute__. Initial 
implementation by Nick Coghlan, amended and tests added by me.

Phillip Eby objects to this code existing at all as it doesn't play well with 
proxy objects.

The purpose of getattr_static is for "passive introspection" without triggering 
code execution (as hasattr and getattr both do). Use cases include debugging 
and fetching docstrings from objects.

Caveats with the current implementation are:

Cases that will break `getattr_static`, all pathological enough not
to worry about (i.e. if you do any of these then you deserve to
have everything break anyway):

* `__dict__` existing (e.g. as a property) but not returning a
  dictionary
* classes created with `__slots__` that then have the `__slots__`
  member deleted from the class (or otherwise monkeyed with)

Cases handled incorrectly:

1. where a descriptor with a `__set__` method is shadowed by an
   instance member we return the instance member in preference to
   the descriptor, unlike `getattr`
2. types implemented in C may have neither `__dict__` nor `__slots__`,
   in this case we will be unable to find instance members and return
   the attribute descriptor instead
3. classes that inherit from a class with `__slots__` (whether or not
   they use `__slots__` themselves) will return the slot descriptor
   for instance members 'owned' by a slot on a base class
4. objects that lie about being a type by having __class__ as a
   descriptor (we traverse the mro of whatever type `obj.__class__`
   returns instead of the real type)

1 could be fixed but the code would be annoying. Is it worth fixing?

2 could be detected and where fetching an attribute from an instance
fails but an attribute descriptor is found on the type we could try
it's __get__ method. Worth it?

3 could be detected if we find a slot descriptor on a type trying
its __get__ method. Worth it?

4 could be fixed by using type everywhere instead of __class__.
We also can't use isinstance that uses __class__. If an object
is lying about __class__ then it obviously *intends* us to look
at the 'faked' version. However, this breaks the 'no code
execution' purpose of getattr_static and is inconsistent with
the rest of our behaviour. Worth fixing?

Fixing *all* of these (or any) will significantly complicate the
implimentation. 

Fetching an uninitialized instance member from an instance of a class
with __slots__ returns the slot descriptor rather than raising an
AttributeError as the descriptor does. As the slot descriptor is
a Python implementation detail perhaps we are better off propagating
the exception here. (?) On the other hand, the descriptor is
available on the class and the job of this function is to fetch
members when they are available...

I'm not aware of any other caveats / potential pitfalls. Please
point them out to me. :-)Cases that will break `getattr_static`, all 
pathological enough not
to worry about (i.e. if you do any of these then you deserve to
have everything break anyway):

* `__dict__` existing (e.g. as a property) but not returning a
  dictionary
* classes created with `__slots__` that then have the `__slots__`
  member deleted from the class (or otherwise monkeyed with)

Cases handled incorrectly:

1. where a descriptor with a `__set__` method is shadowed by an
   instance member we return the instance member in preference to
   the descriptor, unlike `getattr`
2. types implemented in C may have neither `__dict__` nor `__slots__`,
   in this case we will be unable to find instance members and return
   the attribute descriptor instead
3. classes that inherit from a class with `__slots__` (whether or not
   they use `__slots__` themselves) will return the slot descriptor
   for instance members 'owned' by a slot on a base class
4. objects that lie about being a type by having __class__ as a
   descriptor (we traverse the mro of whatever type `obj.__class__`
   returns instead of the real type)

1 could be fixed but the code would be annoying. Is it worth fixing?

2 could be detected and where fetching an attribute from an instance
fails but an attribute descriptor is found on the type we could try
it's __get__ method. Worth it?

3 could be detected if we find a slot descriptor on a type trying
its __get__ method. Worth it?

4 could be fixed by using type everywhere instead of __class__.
We also can't use isinstance that uses __class__. If an object
is lying about __class__ then it obviously *intends* us to look
at the 'faked' version. However, this breaks the 'no code
execution' purpose of getattr_static and is inconsistent with
the rest of our behaviour. Worth fixing?

Fixing *all* of these (or any) will significantly complicate the
implimentation. 

Fetching an uninitialized instance member from an instance of a class
with __slots__ returns the slot descriptor rather than ra

[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Michael Foord  added the comment:

Tests require Python 3. Implementation works with Python 2 as well.

--
Added file: http://bugs.python.org/file18700/test_static.py

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Changes by Michael Foord :


Removed file: http://bugs.python.org/file18700/test_static.py

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Changes by Michael Foord :


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

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Michael Foord  added the comment:

Tests require Python 3. Implementation works with Python 2 as well.

--
Added file: http://bugs.python.org/file18701/test_static.py

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

+1 on the principle. This could help things like pydoc, especially on modern 
Web frameworks which do incredibly ugly things (per-thread global variables, 
descriptors executing tons of code etc.).

--
nosy: +pitrou

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Changes by Michael Foord :


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

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Michael Foord  added the comment:

(Reposted as text was entirely duplicated - oops.)

As discussed on python-dev, a version of getattr that does static lookups - 
bypassing the descriptor protocol, __getattr__, and __getattribute__. Initial 
implementation by Nick Coghlan, amended and tests added by me.

Phillip Eby objects to this code existing at all as it doesn't play well with 
proxy objects.

The purpose of getattr_static is for "passive introspection" without triggering 
code execution (as hasattr and getattr both do). Use cases include debugging 
and fetching docstrings from objects.

Caveats with the current implementation are:

Cases that will break `getattr_static`, all pathological enough not
to worry about (i.e. if you do any of these then you deserve to
have everything break anyway):

* `__dict__` existing (e.g. as a property) but not returning a
  dictionary
* classes created with `__slots__` that then have the `__slots__`
  member deleted from the class (or otherwise monkeyed with)

Cases handled incorrectly:

1. where a descriptor with a `__set__` method is shadowed by an
   instance member we return the instance member in preference to
   the descriptor, unlike `getattr`
2. types implemented in C may have neither `__dict__` nor `__slots__`,
   in this case we will be unable to find instance members and return
   the attribute descriptor instead
3. classes that inherit from a class with `__slots__` (whether or not
   they use `__slots__` themselves) will return the slot descriptor
   for instance members 'owned' by a slot on a base class
4. objects that lie about being a type by having __class__ as a
   descriptor (we traverse the mro of whatever type `obj.__class__`
   returns instead of the real type)

1 could be fixed but the code would be annoying. Is it worth fixing?

2 could be detected and where fetching an attribute from an instance
fails but an attribute descriptor is found on the type we could try
it's __get__ method. Worth it?

3 could be detected if we find a slot descriptor on a type trying
its __get__ method. Worth it?

4 could be fixed by using type everywhere instead of __class__.
We also can't use isinstance that uses __class__. If an object
is lying about __class__ then it obviously *intends* us to look
at the 'faked' version. However, this breaks the 'no code
execution' purpose of getattr_static and is inconsistent with
the rest of our behaviour. Worth fixing?

Fixing *all* of these (or any) will significantly complicate the
implimentation. 

Fetching an uninitialized instance member from an instance of a class
with __slots__ returns the slot descriptor rather than raising an
AttributeError as the descriptor does. As the slot descriptor is
a Python implementation detail perhaps we are better off propagating
the exception here. (?) On the other hand, the descriptor is
available on the class and the job of this function is to fetch
members when they are available...

I'm not aware of any other caveats / potential pitfalls. Please
point them out to me. :-)

--

___
Python tracker 

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



[issue9212] dict_keys purports to implement the Set ABC, but is missing the isdisjoint method

2010-09-01 Thread Daniel Urban

Daniel Urban  added the comment:

Thanks for the corrections.  I'm attaching the new patch as issue9212b.diff.  
I'm using PyAnySet_Check to determine if the other argument is really a set, 
but I'm not entirely sure, that this is correct. Please let me know if other 
corrections are needed.

--
Added file: http://bugs.python.org/file18702/issue9212b.diff

___
Python tracker 

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



[issue9733] Can't iterate over multiprocessing.managers.DictProxy

2010-09-01 Thread Juan José Conti

New submission from Juan José Conti :

I expected I could iterate over a DictProxy as I do over a regular dict.

>>> from multiprocessing import Manager
>>> m = Manager()
>>> d = m.dict()
>>> d

>>> for x in d:
... print x
...
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in __getitem__
  File "/usr/lib/python2.6/multiprocessing/managers.py", line 740, in 
_callmethod
raise convert_to_error(kind, result)
KeyError: 0
>>> d['a'] = 1
>>> for x in d:
... print x
...
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 2, in __getitem__
  File "/usr/lib/python2.6/multiprocessing/managers.py", line 740, in 
_callmethod
raise convert_to_error(kind, result)
KeyError: 0

--
components: Library (Lib)
messages: 115302
nosy: jjconti
priority: normal
severity: normal
status: open
title: Can't iterate over multiprocessing.managers.DictProxy
versions: Python 2.6, Python 2.7

___
Python tracker 

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



[issue9549] Remove sys.setdefaultencoding()

2010-09-01 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +haypo

___
Python tracker 

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



[issue9711] ssl.SSLSocket's keyfile argument seems to be ignored if specified without certfile

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

I'm not sure which commit it is, but test_ssl has started failing on some 
buildbots:

==
ERROR: test_errors (test.test_ssl.BasicSocketTests)
--
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 186, in test_errors
s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/ssl.py", line 414, 
in wrap_socket
ciphers=ciphers)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/ssl.py", line 137, 
in __init__
self.context.load_cert_chain(certfile, keyfile)
ssl.SSLError: [Errno 185057381] _ssl.c:1609: error:0B07C065:x509 certificate 
routines:X509_STORE_add_cert:cert already in hash table

==
ERROR: test_protocol_sslv2 (test.test_ssl.ThreadedTests)
Connecting to an SSLv2 server with various client options
--
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 80, in f
return func(*args, **kwargs)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 1100, in test_protocol_sslv2
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 969, in try_protocol_combo
ctx.load_cert_chain(CERTFILE)
ssl.SSLError: [Errno 336445442] _ssl.c:1609: error:140DC002:SSL 
routines:SSL_CTX_use_certificate_chain_file:system lib

See e.g. 
http://www.python.org/dev/buildbot/builders/x86%20Ubuntu%203.x/builds/1870

--
assignee:  -> giampaolo.rodola
status: closed -> open

___
Python tracker 

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



[issue5506] io.BytesIO doesn't support the buffer protocol

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Thinking about it, I'm not sure this would be a good idea to do this by 
default. There is an ambiguity where it's not obvious if the buffer would 
contain the whole data or only the bytes after the current position.

I think perhaps an explicit method (getbuffer()?) could be used to export a 
buffer-compatible object, without copying. Perhaps a memoryview; this would 
imply defining bf_releasebuffer without bf_getbuffer.

--
stage: unit test needed -> needs patch

___
Python tracker 

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



[issue9731] ABCMeta.register should verify that methods are present

2010-09-01 Thread Guido van Rossum

Guido van Rossum  added the comment:

That would be too hard-headed. A complaint I often hear about Interfaces in 
Java is that classes have a hard time if they choose not to implement a certain 
method. It also would not be enough -- there are tons of ways you would be able 
to satisfy such a check to the letter while still breaking any call.

It may be a good idea for a lint-style tool to warn about these though.

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



[issue9711] ssl.SSLSocket's keyfile argument seems to be ignored if specified without certfile

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Actually, it started failing exactly after r84352 (issue #9706).

--
status: open -> closed

___
Python tracker 

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



[issue9706] ssl errors checking

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Some buildbots have started failing exactly after this commit:

==
ERROR: test_errors (test.test_ssl.BasicSocketTests)
--
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 186, in test_errors
s = ssl.wrap_socket(sock, server_side=True, certfile=CERTFILE)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/ssl.py", line 414, 
in wrap_socket
ciphers=ciphers)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/ssl.py", line 137, 
in __init__
self.context.load_cert_chain(certfile, keyfile)
ssl.SSLError: [Errno 185057381] _ssl.c:1609: error:0B07C065:x509 certificate 
routines:X509_STORE_add_cert:cert already in hash table

==
ERROR: test_protocol_sslv2 (test.test_ssl.ThreadedTests)
Connecting to an SSLv2 server with various client options
--
Traceback (most recent call last):
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 80, in f
return func(*args, **kwargs)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 1100, in test_protocol_sslv2
try_protocol_combo(ssl.PROTOCOL_SSLv2, ssl.PROTOCOL_SSLv2, True)
  File "/srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/test_ssl.py", 
line 969, in try_protocol_combo
ctx.load_cert_chain(CERTFILE)
ssl.SSLError: [Errno 336445442] _ssl.c:1609: error:140DC002:SSL 
routines:SSL_CTX_use_certificate_chain_file:system lib

See e.g. 
http://www.python.org/dev/buildbot/builders/x86%20Ubuntu%203.x/builds/1870

This is probably dependent on the OpenSSL version.

--
status: closed -> open

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Guido van Rossum

Guido van Rossum  added the comment:

Just jumping in here with commentary from the side bench... I noticed you say 
"this does not always return the same results as dir(x)". But since dir(x) 
exists, perhaps it would make sense to match dir(x) as closely as possible? 
I.e. if dir(x) doesn't know about it, don't return it, if dir(x) does know 
about it, do return it? Those would be ease rules to remember for sure.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue9731] ABCMeta.register should verify that methods are present

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Would it be useful to provide a separate function to perform the check, which 
could be used by lint-style tools as well as automated tests?

It would be great if every call to .register in the standard library had a 
corresponding test that verified that the appropriate methods were defined.  
That would prevent future oversights where methods are missing entirely.

--

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Michael Foord  added the comment:

Since the addition of __dir__, dir(obj) can return arbitrary values. Typically 
(I guess) this will be used to add dynamically created attributes that this 
function will fail to find - so it is *more* likely that we will fail to find 
something in dir than the reverse.

__dir__ could also be  used to filter non-public members that getattr(...) 
would find. I would find it odd that getattr finds a member that exists but 
this function fails. I think this function is more akin to getattr than dir.

Perhaps a better warning would be that this function may fail to find members 
that getattr finds?

--

___
Python tracker 

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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Michael Foord

Michael Foord  added the comment:

(Or vice versa - getattr_static may succeed in finding members - like 
descriptors that raise AttributeError when fetched - when getattr fails.)

--

___
Python tracker 

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



[issue9731] ABCMeta.register should verify that methods are present

2010-09-01 Thread Guido van Rossum

Guido van Rossum  added the comment:

> Would it be useful to provide a separate function to perform the check, which 
> could be used by lint-style tools as well as automated tests?
>
> It would be great if every call to .register in the standard library had a 
> corresponding test that verified that the appropriate methods were defined.  
> That would prevent future oversights where methods are missing entirely.

Yeah, that makes sense. You could put those checks in the unittests.

--

___
Python tracker 

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



[issue7415] PyUnicode_FromEncodedObject() uses PyObject_AsCharBuffer()

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Patch committed in r84394 (py3k) and r84396 (3.1). Thank you Stefan!

--
resolution:  -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
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



[issue9732] Addition of getattr_static for inspect module

2010-09-01 Thread Guido van Rossum

Guido van Rossum  added the comment:

> Since the addition of __dir__, dir(obj) can return arbitrary values. 
> Typically (I guess) this will be used to add dynamically created attributes 
> that this function will fail to find - so it is *more* likely that we will 
> fail to find something in dir than the reverse.
>
> __dir__ could also be  used to filter non-public members that getattr(...) 
> would find. I would find it odd that getattr finds a member that exists but 
> this function fails. I think this function is more akin to getattr than dir.

Gotcha.

> Perhaps a better warning would be that this function may fail to find members 
> that getattr finds?

Ah, yes, and vice versa (well, just yesterday I wrote a descriptor
that always raises AttributeError :-).

--

___
Python tracker 

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



[issue8685] set(range(100000)).difference(set()) is slow

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> I would consider reviewing and possibly apply this change, but I don't 
> want to invade anyone's territory.

I don't think there would be any invasion. I think the patch is simple enough, 
and seems to provide a nice benefit.

--

___
Python tracker 

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



[issue9731] Add ABCMeta.has_methods and tests that use it

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Re-opening and re-titling the issue to that effect.

Proposed syntax and usage:

# in Lib/abc.py
class ABCMeta(type):
# ...

def has_methods(cls, subclass):
"Returns True iff subclass implements the appropriate methods"
# ...

Usage within the unit tests:

# In Lib/test/test_collections.py
def test_methods(self):
self.assertTrue(Sequence.has_methods(range))
self.assertTrue(MutableSet.has_methods(set))
# ... and many more

--
assignee:  -> stutzbach
components: +Tests
resolution: rejected -> accepted
stage:  -> needs patch
status: closed -> open
title: ABCMeta.register should verify that methods are present -> Add 
ABCMeta.has_methods and tests that use it

___
Python tracker 

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



[issue9042] Gettext cache and classes

2010-09-01 Thread v_peter

v_peter  added the comment:

Any comments on the patch for 3.2?

--

___
Python tracker 

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



[issue9549] Remove sys.setdefaultencoding()

2010-09-01 Thread STINNER Victor

STINNER Victor  added the comment:

Ok to remove it from Python 3.2. I don't think that it is necessary to update 
Python 2.7 code/doc.

--

___
Python tracker 

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



[issue8685] set(range(100000)).difference(set()) is slow

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Please leave this for me.
Thank you.

--

___
Python tracker 

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



[issue9549] Remove sys.setdefaultencoding()

2010-09-01 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis :


--
nosy: +Arfrever

___
Python tracker 

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



[issue9212] dict_keys purports to implement the Set ABC, but is missing the isdisjoint method

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

It would be nice to get this fixed before the next release.

--

___
Python tracker 

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



[issue9731] Add ABCMeta.has_methods and tests that use it

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

+1 for the basic idea.

It could use a better name, Sequence.has_methods(range) reads backwards to me.  
Perhaps something like:  Sequence.implemented_by(range) or 
Sequence.verify_full_api(range) or some such.

Also, when the tests get added, they should go in the test file for the 
implementing class (like test_range for example.)

--
nosy: +rhettinger

___
Python tracker 

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



[issue9212] dict_keys purports to implement the Set ABC, but is missing the isdisjoint method

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

I will aim to spend some time with this (and the similar Issue #9213) today 
and/or tomorrow, so that it can be committed in time for 3.2a2.

--
resolution:  -> accepted
stage: unit test needed -> patch review

___
Python tracker 

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



[issue9734] ABC issubclass/isinstance leaks in Python 2

2010-09-01 Thread Jim Fulton

New submission from Jim Fulton :

I assume ABCs use some sort of cache for issubclass checks.

I also assume the cache doesn't use weakrefs, leading to leaks in classes 
created on the fly (as is common in tests).

The attached script demonstrates the leak.

The leak doesn't seem to occur in Python 3.1.2.

--
files: abc_issubclass_leak.py
messages: 115323
nosy: j1m
priority: normal
severity: normal
status: open
title: ABC issubclass/isinstance leaks in Python 2
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file18703/abc_issubclass_leak.py

___
Python tracker 

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



[issue9549] Remove sys.setdefaultencoding()

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Done in r84397.

--
resolution:  -> fixed
stage: needs patch -> committed/rejected
status: open -> closed
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



[issue9735] cheatsheet outdated

2010-09-01 Thread Antoine Pitrou

New submission from Antoine Pitrou :

The Misc/cheatsheet file is totally outdated (the title “Python 2.3 Quick 
Reference” already gives you a hint).
It is also not clear if it is meant for plain text viewing, or should be 
formatted using an external program...

--
assignee: d...@python
components: Documentation
messages: 115325
nosy: d...@python, pitrou, rhettinger
priority: normal
severity: normal
stage: needs patch
status: open
title: cheatsheet outdated
type: behavior
versions: Python 2.7, 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



[issue9736] doctest.DocTestSuite doesn't handle test globs correctly

2010-09-01 Thread Jim Fulton

New submission from Jim Fulton :

We often run test suites repeatedly using a debug build of python
to look for memory leaks.

We also got in the bad habit of using a fork of doctest. Recently, we've 
switched away from our fork and have noticed a problem with the standard 
doctest's handling of test globs (globals).

DocTestSuite gets an initial set of globals from the module the doctest's came 
from.  After running the tests, it seems to clear these, leading to errors if 
the tests are run again.

I've attached a script that illustrates the problem.  The script runs a simple 
test twice and gets a spurious failure the second time.

--
components: Library (Lib)
files: doctest_DocTestSuite_globs_breakage.py
messages: 115326
nosy: j1m
priority: normal
severity: normal
status: open
title: doctest.DocTestSuite doesn't handle test globs correctly
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1
Added file: 
http://bugs.python.org/file18704/doctest_DocTestSuite_globs_breakage.py

___
Python tracker 

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



[issue9733] Can't iterate over multiprocessing.managers.DictProxy

2010-09-01 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
assignee:  -> jnoller
nosy: +jnoller
stage:  -> needs patch
type:  -> behavior
versions: +Python 3.1, Python 3.2 -Python 2.6

___
Python tracker 

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



[issue9116] test_capi.test_no_FatalError_infinite_loop crash on Windows

2010-09-01 Thread Éric Araujo

Changes by Éric Araujo :


--
keywords:  -patch

___
Python tracker 

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



[issue9735] cheatsheet outdated

2010-09-01 Thread Éric Araujo

Changes by Éric Araujo :


--
resolution:  -> duplicate
stage: needs patch -> committed/rejected
status: open -> closed
superseder:  -> Misc/cheatsheet needs updating

___
Python tracker 

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



[issue4819] Misc/cheatsheet needs updating

2010-09-01 Thread Éric Araujo

Éric Araujo  added the comment:

Merging nosy from duplicate report.

--
nosy: +pitrou, rhettinger

___
Python tracker 

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



[issue4819] Misc/cheatsheet needs updating

2010-09-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
nosy:  -rhettinger

___
Python tracker 

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



[issue9706] ssl errors checking

2010-09-01 Thread Giampaolo Rodola'

Giampaolo Rodola'  added the comment:

Committed r84400 which should fix the first test failure.
I'll take a look at the buildbots to see how it goes.
As for the second failure I have no idea at the moment.

--

___
Python tracker 

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



[issue1552880] Unicode Imports

2010-09-01 Thread STINNER Victor

STINNER Victor  added the comment:

> According to the Unicode standard the high and low surrogate halves used
> by UTF-16 (...)

Yes, but in Python, U+DC80..D+DCFF range is used to store undecodable bytes. 
Eg. 'abc\xff'.decode('ascii', 'surrogateescape') gives 'abc\udcff'.

> Anyway, as you remark, my approach is a _patch_, designed to make python
> (2.x) work in an unicode environment, with the least amount of code
> change, for those willing to commit such a patch.

Python 2.7 is out and I think it is too late to fix Python2. Anyway, Python2 
uses bytes for sys.path or other paths, so the problem only occurs if the user 
specifies unicode paths.

> In 3.x you may want to do things differently.

I choosed to rewrite the C code to manipulate unicode paths instead of byte 
paths => #9425

--

___
Python tracker 

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



[issue1552880] Unicode Imports

2010-09-01 Thread Éric Araujo

Changes by Éric Araujo :


--
nosy: +eric.araujo

___
Python tracker 

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



[issue8685] set(range(100000)).difference(set()) is slow

2010-09-01 Thread Jean-Paul Calderone

Changes by Jean-Paul Calderone :


--
nosy:  -exarkun

___
Python tracker 

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



[issue1856] shutdown (exit) can hang or segfault with daemon threads running

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

It is certainly still a problem with 3.x, but I don't find a way to exhibit it 
here.

--
nosy: +pitrou
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



[issue4111] Add Systemtap/DTrace probes

2010-09-01 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue9729] Unconnected SSLSocket.{send, recv} raises TypeError: 'member_descriptor' object is not callable

2010-09-01 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue8990] array constructor and array.fromstring should accept bytearray.

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

The patches were committed in r84403. Thank you very much!

--
resolution:  -> fixed
stage: unit test needed -> committed/rejected
status: open -> closed
versions:  -Python 3.1

___
Python tracker 

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



[issue9677] "Global Module Index" link dead

2010-09-01 Thread Georg Brandl

Georg Brandl  added the comment:

Fixed in r84407.

--
nosy: +georg.brandl
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



[issue9737] Del on memoryview crashes CPython

2010-09-01 Thread Dino Viehland

New submission from Dino Viehland :

x = bytearray(b'abc')
y = memoryview(x)
del y[0:1]

This crashes CPython 3.1.1 and 2.7.

--
components: Interpreter Core
messages: 115333
nosy: dino.viehland
priority: normal
severity: normal
status: open
title: Del on memoryview crashes CPython
type: crash
versions: Python 2.7, Python 3.1

___
Python tracker 

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



[issue9737] Del on memoryview crashes CPython

2010-09-01 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Nice catch, thank you. I've fixed it in r84408 (py3k), r84410 (3.1) and r84411 
(2.7).

--
nosy: +pitrou

___
Python tracker 

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



[issue9737] Del on memoryview crashes CPython

2010-09-01 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
resolution:  -> fixed
stage:  -> committed/rejected
status: open -> closed
versions: +Python 3.2

___
Python tracker 

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



[issue1856] shutdown (exit) can hang or segfault with daemon threads running

2010-09-01 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue8685] set(range(100000)).difference(set()) is slow

2010-09-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

___
Python tracker 

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



[issue8425] a -= b should be fast if a is a small set and b is a large set

2010-09-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

___
Python tracker 

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



[issue2986] difflib.SequenceMatcher not matching long sequences

2010-09-01 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

While refactoring the code for 2.7, I discovered that the description of the 
heuristic for 2.6 and in the code comments is off by 1. "items that appear more 
than 1% of the time" should actually be "items whose duplicates (after the 
first) appear more than 1% of the time". The discrepancy arises because in the 
following code

for i, elt in enumerate(b):
if elt in b2j:
indices = b2j[elt]
if n >= 200 and len(indices) * 100 > n:
populardict[elt] = 1
del indices[:]
else:
indices.append(i)
else:
b2j[elt] = [i]

len(indices) is retrieved *before* the index i of the current elt is added. 
Whatever one might think the heuristic 'should' have been (and by the nature of 
heuristics, there is no right answer), the default behavior must remain as it 
is, so we adjusted the code and doc to match that.

--

___
Python tracker 

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



[issue2459] speedup for / while / if with better bytecode

2010-09-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

___
Python tracker 

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



[issue9155] Reserve COMPARE_OP for rich comparisons

2010-09-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

___
Python tracker 

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



[issue1569291] Speed-up in array_repeat()

2010-09-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

___
Python tracker 

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



[issue9695] Return from generators in Python 3.2

2010-09-01 Thread Georg Brandl

Georg Brandl  added the comment:

Uh, if I understand correctly, this is akin to what PEP 380 does with generator 
returns, just with a different exception.

As such, if I'm not mistaken, it is a) a new language feature for after the 
moratorium and b) needs a competing PEP.

--
nosy: +georg.brandl
resolution:  -> 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



[issue2690] Precompute range length

2010-09-01 Thread Daniel Stutzbach

Changes by Daniel Stutzbach :


--
nosy: +stutzbach

___
Python tracker 

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



[issue5362] Add configure option to disable Py3k warnings

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Since this issue doesn't apply in Python 3 and (as I understand it) the 2.7 
branch is only open to bug fixes, can we close this performance issue?

--
nosy: +stutzbach

___
Python tracker 

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



[issue5362] Add configure option to disable Py3k warnings

2010-09-01 Thread Brett Cannon

Changes by Brett Cannon :


--
resolution:  -> out of date
status: open -> closed

___
Python tracker 

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



[issue2690] Precompute range length

2010-09-01 Thread Guido van Rossum

Changes by Guido van Rossum :


--
nosy:  -gvanrossum

___
Python tracker 

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



[issue9042] Gettext cache and classes

2010-09-01 Thread Éric Araujo

Éric Araujo  added the comment:

Relying on str(cls) breaks if two classes have the same name, but I guess this 
is not a concern outside of the interactive interpreter. Patch looks good to me.

--
stage:  -> patch review

___
Python tracker 

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



[issue9738] Document the encoding of functions bytes arguments of the C API

2010-09-01 Thread STINNER Victor

New submission from STINNER Victor :

Many C functions have bytes argument (char* type) but the encoding is not 
documented. If would not be a problem if the encoding was always the same, but 
it is not. Examples:
 - format of PyUnicode_FromFormat() should be encoded as ISO-8859-1
 - filename of PyParser_ASTFromString() should be encoded as utf-8
 - filename of PyErr_SetFromErrnoWithFilename() should be encoded to the 
filesystem encoding (with strict error handler, and not surrogateescape)
 - 's' argument of PyParser_ASTFromString() should be encoded as utf-8 if 
PyPARSE_IGNORE_COOKIE flag is set, otherwise the parser checks for #coding:xxx 
cookie (if there is no cookie, utf-8 is used)

Attached patch is a try to document most low level functions. I choosed to add 
the name of function arguments in the headers because I consider that a header 
can be used as a quick documentation. I only touched .c files to change 
argument names.

It is hard to get the right encoding, so I cannot ensure that my patch is 
correct. My patch is just a draft.

I don't know if "encoded to utf-8" is the right expression. Or should it be 
"decoded as utf-8"?

--
assignee: d...@python
components: Documentation, Interpreter Core, Unicode
files: encodings.patch
keywords: patch
messages: 115339
nosy: d...@python, haypo
priority: normal
severity: normal
status: open
title: Document the encoding of functions bytes arguments of the C API
versions: Python 3.2
Added file: http://bugs.python.org/file18705/encodings.patch

___
Python tracker 

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



[issue2340] Backport PEP 3132 (extended iterable unpacking)

2010-09-01 Thread ipatrol

ipatrol  added the comment:

Can this be added in a minor release? I came across wanting it while parsing 
some html forms.

--
nosy: +ipatrol

___
Python tracker 

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



[issue9042] Gettext cache and classes

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

The patch looks fine.

--
nosy: +rhettinger
resolution:  -> accepted

___
Python tracker 

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



[issue2340] Backport PEP 3132 (extended iterable unpacking)

2010-09-01 Thread Brett Cannon

Brett Cannon  added the comment:

No, only bugfixes can go into Python 2.7.

--

___
Python tracker 

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



[issue9425] Rewrite import machinery to work with unicode paths

2010-09-01 Thread STINNER Victor

STINNER Victor  added the comment:

r84429 creates Py_UNICODE_strcat() (change with the patch: return the right 
value).

r84430 creates PyUnicode_strdup() (change with the patch: rename the function 
from Py_UNICODE_strdup() to PyUnicode_strdup() and mangle the function name).

--

___
Python tracker 

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



[issue9425] Rewrite import machinery to work with unicode paths

2010-09-01 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file18672/Py_UNICODE_strdup.patch

___
Python tracker 

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



[issue9425] Rewrite import machinery to work with unicode paths

2010-09-01 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file18671/Py_UNICODE_strcat.patch

___
Python tracker 

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



[issue8743] set() operators don't work with collections.Set instances

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

The operator methods in setobject.c should be liberalized to accept instances 
of collections.Set as arguments.  For speed, they should continue to check 
PyAnySet_Check(other) first and then if that fails, fall back to testing 
PyObject_IsInstance(other, collections.Set).  

Internally, the set methods will still need to process "other" as just an 
iterable container because it cannot rely on elements in "other" as being 
hashable (for example, the ListBasedSet in the docs does not require 
hashability) or unique (as perceived by setobject.c it may not work with some 
set implementing a key-function for an equivalence class whose key-function 
would be unknown to setobject.c which relies on __hash__ and __eq__).

To implement PyObject_IsInstance(other, collections.Set), there may be a 
bootstrap issue (with the C code being compiled and runnable before _abcoll.py 
is able to create the Set ABC).  If so, it may be necessary to create an 
internal _BaseSet object in setobject.c that can be used in collections.Set.  
Alternatively, the code in setobject.c can lazily (at runtime) lookup 
collections.Set by name and cache it so that we only do one successful lookup 
per session.

Whatever approach is taken, it should be done with an eye towards the larger 
problem that Python is filled with concrete isinstance() checks that pre-date 
ABCs and many of those need to be liberalized (accepting a registered ABC and 
providing different execution paths for known and unknown concrete types).

--
stage: unit test needed -> needs patch

___
Python tracker 

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



[issue9155] Reserve COMPARE_OP for rich comparisons

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

I'm marking this one as rejected.  The timings have shown mixed results (some 
favorable, some not).  In general, there is a bias against expanding the number 
of opcodes because 1) there aren't that many codes available, 2) it grows the 
size of the switch-case (which has been problematic from some compilers on 
various systems), and because it complicates other optimization efforts such as 
the peephole optimizer or in other tools that depend on bytecode (such as the 
Unladen Swallow LLVM project, Psyco, or ByteCodeHacks). 

Also, the potential improvement is very small because it removes only one 
indirection out of long chain of events involved in a comparison.  Most of the 
time is consumed in abstract dispatch to a concrete comparison method and it 
that method itself.

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



[issue9634] Add timeout parameter to Queue.join()

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Kelly, thanks for posting the idea.
I'm going to close this one for now
but it can be reopened if compelling
use cases arise.

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



[issue7796] No way to find out if an object is an instance of a namedtuple

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Am deferring this to Py3.3.  There is a workaround available just using 
duck-typing and I would like to wait until more more has been done on StructSeq 
before setting committing to an new namedtuple Abstract Base Class (one 
released, it would be very hard to change).  Also, I would like to see how 
pprint() evolves (because it may also want to have special handling for named 
tuples).

--
priority: high -> low
resolution:  -> later
versions: +Python 3.3 -Python 2.7, Python 3.2

___
Python tracker 

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



[issue1818] Add named tuple reader to CSV module

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Unassigning, this needs fresh thought and a fresh patch from someone who can 
devote a little deep thinking on how to solve this problem cleanly.  In the 
meantime, it is no problem to simply cast the CSV tuples into named tuples.

--
assignee: rhettinger -> 
priority: normal -> low
stage: patch review -> needs patch
versions:  -Python 3.2

___
Python tracker 

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



[issue9269] Cannot pickle self-referencing sets

2010-09-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
priority: normal -> low

___
Python tracker 

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



[issue6133] LOAD_CONST followed by LOAD_ATTR can be optimized to just be a LOAD_CONST

2010-09-01 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

This proposal hasn't gotten much love or support and I'm no longer interested 
in it.  Aside from ''.join and '{}'.format, there doesn't seem to be many 
common cases, so there's no big win here.

--
assignee: rhettinger -> 
resolution:  -> later
versions: +Python 3.3 -Python 3.2

___
Python tracker 

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



[issue4395] Document auto __ne__ generation; provide a use case for non-trivial __ne__

2010-09-01 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> terry.reedy
priority: normal -> low

___
Python tracker 

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



[issue6133] LOAD_CONST followed by LOAD_ATTR can be optimized to just be a LOAD_CONST

2010-09-01 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

What's the point of '{}'.format() anyway given the format() builtin?

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue9734] ABC issubclass/isinstance leaks in Python 2

2010-09-01 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Will be fixed in 2.7.1.

--
nosy: +benjamin.peterson
resolution:  -> out of date
status: open -> closed

___
Python tracker 

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



[issue7141] 2to3 should add from __future__ import print_statement

2010-09-01 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

I don't think this is very useful. You could just as well exclude the future 
fixer completely.

--

___
Python tracker 

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



[issue7141] 2to3 should add from __future__ import print_statement

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Excluding the future fixer would only get me half of the way there.  I would 
still need to add "from __future__ import print_statement" to all of my scripts 
if I want them to continue to work under 2.6.

(Well, for me personally, I have already done exactly that, by hand.  Rather 
tedious.)

--

___
Python tracker 

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



[issue1552880] Unicode Imports

2010-09-01 Thread Kristján Valur Jónsson

Kristján Valur Jónsson  added the comment:

> Yes, but in Python, U+DC80..D+DCFF range is used to store undecodable bytes. 
> Eg. 'abc\xff'.decode('ascii', 'surrogateescape') gives 'abc\udcff'.

That's an inventive way of breaking the unicode standard :)
Anyway, why would you worry about that?  My patch doesn't use "surrogateescape" 
so there is no problem.  There are only two places where I "decode":  
1) module names and sys.path components in the system file encoding:  If they 
contain undecodable characters, then that is an error.  No reason to propagate 
that error into the import machinery.
2) when decoding utf-8 back into unicode, but that utf-8 is already leagal 
since _we_ generated it.

If a _unicode_ input (sys.path) contains a valid surrogate pair, then the utf-8 
encoder just encodes it.
But if it finds a lone surrogate as you describe (python special) then that 
represends an undecodable chacater, something that should have been covered 
earlier and something we know nothing about.  Clearly, that makes that 
particular unicode sys.path component invalid.

(Hm, I notice that 2.7 happily encodes lone surrogates to utf-8)

> Python 2.7 is out and I think it is too late to fix Python2. Anyway, Python2 
> uses bytes for sys.path or other paths, so the problem only occurs if the 
> user 
> specifies unicode paths.
Which is precisely the case that it is designed to solve.  When the chinese 
user installs EVE Online in a weird folder, then that should work.
Also, 2.x is not quite dead yet.  There are quite a few people doing their own 
patches for their private purposes.  Although my patch won't go into any 
official version, there might be others in the same situation like us:  Trying 
to support an _embedded_ python 2.x version in an internationalized 
enverionment (on windows :)

--

___
Python tracker 

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



[issue7141] 2to3 should add from __future__ import print_statement

2010-09-01 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

2010/9/1 Daniel Stutzbach :
>
> Daniel Stutzbach  added the comment:
>
> Excluding the future fixer would only get me half of the way there.  I would 
> still need to add "from __future__ import print_statement" to all of my 
> scripts if I want them to continue to work under 2.6.

I'm still apprehensive because it's not really the point of 2to3 to
port apps to 2.6.

--

___
Python tracker 

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



[issue7141] 2to3 should add from __future__ import print_statement

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

Well, I grant you that it's a bit of scope-creep, and if you want to reject it 
on those grounds I can't blame you.

To me it seems like a relatively small change that would greatly help people 
like myself who want to update older code so that it will run under 2.6, 2.7, 
and 3.1+.  Of course, since I don't know how to make the change, I could also 
be wrong about how easy it would be for a knowledgeable person to fit it into 
the existing 2to3 framework.

--

___
Python tracker 

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



[issue8743] set() operators don't work with collections.Set instances

2010-09-01 Thread Daniel Stutzbach

Daniel Stutzbach  added the comment:

> The operator methods in setobject.c should be liberalized to accept
> instances of collections.Set as arguments.

Under this plan, set() and collections.Set will still have slightly different 
behavior.  collections.Set will be more liberal and accept any iterable.  Are 
you okay with that?  I don't feel strongly about this point; I just want to 
make sure it's a conscious decision.

I do feel strongly that set and collections.Set should be able to inter-operate 
nicely and the proposal satisfies that requirement so I would be happy with it.

> To implement PyObject_IsInstance(other, collections.Set), there may
> be a bootstrap issue (with the C code being compiled and runnable
> before _abcoll.py is able to create the Set ABC). Alternatively, 
> the code in setobject.c can lazily (at runtime) lookup 
> collections.Set by name and cache it so that we only do one
> successful lookup per session.

I favor the lazy lookup approach.

> Whatever approach is taken, it should be done with an eye towards 
> the larger problem that Python is filled with concrete isinstance()
> checks that pre-date ABCs and many of those need to be liberalized
> (accepting a registered ABC and providing different execution paths
> for known and unknown concrete types).

Agreed.  Ideally, the "PyObject_IsInstance(other, collections.Set)" logic would 
be abstracted out as much as possible so other parts of Python can make similar 
checks without needing tons of boilerplate code in every spot.

For what it's worth, I don't think we will find as many inconsistency issues 
with ABCs other than Set.  Set has methods that take another Set and return a 
third Set.  That forces different concrete implementations of the Set ABC to 
interact in a way that won't come up for a Sequence or Mapping.

(I suppose that Sequence.extend or MutableMapping.update are somewhat similar, 
but list.extend and dict.update are already very liberal in what they accept as 
a parameter.)

--
resolution:  -> accepted
versions: +Python 3.1

___
Python tracker 

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



[issue9633] pdb go stack up/down

2010-09-01 Thread Meador Inge

Meador Inge  added the comment:

I believe this is slightly tricky because 'bdb.format_stack_entry' makes 
references to '.f_locals' and 'bdb.format_stack_entry' is invoked in several 
places in 'pdb'.  One option would be to add a extra parameter to 
'bdb.format_stack_entry' to accept a dictionary of locals to operate with.

I implemented this approach and added a doctest to verify.  See attached patch. 
 I didn't update the 'bdb' documentation to note the new parameter, but will if 
this approach seems reasonable.

--
keywords: +patch
Added file: http://bugs.python.org/file18706/issue9633.patch

___
Python tracker 

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



[issue9739] Output of help(...) is wider than 80 characters

2010-09-01 Thread Case Van Horsen

New submission from Case Van Horsen :

In several modules, the output of help(some_module) is wider than 80 
characters. This results in extra line wrapping and incorrect formatting of the 
help text.

I've attached a single patch (doc_width1.diff) that corrects the issue for 
math, cmath, tuple, datetime, and time modules. I can continue to create 
patches for a few modules at a time, or I can create patches for individual 
modules.

I'm not changing any text, only adding \n as needed.

--
components: Extension Modules
files: doc_width1.diff
keywords: patch
messages: 115359
nosy: casevh
priority: normal
severity: normal
status: open
title: Output of help(...) is wider than 80 characters
type: behavior
Added file: http://bugs.python.org/file18707/doc_width1.diff

___
Python tracker 

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



[issue9726] logging.handlers.RotatingFileHandler: implement "preserve log file name extension" feature

2010-09-01 Thread Vinay Sajip

Vinay Sajip  added the comment:

Only bug-fixes are supposed to go into 2.7, so reclassifying.

--
assignee:  -> vinay.sajip
nosy: +vinay.sajip
versions: +Python 3.2 -Python 2.7

___
Python tracker 

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



  1   2   >