Commit eb270f7e authored by Stefan Behnel's avatar Stefan Behnel

Repair string forward references to extension types in cython.locals() decorator.

parent fbb18722
......@@ -8,6 +8,9 @@ Cython Changelog
Bugs fixed
----------
* String forward references to extension types like ``@cython.locals(x="ExtType")``
failed to find the named type. (Github issue #1962)
* NumPy slicing generated incorrect results when compiled with Pythran.
(Github issue #1946)
......
......@@ -1362,6 +1362,11 @@ def _analyse_name_as_type(name, pos, env):
type = PyrexTypes.parse_basic_type(name)
if type is not None:
return type
global_entry = env.global_scope().lookup_here(name)
if global_entry and global_entry.type and global_entry.type.is_extension_type:
return global_entry.type
from .TreeFragment import TreeFragment
with local_errors(ignore=True):
pos = (pos[0], pos[1], pos[2]-7)
......
......@@ -160,3 +160,23 @@ def test_declare_c_types(n):
#z01 = cython.declare(cython.floatcomplex, n+1j)
#z02 = cython.declare(cython.doublecomplex, n+1j)
#z03 = cython.declare(cython.longdoublecomplex, n+1j)
cdef class ExtType:
"""
>>> x = ExtType()
>>> x.forward_ref(x)
'ExtType'
"""
@cython.locals(x="ExtType")
def forward_ref(self, x):
return cython.typeof(x)
def ext_type_string_ref(x: "ExtType"):
"""
>>> x = ExtType()
>>> ext_type_string_ref(x)
'ExtType'
"""
return cython.typeof(x)
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