Commit 8be99465 authored by Stefan Behnel's avatar Stefan Behnel

code simplification

parent 81161bc8
...@@ -6252,17 +6252,10 @@ class CoerceIntToBytesNode(CoerceToPyTypeNode): ...@@ -6252,17 +6252,10 @@ class CoerceIntToBytesNode(CoerceToPyTypeNode):
'"value too large to pack into a byte"); %s' % ( '"value too large to pack into a byte"); %s' % (
code.error_goto(self.pos))) code.error_goto(self.pos)))
code.putln('}') code.putln('}')
temp = None code.putln('%s = PyBytes_FromStringAndSize((const char*)&%s, 1); %s' % (
if arg.type is not PyrexTypes.c_char_type:
temp = code.funcstate.allocate_temp(PyrexTypes.c_char_type, manage_ref=False)
code.putln("%s = (char)%s;" % (temp, arg_result))
arg_result = temp
code.putln('%s = PyBytes_FromStringAndSize(&%s, 1); %s' % (
self.result(), self.result(),
arg_result, arg_result,
code.error_goto_if_null(self.result(), self.pos))) code.error_goto_if_null(self.result(), self.pos)))
if temp is not None:
code.funcstate.release_temp(temp)
code.put_gotref(self.py_result()) code.put_gotref(self.py_result())
......
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