[issue643841] New class special method lookup change

Nick Coghlan report at bugs.python.org
Thu Jun 5 16:16:40 CEST 2008


Nick Coghlan <ncoghlan at gmail.com> added the comment:

I've attached the latest version of the module as an actual patch
against Python SVN.

It differs slightly from the last version uploaded as separate files, in
that in-place operations on a proxied object will no longer strip the
proxy wrapper off the object. Instead, either the same proxy object will
be returned if the target returned itself from the in-place operation
(mutable objects), or a new proxy wrapper around the result of the
target returned a different object (immutable objects).

Example with a mutable target:
>>> from typetools import ProxyMixin as p
>>> x = p([])
>>> last_x = x
>>> x += [1]
>>> x
<ProxyMixin for [1]>
>>> last_x
<ProxyMixin for [1]>

Example with an immutable target:
>>> from typetools import ProxyMixin as p
>>> x = p(1)
>>> last_x = x
>>> x += 1
>>> x
<ProxyMixin for 2>
>>> last_x
<ProxyMixin for 1>

Added file: http://bugs.python.org/file10521/issue643841_typetools.diff

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue643841>
_______________________________________


More information about the Python-bugs-list mailing list