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
a7b253ab
Commit
a7b253ab
authored
Sep 04, 2017
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make string handling and escaping in gdb tests safe.
parent
506f1fdf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
Cython/Debugger/Tests/test_libpython_in_gdb.py
Cython/Debugger/Tests/test_libpython_in_gdb.py
+8
-8
No files found.
Cython/Debugger/Tests/test_libpython_in_gdb.py
View file @
a7b253ab
...
@@ -59,25 +59,25 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
...
@@ -59,25 +59,25 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
assert
b'"'
not
in
string
assert
b'"'
not
in
string
# ensure double quotes
# ensure double quotes
code
=
'(PyObject *) %s("%s", %d)'
%
(
funcname
,
string
,
len
(
string
))
code
=
'(PyObject *) %s("%s", %d)'
%
(
funcname
,
string
.
decode
(
'iso8859-1'
)
,
len
(
string
))
return
self
.
pyobject_fromcode
(
code
,
gdbvar
=
gdbvar
)
return
self
.
pyobject_fromcode
(
code
,
gdbvar
=
gdbvar
)
def
alloc_unicodestring
(
self
,
string
,
gdbvar
=
None
):
def
alloc_unicodestring
(
self
,
string
,
gdbvar
=
None
):
self
.
alloc_bytestring
(
string
.
encode
(
'UTF-8'
),
gdbvar
=
'_temp'
)
postfix
=
libpython
.
get_inferior_unicode_postfix
()
postfix
=
libpython
.
get_inferior_unicode_postfix
()
funcname
=
'PyUnicode%s_
FromEncodedObject
'
%
(
postfix
,)
funcname
=
'PyUnicode%s_
DecodeUnicodeEscape
'
%
(
postfix
,)
data
=
string
.
encode
(
"unicode_escape"
).
decode
(
'iso8859-1'
)
return
self
.
pyobject_fromcode
(
return
self
.
pyobject_fromcode
(
'(PyObject *) %s($_temp, "UTF-8", "strict")'
%
funcname
,
'(PyObject *) %s("%s", %d, "strict")'
%
(
funcname
,
data
.
replace
(
'"'
,
r'\"'
).
replace
(
'
\
\
'
,
r'\\'
),
len
(
data
)),
gdbvar
=
gdbvar
)
gdbvar
=
gdbvar
)
def
test_bytestring
(
self
):
def
test_bytestring
(
self
):
bytestring
=
self
.
alloc_bytestring
(
"spam"
)
bytestring
=
self
.
alloc_bytestring
(
b
"spam"
)
if
inferior_python_version
<
(
3
,
0
):
if
inferior_python_version
<
(
3
,
0
):
bytestring_class
=
libpython
.
PyStringObjectPtr
bytestring_class
=
libpython
.
PyStringObjectPtr
expected
=
repr
(
"spam"
)
expected
=
repr
(
b
"spam"
)
else
:
else
:
bytestring_class
=
libpython
.
PyBytesObjectPtr
bytestring_class
=
libpython
.
PyBytesObjectPtr
expected
=
"b'spam'"
expected
=
"b'spam'"
...
@@ -88,7 +88,7 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
...
@@ -88,7 +88,7 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
def
test_unicode
(
self
):
def
test_unicode
(
self
):
unicode_string
=
self
.
alloc_unicodestring
(
u"spam ἄλφα"
)
unicode_string
=
self
.
alloc_unicodestring
(
u"spam ἄλφα"
)
expected
=
"'spam ἄλφα'"
expected
=
u
"'spam ἄλφα'"
if
inferior_python_version
<
(
3
,
0
):
if
inferior_python_version
<
(
3
,
0
):
expected
=
'u'
+
expected
expected
=
'u'
+
expected
...
...
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