pycall 0.1.0.alpha.20170419a → 0.1.0.alpha.20170419b
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pycall/pyobject_wrapper.rb +9 -1
- data/lib/pycall/utils.rb +13 -3
- 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: 36ce6abd1f064086a1f22ae9d67294e6b4687387
|
4
|
+
data.tar.gz: 474754869f8f19454eb462523afb95d678f2a8f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac241e957192e609d29df35bf7655c3430a07b7ae75d4eacec7317157d1435f655c3cdee7c4224cf0de7a55e51b029d5db5e04c099586ecdede39a926e07f189
|
7
|
+
data.tar.gz: a5fcf65ce708790d6f82c6d757c3b8c5313e4e62310064a32917e9c9c80e0761cd11c4188b3618e91d016efdf09e691dd73ba582020951e7952116ffe0edcfca
|
@@ -168,7 +168,15 @@ module PyCall
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def method_missing(name, *args, **kwargs)
|
171
|
-
|
171
|
+
name_s = name.to_s
|
172
|
+
if name_s.end_with? '='
|
173
|
+
name = name_s[0..-2]
|
174
|
+
if PyCall.hasattr?(__pyobj__, name.to_s)
|
175
|
+
PyCall.setattr(__pyobj__, name, args.first)
|
176
|
+
else
|
177
|
+
raise NameError, "object has no attribute `#{name}'"
|
178
|
+
end
|
179
|
+
elsif PyCall.hasattr?(__pyobj__, name.to_s)
|
172
180
|
PyCall.getattr(__pyobj__, name)
|
173
181
|
else
|
174
182
|
super
|
data/lib/pycall/utils.rb
CHANGED
@@ -81,9 +81,19 @@ module PyCall
|
|
81
81
|
|
82
82
|
def with(ctx)
|
83
83
|
__exit__ = PyCall.getattr(ctx, :__exit__)
|
84
|
-
|
85
|
-
|
86
|
-
|
84
|
+
begin
|
85
|
+
yield PyCall.getattr(ctx,:__enter__).()
|
86
|
+
rescue Exception => err
|
87
|
+
if err.kind_of? PyError
|
88
|
+
exit_value = __exit__.(err.type, err.value, err.traceback)
|
89
|
+
else
|
90
|
+
# TODO: support telling what exception has been catched
|
91
|
+
exit_value = __exit__.(PyCall.None, PyCall.None, PyCall.None)
|
92
|
+
end
|
93
|
+
raise err unless exit_value.equal? true
|
94
|
+
else
|
95
|
+
__exit__.(PyCall.None, PyCall.None, PyCall.None)
|
96
|
+
end
|
87
97
|
end
|
88
98
|
|
89
99
|
def format_traceback(pyobj)
|
data/lib/pycall/version.rb
CHANGED