Project

General

Profile

Bug #14074

TracePoint#new without a block should not raise ThreadError

Added by atul (Atul Bhosale) over 1 year ago. Updated over 1 year ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
trunk
[ruby-core:83632]

Description

While working on RubySpecs with Marc-Andre Lafortune, we discovered that TracePoint.new raises a ThreadError instead of ArgumentError.
For example :

TracePoint.new => # => ThreadError: must be called with a block

Associated revisions

Revision a5abde57
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

TracePoint.new: raise ArgumentError when no block given [#14074]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60728
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

TracePoint.new: raise ArgumentError when no block given [#14074]

Revision 60728
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

TracePoint.new: raise ArgumentError when no block given [#14074]

Revision 60728
Added by marcandre (Marc-Andre Lafortune) over 1 year ago

TracePoint.new: raise ArgumentError when no block given [#14074]

History

Updated by atul (Atul Bhosale) over 1 year ago

While working on RubySpecs with Marc-Andre Lafortune, we discovered that TracePoint.new raises a ThreadError instead of ArgumentError.
For example :


TracePoint.new => # => ThreadError: must be called with a block

Updated by marcandre (Marc-Andre Lafortune) over 1 year ago

  • Target version set to 2.5
  • Assignee set to marcandre (Marc-Andre Lafortune)

Is there an objection to change this to an ArgumentError?

I wouldn't be asking if the documentation wasn't mentioning it, but sadly it is.

I believe the reason it a ThreadError is raised is that:
1) the code in question was simply copy-pasted from thread.c or thread_sync.c:

$ grep "must be called with a block" *.c
thread.c:   rb_raise(rb_eThreadError, "must be called with a block");
thread_sync.c:  rb_raise(rb_eThreadError, "must be called with a block");
vm_trace.c: rb_raise(rb_eThreadError, "must be called with a block");

2) When Zack documented the TracePoint API, he simply wrote what the behavior was, without questioning it. [#6895]

I don't believe there's actual cases in production of TracePoint.new being called without a black. Nevertheless, we might as well fix this.

So unless there's an objection, I will change the code to raise an ArgumentError and modify the documentation so it does not mention the class of error raised, like in the rest of the documentation.

FWIW, Thread.new and Mutex#synchronize raising ThreadError also seem wrong to be me.

#3

Updated by marcandre (Marc-Andre Lafortune) over 1 year ago

  • Status changed from Open to Closed

Also available in: Atom PDF