Open 379dc349-3a10-424f-b9d2-a0104f092359 opened 8 years ago
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'>
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at = None created_at =
labels = ['library']
title = 'WeakMethod does not support builtin methods'
updated_at =
user = 'https://github.com/anntzer'
```
bugs.python.org fields:
```python
activity =
actor = 'Antony.Lee'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation =
creator = 'Antony.Lee'
dependencies = []
files = []
hgrepos = []
issue_num = 27865
keywords = []
message_count = 1.0
messages = ['273688']
nosy_count = 1.0
nosy_names = ['Antony.Lee']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue27865'
versions = ['Python 3.5', 'Python 3.6']
```