ruby-changes:65302
From: nagachika <ko1@a...>
Date: Sat, 20 Feb 2021 17:30:21 +0900 (JST)
Subject: [ruby-changes:65302] 14823c2d7c (ruby_2_7): merge revision(s) 6f6dfdcc685077f0f85dcdd63843ecfc0f6fbfb6: [Backport #17523]
https://git.ruby-lang.org/ruby.git/commit/?id=14823c2d7c From 14823c2d7c20dba288025749b4d55c02d8729871 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 20 Feb 2021 17:29:32 +0900 Subject: merge revision(s) 6f6dfdcc685077f0f85dcdd63843ecfc0f6fbfb6: [Backport #17523] Make warning values consistent [Bug #17523] They should be affected, as well as `$VERBOSE`, by `-w`/`-W` options, not only in the main script but in scripts loaded by `-r` option too. --- ruby.c | 4 ++-- test/ruby/test_rubyoptions.rb | 9 +++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) --- ruby.c | 5 +++-- test/ruby/test_rubyoptions.rb | 9 +++++++++ version.h | 2 +- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ruby.c b/ruby.c index 96d8f75..7d8d8e3 100644 --- a/ruby.c +++ b/ruby.c @@ -1771,6 +1771,9 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1771 rb_ary_replace(vm->load_path_snapshot, load_path); } } + + rb_warning_category_update(opt->warn.mask, opt->warn.set); + Init_ext(); /* load statically linked extensions before rubygems */ if (opt->features.set & FEATURE_BIT(gems)) { rb_define_module("Gem"); @@ -1819,7 +1822,6 @@ process_options(int argc, char **argv, ruby_cmdline_options_t *opt) https://github.com/ruby/ruby/blob/trunk/ruby.c#L1822 ruby_set_script_name(progname); rb_parser_set_options(parser, opt->do_print, opt->do_loop, opt->do_line, opt->do_split); - rb_warning_category_update(opt->warn.mask, opt->warn.set); ast = rb_parser_compile_string(parser, opt->script, opt->e_script, 1); } else { @@ -2058,7 +2060,6 @@ load_file_internal(VALUE argp_v) https://github.com/ruby/ruby/blob/trunk/ruby.c#L2060 } rb_parser_set_options(parser, opt->do_print, opt->do_loop, opt->do_line, opt->do_split); - rb_warning_category_update(opt->warn.mask, opt->warn.set); if (NIL_P(f)) { f = rb_str_new(0, 0); rb_enc_associate(f, enc); diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index fba53cd..26e7f5d 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -83,6 +83,15 @@ class TestRubyOptions < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_rubyoptions.rb#L83 assert_in_out_err(%w(-w -e) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-W -e) + ['p Warning[:deprecated]'], "", %w(true), []) assert_in_out_err(%w(-e) + ['p Warning[:deprecated]'], "", %w(false), []) + code = 'puts "#{$VERBOSE}:#{Warning[:deprecated]}:#{Warning[:experimental]}"' + Tempfile.create(["test_ruby_test_rubyoption", ".rb"]) do |t| + t.puts code + t.close + assert_in_out_err(["-r#{t.path}", '-e', code], "", %w(false:false:true false:false:true), []) + assert_in_out_err(["-r#{t.path}", '-w', '-e', code], "", %w(true:true:true true:true:true), []) + assert_in_out_err(["-r#{t.path}", '-W:deprecated', '-e', code], "", %w(false:true:true false:true:true), []) + assert_in_out_err(["-r#{t.path}", '-W:no-experimental', '-e', code], "", %w(false:false:false false:false:false), []) + end ensure ENV['RUBYOPT'] = save_rubyopt end diff --git a/version.h b/version.h index 74122dc..41d2f20 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 156 +#define RUBY_PATCHLEVEL 157 #define RUBY_RELEASE_YEAR 2021 #define RUBY_RELEASE_MONTH 2 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/