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
f9388e15
Commit
f9388e15
authored
Oct 14, 2018
by
Stefan Behnel
Committed by
GitHub
Oct 14, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2645 from jdemeyer/bytes_non_ascii
Only error out for non-ASCII literals on actual bytes literals
parents
eb841ce5
5d501019
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
1 deletion
+3
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
tests/run/cython3_no_unicode_literals.pyx
tests/run/cython3_no_unicode_literals.pyx
+2
-0
No files found.
Cython/Compiler/Parsing.py
View file @
f9388e15
...
@@ -960,7 +960,7 @@ def p_string_literal(s, kind_override=None):
...
@@ -960,7 +960,7 @@ def p_string_literal(s, kind_override=None):
bytes_value
,
unicode_value
=
chars
.
getstrings
()
bytes_value
,
unicode_value
=
chars
.
getstrings
()
if
is_python3_source
and
has_non_ascii_literal_characters
:
if
is_python3_source
and
has_non_ascii_literal_characters
:
# Python 3 forbids literal non-ASCII characters in byte strings
# Python 3 forbids literal non-ASCII characters in byte strings
if
kind
not
in
(
'u'
,
'f'
)
:
if
kind
==
'b'
:
s
.
error
(
"bytes can only contain ASCII literal characters."
,
pos
=
pos
)
s
.
error
(
"bytes can only contain ASCII literal characters."
,
pos
=
pos
)
bytes_value
=
None
bytes_value
=
None
if
kind
==
'f'
:
if
kind
==
'f'
:
...
...
tests/run/cython3_no_unicode_literals.pyx
View file @
f9388e15
...
@@ -57,6 +57,8 @@ def no_unicode_literals():
...
@@ -57,6 +57,8 @@ def no_unicode_literals():
>>> print( no_unicode_literals() )
>>> print( no_unicode_literals() )
True
True
abcdefg
abcdefg
Testing non-ASCII docstrings: Πυθαγόρας
"""
"""
print
(
isinstance
(
str_string
,
str
)
or
type
(
str_string
))
print
(
isinstance
(
str_string
,
str
)
or
type
(
str_string
))
return
str_string
return
str_string
...
...
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