[Python-Dev] Enum: subclassing?

Georg Brandl g.brandl at gmx.net
Wed May 1 23:53:30 CEST 2013

Am 01.05.2013 23:44, schrieb Georg Brandl:

> Traceback (most recent call last):
>   File "/home/gbr/devel/ref435/ref435.py", line 84, in __new__
>     enum_item = obj_type.__new__(result, value)
> TypeError: object.__new__(SIPStatusCode) is not safe, use int.__new__()
> During handling of the above exception, another exception occurred:
> Traceback (most recent call last):
>   File "ex.py", line 11, in <module>
>     class SIPStatusCode(IETFStatusCode, int, Enum):
>   File "/home/gbr/devel/ref435/ref435.py", line 86, in __new__
>     raise EnumError(*exc.args) from None
> TypeError: exception causes must derive from BaseException

To be fair the secondary exception is an artifact of me trying the example
with Python 3.2, which doesn't have "from None".


More information about the Python-Dev mailing list