summaryrefslogtreecommitdiff
path: root/Cython/Debugger
diff options
context:
space:
mode:
authorStefan Behnel <stefan_ml@behnel.de>2017-09-04 10:41:00 +0200
committerStefan Behnel <stefan_ml@behnel.de>2017-09-04 10:41:00 +0200
commita7b253ab4efff1ea98cf43341b055b0100a79ed5 (patch)
tree5965c265be5ef9e7be623c12f02b1096a347225f /Cython/Debugger
parent506f1fdfc2de4b5e5d3ae8024aa62858c8d19bd7 (diff)
downloadcython-a7b253ab4efff1ea98cf43341b055b0100a79ed5.tar.gz
Make string handling and escaping in gdb tests safe.
Diffstat (limited to 'Cython/Debugger')
-rw-r--r--Cython/Debugger/Tests/test_libpython_in_gdb.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/Cython/Debugger/Tests/test_libpython_in_gdb.py b/Cython/Debugger/Tests/test_libpython_in_gdb.py
index 7f384feb8..6f34cee47 100644
--- a/Cython/Debugger/Tests/test_libpython_in_gdb.py
+++ b/Cython/Debugger/Tests/test_libpython_in_gdb.py
@@ -59,25 +59,25 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
assert b'"' not in string
# 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)
def alloc_unicodestring(self, string, gdbvar=None):
- self.alloc_bytestring(string.encode('UTF-8'), gdbvar='_temp')
-
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(
- '(PyObject *) %s($_temp, "UTF-8", "strict")' % funcname,
+ '(PyObject *) %s("%s", %d, "strict")' % (
+ funcname, data.replace('"', r'\"').replace('\\', r'\\'), len(data)),
gdbvar=gdbvar)
def test_bytestring(self):
- bytestring = self.alloc_bytestring("spam")
+ bytestring = self.alloc_bytestring(b"spam")
if inferior_python_version < (3, 0):
bytestring_class = libpython.PyStringObjectPtr
- expected = repr("spam")
+ expected = repr(b"spam")
else:
bytestring_class = libpython.PyBytesObjectPtr
expected = "b'spam'"
@@ -88,7 +88,7 @@ class TestPrettyPrinters(test_libcython_in_gdb.DebugTestCase):
def test_unicode(self):
unicode_string = self.alloc_unicodestring(u"spam ἄλφα")
- expected = "'spam ἄλφα'"
+ expected = u"'spam ἄλφα'"
if inferior_python_version < (3, 0):
expected = 'u' + expected