Method: PyCall.with

Defined in:
lib/pycall.rb

.with(ctx) ⇒ Object



113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/pycall.rb', line 113

def with(ctx)
  begin
    yield ctx.__enter__
  rescue PyError => err
    raise err unless ctx.__exit__(err.type, err.value, err.traceback)
  rescue Exception => err
    # TODO: support telling what exception has been catched
    raise err unless ctx.__exit__(err.class, err, err.backtrace_locations)
  else
    ctx.__exit__(nil, nil, nil)
  end
end