Sha256: 4b2feac418fa82f545ac39f94dc5a7cbc79032364ea314fde4b685c160f820c0
Contents?: true
Size: 812 Bytes
Versions: 2
Compression:
Stored size: 812 Bytes
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("#{@type.inspect}: #{PyCall.eval('str').(@value)}") end attr_reader :type, :value, :traceback end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pycall-0.1.0.alpha.20170224b | lib/pycall/pyerror.rb |
pycall-0.1.0.alpha.20170224 | lib/pycall/pyerror.rb |