新井です。

Ruby/Tkのパッチ(その2)です。

tk.rb で、例外の発生にraiseを使っている箇所がありますが、
TkWindow#raiseと紛らわしいので、すべてfailに書き直しました。

TkTextWin で使っているraiseはバグだと思います。

  require 'tk'
  TkTextWin.new

  パッチ前:
  => /usr/local/lib/ruby/1.4/tk.rb:2152:in `raise': wrong # of arguments(2 for 1) (ArgumentError)

  パッチ後:
  => /usr/local/lib/ruby/1.5/tk.rb:2152:in `create_self': TkTextWin is abstract class (TypeError)


--- ext/tk/lib/tk.rb.old Mon Jan 24 04:13:01 2000 +++ ext/tk/lib/tk.rb Sat Jan 22 14:50:30 2000 @@ -417,11 +417,11 @@ INTERP._invoke("proc", "rb_out", "args", "if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $args]} ret]] != 0} {if {[regsub -all {!} $args {\\!} newargs] == 0} {return -code $st $ret} {if {[set st [catch {ruby [format \"TkCore.callback %%Q!%s!\" $newargs]} ret]] != 0} {return -code $st $ret} {return $ret}}} {return $ret}") def callback_break - raise TkCallbackBreak, "Tk callback returns 'break' status" + fail TkCallbackBreak, "Tk callback returns 'break' status" end def callback_continue - raise TkCallbackContinue, "Tk callback returns 'continue' status" + fail TkCallbackContinue, "Tk callback returns 'continue' status" end def after(ms, cmd=Proc.new) @@ -527,8 +527,8 @@ args.unshift "unknown" res = INTERP._invoke(*args) rescue - raise unless /^invalid command/ =~ $! - raise err + fail unless /^invalid command/ =~ $! + fail err end end if INTERP._return_value() != 0 @@ -784,7 +784,7 @@ INTERP._eval(format('global %s; set %s', @id, @id)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else Hash[*tk_split_simplelist(INTERP._eval(format('global %s; array get %s', @id, @id)))] @@ -798,7 +798,7 @@ INTERP._eval(format('global %s; set %s %s', @id, @id, s)) rescue if INTERP._eval(format('global %s; array exists %s', @id, @id)) != "1" - raise + fail else if val == [] INTERP._eval(format('global %s; unset %s; set %s(0) 0; unset %s(0)', @@ -815,7 +815,7 @@ INTERP._eval(format('global %s; unset %s; array set %s %s', @id, @id, @id, s)) else - raise + fail end end end @@ -2149,7 +2149,7 @@ class TkTextWin<TkWindow def create_self - raise TypeError, "TkTextWin is abstract class" + fail TypeError, "TkTextWin is abstract class" end def bbox(index)