From 5e9d7562ec2808c4835a7037759793c044028af4 Mon Sep 17 00:00:00 2001 From: Mark Florisson Date: Tue, 30 Nov 2010 00:28:53 +0100 Subject: [PATCH] Changed bytes object ob_sval cast to unsigned char * to prevent a RuntimeError with "Invalid cast" --- Cython/Debugger/libcython.py | 5 ++++- Cython/Debugger/libpython.py | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Cython/Debugger/libcython.py b/Cython/Debugger/libcython.py index a6142ab5..07234e90 100644 --- a/Cython/Debugger/libcython.py +++ b/Cython/Debugger/libcython.py @@ -578,13 +578,16 @@ class CyCy(CythonCommand): cy next cy run cy cont + cy finish cy up cy down + cy select cy bt / cy backtrace - cy print cy list + cy print cy locals cy globals + cy exec """ name = 'cy' diff --git a/Cython/Debugger/libpython.py b/Cython/Debugger/libpython.py index dfca4dda..66242cf8 100644 --- a/Cython/Debugger/libpython.py +++ b/Cython/Debugger/libpython.py @@ -48,6 +48,7 @@ from __future__ import with_statement import os import re import sys +import struct import locale import atexit import warnings @@ -1026,8 +1027,8 @@ class PyBytesObjectPtr(PyObjectPtr): def __str__(self): field_ob_size = self.field('ob_size') field_ob_sval = self.field('ob_sval') - char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr) - return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) + return ''.join(struct.pack('b', field_ob_sval[i]) + for i in safe_range(field_ob_size)) def proxyval(self, visited): return str(self) -- 2.26.2