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
Kirill Smelkov
cython
Commits
9912e336
Commit
9912e336
authored
Apr 14, 2019
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure we always have a correct "qualified_name" for all symtab Entry instances.
Closes GH-2811.
parent
43bdeb03
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
4 deletions
+20
-4
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+6
-2
tests/run/cython3.pyx
tests/run/cython3.pyx
+14
-2
No files found.
Cython/Compiler/Symtab.py
View file @
9912e336
...
@@ -825,6 +825,7 @@ class Scope(object):
...
@@ -825,6 +825,7 @@ class Scope(object):
if
overridable
:
if
overridable
:
# names of cpdef functions can be used as variables and can be assigned to
# names of cpdef functions can be used as variables and can be assigned to
var_entry
=
Entry
(
name
,
cname
,
py_object_type
)
# FIXME: cname?
var_entry
=
Entry
(
name
,
cname
,
py_object_type
)
# FIXME: cname?
var_entry
.
qualified_name
=
self
.
qualify_name
(
name
)
var_entry
.
is_variable
=
1
var_entry
.
is_variable
=
1
var_entry
.
is_pyglobal
=
1
var_entry
.
is_pyglobal
=
1
var_entry
.
scope
=
entry
.
scope
var_entry
.
scope
=
entry
.
scope
...
@@ -1037,6 +1038,7 @@ class BuiltinScope(Scope):
...
@@ -1037,6 +1038,7 @@ class BuiltinScope(Scope):
else
:
else
:
python_equiv
=
EncodedString
(
python_equiv
)
python_equiv
=
EncodedString
(
python_equiv
)
var_entry
=
Entry
(
python_equiv
,
python_equiv
,
py_object_type
)
var_entry
=
Entry
(
python_equiv
,
python_equiv
,
py_object_type
)
var_entry
.
qualified_name
=
self
.
qualify_name
(
name
)
var_entry
.
is_variable
=
1
var_entry
.
is_variable
=
1
var_entry
.
is_builtin
=
1
var_entry
.
is_builtin
=
1
var_entry
.
utility_code
=
utility_code
var_entry
.
utility_code
=
utility_code
...
@@ -1060,6 +1062,7 @@ class BuiltinScope(Scope):
...
@@ -1060,6 +1062,7 @@ class BuiltinScope(Scope):
type
=
self
.
lookup
(
'type'
).
type
,
# make sure "type" is the first type declared...
type
=
self
.
lookup
(
'type'
).
type
,
# make sure "type" is the first type declared...
pos
=
entry
.
pos
,
pos
=
entry
.
pos
,
cname
=
entry
.
type
.
typeptr_cname
)
cname
=
entry
.
type
.
typeptr_cname
)
var_entry
.
qualified_name
=
self
.
qualify_name
(
name
)
var_entry
.
is_variable
=
1
var_entry
.
is_variable
=
1
var_entry
.
is_cglobal
=
1
var_entry
.
is_cglobal
=
1
var_entry
.
is_readonly
=
1
var_entry
.
is_readonly
=
1
...
@@ -1241,14 +1244,13 @@ class ModuleScope(Scope):
...
@@ -1241,14 +1244,13 @@ class ModuleScope(Scope):
entry
.
is_builtin
=
1
entry
.
is_builtin
=
1
entry
.
is_const
=
1
# cached
entry
.
is_const
=
1
# cached
entry
.
name
=
name
entry
.
name
=
name
entry
.
qualified_name
=
'__builtin__.'
+
name
entry
.
cname
=
Naming
.
builtin_prefix
+
name
entry
.
cname
=
Naming
.
builtin_prefix
+
name
self
.
cached_builtins
.
append
(
entry
)
self
.
cached_builtins
.
append
(
entry
)
self
.
undeclared_cached_builtins
.
append
(
entry
)
self
.
undeclared_cached_builtins
.
append
(
entry
)
else
:
else
:
entry
.
is_builtin
=
1
entry
.
is_builtin
=
1
entry
.
name
=
name
entry
.
name
=
name
entry
.
qualified_name
=
'__builtin__.'
+
name
entry
.
qualified_name
=
self
.
builtin_scope
().
qualify_name
(
name
)
return
entry
return
entry
def
find_module
(
self
,
module_name
,
pos
,
relative_level
=-
1
):
def
find_module
(
self
,
module_name
,
pos
,
relative_level
=-
1
):
...
@@ -1712,6 +1714,7 @@ class ModuleScope(Scope):
...
@@ -1712,6 +1714,7 @@ class ModuleScope(Scope):
type
=
Builtin
.
type_type
,
type
=
Builtin
.
type_type
,
pos
=
entry
.
pos
,
pos
=
entry
.
pos
,
cname
=
entry
.
type
.
typeptr_cname
)
cname
=
entry
.
type
.
typeptr_cname
)
var_entry
.
qualified_name
=
entry
.
qualified_name
var_entry
.
is_variable
=
1
var_entry
.
is_variable
=
1
var_entry
.
is_cglobal
=
1
var_entry
.
is_cglobal
=
1
var_entry
.
is_readonly
=
1
var_entry
.
is_readonly
=
1
...
@@ -2314,6 +2317,7 @@ class CClassScope(ClassScope):
...
@@ -2314,6 +2317,7 @@ class CClassScope(ClassScope):
entry
=
self
.
declare_cfunction
(
entry
=
self
.
declare_cfunction
(
name
,
type
,
pos
=
None
,
cname
=
cname
,
visibility
=
'extern'
,
utility_code
=
utility_code
)
name
,
type
,
pos
=
None
,
cname
=
cname
,
visibility
=
'extern'
,
utility_code
=
utility_code
)
var_entry
=
Entry
(
name
,
name
,
py_object_type
)
var_entry
=
Entry
(
name
,
name
,
py_object_type
)
var_entry
.
qualified_name
=
name
var_entry
.
is_variable
=
1
var_entry
.
is_variable
=
1
var_entry
.
is_builtin
=
1
var_entry
.
is_builtin
=
1
var_entry
.
utility_code
=
utility_code
var_entry
.
utility_code
=
utility_code
...
...
tests/run/cython3.pyx
View file @
9912e336
# cython: language_level=3, binding=True
# cython: language_level=3, binding=True
, annotation_typing=False
# mode: run
# mode: run
# tag: generators, python3, exceptions
# tag: generators, python3, exceptions
, gh2230, gh2811
print
(
end
=
''
)
# test that language_level 3 applies immediately at the module start, for the first token.
print
(
end
=
''
)
# test that language_level 3 applies immediately at the module start, for the first token.
...
@@ -553,6 +553,18 @@ def annotation_syntax(a: "test new test", b : "other" = 2, *args: "ARGS", **kwar
...
@@ -553,6 +553,18 @@ def annotation_syntax(a: "test new test", b : "other" = 2, *args: "ARGS", **kwar
return
result
return
result
def
builtin_as_annotation
(
text
:
str
):
# See https://github.com/cython/cython/issues/2811
"""
>>> builtin_as_annotation("abc")
a
b
c
"""
for
c
in
text
:
print
(
c
)
async
def
async_def_annotations
(
x
:
'int'
)
->
'float'
:
async
def
async_def_annotations
(
x
:
'int'
)
->
'float'
:
"""
"""
>>> ret, arg = sorted(async_def_annotations.__annotations__.items())
>>> ret, arg = sorted(async_def_annotations.__annotations__.items())
...
...
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