From 16005a3dfdea751c88a0a1fb0ba994a3d3b641e2 Mon Sep 17 00:00:00 2001 From: Nikita Nemkin Date: Sat, 6 Apr 2013 16:19:46 +0600 Subject: [PATCH] In cimport_from_pyx mode don't treat "cdef extern from" variables as being defined, preventing erroneous cross-module cimport. --- Cython/Compiler/Pipeline.py | 3 ++- tests/run/cimport_from_pyx.srctree | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Cython/Compiler/Pipeline.py b/Cython/Compiler/Pipeline.py index b945fce..f4a0735 100644 --- a/Cython/Compiler/Pipeline.py +++ b/Cython/Compiler/Pipeline.py @@ -275,7 +275,8 @@ def create_pyx_as_pxd_pipeline(context, result): break def fake_pxd(root): for entry in root.scope.entries.values(): - entry.defined_in_pxd = 1 + if not entry.in_cinclude: + entry.defined_in_pxd = 1 return StatListNode(root.pos, stats=[]), root.scope pipeline.append(fake_pxd) return pipeline diff --git a/tests/run/cimport_from_pyx.srctree b/tests/run/cimport_from_pyx.srctree index 04bb0f0..6021887 100644 --- a/tests/run/cimport_from_pyx.srctree +++ b/tests/run/cimport_from_pyx.srctree @@ -15,12 +15,13 @@ setup( ######## a.pyx ######## -from b cimport Bclass, Bfunc, Bstruct, Benum, Benum_value, Btypedef +from b cimport Bclass, Bfunc, Bstruct, Benum, Benum_value, Btypedef, Py_EQ, Py_NE cdef Bclass b = Bclass(5) assert Bfunc(&b.value) == b.value assert b.asStruct().value == b.value cdef Btypedef b_type = &b.value cdef Benum b_enum = Benum_value +cdef int tmp = Py_EQ #from c cimport ClassC #cdef ClassC c = ClassC() @@ -28,6 +29,8 @@ cdef Benum b_enum = Benum_value ######## b.pyx ######## +from cpython.object cimport Py_EQ, Py_NE + cdef enum Benum: Benum_value -- 2.7.4