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
489fcbd3
Commit
489fcbd3
authored
Oct 12, 2022
by
Xavier Thompson
Committed by
Xavier Thompson
Nov 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix cypclass initialization after __new__ returns NULL
parent
bcbfa073
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+2
-0
tests/run/cypclass_new_alloc.pyx
tests/run/cypclass_new_alloc.pyx
+26
-0
No files found.
Cython/Compiler/ModuleNode.py
View file @
489fcbd3
...
...
@@ -1302,6 +1302,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
)
if
init_entry
and
is_new_return_type
:
code
.
putln
(
"if (self) {"
)
# Calling __init__
...
...
@@ -1384,6 +1385,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
init_arg_string
=
','
.
join
(
arg_names
)
code
.
putln
(
"self->%s(%s);"
%
(
init_entry
.
cname
,
init_arg_string
))
code
.
putln
(
"}"
)
code
.
putln
(
"return self;"
)
code
.
putln
(
"}"
)
...
...
tests/run/cypclass_new_alloc.pyx
View file @
489fcbd3
...
...
@@ -109,3 +109,29 @@ def test_new_args_unpacking():
print
obj1
.
b
print
obj2
.
a
print
obj2
.
b
cdef
cypclass
NullNew
:
int
a
NullNew
__new__
(
alloc
,
int
a
):
if
a
<
0
:
with
gil
:
print
(
"nil"
)
return
NULL
return
alloc
()
__init__
(
self
,
int
a
):
with
gil
:
print
(
a
)
self
.
a
=
a
def
test_null_new
():
"""
>>> test_null_new()
nil
1
"""
cdef
NullNew
nil
=
NullNew
(
-
1
)
cdef
NullNew
one
=
NullNew
(
1
)
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