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
Show 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):
...
@@ -1633,7 +1633,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
rev_entries
.
reverse
()
rev_entries
.
reverse
()
for
entry
in
rev_entries
:
for
entry
in
rev_entries
:
if
entry
.
visibility
!=
'extern'
:
if
entry
.
visibility
!=
'extern'
:
if
entry
.
type
.
is_pyobject
:
if
entry
.
type
.
is_pyobject
and
entry
.
used
:
code
.
put_var_decref_clear
(
entry
)
code
.
put_var_decref_clear
(
entry
)
if
Options
.
generate_cleanup_code
>=
3
:
if
Options
.
generate_cleanup_code
>=
3
:
code
.
putln
(
"/*--- Type import cleanup code ---*/"
)
code
.
putln
(
"/*--- Type import cleanup code ---*/"
)
...
@@ -1734,7 +1734,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1734,7 +1734,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# variables to None.
# variables to None.
for
entry
in
env
.
var_entries
:
for
entry
in
env
.
var_entries
:
if
entry
.
visibility
!=
'extern'
:
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
)
code
.
put_init_var_to_py_none
(
entry
)
def
generate_c_function_export_code
(
self
,
env
,
code
):
def
generate_c_function_export_code
(
self
,
env
,
code
):
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
e2f43afd
...
@@ -183,9 +183,10 @@ class PostParse(CythonTransform):
...
@@ -183,9 +183,10 @@ class PostParse(CythonTransform):
handler
(
decl
)
handler
(
decl
)
continue
# Remove declaration
continue
# Remove declaration
raise
PostParseError
(
decl
.
pos
,
ERR_CDEF_INCLASS
)
raise
PostParseError
(
decl
.
pos
,
ERR_CDEF_INCLASS
)
first_assignment
=
self
.
scope_type
!=
'module'
stats
.
append
(
SingleAssignmentNode
(
node
.
pos
,
stats
.
append
(
SingleAssignmentNode
(
node
.
pos
,
lhs
=
NameNode
(
node
.
pos
,
name
=
declbase
.
name
),
lhs
=
NameNode
(
node
.
pos
,
name
=
declbase
.
name
),
rhs
=
declbase
.
default
,
first
=
True
))
rhs
=
declbase
.
default
,
first
=
first_assignment
))
declbase
.
default
=
None
declbase
.
default
=
None
newdecls
.
append
(
decl
)
newdecls
.
append
(
decl
)
node
.
declarators
=
newdecls
node
.
declarators
=
newdecls
...
...
Cython/Compiler/Symtab.py
View file @
e2f43afd
...
@@ -934,6 +934,8 @@ class ModuleScope(Scope):
...
@@ -934,6 +934,8 @@ class ModuleScope(Scope):
entry.is_pyglobal = 1
entry.is_pyglobal = 1
else:
else:
entry.is_cglobal = 1
entry.is_cglobal = 1
if entry.type.is_pyobject:
entry.init = 0
self.var_entries.append(entry)
self.var_entries.append(entry)
return entry
return entry
...
...
tests/compile/globvardef.pyx
View file @
e2f43afd
...
@@ -3,3 +3,5 @@ cdef a_global_pyobject
...
@@ -3,3 +3,5 @@ cdef a_global_pyobject
a_global_int
=
0
a_global_int
=
0
a_global_pyobject
=
None
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