Commit 0369269d authored by Robert Bradshaw's avatar Robert Bradshaw

Don't generate wrappers for cimported enums.

parent 42ac1407
......@@ -2377,7 +2377,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
def generate_wrapped_entries_code(self, env, code):
for name, entry in env.entries.items():
if entry.create_wrapper and not entry.is_type:
if (entry.create_wrapper
and not entry.is_type
and entry.scope is env):
if not entry.type.create_to_py_utility_code(env):
error(entry.pos, "Cannot convert '%s' to Python object" % entry.type)
code.putln("{")
......
PYTHON setup.py build_ext --inplace
PYTHON -c "import import_enums_test"
######## setup.py ########
from Cython.Build.Dependencies import cythonize
from distutils.core import setup
setup(
ext_modules = cythonize(["enums.pyx", "no_enums.pyx"]),
)
######## enums.pyx ########
cpdef enum:
BAR
cpdef foo(): pass
######## enums.pxd ########
cpdef enum:
FOO
cpdef foo()
######## no_enums.pyx ########
from enums cimport *
######## import_enums_test.py ########
# We can import enums with a star import.
from enums import *
print dir()
assert 'BAR' in dir() and 'FOO' in dir()
# enums not generated in the wrong module
import no_enums
print dir(no_enums)
assert 'FOO' not in dir(no_enums)
assert 'foo' not in dir(no_enums)
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