[issue27865] WeakMethod does not support builtin methods
Antony Lee
report at bugs.python.org
Thu Aug 25 22:46:05 EDT 2016
New submission from Antony Lee:
List subclasses can be weakref'd (as mentioned by the docs), but their methods cannot be wrapped by WeakMethod, even though this makes sense semantically:
```
In [25]: class L(list): pass
In [26]: weakref.WeakMethod(L().append)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-26-f6246b3b483e> in <module>()
----> 1 weakref.WeakMethod(L().append)
/usr/lib/python3.5/weakref.py in __new__(cls, meth, callback)
47 except AttributeError:
48 raise TypeError("argument should be a bound method, not {}"
---> 49 .format(type(meth))) from None
50 def _cb(arg):
51 # The self-weakref trick is needed to avoid creating a reference
TypeError: argument should be a bound method, not <class 'builtin_function_or_method'>
```
----------
components: Library (Lib)
messages: 273688
nosy: Antony.Lee
priority: normal
severity: normal
status: open
title: WeakMethod does not support builtin methods
versions: Python 3.5, Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue27865>
_______________________________________
More information about the Python-bugs-list
mailing list