Skip to content

Commit

Permalink
Merge pull request cython#2645 from jdemeyer/bytes_non_ascii
Browse files Browse the repository at this point in the history
Only error out for non-ASCII literals on actual bytes literals
  • Loading branch information
scoder authored Oct 14, 2018
2 parents eb841ce + 5d50101 commit f9388e1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cython/Compiler/Parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def p_string_literal(s, kind_override=None):
bytes_value, unicode_value = chars.getstrings()
if is_python3_source and has_non_ascii_literal_characters:
# 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)
bytes_value = None
if kind == 'f':
Expand Down
2 changes: 2 additions & 0 deletions tests/run/cython3_no_unicode_literals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def no_unicode_literals():
>>> print( no_unicode_literals() )
True
abcdefg
Testing non-ASCII docstrings: Πυθαγόρας
"""
print(isinstance(str_string, str) or type(str_string))
return str_string
Expand Down

0 comments on commit f9388e1

Please sign in to comment.