[#104169] [Ruby master Feature#17938] Keyword alternative for boolean positional arguments — matheusrichardt@...

Issue #17938 has been reported by matheusrich (Matheus Richard).

12 messages 2021/06/04

[#104213] [Ruby master Feature#17942] Add a `initialize(public @a, private @b)` shortcut syntax for defining public/private accessors for instance vars — tyler@...

Issue #17942 has been reported by TylerRick (Tyler Rick).

6 messages 2021/06/09

[#104288] [Ruby master Bug#17992] Upstreaming the htmlentities gem into CGI#.(un)escape_html — alexandermomchilov@...

Issue #17992 has been reported by AMomchilov (Alexander Momchilov).

9 messages 2021/06/15

[#104338] [Ruby master Misc#17997] DevelopersMeeting20210715Japan — mame@...

Issue #17997 has been reported by mame (Yusuke Endoh).

10 messages 2021/06/17

[#104361] [Ruby master Bug#18000] have_library doesn't work when ruby is compiled with --disable-shared --disable-install-static-library — jean.boussier@...

Issue #18000 has been reported by byroot (Jean Boussier).

9 messages 2021/06/18

[#104401] [Ruby master Feature#18007] Help developers of C extensions meet requirements in "doc/extension.rdoc" — mike.dalessio@...

Issue #18007 has been reported by mdalessio (Mike Dalessio).

16 messages 2021/06/25

[#104430] [Ruby master Bug#18011] `Method#parameters` is incorrect for forwarded arguments — josh.cheek@...

Issue #18011 has been reported by josh.cheek (Josh Cheek).

12 messages 2021/06/29

[ruby-core:104320] [Ruby master Feature#14835] Support TracePoint#raised_exception on non-:raise events

From: merch-redmine@...
Date: 2021-06-16 19:46:41 UTC
List: ruby-core #104320
Issue #14835 has been updated by jeremyevans0 (Jeremy Evans).

Backport deleted (2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN)
ruby -v deleted (ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-darwin17])
Subject changed from Impossible to know whether an exception was rescued or not using TracePoint to Support TracePoint#raised_exception on non-:raise events
Tracker changed from Bug to Feature

I looked into this, and with the current TracePoint design, it does not appear possible.  For `:raise` events, the `raised_exception` is stored in `trace_args->data`.  This is the same location that the return value is stored for `:return`, `:c_return`, and `:b_return` events.  To change this, we would have to modify `rb_trace_arg_struct` to support additional space for storing the exception in the non-`:raise` case, and I'm not sure at the point of `:return` (or `:c_return`/`:b_return`) if we can get the exception.

`TracePoint#raised_exception` is documented to only work for `:raise` events and not other events.  So the current behavior is not a bug.  I agree that there may be cases where `raised_exception` would be useful in other events.  So I'm switching to feature request, though I don't know if it is feasible to implement such a feature.

----------------------------------------
Feature #14835: Support TracePoint#raised_exception on non-:raise events
https://bugs.ruby-lang.org/issues/14835#change-92543

* Author: tagomoris (Satoshi TAGOMORI)
* Status: Open
* Priority: Normal
----------------------------------------
TracePoint supports :raise and :return events, and :return event will be invoked when an exception occurs in a method.
But its TracePoint block parameter instance doesn't have any information about raised exceptions.

That means, we can know an exception was raised in a method, but we cannot know an exception was rescued or not there.

```ruby
def thrower
  raise "exception"
end

def caller_without_rescue
  thrower
end

tp = TracePoint.trace(:raise, :return) do |tp|
  case tp.event
  when :raise
    p(here: "trace", event: :raise, klass: tp.defined_class, method: tp.method_id, exception: tp.raised_exception)
  else
    p(here: "trace", event: tp.event, klass: tp.defined_class, method: tp.method_id, value: tp.return_value)
  end
end


caller_with_rescue

puts "\n----------------------\n"

begin
  caller_without_rescue
rescue => e2
  puts "outer rescue: #{e2}"
end
```

The script above shows these events, but TracePoint events are completely same in these two examples.

```
# caller_with_rescue
{:here=>"trace", :event=>:raise, :klass=>Object, :method=>:thrower, :exception=>#<RuntimeError: exception>}
{:here=>"trace", :event=>:return, :klass=>Object, :method=>:thrower, :value=>nil}
rescue: exception
{:here=>"trace", :event=>:return, :klass=>Object, :method=>:caller_with_rescue, :value=>nil}

----------------------
# caller_without_rescue
{:here=>"trace", :event=>:raise, :klass=>Object, :method=>:thrower, :exception=>#<RuntimeError: exception>}
{:here=>"trace", :event=>:return, :klass=>Object, :method=>:thrower, :value=>nil}
{:here=>"trace", :event=>:return, :klass=>Object, :method=>:caller_without_rescue, :value=>nil}
outer rescue: exception
```

My expectation is that TracePoint instance should contain exception instance in `raised_exception` at the time when it's not rescued.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next