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
78576564
Commit
78576564
authored
Aug 11, 2008
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup: removed special cases from string escaping code
parent
83a9dd2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
Cython/Utils.py
Cython/Utils.py
+7
-5
No files found.
Cython/Utils.py
View file @
78576564
...
...
@@ -100,15 +100,18 @@ class EncodedString(unicode):
# getattr(other, 'encoding', '') == self.encoding
def
_to_oct_sequence
(
s
):
return
''
.
join
([
'
\
\
%03o'
%
ord
(
c
)
for
c
in
s
])
if
s
in
'
\
n
\
r
\
t
'
:
return
repr
(
s
)[
1
:
-
1
]
else
:
return
''
.
join
([
'
\
\
%03o'
%
ord
(
c
)
for
c
in
s
])
_c_special
=
(
'
\
0
'
,
'??'
,
'<:'
,
':>'
,
'<%'
,
'%>'
,
'%:'
,
'%:'
)
_c_special
=
(
'
\
0
'
,
'
\
n
'
,
'
\
r
'
,
'
\
t
'
,
'
??'
,
'<:'
,
':>'
,
'<%'
,
'%>'
,
'%:'
,
'%:'
)
_c_special_replacements
=
zip
(
_c_special
,
map
(
_to_oct_sequence
,
_c_special
))
def
_build_special_test
():
subexps
=
[]
for
special
in
_c_special
+
(
'
\
n
'
,
'
\
r
'
,
'
\
t
'
)
:
regexp
=
''
.
join
([
'[%s]'
%
c
for
c
in
special
])
for
special
in
_c_special
:
regexp
=
''
.
join
([
'[%s]'
%
c
for
c
in
special
])
subexps
.
append
(
regexp
)
return
re
.
compile
(
'('
+
'|'
.
join
(
subexps
)
+
')'
).
search
...
...
@@ -116,7 +119,6 @@ _has_specials = _build_special_test()
def
escape_byte_string
(
s
):
if
_has_specials
(
s
):
s
=
s
.
replace
(
'
\
n
'
,
r'\n'
).
replace
(
'
\
r
'
,
r'\r'
).
replace
(
'
\
t
'
,
r'\t'
)
for
special
,
replacement
in
_c_special_replacements
:
s
=
s
.
replace
(
special
,
replacement
)
try
:
...
...
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