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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
71ec1a4a
Commit
71ec1a4a
authored
7 years ago
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
Show 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)
===================
...
...
This diff is collapsed.
Click to expand it.
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
...
...
This diff is collapsed.
Click to expand it.
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'
This diff is collapsed.
Click to expand it.
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
'
...
...
This diff is collapsed.
Click to expand it.
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