pycall 0.1.0.alpha.20170308 → 0.1.0.alpha.20170309

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 438d4095d0ef876b3a9593ee86a5608851cc5384
4
- data.tar.gz: 044d40dcceed8e34a5c3a701a60fa7baf7879d5f
3
+ metadata.gz: e9498fcad907f67277117e9e637247b85228485e
4
+ data.tar.gz: b0981d9a5d30e35d80480905381210323d86d852
5
5
  SHA512:
6
- metadata.gz: 9928a513029558ef850a99c209ab9a821037a9473406f5f6159d873d535a72ca9869ccd82a241444bcf64a25909b1c6c41e1b2a4393a7cd89645f3063efb9a7e
7
- data.tar.gz: e04f844e7d2d239556ca4e32c82a6ea4e8a40bc7f53dcd9bf30700bdd02269abed6c63a81d060a36954d87897db170021c0da4fee7a80740eace43df65c4b023
6
+ metadata.gz: 20a307abbe8494a1bfb584d1a9c7acceea1f10ad1c7416e01adb2320a8c62f3a315ab1c25693c227ee984319c8139d0c78498df9c2fbee5f5fa8af63679ce678
7
+ data.tar.gz: 17aae937f321ae1590e4c8bbf089b6024288defe20457282908d090fb6c56a3c7641dd171d5dd832115ac2515b459236364a6f6ee1310c7507b19eb69032bb1a
@@ -45,6 +45,8 @@ module PyCall
45
45
 
46
46
  def self.from_ruby(obj)
47
47
  case obj
48
+ when LibPython::PyObjectStruct
49
+ obj
48
50
  when PyObject, PyObjectWrapper
49
51
  obj.__pyobj__
50
52
  when TrueClass, FalseClass
@@ -7,9 +7,9 @@ module PyCall
7
7
  ptraceback = ptrs + 2 * ptrs.type_size
8
8
  LibPython.PyErr_Fetch(ptype, pvalue, ptraceback)
9
9
  LibPython.PyErr_NormalizeException(ptype, pvalue, ptraceback)
10
- type = PyObject.new(LibPython::PyObjectStruct.new(ptype.read(:pointer)))
11
- value = PyObject.new(LibPython::PyObjectStruct.new(pvalue.read(:pointer)))
12
- traceback = PyObject.new(LibPython::PyObjectStruct.new(ptraceback.read(:pointer)))
10
+ type = Conversions.to_ruby(LibPython::PyObjectStruct.new(ptype.read(:pointer)))
11
+ value = Conversions.to_ruby(LibPython::PyObjectStruct.new(pvalue.read(:pointer)))
12
+ traceback = Conversions.to_ruby(LibPython::PyObjectStruct.new(ptraceback.read(:pointer)))
13
13
  new(type, value, traceback)
14
14
  end
15
15
 
@@ -23,7 +23,7 @@ module PyCall
23
23
  attr_reader :type, :value, :traceback
24
24
 
25
25
  def message
26
- "#{PyObject.new(type.to_ptr)}: #{value}".tap do |msg|
26
+ "#{type}: #{value}".tap do |msg|
27
27
  unless traceback.null?
28
28
  if (o = PyCall.format_traceback(traceback))
29
29
  msg.concat("\n", *o)
@@ -122,41 +122,41 @@ module PyCall
122
122
 
123
123
  def +(other)
124
124
  other = Conversions.from_ruby(other)
125
- value = LibPython.PyNumber_Add(self, other)
125
+ value = LibPython.PyNumber_Add(__pyobj__, other)
126
126
  return value.to_ruby unless value.null?
127
127
  raise PyError.fetch
128
128
  end
129
129
 
130
130
  def -(other)
131
131
  other = Conversions.from_ruby(other)
132
- value = LibPython.PyNumber_Subtract(self, other)
132
+ value = LibPython.PyNumber_Subtract(__pyobj__, other)
133
133
  return value.to_ruby unless value.null?
134
134
  raise PyError.fetch
135
135
  end
136
136
 
137
137
  def *(other)
138
138
  other = Conversions.from_ruby(other)
139
- value = LibPython.PyNumber_Multiply(self, other)
139
+ value = LibPython.PyNumber_Multiply(__pyobj__, other)
140
140
  return value.to_ruby unless value.null?
141
141
  raise PyError.fetch
142
142
  end
143
143
 
144
144
  def /(other)
145
145
  other = Conversions.from_ruby(other)
146
- value = LibPython.PyNumber_TrueDivide(self, other)
146
+ value = LibPython.PyNumber_TrueDivide(__pyobj__, other)
147
147
  return value.to_ruby unless value.null?
148
148
  raise PyError.fetch
149
149
  end
150
150
 
151
151
  def **(other)
152
152
  other = Conversions.from_ruby(other)
153
- value = LibPython.PyNumber_Power(self, other, PyCall.None)
153
+ value = LibPython.PyNumber_Power(__pyobj__, other, PyCall.None)
154
154
  return value.to_ruby unless value.null?
155
155
  raise PyError.fetch
156
156
  end
157
157
 
158
158
  def coerce(other)
159
- [Conversions.from_ruby(other), self]
159
+ [PyObject.new(Conversions.from_ruby(other)), self]
160
160
  end
161
161
 
162
162
  def call(*args, **kwargs)
@@ -2,7 +2,7 @@ module PyCall
2
2
  module Utils
3
3
  def append_sys_path(path_str)
4
4
  pyobj = LibPython.PyUnicode_DecodeUTF8(path_str, path_str.bytesize, nil)
5
- sys.path.append.(pyobj)
5
+ sys.path << pyobj
6
6
  end
7
7
 
8
8
  def callable?(pyobj)
@@ -1,3 +1,3 @@
1
1
  module PyCall
2
- VERSION = "0.1.0.alpha.20170308"
2
+ VERSION = "0.1.0.alpha.20170309"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pycall
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha.20170308
4
+ version: 0.1.0.alpha.20170309
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata