lib/pycall/pyobject_wrapper.rb in pycall-0.1.0.alpha.20170309 vs lib/pycall/pyobject_wrapper.rb in pycall-0.1.0.alpha.20170311
- old
+ new
@@ -47,10 +47,11 @@
def self.included(mod)
mod.extend ClassMethods
end
def initialize(pyobj)
+ pyobj = LibPython::PyObjectStruct.new(pyobj) if pyobj.kind_of? FFI::Pointer
pyobj = pyobj.__pyobj__ unless pyobj.kind_of? LibPython::PyObjectStruct
@__pyobj__ = pyobj
end
attr_reader :__pyobj__
@@ -84,11 +85,10 @@
def rich_compare(other, op)
opcode = RICH_COMPARISON_OPCODES[op]
raise ArgumentError, "Unknown comparison op: #{op}" unless opcode
- other = other.__pyobj__ unless other.kind_of? LibPython::PyObjectStruct
- other = Conversions.from_ruby(other) unless other.kind_of?(LibPython::PyObjectStruct)
+ other = Conversions.from_ruby(other)
return other.null? if __pyobj__.null?
return false if other.null?
value = LibPython.PyObject_RichCompare(__pyobj__, other, opcode)
raise "Unable to compare: #{self} #{op} #{other}" if value.null?