This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xiang.zhang
Recipients amogorkon, eryksun, ethan.furman, lukasz.langa, ncoghlan, rhettinger, xiang.zhang
Date 2016-09-07.09:39:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473241148.19.0.728152111291.issue27984@psf.upfronthosting.co.za>
In-reply-to
Content
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
>>>
History
Date User Action Args
2016-09-07 09:39:08xiang.zhangsetrecipients: + xiang.zhang, rhettinger, ncoghlan, ethan.furman, lukasz.langa, eryksun, amogorkon
2016-09-07 09:39:08xiang.zhangsetmessageid: <1473241148.19.0.728152111291.issue27984@psf.upfronthosting.co.za>
2016-09-07 09:39:08xiang.zhanglinkissue27984 messages
2016-09-07 09:39:08xiang.zhangcreate