ruby-changes:62143
From: Jeremy <ko1@a...>
Date: Mon, 6 Jul 2020 08:56:26 +0900 (JST)
Subject: [ruby-changes:62143] ceb9d516c6 (master): [ruby/bigdecimal] Undef BigDecimal#initialize_copy
https://git.ruby-lang.org/ruby.git/commit/?id=ceb9d516c6 From ceb9d516c6d17b0619cf53dfba7cb7b29fe073e4 Mon Sep 17 00:00:00 2001 From: Jeremy Evans <code@j...> Date: Tue, 8 Oct 2019 15:23:46 -0700 Subject: [ruby/bigdecimal] Undef BigDecimal#initialize_copy Both BigDecimal#clone and BigDecimal#dup return self, there is no reason to have initialize_copy exposed as a Ruby method. The same is true for initialize_clone and initialize_dup. https://github.com/ruby/bigdecimal/commit/aaf237fa9e diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index c442335..23851ee 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -3451,7 +3451,9 @@ Init_bigdecimal(void) https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L3451 /* instance methods */ - rb_define_method(rb_cBigDecimal, "initialize_copy", BigDecimal_initialize_copy, 1); + rb_undef_method(rb_cBigDecimal, "initialize_copy"); + rb_undef_method(rb_cBigDecimal, "initialize_clone"); + rb_undef_method(rb_cBigDecimal, "initialize_dup"); rb_define_method(rb_cBigDecimal, "precs", BigDecimal_prec, 0); rb_define_method(rb_cBigDecimal, "add", BigDecimal_add2, 2); diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index 4598936..6928834 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -1876,6 +1876,12 @@ class TestBigDecimal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/bigdecimal/test_bigdecimal.rb#L1876 EOS end + def test_no_initialize_copy + assert_equal(false, BigDecimal(1).respond_to?(:initialize_copy, true)) + assert_equal(false, BigDecimal(1).respond_to?(:initialize_dup, true)) + assert_equal(false, BigDecimal(1).respond_to?(:initialize_clone, true)) + end + def assert_no_memory_leak(code, *rest, **opt) code = "8.times {20_000.times {begin #{code}; rescue NoMemoryError; end}; GC.start}" super(["-rbigdecimal"], -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/