Commit 5e9d7562 authored by Mark Florisson's avatar Mark Florisson

Changed bytes object ob_sval cast to unsigned char * to prevent a RuntimeError with "Invalid cast"

parent 18024c4f
......@@ -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'
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment