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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d20285dca71a8867bee55637a8b1995fce47e898
4
- data.tar.gz: 214b2056f3505f635454e5f6e8673f4f2775d598
3
+ metadata.gz: 36ce6abd1f064086a1f22ae9d67294e6b4687387
4
+ data.tar.gz: 474754869f8f19454eb462523afb95d678f2a8f4
5
5
  SHA512:
6
- metadata.gz: ad310a0658b1beeb3c5036cf54feca2659f22fae5939290c02892f6420991b4bc7280eda88cae278f6f71eb427fde4d1ae00bf938e3a0aca3782e0e11af439f7
7
- data.tar.gz: 7b4dce3bb4d7e8728a365574a7575983447c532f15a24b58a61a68c9e4f7b59208ab72213d792c11cab076483ecdc838a7b6cd01f0a402516edf35be1897b3ef
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
- if PyCall.hasattr?(__pyobj__, name.to_s)
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
- yield PyCall.getattr(ctx,:__enter__).()
85
- ensure
86
- __exit__.()
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)
@@ -1,3 +1,3 @@
1
1
  module PyCall
2
- VERSION = "0.1.0.alpha.20170419a"
2
+ VERSION = "0.1.0.alpha.20170419b"
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.20170419a
4
+ version: 0.1.0.alpha.20170419b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Murata