ruby-changes:70636
From: Nobuyoshi <ko1@a...>
Date: Tue, 28 Dec 2021 18:36:41 +0900 (JST)
Subject: [ruby-changes:70636] bf97415c02 (master): Removed deprecated Dir.exists? and File.exists?
https://git.ruby-lang.org/ruby.git/commit/?id=bf97415c02 From bf97415c02b11a8949f715431aca9eeb6311add2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 30 Nov 2020 23:33:20 +0900 Subject: Removed deprecated Dir.exists? and File.exists? --- dir.c | 9 --------- file.c | 18 ------------------ test/ruby/test_exception.rb | 8 ++++++-- 3 files changed, 6 insertions(+), 29 deletions(-) diff --git a/dir.c b/dir.c index 184dbf007ed..1a3ba820708 100644 --- a/dir.c +++ b/dir.c @@ -3260,14 +3260,6 @@ rb_file_directory_p(void) https://github.com/ruby/ruby/blob/trunk/dir.c#L3260 } #endif -/* :nodoc: */ -static VALUE -rb_dir_exists_p(VALUE obj, VALUE fname) -{ - rb_warn_deprecated("Dir.exists?", "Dir.exist?"); - return rb_file_directory_p(obj, fname); -} - static void * nogvl_dir_empty_p(void *ptr) { @@ -3386,7 +3378,6 @@ Init_Dir(void) https://github.com/ruby/ruby/blob/trunk/dir.c#L3378 rb_define_singleton_method(rb_cDir,"home", dir_s_home, -1); rb_define_singleton_method(rb_cDir,"exist?", rb_file_directory_p, 1); - rb_define_singleton_method(rb_cDir,"exists?", rb_dir_exists_p, 1); rb_define_singleton_method(rb_cDir,"empty?", rb_dir_s_empty_p, 1); rb_define_singleton_method(rb_cFile,"fnmatch", file_s_fnmatch, -1); diff --git a/file.c b/file.c index 2d0f3234067..5a5e6b27060 100644 --- a/file.c +++ b/file.c @@ -1786,23 +1786,6 @@ rb_file_exist_p(VALUE obj, VALUE fname) https://github.com/ruby/ruby/blob/trunk/file.c#L1786 return Qtrue; } -/* :nodoc: */ -static VALUE -rb_file_exists_p(VALUE obj, VALUE fname) -{ - const char *s = "FileTest#exist?"; - if (obj == rb_mFileTest) { - s = "FileTest.exist?"; - } - else if (obj == rb_cFile || - (RB_TYPE_P(obj, T_CLASS) && - RTEST(rb_class_inherited_p(obj, rb_cFile)))) { - s = "File.exist?"; - } - rb_warn_deprecated("%.*ss?", s, (int)(strlen(s)-1), s); - return rb_file_exist_p(obj, fname); -} - /* * call-seq: * File.readable?(file_name) -> true or false @@ -6703,7 +6686,6 @@ Init_File(void) https://github.com/ruby/ruby/blob/trunk/file.c#L6686 define_filetest_function("directory?", rb_file_directory_p, 1); define_filetest_function("exist?", rb_file_exist_p, 1); - define_filetest_function("exists?", rb_file_exists_p, 1); define_filetest_function("readable?", rb_file_readable_p, 1); define_filetest_function("readable_real?", rb_file_readable_real_p, 1); define_filetest_function("world_readable?", rb_file_world_readable_p, 1); diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 4a088294736..4ddd6011b9c 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1064,13 +1064,17 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L1064 end def test_warn_deprecated_backwards_compatibility_category - warning = capture_warning_warn { Dir.exists?("non-existent") } + skip "no method to test" + + warning = capture_warning_warn { } assert_match(/deprecated/, warning[0]) end def test_warn_deprecated_category - warning = capture_warning_warn(category: true) { Dir.exists?("non-existent") } + skip "no method to test" + + warning = capture_warning_warn(category: true) { } assert_equal :deprecated, warning[0][1] end -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/