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
ff08e584
Commit
ff08e584
authored
May 22, 2011
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reverted NoneCheckNode changes
parent
83991ecb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
19 deletions
+31
-19
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+31
-19
No files found.
Cython/Compiler/ExprNodes.py
View file @
ff08e584
...
...
@@ -3744,13 +3744,6 @@ class AttributeNode(ExprNode):
# methods need the normal attribute lookup
# because they do not have struct entries
if
entry
.
is_variable
or
entry
.
is_cmethod
:
# obj.type may be unavailable during type inference
if
self
.
needs_none_check
and
self
.
obj
.
type
and
not
env
.
nogil
:
# FIXME: not sure if 'nogil' should be an
# error or just skip the None check
self
.
obj
=
self
.
obj
.
as_none_safe_node
(
"'NoneType' object has no attribute '%s'"
%
self
.
attribute
,
error
=
'PyExc_AttributeError'
)
self
.
type
=
entry
.
type
self
.
member
=
entry
.
cname
return
...
...
@@ -3835,9 +3828,12 @@ class AttributeNode(ExprNode):
code
.
error_goto_if_null
(
self
.
result
(),
self
.
pos
)))
code
.
put_gotref
(
self
.
py_result
())
else
:
# result_code contains what is needed, unless we need utility code
if
not
self
.
obj
.
type
.
is_extension_type
:
if
self
.
entry
and
self
.
entry
.
utility_code
and
self
.
entry
.
is_cmethod
:
# result_code contains what is needed, but we may need to insert
# a check and raise an exception
if
self
.
obj
.
type
.
is_extension_type
:
if
self
.
needs_none_check
and
code
.
globalstate
.
directives
[
'nonecheck'
]:
self
.
put_nonecheck
(
code
)
elif
self
.
entry
and
self
.
entry
.
is_cmethod
and
self
.
entry
.
utility_code
:
# C method implemented as function call with utility code
code
.
globalstate
.
use_utility_code
(
self
.
entry
.
utility_code
)
...
...
@@ -3857,6 +3853,11 @@ class AttributeNode(ExprNode):
self
.
obj
.
result_as
(
self
.
obj
.
type
),
rhs
.
result_as
(
self
.
ctype
())))
else
:
if
(
self
.
obj
.
type
.
is_extension_type
and
self
.
needs_none_check
and
code
.
globalstate
.
directives
[
'nonecheck'
]):
self
.
put_nonecheck
(
code
)
select_code
=
self
.
result
()
if
self
.
type
.
is_pyobject
and
self
.
use_managed_ref
:
rhs
.
make_owned_reference
(
code
)
...
...
@@ -3892,6 +3893,13 @@ class AttributeNode(ExprNode):
else
:
code
.
annotate
(
self
.
pos
,
AnnotationItem
(
'c_attr'
,
'c attribute'
,
size
=
len
(
self
.
attribute
)))
def
put_nonecheck
(
self
,
code
):
code
.
globalstate
.
use_utility_code
(
raise_noneattr_error_utility_code
)
code
.
putln
(
"if (%s) {"
%
code
.
unlikely
(
"%s == Py_None"
)
%
self
.
obj
.
result_as
(
PyrexTypes
.
py_object_type
))
code
.
putln
(
"__Pyx_RaiseNoneAttributeError(
\
"
%s
\
"
);"
%
self
.
attribute
)
code
.
putln
(
code
.
error_goto
(
self
.
pos
))
code
.
putln
(
"}"
)
#-------------------------------------------------------------------
#
...
...
@@ -7475,8 +7483,6 @@ class NoneCheckNode(CoercionNode):
# raises an appropriate exception (as specified by the creating
# transform).
gil_message
=
"Exception raising on None check"
def
__init__
(
self
,
arg
,
exception_type_cname
,
exception_message
):
CoercionNode
.
__init__
(
self
,
arg
)
self
.
type
=
arg
.
type
...
...
@@ -7485,7 +7491,7 @@ class NoneCheckNode(CoercionNode):
self
.
exception_message
=
exception_message
def
analyse_types
(
self
,
env
):
self
.
arg
.
analyse_types
(
env
)
pass
def
may_be_none
(
self
):
return
False
...
...
@@ -7500,10 +7506,6 @@ class NoneCheckNode(CoercionNode):
return
self
.
arg
.
result
()
def
generate_result_code
(
self
,
code
):
if
False
and
not
code
.
globalstate
.
directives
[
'nonecheck'
]:
# disabled - None checks are often required for safety
# and nonecheck is disabled by default - WTF!
return
code
.
putln
(
"if (unlikely(%s == Py_None)) {"
%
self
.
arg
.
result
())
code
.
putln
(
'PyErr_SetString(%s, "%s"); %s '
%
(
...
...
@@ -8231,6 +8233,16 @@ static CYTHON_INLINE int __Pyx_ErrOccurredWithGIL(void) {
#------------------------------------------------------------------------------------
raise_noneattr_error_utility_code
=
UtilityCode
(
proto
=
"""
static CYTHON_INLINE void __Pyx_RaiseNoneAttributeError(const char* attrname);
"""
,
impl
=
'''
static CYTHON_INLINE void __Pyx_RaiseNoneAttributeError(const char* attrname) {
PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", attrname);
}
'''
)
raise_noneindex_error_utility_code
=
UtilityCode
(
proto
=
"""
static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
...
...
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