Message274784
It's also better to add the typecheck to dispatch. Otherwise sometimes it can generate not obvious exception message.
>>> from enum import IntEnum
>>> from functools import singledispatch
>>> IS = IntEnum("IS", "a, b")
>>> @singledispatch
... def foo(x):
... pass
...
>>> foo.dispatch(IS.a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/angwer/cpython/Lib/functools.py", line 718, in dispatch
impl = dispatch_cache[cls]
File "/home/angwer/cpython/Lib/weakref.py", line 365, in __getitem__
return self.data[ref(key)]
TypeError: cannot create weak reference to 'IS' object
>>> |
|
Date |
User |
Action |
Args |
2016-09-07 09:39:08 | xiang.zhang | set | recipients:
+ xiang.zhang, rhettinger, ncoghlan, ethan.furman, lukasz.langa, eryksun, amogorkon |
2016-09-07 09:39:08 | xiang.zhang | set | messageid: <1473241148.19.0.728152111291.issue27984@psf.upfronthosting.co.za> |
2016-09-07 09:39:08 | xiang.zhang | link | issue27984 messages |
2016-09-07 09:39:08 | xiang.zhang | create | |
|