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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
e2f43afd
Commit
e2f43afd
authored
Oct 16, 2008
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix the declaration/initilization/cleanup of module global cdef Python objects
parent
94b89da9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
4 deletions
+9
-4
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-2
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+2
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+2
-0
tests/compile/globvardef.pyx
tests/compile/globvardef.pyx
+3
-1
No files found.
Cython/Compiler/ModuleNode.py
View file @
e2f43afd
...
...
@@ -1633,7 +1633,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
rev_entries
.
reverse
()
for
entry
in
rev_entries
:
if
entry
.
visibility
!=
'extern'
:
if
entry
.
type
.
is_pyobject
:
if
entry
.
type
.
is_pyobject
and
entry
.
used
:
code
.
put_var_decref_clear
(
entry
)
if
Options
.
generate_cleanup_code
>=
3
:
code
.
putln
(
"/*--- Type import cleanup code ---*/"
)
...
...
@@ -1734,7 +1734,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# variables to None.
for
entry
in
env
.
var_entries
:
if
entry
.
visibility
!=
'extern'
:
if
entry
.
type
.
is_pyobject
:
if
entry
.
type
.
is_pyobject
and
entry
.
used
:
code
.
put_init_var_to_py_none
(
entry
)
def
generate_c_function_export_code
(
self
,
env
,
code
):
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
e2f43afd
...
...
@@ -183,9 +183,10 @@ class PostParse(CythonTransform):
handler
(
decl
)
continue
# Remove declaration
raise
PostParseError
(
decl
.
pos
,
ERR_CDEF_INCLASS
)
first_assignment
=
self
.
scope_type
!=
'module'
stats
.
append
(
SingleAssignmentNode
(
node
.
pos
,
lhs
=
NameNode
(
node
.
pos
,
name
=
declbase
.
name
),
rhs
=
declbase
.
default
,
first
=
True
))
rhs
=
declbase
.
default
,
first
=
first_assignment
))
declbase
.
default
=
None
newdecls
.
append
(
decl
)
node
.
declarators
=
newdecls
...
...
Cython/Compiler/Symtab.py
View file @
e2f43afd
...
...
@@ -934,6 +934,8 @@ class ModuleScope(Scope):
entry.is_pyglobal = 1
else:
entry.is_cglobal = 1
if entry.type.is_pyobject:
entry.init = 0
self.var_entries.append(entry)
return entry
...
...
tests/compile/globvardef.pyx
View file @
e2f43afd
...
...
@@ -2,4 +2,6 @@ cdef int a_global_int
cdef
a_global_pyobject
a_global_int
=
0
a_global_pyobject
=
None
\ No newline at end of file
a_global_pyobject
=
None
cdef
object
unused
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