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 +4 -4
- data/lib/pycall/conversion.rb +2 -0
- data/lib/pycall/pyerror.rb +4 -4
- data/lib/pycall/pyobject_wrapper.rb +6 -6
- data/lib/pycall/utils.rb +1 -1
- data/lib/pycall/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9498fcad907f67277117e9e637247b85228485e
|
4
|
+
data.tar.gz: b0981d9a5d30e35d80480905381210323d86d852
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20a307abbe8494a1bfb584d1a9c7acceea1f10ad1c7416e01adb2320a8c62f3a315ab1c25693c227ee984319c8139d0c78498df9c2fbee5f5fa8af63679ce678
|
7
|
+
data.tar.gz: 17aae937f321ae1590e4c8bbf089b6024288defe20457282908d090fb6c56a3c7641dd171d5dd832115ac2515b459236364a6f6ee1310c7507b19eb69032bb1a
|
data/lib/pycall/conversion.rb
CHANGED
data/lib/pycall/pyerror.rb
CHANGED
@@ -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 =
|
11
|
-
value =
|
12
|
-
traceback =
|
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
|
-
"#{
|
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(
|
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(
|
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(
|
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(
|
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(
|
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)
|
data/lib/pycall/utils.rb
CHANGED
data/lib/pycall/version.rb
CHANGED