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
1a56a04b
Commit
1a56a04b
authored
Jan 12, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
call object.__new__() only when we expect an error due to an abstract class being instantiated
parent
6b47bbfe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+14
-3
No files found.
Cython/Compiler/ModuleNode.py
View file @
1a56a04b
...
@@ -1075,6 +1075,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1075,6 +1075,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
have_entries
,
(
py_attrs
,
py_buffers
,
memoryview_slices
)
=
\
have_entries
,
(
py_attrs
,
py_buffers
,
memoryview_slices
)
=
\
scope
.
get_refcounted_entries
()
scope
.
get_refcounted_entries
()
is_final_type
=
scope
.
parent_type
.
is_final_type
if
scope
.
is_internal
:
if
scope
.
is_internal
:
# internal classes (should) never need None inits, normal zeroing will do
# internal classes (should) never need None inits, normal zeroing will do
py_attrs
=
[]
py_attrs
=
[]
...
@@ -1124,9 +1125,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1124,9 +1125,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
freelist_size
:
if
freelist_size
:
code
.
globalstate
.
use_utility_code
(
code
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"IncludeStringH"
,
"StringTools.c"
))
UtilityCode
.
load_cached
(
"IncludeStringH"
,
"StringTools.c"
))
if
is_final_type
:
abstract_check
=
''
else
:
abstract_check
=
' & ((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)'
obj_struct
=
type
.
declaration_code
(
""
,
deref
=
True
)
obj_struct
=
type
.
declaration_code
(
""
,
deref
=
True
)
code
.
putln
(
"if (likely((%s > 0) & (t->tp_basicsize == sizeof(%s))
& ((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)
)) {"
%
(
code
.
putln
(
"if (likely((%s > 0) & (t->tp_basicsize == sizeof(%s))
%s
)) {"
%
(
freecount_name
,
obj_struct
))
freecount_name
,
obj_struct
,
abstract_check
))
code
.
putln
(
"o = (PyObject*)%s[--%s];"
%
(
code
.
putln
(
"o = (PyObject*)%s[--%s];"
%
(
freelist_name
,
freecount_name
))
freelist_name
,
freecount_name
))
code
.
putln
(
"memset(o, 0, sizeof(%s));"
%
obj_struct
)
code
.
putln
(
"memset(o, 0, sizeof(%s));"
%
obj_struct
)
...
@@ -1134,7 +1139,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
...
@@ -1134,7 +1139,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
if
scope
.
needs_gc
():
if
scope
.
needs_gc
():
code
.
putln
(
"PyObject_GC_Track(o);"
)
code
.
putln
(
"PyObject_GC_Track(o);"
)
code
.
putln
(
"} else {"
)
code
.
putln
(
"} else {"
)
code
.
putln
(
"o = (PyObject *) PyBaseObject_Type.tp_new(t, %s, 0);"
%
Naming
.
empty_tuple
)
if
not
is_final_type
:
code
.
putln
(
"if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {"
)
code
.
putln
(
"o = (*t->tp_alloc)(t, 0);"
)
if
not
is_final_type
:
code
.
putln
(
"} else {"
)
code
.
putln
(
"o = (PyObject *) PyBaseObject_Type.tp_new(t, %s, 0);"
%
Naming
.
empty_tuple
)
code
.
putln
(
"}"
)
code
.
putln
(
"if (unlikely(!o)) return 0;"
)
code
.
putln
(
"if (unlikely(!o)) return 0;"
)
if
freelist_size
and
not
base_type
:
if
freelist_size
and
not
base_type
:
code
.
putln
(
'}'
)
code
.
putln
(
'}'
)
...
...
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