From: Akio Tajima Date: 2009-02-13T01:15:28+09:00 Subject: [ruby-dev:37979] [Bug #1150] calling instance_eval in extended library cause exception Bug #1150: calling instance_eval in extended library cause exception http://redmine.ruby-lang.org/issues/show/1150 起票者: Akio Tajima ステータス: Open, 優先度: Normal Target version: 1.9.1 ruby -v: ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-mswin32] 拡張ライブラリ内のメソッドでinstance_evalを呼び出すと、Can't eval on top of Fiber or Thread (RuntimeError)になります。 再現コードを以下に示します。 // cmodev.c #include "ruby.h" #include "extconf.h" static VALUE cmodev; static VALUE xtest_func(VALUE self, VALUE s) { return rb_funcall2(self, rb_intern("instance_eval"), 1, &s); } void Init_cmodev() { cmodev = rb_define_class("XTest", rb_cObject); rb_define_method(cmodev, "xtest", xtest_func, 1); } #t.rb require 'cmodev' x = XTest.new x.xtest("puts 'hello'") 実行例 c:\test\modev\test>ruby t.rb t.rb:3:in `instance_eval': Can't eval on top of Fiber or Thread (RuntimeError) from t.rb:3:in `xtest' from t.rb:3:in `
' ---------------------------------------- http://redmine.ruby-lang.org