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
Boxiang Sun
cython
Commits
04c4aac2
Commit
04c4aac2
authored
Apr 11, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #111 from scoder/_warn_charptr_from_pyglobal
warn when taking char* from a global Python variable
parents
5a8c28b3
dbefbb55
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+8
-3
tests/errors/charptr_from_temp.pyx
tests/errors/charptr_from_temp.pyx
+24
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
04c4aac2
...
...
@@ -9187,9 +9187,14 @@ class CoerceFromPyTypeNode(CoercionNode):
if
not
result_type
.
create_from_py_utility_code
(
env
):
error
(
arg
.
pos
,
"Cannot convert Python object to '%s'"
%
result_type
)
if
self
.
type
.
is_string
and
self
.
arg
.
is_ephemeral
():
if
self
.
type
.
is_string
:
if
self
.
arg
.
is_ephemeral
():
error
(
arg
.
pos
,
"Obtaining char * from temporary Python value"
)
"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
):
# The arg is always already analysed
...
...
tests/errors/charptr_from_temp.pyx
0 → 100644
View file @
04c4aac2
# mode: error
# tag: werror, charptr, conversion, temp
cdef
bytes
c_s
=
b"abc"
s
=
b"abc"
cdef
char
*
cptr
# constant => ok
cptr
=
b"xyz"
# global cdef variable => ok
cptr
=
c_s
# pyglobal => warning
cptr
=
s
# temp => error
cptr
=
s
+
b"cba"
_ERRORS
=
"""
16:8: Obtaining char* from externally modifiable global Python value
19: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