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 amogorkon
Recipients amogorkon
Date 2016-09-06.23:18:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473203931.8.0.512988366273.issue27984@psf.upfronthosting.co.za>
In-reply-to
Content
from functools import singledispatch
from enum import Enum

IS = Enum("IS", "a, b")

@singledispatch
def foo(x):
    print(foo.dispatch(x))
    print("foo")

@foo.register(IS.a)
def bar(x):
    print(foo.dispatch(x))
    print("bar")
    
@foo.register(int)
def baz(x):
    print("baz")
    
>>> foo(IS.a)
<function bar at 0x7fa92c319d90>
foo


I think the result is self-explaining. The foo.dispatch() correctly says function bar should be handling the call when IS.a is passed, but foo is handling the call anyway. If an int is passed, baz works as expected.
History
Date User Action Args
2016-09-06 23:18:51amogorkonsetrecipients: + amogorkon
2016-09-06 23:18:51amogorkonsetmessageid: <1473203931.8.0.512988366273.issue27984@psf.upfronthosting.co.za>
2016-09-06 23:18:51amogorkonlinkissue27984 messages
2016-09-06 23:18:51amogorkoncreate