diff --git a/ChangeLog b/ChangeLog index dedabe8bc6..d003db5365 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Aug 29 12:19:58 2010 Nobuyoshi Nakada + + * load.c (load_failed): should honor encoding. [ruby-core:31915] + Sun Aug 29 09:35:10 2010 NARUSE, Yui * common.mk (clean): exclude *.inc. [ruby-dev:41931] diff --git a/load.c b/load.c index 891eae48ee..c956977527 100644 --- a/load.c +++ b/load.c @@ -551,8 +551,9 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) static void load_failed(VALUE fname) { - rb_raise(rb_eLoadError, "cannot load such file -- %s", - RSTRING_PTR(fname)); + VALUE mesg = rb_str_buf_new_cstr("cannot load such file -- "); + rb_str_append(mesg, fname); /* should be ASCII compatible */ + rb_exc_raise(rb_exc_new3(rb_eLoadError, mesg)); } static VALUE diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index dd4b808201..6de5659e54 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -40,6 +40,12 @@ class TestRequire < Test::Unit::TestCase end end + def test_require_nonascii + bug3758 = '[ruby-core:31915]' + e = assert_raise(LoadError, bug3758) {require "\u{221e}"} + assert_match(/\u{221e}\z/, e.message, bug3758) + end + def test_require_path_home env_rubypath, env_home = ENV["RUBYPATH"], ENV["HOME"]