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
27f8ddb6
Commit
27f8ddb6
authored
Aug 09, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix #855: make "import *" include all necessary "from_py" coercion helper functions
parent
77bb90df
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletion
+34
-1
CHANGES.rst
CHANGES.rst
+4
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+17
-1
Cython/Compiler/Pipeline.py
Cython/Compiler/Pipeline.py
+1
-0
tests/run/import_star.pyx
tests/run/import_star.pyx
+12
-0
No files found.
CHANGES.rst
View file @
27f8ddb6
...
...
@@ -8,6 +8,10 @@ Latest changes
Bugs fixed
----------
* Code that uses "from xyz import *" and global C struct/union/array
variables could fail to compile due to missing helper functions.
This fixes ticket 851.
* Misnamed PEP 492 coroutine property ``cr_yieldfrom`` renamed to
``cr_await`` to match CPython.
...
...
Cython/Compiler/ModuleNode.py
View file @
27f8ddb6
...
...
@@ -102,6 +102,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
env
.
directives
=
self
.
directives
self
.
body
.
analyse_declarations
(
env
)
def
prepare_utility_code
(
self
):
# prepare any utility code that must be created before code generation
# specifically: CythonUtilityCode
env
=
self
.
scope
if
env
.
has_import_star
:
self
.
create_import_star_conversion_utility_code
(
env
)
def
process_implementation
(
self
,
options
,
result
):
env
=
self
.
scope
env
.
return_type
=
PyrexTypes
.
c_void_type
...
...
@@ -1964,6 +1971,14 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"};"
)
def
create_import_star_conversion_utility_code
(
self
,
env
):
# Create all conversion helpers that are needed for "import *" assignments.
# Must be done before code generation to support CythonUtilityCode.
for
name
,
entry
in
env
.
entries
.
items
():
if
entry
.
is_cglobal
and
entry
.
used
:
if
not
entry
.
type
.
is_pyobject
:
entry
.
type
.
create_from_py_utility_code
(
env
)
def
generate_import_star
(
self
,
env
,
code
):
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"CStringEquals"
,
"StringTools.c"
))
code
.
putln
()
...
...
@@ -2001,7 +2016,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"%s = %s;"
%
(
entry
.
cname
,
PyrexTypes
.
typecast
(
entry
.
type
,
py_object_type
,
"o"
)))
elif
entry
.
type
.
from_py_function
:
elif
entry
.
type
.
create_from_py_utility_code
(
env
):
# if available, utility code was already created in self.prepare_utility_code()
rhs
=
"%s(o)"
%
entry
.
type
.
from_py_function
if
entry
.
type
.
is_enum
:
rhs
=
PyrexTypes
.
typecast
(
entry
.
type
,
PyrexTypes
.
c_long_type
,
rhs
)
...
...
Cython/Compiler/Pipeline.py
View file @
27f8ddb6
...
...
@@ -80,6 +80,7 @@ def use_utility_code_definitions(scope, target, seen=None):
def
inject_utility_code_stage_factory
(
context
):
def
inject_utility_code_stage
(
module_node
):
module_node
.
prepare_utility_code
()
use_utility_code_definitions
(
context
.
cython_scope
,
module_node
.
scope
)
added
=
[]
# Note: the list might be extended inside the loop (if some utility code
...
...
tests/run/import_star.pyx
View file @
27f8ddb6
# mode: run
cdef
object
executable
,
version_info
cdef
long
hexversion
ctypedef
struct
MyStruct
:
int
x
,
y
,
z
# conversion code for this struct will be generated but not used
# (there used to be a problem getting Cython conversion code generated here)
cdef
MyStruct
_no_such_name_
=
MyStruct
(
1
,
2
,
3
)
from
sys
import
*
def
test_cdefed_objects
():
"""
>>> ex, vi = test_cdefed_objects()
...
...
@@ -12,6 +22,7 @@ def test_cdefed_objects():
"""
return
executable
,
version_info
def
test_cdefed_cvalues
():
"""
>>> hexver = test_cdefed_cvalues()
...
...
@@ -20,6 +31,7 @@ def test_cdefed_cvalues():
"""
return
hexversion
def
test_non_cdefed_names
():
"""
>>> mod, pth = test_non_cdefed_names()
...
...
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