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
81026937
Commit
81026937
authored
Jul 27, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid traversing/clearing exttype attributes with simple types during garbage collection
parent
5a76ba3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
11 deletions
+48
-11
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+4
-9
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+4
-2
tests/run/cyclic_gc.pyx
tests/run/cyclic_gc.pyx
+40
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
81026937
...
...
@@ -1290,8 +1290,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
"static int %s(PyObject *o, visitproc v, void *a) {"
%
slot_func
)
have_entries
,
(
py_attrs
,
py_buffers
,
memoryview_slices
)
=
scope
.
get_refcounted_entries
(
)
have_entries
,
(
py_attrs
,
py_buffers
,
memoryview_slices
)
=
(
scope
.
get_refcounted_entries
(
include_gc_simple
=
False
)
)
if
base_type
or
py_attrs
:
code
.
putln
(
"int e;"
)
...
...
@@ -1354,13 +1354,8 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
tp_slot
.
slot_code
(
scope
)
!=
slot_func
:
return
# never used
py_attrs
=
[]
py_buffers
=
[]
for
entry
in
scope
.
var_entries
:
if
entry
.
type
.
is_pyobject
and
entry
.
name
!=
"__weakref__"
:
py_attrs
.
append
(
entry
)
if
entry
.
type
==
PyrexTypes
.
c_py_buffer_type
:
py_buffers
.
append
(
entry
)
have_entries
,
(
py_attrs
,
py_buffers
,
memoryview_slices
)
=
(
scope
.
get_refcounted_entries
(
include_gc_simple
=
False
))
if
py_attrs
or
py_buffers
or
base_type
:
unused
=
''
...
...
Cython/Compiler/Symtab.py
View file @
81026937
...
...
@@ -832,7 +832,8 @@ class Scope(object):
def
add_include_file
(
self
,
filename
):
self
.
outer_scope
.
add_include_file
(
filename
)
def
get_refcounted_entries
(
self
,
include_weakref
=
False
):
def
get_refcounted_entries
(
self
,
include_weakref
=
False
,
include_gc_simple
=
True
):
py_attrs
=
[]
py_buffers
=
[]
memoryview_slices
=
[]
...
...
@@ -840,7 +841,8 @@ class Scope(object):
for
entry
in
self
.
var_entries
:
if
entry
.
type
.
is_pyobject
:
if
include_weakref
or
entry
.
name
!=
"__weakref__"
:
py_attrs
.
append
(
entry
)
if
include_gc_simple
or
not
entry
.
type
.
is_gc_simple
:
py_attrs
.
append
(
entry
)
elif
entry
.
type
==
PyrexTypes
.
c_py_buffer_type
:
py_buffers
.
append
(
entry
)
elif
entry
.
type
.
is_memoryviewslice
:
...
...
tests/run/cyclic_gc.pyx
View file @
81026937
...
...
@@ -79,12 +79,16 @@ cdef class ExtTypePyArgsWithGC:
>>> obj = ExtTypePyArgsWithGC()
>>> obj = ExtTypePyArgsWithGC()
>>> obj = ExtTypePyArgsWithGC()
>>> obj.create_cycle()
"""
cdef
bytes
b
cdef
str
s
cdef
unicode
u
cdef
list
l
def
create_cycle
(
self
):
self
.
l
=
[
self
]
@
cython
.
test_fail_if_path_exists
(
'//CClassDefNode[@scope.has_cyclic_pyobject_attrs = True]'
)
@
cython
.
test_assert_path_exists
(
'//CClassDefNode'
,
...
...
@@ -98,4 +102,40 @@ cdef class ExtSubTypePyArgsWithGC(ExtTypePyArgsWithGC):
>>> obj = ExtSubTypePyArgsWithGC()
>>> obj = ExtSubTypePyArgsWithGC()
>>> obj = ExtSubTypePyArgsWithGC()
>>> obj.create_cycle()
"""
@
cython
.
test_fail_if_path_exists
(
'//CClassDefNode[@scope.has_cyclic_pyobject_attrs = True]'
)
@
cython
.
test_assert_path_exists
(
'//CClassDefNode'
,
'//CClassDefNode[@scope]'
,
'//CClassDefNode[@scope.has_cyclic_pyobject_attrs = False]'
)
cdef
class
ExtSubTypePlusPyArgsWithGC
(
ExtSubTypePyArgsWithGC
):
"""
>>> obj = ExtSubTypePlusPyArgsWithGC()
>>> obj = ExtSubTypePlusPyArgsWithGC()
>>> obj = ExtSubTypePlusPyArgsWithGC()
>>> obj = ExtSubTypePlusPyArgsWithGC()
>>> obj = ExtSubTypePlusPyArgsWithGC()
>>> obj = ExtSubTypePlusPyArgsWithGC()
>>> obj.create_cycle()
"""
cdef
bytes
b2
cdef
unicode
u2
@
cython
.
test_fail_if_path_exists
(
'//CClassDefNode[@scope.has_cyclic_pyobject_attrs = False]'
)
@
cython
.
test_assert_path_exists
(
'//CClassDefNode'
,
'//CClassDefNode[@scope]'
,
'//CClassDefNode[@scope.has_cyclic_pyobject_attrs = True]'
)
cdef
class
ExtSubTypePlusGCPyArgsWithGC
(
ExtSubTypePlusPyArgsWithGC
):
"""
>>> obj = ExtSubTypePlusGCPyArgsWithGC()
>>> obj = ExtSubTypePlusGCPyArgsWithGC()
>>> obj = ExtSubTypePlusGCPyArgsWithGC()
>>> obj = ExtSubTypePlusGCPyArgsWithGC()
>>> obj = ExtSubTypePlusGCPyArgsWithGC()
>>> obj = ExtSubTypePlusGCPyArgsWithGC()
>>> obj.create_cycle()
"""
cdef
tuple
t
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