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
808ed5c2
Commit
808ed5c2
authored
Aug 09, 2010
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent control characters in unicode literals (ord<32) from sneaking into the C source
parent
812eefa1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
Cython/Compiler/StringEncoding.py
Cython/Compiler/StringEncoding.py
+3
-2
No files found.
Cython/Compiler/StringEncoding.py
View file @
808ed5c2
...
@@ -135,7 +135,7 @@ def _to_escape_sequence(s):
...
@@ -135,7 +135,7 @@ def _to_escape_sequence(s):
# within a character sequence, oct passes much better than hex
# within a character sequence, oct passes much better than hex
return
''
.
join
([
'
\
\
%03o'
%
ord
(
c
)
for
c
in
s
])
return
''
.
join
([
'
\
\
%03o'
%
ord
(
c
)
for
c
in
s
])
_c_special
=
(
'
\
\
'
,
'
\
0
'
,
'
\
n
'
,
'
\
r
'
,
'
\
t
'
,
'??'
,
'"'
)
_c_special
=
(
'
\
\
'
,
'
??'
,
'"'
)
+
tuple
(
map
(
chr
,
range
(
32
))
)
_c_special_replacements
=
[(
orig
.
encode
(
'ASCII'
),
_c_special_replacements
=
[(
orig
.
encode
(
'ASCII'
),
_to_escape_sequence
(
orig
).
encode
(
'ASCII'
))
_to_escape_sequence
(
orig
).
encode
(
'ASCII'
))
for
orig
in
_c_special
]
for
orig
in
_c_special
]
...
@@ -171,6 +171,7 @@ def escape_byte_string(s):
...
@@ -171,6 +171,7 @@ def escape_byte_string(s):
"""
"""
if
_has_specials
(
s
):
if
_has_specials
(
s
):
for
special
,
replacement
in
_c_special_replacements
:
for
special
,
replacement
in
_c_special_replacements
:
if
special
in
s
:
s
=
s
.
replace
(
special
,
replacement
)
s
=
s
.
replace
(
special
,
replacement
)
try
:
try
:
return
s
.
decode
(
"ASCII"
)
# trial decoding: plain ASCII => done
return
s
.
decode
(
"ASCII"
)
# trial decoding: plain ASCII => done
...
...
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