Project

General

Profile

marshal-dynamic.patch

oggy (George Ogata), 07/05/2016 04:47 AM

View differences:

test/ruby/test_marshal.rb (working copy)
457 457
    assert_equal(o1, o2, bug6209)
458 458
  end
459 459

  
460
  def test_marshal_dynamic_class
461
    mod = Module.new do
462
      def self.const_missing(name)
463
        const_set(name, Class.new) if name == :C
464
      end
465

  
466
      def self.remove_C
467
        remove_const :C
468
      end
469
    end
470
    Object.const_set :M, mod
471

  
472
    begin
473
      object = M::C.new
474
      string = Marshal.dump(object)
475

  
476
      M.remove_C
477
      assert !M.const_defined?(:C)
478

  
479
      object = Marshal.load(string)
480
      assert_same M::C, object.class
481
    ensure
482
      Object.__send__ :remove_const, :M
483
    end
484
  end
485

  
460 486
  class PrivateClass
461 487
    def initialize(foo)
462 488
      @foo = foo
variable.c (working copy)
25 25

  
26 26
static void check_before_mod_set(VALUE, ID, VALUE, const char *);
27 27
static void setup_const_entry(rb_const_entry_t *, VALUE, VALUE, rb_const_flag_t);
28
static VALUE rb_const_get_0(VALUE klass, ID id, int exclude, int recurse, int visibility);
28 29
static VALUE rb_const_search(VALUE klass, ID id, int exclude, int recurse, int visibility);
29 30
static st_table *generic_iv_tbl;
30 31
static st_table *generic_iv_tbl_compat;
......
415 416
	    rb_raise(rb_eArgError, "undefined class/module % "PRIsVALUE,
416 417
		     rb_str_subseq(pathname, 0, p-path));
417 418
	}
418
	c = rb_const_search(c, id, TRUE, FALSE, FALSE);
419
	c = rb_const_get_0(c, id, TRUE, FALSE, FALSE);
419 420
	if (c == Qundef) goto undefined_class;
420 421
	if (!RB_TYPE_P(c, T_MODULE) && !RB_TYPE_P(c, T_CLASS)) {
421 422
	    rb_raise(rb_eTypeError, "%"PRIsVALUE" does not refer to class/module",