[macruby-changes] [4591] MacRuby/trunk

source_changes at macosforge.org source_changes at macosforge.org
Thu Oct 7 23:00:37 PDT 2010


Revision: 4591
          http://trac.macosforge.org/projects/ruby/changeset/4591
Author:   lsansonetti at apple.com
Date:     2010-10-07 23:00:36 -0700 (Thu, 07 Oct 2010)
Log Message:
-----------
fix a bug when creating a NameError exception where calling #inspect on the receiver object would raise an exception and cause an infinite loop

Modified Paths:
--------------
    MacRuby/trunk/error.c
    MacRuby/trunk/eval.c

Modified: MacRuby/trunk/error.c
===================================================================
--- MacRuby/trunk/error.c	2010-10-08 05:19:24 UTC (rev 4590)
+++ MacRuby/trunk/error.c	2010-10-08 06:00:36 UTC (rev 4591)
@@ -773,6 +773,21 @@
     return Qtrue;
 }
 
+static VALUE
+inspect_exec(VALUE obj, VALUE data, int recur)
+{
+    if (recur) {
+	return Qnil;
+    }
+    return rb_inspect(obj);
+}
+
+static VALUE
+safe_inspect(VALUE obj)
+{
+    return rb_exec_recursive(inspect_exec, obj, 0);
+}
+
 /* :nodoc: */
 static VALUE
 name_err_mesg_to_str(VALUE obj, SEL sel)
@@ -800,7 +815,7 @@
 	    desc = "false";
 	    break;
 	  default:
-	    d = rb_protect(rb_inspect, obj, 0);
+	    d = rb_protect(safe_inspect, obj, 0);
 	    if (NIL_P(d) || RSTRING_LEN(d) > 65) {
 		d = rb_any_to_s(obj);
 	    }

Modified: MacRuby/trunk/eval.c
===================================================================
--- MacRuby/trunk/eval.c	2010-10-08 05:19:24 UTC (rev 4590)
+++ MacRuby/trunk/eval.c	2010-10-08 06:00:36 UTC (rev 4591)
@@ -485,13 +485,12 @@
 }
 
 VALUE
-rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
+rb_protect(VALUE (* proc) (VALUE), VALUE data, int *state)
 {
-    // TODO
     if (state != NULL) {
 	*state = 0;
     }
-    return (*proc)(data);
+    return rb_rescue2(proc, data, NULL, 0, rb_eStandardError, (VALUE)0);
 }
 
 ID
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101007/19584a6c/attachment.html>


More information about the macruby-changes mailing list