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): ...@@ -578,13 +578,16 @@ class CyCy(CythonCommand):
cy next cy next
cy run cy run
cy cont cy cont
cy finish
cy up cy up
cy down cy down
cy select
cy bt / cy backtrace cy bt / cy backtrace
cy print
cy list cy list
cy print
cy locals cy locals
cy globals cy globals
cy exec
""" """
name = 'cy' name = 'cy'
......
...@@ -48,6 +48,7 @@ from __future__ import with_statement ...@@ -48,6 +48,7 @@ from __future__ import with_statement
import os import os
import re import re
import sys import sys
import struct
import locale import locale
import atexit import atexit
import warnings import warnings
...@@ -1026,8 +1027,8 @@ class PyBytesObjectPtr(PyObjectPtr): ...@@ -1026,8 +1027,8 @@ class PyBytesObjectPtr(PyObjectPtr):
def __str__(self): def __str__(self):
field_ob_size = self.field('ob_size') field_ob_size = self.field('ob_size')
field_ob_sval = self.field('ob_sval') field_ob_sval = self.field('ob_sval')
char_ptr = field_ob_sval.address.cast(_type_unsigned_char_ptr) return ''.join(struct.pack('b', field_ob_sval[i])
return ''.join([chr(char_ptr[i]) for i in safe_range(field_ob_size)]) for i in safe_range(field_ob_size))
def proxyval(self, visited): def proxyval(self, visited):
return str(self) 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