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
Gwenaël Samain
cython
Commits
7dd76b30
Commit
7dd76b30
authored
Oct 31, 2009
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tp_new() function return type
parent
da1acf30
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
13 deletions
+6
-13
Cython/Compiler/Optimize.py
Cython/Compiler/Optimize.py
+6
-13
No files found.
Cython/Compiler/Optimize.py
View file @
7dd76b30
...
...
@@ -1038,6 +1038,11 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
### special methods
Pyx_tp_new_func_type
=
PyrexTypes
.
CFuncType
(
PyrexTypes
.
py_object_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"type"
,
Builtin
.
type_type
,
None
)
])
def
_handle_simple_methodany___new__
(
self
,
node
,
args
,
is_unbound_method
):
"""Replace 'exttype.__new__(exttype)' by a call to exttype->tp_new()
"""
...
...
@@ -1063,20 +1068,8 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
type_arg
.
type_entry
.
name
))
return
node
return_type
=
None
if
obj
.
type_entry
:
return_type
=
obj
.
type_entry
.
type
if
return_type
is
None
and
type_arg
.
type_entry
:
return_type
=
type_arg
.
type_entry
.
type
if
return_type
is
None
:
return_type
=
PyrexTypes
.
py_object_type
# FIXME: we could potentially look up the actual tp_new C method
# of the extension type and call that instead of the generic slot
func_type
=
PyrexTypes
.
CFuncType
(
return_type
,
[
PyrexTypes
.
CFuncTypeArg
(
"type"
,
Builtin
.
type_type
,
None
)
])
if
not
type_arg
.
type_entry
:
# arbitrary variable, needs a None check for safety
...
...
@@ -1085,7 +1078,7 @@ class OptimizeBuiltinCalls(Visitor.EnvTransform):
"object.__new__(X): X is not a type object (NoneType)"
)
return
ExprNodes
.
PythonCapiCallNode
(
node
.
pos
,
"__Pyx_tp_new"
,
func_type
,
node
.
pos
,
"__Pyx_tp_new"
,
self
.
Pyx_tp_new_
func_type
,
args
=
[
type_arg
],
utility_code
=
tpnew_utility_code
,
is_temp
=
node
.
is_temp
...
...
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