lib/pycall/pyerror.rb in pycall-0.1.0.alpha.20170308 vs lib/pycall/pyerror.rb in pycall-0.1.0.alpha.20170309

- old
+ new

@@ -5,13 +5,13 @@ ptype = ptrs + 0 * ptrs.type_size pvalue = ptrs + 1 * ptrs.type_size ptraceback = ptrs + 2 * ptrs.type_size LibPython.PyErr_Fetch(ptype, pvalue, ptraceback) LibPython.PyErr_NormalizeException(ptype, pvalue, ptraceback) - type = PyObject.new(LibPython::PyObjectStruct.new(ptype.read(:pointer))) - value = PyObject.new(LibPython::PyObjectStruct.new(pvalue.read(:pointer))) - traceback = PyObject.new(LibPython::PyObjectStruct.new(ptraceback.read(:pointer))) + type = Conversions.to_ruby(LibPython::PyObjectStruct.new(ptype.read(:pointer))) + value = Conversions.to_ruby(LibPython::PyObjectStruct.new(pvalue.read(:pointer))) + traceback = Conversions.to_ruby(LibPython::PyObjectStruct.new(ptraceback.read(:pointer))) new(type, value, traceback) end def initialize(type, value, traceback) @type = type @@ -21,10 +21,10 @@ end attr_reader :type, :value, :traceback def message - "#{PyObject.new(type.to_ptr)}: #{value}".tap do |msg| + "#{type}: #{value}".tap do |msg| unless traceback.null? if (o = PyCall.format_traceback(traceback)) msg.concat("\n", *o) end end