Project

General

Profile

Actions

Backport #7185

closed

requireしたファイルからのthrowをcatchするとNotImplementedErrorが起きる

Added by Anonymous over 11 years ago. Updated over 11 years ago.

Status:
Closed
[ruby-dev:46234]

Description

はじめまして、yfujitaと申します.

以下の2つのファイルを用意して、./req.rb を実行するとエラーになります.
これは、1.9 以降はこういう記述はできなくなったという事なのでしょうか?

require される側(dep.rb)を途中で抜けるために使っていたのですが、
良い方法はないでしょうか?

==== ./dep.rb ====
#!/usr/local/bin/ruby

throw :extdep

==== ./req.rb ====
#!/usr/local/bin/ruby
$:.unshift(".")

catch(:extdep){
require 'dep.rb'
}

./req.rb

/usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': method backtrace' called on unexpected T_NODE object (0x00000002337d20
flags=0x381c klass=0x0) (NotImplementedError)
from /usr/local/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' from ./req.rb:5:in block in '
from ./req.rb:4:in catch' from ./req.rb:4:in '

ruby -v

ruby 1.9.3p286 (2012-10-12 revision 37165) [x86_64-linux]

ruby 1.8.7 では正常に終了します.

ruby -v

ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]

./req.rb

ubuntu に入っているruby1.9.3p0でもエラーで終了します.

ruby -v

ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-linux]

./req.rb

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require': method backtrace' called on unexpected T_NODE object (0x000000011fce20
flags=0x381c klass=0x0) (NotImplementedError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in require' from ./req.rb:5:in block in '
from ./req.rb:4:in catch' from ./req.rb:4:in '

  • 環境

Ubuntu 12.04 server 64 bit
仮想PC(Virtualbox)
ruby 1.9.3p286

ruby1.9.3p286は、Ubuntu 12.04 server 上でコンパイルしたものです.
make test-all でいくつかエラーがありましたが無視して
インストールしてみたものです.

Ubuntu 12.04 client 64 bit
実PC
ruby 1.9.3p0
ruby 1.8.7
どちらもubuntu付属のrubyです.

--
Yoshihiko Fujita

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0