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
71ec1a4a
Commit
71ec1a4a
authored
Feb 12, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve unicode escapes in Python 2 raw unicode strings.
Closes #1594.
parent
9746acb3
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
1 deletion
+15
-1
CHANGES.rst
CHANGES.rst
+4
-0
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+2
-1
tests/run/future_unicode_literals.pyx
tests/run/future_unicode_literals.pyx
+6
-0
tests/run/unicodeliterals.pyx
tests/run/unicodeliterals.pyx
+3
-0
No files found.
CHANGES.rst
View file @
71ec1a4a
...
...
@@ -27,6 +27,10 @@ Bugs fixed
* f-string processing was adapted to match recent changes in PEP 498 and
CPython 3.6.
* Unicode escapes in 'ur' raw-unicode strings were not resolved in Py2 code.
Original patch by Aaron Gallagher (Github issue #1594).
0.25.2 (2016-12-08)
===================
...
...
Cython/Compiler/Parsing.py
View file @
71ec1a4a
...
...
@@ -921,7 +921,8 @@ def p_string_literal(s, kind_override=None):
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
:
# in Py2, 'ur' raw unicode strings resolve unicode escapes but nothing else
if
is_raw
and
(
is_python3_source
or
kind
!=
'u'
or
systr
[
1
]
not
in
u'Uu'
):
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
...
...
tests/run/future_unicode_literals.pyx
View file @
71ec1a4a
...
...
@@ -9,6 +9,8 @@ if sys.version_info[0] >= 3:
True
>>> isinstance(b, bytes)
True
>>> raw == 'abc
\
\
\
\
xf8
\
\
\
\
t
\
\
u00f8
\
\
U000000f8' # unescaped by Python (required by doctest)
True
"""
else
:
__doc__
=
u"""
...
...
@@ -18,9 +20,13 @@ else:
True
>>> isinstance(b, str)
True
>>> raw == u'abc
\
\
\
\
xf8
\
\
\
\
t
\
\
u00f8
\
\
U000000f8' # unescaped by Python (required by doctest)
True
"""
u
=
"test"
cdef
char
*
s
=
"bytes test"
b
=
s
raw
=
r'abc\xf8\t\u00f8\U000000f8'
tests/run/unicodeliterals.pyx
View file @
71ec1a4a
...
...
@@ -77,6 +77,8 @@ __doc__ = br"""
True
>>> k == u'
\
\
N{SNOWMAN}' == u'
\
\
u2603'
True
>>> m == u'abc
\
\
\
\
xf8
\
\
\
\
t
\
\
u00f8
\
\
U000000f8' # unescaped by Python (required by doctest)
True
>>> add == u'Søk ik' + u'üÖä' + 'abc'
True
>>> null == u'
\
\
x00' # unescaped by Python (required by doctest)
...
...
@@ -110,6 +112,7 @@ f = u'\xf8'
g
=
u'
\
udc00
'
# lone trail surrogate
h
=
u'
\
ud800
'
# lone lead surrogate
k
=
u'
\
N{SNOWMAN}
'
m
=
ur'abc\xf8\t\u00f8\U000000f8'
add
=
u'Søk ik'
+
u'üÖä'
+
u'abc'
null
=
u'
\
x00
'
...
...
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