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
eb637f5e
Commit
eb637f5e
authored
Jul 07, 2014
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
do not consider indexing unsafe - reference will live safely in a container in most cases
parent
37e4a206
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-2
tests/errors/charptr_from_temp.pyx
tests/errors/charptr_from_temp.pyx
+4
-3
No files found.
Cython/Compiler/ExprNodes.py
View file @
eb637f5e
...
...
@@ -2806,7 +2806,8 @@ class IndexNode(ExprNode):
def
is_ephemeral
(
self
):
# in most cases, indexing will return a safe reference to an object in a container,
# so we consider the result safe if the base object is
return
self
.
base
.
is_ephemeral
()
return
self
.
base
.
is_ephemeral
()
or
self
.
base
.
type
in
(
basestring_type
,
str_type
,
bytes_type
,
unicode_type
)
def
is_simple
(
self
):
if
self
.
is_buffer_access
or
self
.
memslice_index
:
...
...
@@ -10891,7 +10892,7 @@ class CoerceFromPyTypeNode(CoercionNode):
return
self
def
is_ephemeral
(
self
):
return
self
.
type
.
is_ptr
and
self
.
arg
.
is_
temp
and
not
self
.
arg
.
is_name
return
self
.
type
.
is_ptr
and
self
.
arg
.
is_
ephemeral
()
def
generate_result_code
(
self
,
code
):
function
=
self
.
type
.
from_py_function
...
...
tests/errors/charptr_from_temp.pyx
View file @
eb637f5e
...
...
@@ -18,7 +18,7 @@ cptr = s
# temp => error
cptr
=
s
+
b"cba"
# indexing => error
# indexing => error
(but not clear enough to make it a compiler error)
cptr
=
s
[
0
]
cdef
char
*
x
=
<
char
*>
s
[
0
]
...
...
@@ -47,8 +47,9 @@ cuptr = u + u"cba"
_ERRORS
=
"""
16:8: Obtaining 'char *' from externally modifiable global Python value
19:9: Storing unsafe C derivative of temporary Python reference
22:8: Storing unsafe C derivative of temporary Python reference
23:5: Storing unsafe C derivative of temporary Python reference
#22:8: Storing unsafe C derivative of temporary Python reference
#23:5: Storing unsafe C derivative of temporary Python reference
#23:15: Casting temporary Python object to non-numeric non-Python type
26:8: Storing unsafe C derivative of temporary Python reference
41:9: Obtaining 'Py_UNICODE *' from externally modifiable global Python value
44:10: Storing unsafe C derivative of temporary Python reference
...
...
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