Serhiy Storchaka added the comment:

This line is came from the signature of the __call__ method.

>>> import enum, inspect
>>> class A(enum.Enum):
...    x = 1
... 
>>> inspect.signature(A)
<Signature (value, names=None, *, module=None, qualname=None, type=None, 
start=1)>
>>> inspect.signature(A.__call__)
<Signature (value, names=None, *, module=None, qualname=None, type=None, 
start=1)>
>>> inspect.signature(enum.EnumMeta.__call__)
<Signature (cls, value, names=None, *, module=None, qualname=None, type=None, 
start=1)>

But calling A with optional arguments doesn't work.

>>> A(1)
<A.x: 1>
>>> A('B', {'y': 2})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/serhiy/py/cpython/Lib/enum.py", line 293, in __call__
    return cls._create_(value, names, module=module, qualname=qualname, 
type=type, start=start)
  File "/home/serhiy/py/cpython/Lib/enum.py", line 378, in _create_
    _, first_enum = cls._get_mixins_(bases)
  File "/home/serhiy/py/cpython/Lib/enum.py", line 436, in _get_mixins_
    raise TypeError("Cannot extend enumerations")
TypeError: Cannot extend enumerations

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29363>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to