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
4571ec70
Commit
4571ec70
authored
Oct 06, 2013
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
disallow assignment from bytes to basestring (only allow str/unicode)
parent
94f7b0eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
2 additions
and
4 deletions
+2
-4
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+1
-1
tests/run/builtin_basestring.pyx
tests/run/builtin_basestring.pyx
+0
-2
No files found.
Cython/Compiler/ExprNodes.py
View file @
4571ec70
...
...
@@ -1160,7 +1160,7 @@ class BytesNode(ConstNode):
node
=
BytesNode
(
self
.
pos
,
value
=
self
.
value
,
constant_result
=
self
.
constant_result
)
if
dst_type
.
is_pyobject
:
if
dst_type
in
(
py_object_type
,
Builtin
.
bytes_type
,
Builtin
.
basestring_type
):
if
dst_type
in
(
py_object_type
,
Builtin
.
bytes_type
):
node
.
type
=
Builtin
.
bytes_type
else
:
self
.
check_for_coercion_error
(
dst_type
,
env
,
fail
=
True
)
...
...
Cython/Compiler/PyrexTypes.py
View file @
4571ec70
...
...
@@ -963,7 +963,7 @@ class BuiltinObjectType(PyObjectType):
def
assignable_from
(
self
,
src_type
):
if
isinstance
(
src_type
,
BuiltinObjectType
):
if
self
.
name
==
'basestring'
:
return
src_type
.
name
in
(
'
bytes'
,
'
str'
,
'unicode'
,
'basestring'
)
return
src_type
.
name
in
(
'str'
,
'unicode'
,
'basestring'
)
else
:
return
src_type
.
name
==
self
.
name
elif
src_type
.
is_extension_type
:
...
...
tests/run/builtin_basestring.pyx
View file @
4571ec70
...
...
@@ -60,8 +60,6 @@ def basestring_typed_variable(obj):
assert
s
s
=
'abc'
assert
s
s
=
b'abc'
assert
s
# make sure coercion also works in conditional expressions
s
=
u'abc'
if
obj
else
b'abc'
if
obj
else
'abc'
assert
s
...
...
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