From: "ko1 (Koichi Sasada)" Date: 2012-12-05T11:52:01+09:00 Subject: [ruby-core:50561] [ruby-trunk - Bug #7513][Open] TracePoint#enable/disable should not cause error Issue #7513 has been reported by ko1 (Koichi Sasada). ---------------------------------------- Bug #7513: TracePoint#enable/disable should not cause error https://bugs.ruby-lang.org/issues/7513 Author: ko1 (Koichi Sasada) Status: Open Priority: Normal Assignee: ko1 (Koichi Sasada) Category: core Target version: 2.0.0 ruby -v: ruby 2.0.0dev (2012-12-01 trunk 38127) [i386-mswin32_100] =begin = Abstract TracePoint#enable/disable should not cause error if it is enabled or disabled. = Problem The following code cause error because it calls "enable" on enabled tracepoint. trace = TracePoint.trace{} p trace.enabled? #=> true trace.enable #=> `enable': trace is already enable (RuntimeError) However, similar feature "GC.enable" and "GC.disable" don't cause error. They only return previous status. = Solution TracePoint#enable and disable should align GC.enable/disable. trace = TracePoint.trace{} # enable trace.enable # do nothing, and return true (enabled) trace.enable{ ... } # after block, trace is still enable Any comments? =end -- http://bugs.ruby-lang.org/