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
1bd74d59
Commit
1bd74d59
authored
Apr 10, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
warn when taking char* from a global Python variable (which is externally modifiable)
parent
6d4efb6e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-3
tests/errors/charptr_from_temp.pyx
tests/errors/charptr_from_temp.pyx
+15
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
1bd74d59
...
@@ -9187,9 +9187,14 @@ class CoerceFromPyTypeNode(CoercionNode):
...
@@ -9187,9 +9187,14 @@ class CoerceFromPyTypeNode(CoercionNode):
if
not
result_type
.
create_from_py_utility_code
(
env
):
if
not
result_type
.
create_from_py_utility_code
(
env
):
error
(
arg
.
pos
,
error
(
arg
.
pos
,
"Cannot convert Python object to '%s'"
%
result_type
)
"Cannot convert Python object to '%s'"
%
result_type
)
if
self
.
type
.
is_string
and
self
.
arg
.
is_ephemeral
():
if
self
.
type
.
is_string
:
error
(
arg
.
pos
,
if
self
.
arg
.
is_ephemeral
():
"Obtaining char * from temporary Python value"
)
error
(
arg
.
pos
,
"Obtaining char* from temporary Python value"
)
elif
self
.
arg
.
is_name
and
self
.
arg
.
entry
and
self
.
arg
.
entry
.
is_pyglobal
:
warning
(
arg
.
pos
,
"Obtaining char* from externally modifiable global Python value"
,
level
=
1
)
def
analyse_types
(
self
,
env
):
def
analyse_types
(
self
,
env
):
# The arg is always already analysed
# The arg is always already analysed
...
...
tests/errors/charptr_from_temp.pyx
0 → 100644
View file @
1bd74d59
# mode: error
# tag: werror, charptr, conversion, temp
s
=
b"abc"
cdef
char
*
cptr
cptr
=
s
cptr
=
s
+
b"cba"
_ERRORS
=
"""
8:8: Obtaining char* from externally modifiable global Python value
10:9: Obtaining char* from temporary Python value
"""
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