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
Kirill Smelkov
cython
Commits
2b4d1c37
Commit
2b4d1c37
authored
Feb 11, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert the part of the fstring changes that broke Py3 string content checking
parent
f158faef
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
Cython/Compiler/Parsing.pxd
Cython/Compiler/Parsing.pxd
+1
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+6
-1
No files found.
Cython/Compiler/Parsing.pxd
View file @
2b4d1c37
...
...
@@ -68,7 +68,7 @@ cdef p_opt_string_literal(PyrexScanner s, required_type=*)
cdef
bint
check_for_non_ascii_characters
(
unicode
string
)
@
cython
.
locals
(
systr
=
unicode
,
is_python3_source
=
bint
,
is_raw
=
bint
)
cdef
p_string_literal
(
PyrexScanner
s
,
kind_override
=*
)
cdef
_append_escape_sequence
(
kind
,
builder
,
escape_sequence
,
PyrexScanner
s
)
cdef
_append_escape_sequence
(
kind
,
builder
,
unicode
escape_sequence
,
PyrexScanner
s
)
@
cython
.
locals
(
i
=
Py_ssize_t
,
size
=
Py_ssize_t
,
c
=
Py_UCS4
)
cdef
list
p_f_string
(
PyrexScanner
s
,
unicode_value
,
pos
,
bint
is_raw
)
@
cython
.
locals
(
i
=
Py_ssize_t
,
size
=
Py_ssize_t
,
c
=
Py_UCS4
,
quote_char
=
Py_UCS4
,
NO_CHAR
=
Py_UCS4
)
...
...
Cython/Compiler/Parsing.py
View file @
2b4d1c37
...
...
@@ -868,6 +868,7 @@ def p_string_literal(s, kind_override=None):
# s.sy == 'BEGIN_STRING'
pos
=
s
.
position
()
is_python3_source
=
s
.
context
.
language_level
>=
3
has_non_ascii_literal_characters
=
False
kind_string
=
s
.
systring
.
rstrip
(
'"
\
'
'
).
lower
()
if
len
(
kind_string
)
>
1
:
if
len
(
set
(
kind_string
))
!=
len
(
kind_string
):
...
...
@@ -917,9 +918,13 @@ def p_string_literal(s, kind_override=None):
# print "p_string_literal: sy =", sy, repr(s.systring) ###
if
sy
==
'CHARS'
:
chars
.
append
(
systr
)
if
is_python3_source
and
not
has_non_ascii_literal_characters
and
check_for_non_ascii_characters
(
systr
):
has_non_ascii_literal_characters
=
True
elif
sy
==
'ESCAPE'
:
if
is_raw
:
chars
.
append
(
systr
)
if
is_python3_source
and
not
has_non_ascii_literal_characters
and
check_for_non_ascii_characters
(
systr
):
has_non_ascii_literal_characters
=
True
else
:
_append_escape_sequence
(
kind
,
chars
,
systr
,
s
)
elif
sy
==
'NEWLINE'
:
...
...
@@ -939,7 +944,7 @@ def p_string_literal(s, kind_override=None):
error
(
pos
,
u"invalid character literal: %r"
%
bytes_value
)
else
:
bytes_value
,
unicode_value
=
chars
.
getstrings
()
if
is_python3_source
and
unicode_value
and
check_for_non_ascii_characters
(
unicode_value
)
:
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'
):
s
.
error
(
"bytes can only contain ASCII literal characters."
,
pos
=
pos
)
...
...
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