Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
41a4e653
Commit
41a4e653
authored
Sep 30, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent leaking IntEnum import into module namespace when using cpdef enums
parent
bbbbd03f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
Cython/Utility/CpdefEnums.pyx
Cython/Utility/CpdefEnums.pyx
+6
-3
No files found.
Cython/Utility/CpdefEnums.pyx
View file @
41a4e653
...
@@ -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
}}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment