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
Xavier Thompson
cython
Commits
a560f42b
Commit
a560f42b
authored
Jun 08, 2020
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Manage cypclass attributes properly in cdef class __new__ and __dealloc__
parent
76be6d8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
2 deletions
+14
-2
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+14
-2
No files found.
Cython/Compiler/ModuleNode.py
View file @
a560f42b
...
...
@@ -1900,6 +1900,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
cpp_class_attrs
=
[
entry
for
entry
in
scope
.
var_entries
if
entry
.
type
.
is_cpp_class
and
not
entry
.
type
.
is_cyp_class
]
cyp_class_attrs
=
[
entry
for
entry
in
scope
.
var_entries
if
entry
.
type
.
is_cyp_class
]
cinit_func_entry
=
scope
.
lookup_here
(
"__cinit__"
)
if
cinit_func_entry
and
not
cinit_func_entry
.
is_special
:
cinit_func_entry
=
None
...
...
@@ -1932,7 +1935,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
need_self_cast
=
(
type
.
vtabslot_cname
or
(
py_buffers
or
memoryview_slices
or
py_attrs
)
or
cpp_class_attrs
)
cpp_class_attrs
or
cyp_class_attrs
)
if
need_self_cast
:
code
.
putln
(
"%s;"
%
scope
.
parent_type
.
declaration_code
(
"p"
))
if
base_type
:
...
...
@@ -1994,6 +1997,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"new((void*)&(p->%s)) %s();"
%
(
entry
.
cname
,
entry
.
type
.
empty_declaration_code
()))
for
entry
in
cyp_class_attrs
:
code
.
putln
(
"p->%s = NULL;"
%
entry
.
cname
)
for
entry
in
py_attrs
:
if
entry
.
name
==
"__dict__"
:
needs_error_cleanup
=
True
...
...
@@ -2060,7 +2066,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
cpp_class_attrs
=
[
entry
for
entry
in
scope
.
var_entries
if
entry
.
type
.
is_cpp_class
and
not
entry
.
type
.
is_cyp_class
]
if
py_attrs
or
cpp_class_attrs
or
memoryview_slices
or
weakref_slot
or
dict_slot
:
cyp_class_attrs
=
[
entry
for
entry
in
scope
.
var_entries
if
entry
.
type
.
is_cyp_class
]
if
py_attrs
or
cpp_class_attrs
or
cyp_class_attrs
or
memoryview_slices
or
weakref_slot
or
dict_slot
:
self
.
generate_self_cast
(
scope
,
code
)
if
not
is_final_type
:
...
...
@@ -2107,6 +2116,9 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
for
entry
in
cpp_class_attrs
:
code
.
putln
(
"__Pyx_call_destructor(p->%s);"
%
entry
.
cname
)
for
entry
in
cyp_class_attrs
:
code
.
putln
(
"Cy_XDECREF(p->%s);"
%
entry
.
cname
)
for
entry
in
py_attrs
:
code
.
put_xdecref_clear
(
"p->%s"
%
entry
.
cname
,
entry
.
type
,
nanny
=
False
,
clear_before_decref
=
True
)
...
...
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