New submission from Anselm Kiefner:
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.
----------
messages: 274661
nosy: amogorkon
priority: normal
severity: normal
status: open
title: singledispatch is wonky with enums
type: behavior
versions: Python 3.5
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue27984>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com