[前][次][番号順一覧][スレッド一覧]

ruby-changes:21860

From: naruse <ko1@a...>
Date: Wed, 30 Nov 2011 23:44:20 +0900 (JST)
Subject: [ruby-changes:21860] naruse:r33909 (trunk): * variable.c (rb_path2class): don't raise NameError when the middle

naruse	2011-11-30 23:44:06 +0900 (Wed, 30 Nov 2011)

  New Revision: 33909

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33909

  Log:
    * variable.c (rb_path2class): don't raise NameError when the middle
      constant of the path is not defined but defined on toplevel.
      [ruby-core:41410] [Bug #5691]

  Added directories:
    trunk/ext/-test-/path_to_class/
    trunk/test/-ext-/path_to_class/
  Added files:
    trunk/ext/-test-/path_to_class/extconf.rb
    trunk/ext/-test-/path_to_class/path_to_class.c
    trunk/test/-ext-/path_to_class/test_path_to_class.rb
  Modified files:
    trunk/ChangeLog
    trunk/variable.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33908)
+++ ChangeLog	(revision 33909)
@@ -1,3 +1,9 @@
+Wed Nov 30 23:35:45 2011  NARUSE, Yui  <naruse@r...>
+
+	* variable.c (rb_path2class): don't raise NameError when the middle
+	  constant of the path is not defined but defined on toplevel.
+	  [ruby-core:41410] [Bug #5691]
+
 Wed Nov 30 20:02:02 2011  Martin Duerst  <duerst@i...>
 
 	* transcode.c: Simplified rb_econv_binmode, avoided a warning on cygwin.
Index: variable.c
===================================================================
--- variable.c	(revision 33908)
+++ variable.c	(revision 33909)
@@ -272,7 +272,7 @@
 	    p += 2;
 	    pbeg = p;
 	}
-	if (!rb_const_defined(c, id)) {
+	if (!rb_const_defined_at(c, id)) {
 	  undefined_class:
 	    rb_raise(rb_eArgError, "undefined class/module %.*s", (int)(p-path), path);
 	}
Index: ext/-test-/path_to_class/path_to_class.c
===================================================================
--- ext/-test-/path_to_class/path_to_class.c	(revision 0)
+++ ext/-test-/path_to_class/path_to_class.c	(revision 33909)
@@ -0,0 +1,9 @@
+#include "ruby.h"
+
+void
+Init_path_to_class(void)
+{
+    VALUE klass = rb_path2class("Test_PathToClass");
+
+    rb_define_singleton_method(klass, "path_to_class", rb_path_to_class, 1);
+}
Index: ext/-test-/path_to_class/extconf.rb
===================================================================
--- ext/-test-/path_to_class/extconf.rb	(revision 0)
+++ ext/-test-/path_to_class/extconf.rb	(revision 33909)
@@ -0,0 +1,6 @@
+$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")]
+inits = $srcs.map {|s| File.basename(s, ".*")}
+inits.delete("init")
+inits.map! {|s|"X(#{s})"}
+$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\""
+create_makefile("-test-/path_to_class/path_to_class")
Index: test/-ext-/path_to_class/test_path_to_class.rb
===================================================================
--- test/-ext-/path_to_class/test_path_to_class.rb	(revision 0)
+++ test/-ext-/path_to_class/test_path_to_class.rb	(revision 33909)
@@ -0,0 +1,12 @@
+require 'test/unit'
+
+class Test_PathToClass < Test::Unit::TestCase
+  require '-test-/path_to_class/path_to_class'
+
+  def test_path_to_class
+    bug5691 = '[ruby-core:41410]'
+    assert_raise(ArgumentError, bug5691) {
+      Test_PathToClass.path_to_class("Test_PathToClass::Object")
+    }
+  end
+end

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]