ruby-changes:46405
From: usa <ko1@a...>
Date: Sun, 30 Apr 2017 23:05:23 +0900 (JST)
Subject: [ruby-changes:46405] usa:r58519 (ruby_2_3): merge revision(s) 58082, 58083: [Backport #13236]
usa 2017-04-30 23:05:14 +0900 (Sun, 30 Apr 2017) New Revision: 58519 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58519 Log: merge revision(s) 58082,58083: [Backport #13236] class.c: ensure_includable * class.c (ensure_includable): extract checks to include and prepend. class.c: prohibit refinement module * class.c (ensure_includable): cannot include refinement module, or the type and the class do not match. [ruby-core:79632] [Bug #13236] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/class.c branches/ruby_2_3/version.h Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 58518) +++ ruby_2_3/version.h (revision 58519) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.5" #define RUBY_RELEASE_DATE "2017-04-30" -#define RUBY_PATCHLEVEL 308 +#define RUBY_PATCHLEVEL 309 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 4 Index: ruby_2_3/class.c =================================================================== --- ruby_2_3/class.c (revision 58518) +++ ruby_2_3/class.c (revision 58519) @@ -846,18 +846,23 @@ rb_include_class_new(VALUE module, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_3/class.c#L846 static int include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super); +static void +ensure_includable(VALUE klass, VALUE module) +{ + rb_frozen_class_p(klass); + Check_Type(module, T_MODULE); + if (!NIL_P(rb_refinement_module_get_refined_class(module))) { + rb_raise(rb_eArgError, "refinement module is not allowed"); + } + OBJ_INFECT(klass, module); +} + void rb_include_module(VALUE klass, VALUE module) { int changed = 0; - rb_frozen_class_p(klass); - - if (!RB_TYPE_P(module, T_MODULE)) { - Check_Type(module, T_MODULE); - } - - OBJ_INFECT(klass, module); + ensure_includable(klass, module); changed = include_modules_at(klass, RCLASS_ORIGIN(klass), module, TRUE); if (changed < 0) @@ -962,11 +967,7 @@ rb_prepend_module(VALUE klass, VALUE mod https://github.com/ruby/ruby/blob/trunk/ruby_2_3/class.c#L967 VALUE origin; int changed = 0; - rb_frozen_class_p(klass); - - Check_Type(module, T_MODULE); - - OBJ_INFECT(klass, module); + ensure_includable(klass, module); origin = RCLASS_ORIGIN(klass); if (origin == klass) { Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 58518) +++ ruby_2_3/ChangeLog (revision 58519) @@ -1,3 +1,16 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Sun Apr 30 23:01:00 2017 Nobuyoshi Nakada <nobu@r...> + + class.c: ensure_includable + + * class.c (ensure_includable): extract checks to include and + prepend. + + class.c: prohibit refinement module + + * class.c (ensure_includable): cannot include refinement + module, or the type and the class do not match. + [ruby-core:79632] [Bug #13236] + Sun Apr 30 22:55:41 2017 Nobuyoshi Nakada <nobu@r...> keep line number after unterminated string literal Index: ruby_2_3 =================================================================== --- ruby_2_3 (revision 58518) +++ ruby_2_3 (revision 58519) Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58082 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/