Commit 41a4e653 authored by Stefan Behnel's avatar Stefan Behnel

prevent leaking IntEnum import into module namespace when using cpdef enums

parent bbbbd03f
...@@ -22,7 +22,7 @@ cdef class __Pyx_EnumMeta(type): ...@@ -22,7 +22,7 @@ cdef class __Pyx_EnumMeta(type):
return cls.__members__[name] return cls.__members__[name]
# @cython.internal # @cython.internal
cdef type __Pyx_EnumBase cdef object __Pyx_EnumBase
class __Pyx_EnumBase(int): class __Pyx_EnumBase(int):
__metaclass__ = __Pyx_EnumMeta __metaclass__ = __Pyx_EnumMeta
def __new__(cls, value, name=None): def __new__(cls, value, name=None):
...@@ -41,13 +41,16 @@ class __Pyx_EnumBase(int): ...@@ -41,13 +41,16 @@ class __Pyx_EnumBase(int):
def __str__(self): def __str__(self):
return "%s.%s" % (self.__class__.__name__, self.name) return "%s.%s" % (self.__class__.__name__, self.name)
if PY_VERSION_HEX >= 0x03040000:
from enum import IntEnum as __Pyx_EnumBase
#################### EnumType #################### #################### EnumType ####################
#@requires: EnumBase #@requires: EnumBase
cdef dict __Pyx_globals = globals() cdef dict __Pyx_globals = globals()
if PY_VERSION_HEX >= 0x03040000: if PY_VERSION_HEX >= 0x03040000:
from enum import IntEnum # create new IntEnum()
{{name}} = IntEnum('{{name}}', __Pyx_OrderedDict([ {{name}} = __Pyx_EnumBase('{{name}}', __Pyx_OrderedDict([
{{for item in items}} {{for item in items}}
('{{item}}', {{item}}), ('{{item}}', {{item}}),
{{endfor}} {{endfor}}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment