Sha256: 6fb13efa2af5e09ca4e26f64ba3a148dda2bdce41224a1bafdfd4c0ad161dce6
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
module PyCall class PyError < StandardError def self.fetch ptrs = FFI::MemoryPointer.new(:pointer, 3) 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 = PyTypeObject.new(ptype.read(:pointer)) value = PyObject.new(pvalue.read(:pointer)) traceback = PyObject.new(ptraceback.read(:pointer)) new(type, value, traceback) end def initialize(type, value, traceback) @type = type @value = value @traceback = traceback super("Error occurred in Python") end attr_reader :type, :value, :traceback def message "#{PyObject.new(type.to_ptr)}: #{value}".tap do |msg| unless traceback.null? if (o = PyCall.format_traceback(traceback)) msg.concat("\n", *o) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
pycall-0.1.0.alpha.20170307 | lib/pycall/pyerror.rb |
pycall-0.1.0.alpha.20170302 | lib/pycall/pyerror.rb |
pycall-0.1.0.alpha.20170226 | lib/pycall/pyerror.rb |