ruby-changes:65228
From: nagachika <ko1@a...>
Date: Thu, 11 Feb 2021 14:08:21 +0900 (JST)
Subject: [ruby-changes:65228] 4b6df7f735 (ruby_2_7): merge revision(s) a55eb9a2af7950d180d9d31ffde2bce66710f44f: [Backport #17572]
https://git.ruby-lang.org/ruby.git/commit/?id=4b6df7f735 From 4b6df7f735c10f326f09a44fe38dc10b05ced21c Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Thu, 11 Feb 2021 13:34:05 +0900 Subject: merge revision(s) a55eb9a2af7950d180d9d31ffde2bce66710f44f: [Backport #17572] Make reciprocal properly of non-integral rational [Bug #17572] --- rational.c | 2 +- test/ruby/test_rational.rb | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) --- rational.c | 2 +- test/ruby/test_rational.rb | 7 +++++++ version.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/rational.c b/rational.c index c606f3c..dc01425 100644 --- a/rational.c +++ b/rational.c @@ -1875,7 +1875,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/rational.c#L1875 rb_rational_reciprocal(VALUE x) { get_dat1(x); - return f_rational_new_no_reduce2(CLASS_OF(x), dat->den, dat->num); + return nurat_convert(CLASS_OF(x), dat->den, dat->num, FALSE); } /* diff --git a/test/ruby/test_rational.rb b/test/ruby/test_rational.rb index 301890b..5676b41 100644 --- a/test/ruby/test_rational.rb +++ b/test/ruby/test_rational.rb @@ -598,6 +598,13 @@ class Rational_Test < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rational.rb#L598 assert_nothing_raised(TypeError, '[Bug #5020] [ruby-dev:44088]') do Rational(1,2).coerce(Complex(1,1)) end + + assert_raise(ZeroDivisionError) do + 1 / 0r.coerce(0+0i)[0] + end + assert_raise(ZeroDivisionError) do + 1 / 0r.coerce(0.0+0i)[0] + end end class ObjectX diff --git a/version.h b/version.h index afd5761..0f507c0 100644 --- a/version.h +++ b/version.h @@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L2 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 152 +#define RUBY_PATCHLEVEL 153 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 2 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/