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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
eb270f7e
Commit
eb270f7e
authored
Oct 29, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Repair string forward references to extension types in cython.locals() decorator.
parent
fbb18722
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
0 deletions
+28
-0
CHANGES.rst
CHANGES.rst
+3
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+5
-0
tests/run/pure.pyx
tests/run/pure.pyx
+20
-0
No files found.
CHANGES.rst
View file @
eb270f7e
...
...
@@ -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)
...
...
Cython/Compiler/ExprNodes.py
View file @
eb270f7e
...
...
@@ -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
)
...
...
tests/run/pure.pyx
View file @
eb270f7e
...
...
@@ -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
)
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