[issue1075356] exceeding obscure weakproxy bug

Amaury Forgeot d'Arc report at bugs.python.org
Tue Jan 4 17:24:14 CET 2011


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

It's not fixed. range() now uses the tp_index slot, in weakrefs this becomes:
    WRAP_UNARY(proxy_index, PyNumber_Index)
and indeed PyNumber_Index does not accept strings.

But try with time.sleep() instead; here the line
    WRAP_UNARY(proxy_float, PyNumber_Float)
is involved:


import _weakref, time

class U(str): pass
u = U("1")

try:
    time.sleep(u)
except TypeError:
    print("raised, good")
else:
    print("didn't raise, bad")

try:
    time.sleep(_weakref.proxy(u))
except TypeError:
    print("raised, good")
else:
    print("didn't raise, bad")

----------
nosy: +amaury.forgeotdarc

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


More information about the Python-bugs-list mailing list