bpo-27984: explictly check type of singledispatch.dispatch() argument by zhangyangyu · Pull Request #6114 · python/cpython (original) (raw)
As commented on the BPO issue: the problem described in this issue is fixed, by BPO-32227.
The wrapper returned by the @register
decorator is calling dispatch()
with the first argument's __class__
. It can only ever be invalid if somebody deliberately wrote something invalid to the object's __class__
. It's extremely unlikely.
We should not slow down calling of all generic functions on the basis that somebody might pass a non-type straight to dispatch()
.