[前][次][番号順一覧][スレッド一覧]

ruby-changes:65375

From: usa <ko1@a...>
Date: Tue, 2 Mar 2021 20:23:54 +0900 (JST)
Subject: [ruby-changes:65375] 82019f272d (ruby_2_6): merge revision(s) a19228f8: [Backport #16979]

https://git.ruby-lang.org/ruby.git/commit/?id=82019f272d

From 82019f272dff1990e7a273125a8414d056f6306d Mon Sep 17 00:00:00 2001
From: usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>
Date: Tue, 2 Mar 2021 11:23:42 +0000
Subject: merge revision(s) a19228f8: [Backport #16979]

	brace the fact that lchmod(2) can EOPNOTSUPP

	Musl libc has this function as a tiny wrapper of fchmodat(3posix).  On
	the other hand Linux kernel does not support changing modes of a symlink.
	The operation always fails with EOPNOTSUPP.  This fchmodat behaviour is
	defined in POSIX.  We have to take care of such exceptions.
	---
	 lib/fileutils.rb               |  3 ++-
	 test/pathname/test_pathname.rb |  2 +-
	 test/ruby/test_notimp.rb       | 19 ++++++++++++-------
	 3 files changed, 15 insertions(+), 9 deletions(-)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
---
 lib/fileutils.rb               |  3 ++-
 test/pathname/test_pathname.rb |  2 +-
 test/ruby/test_notimp.rb       | 19 ++++++++++++-------
 version.h                      |  2 +-
 4 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/lib/fileutils.rb b/lib/fileutils.rb
index 8981ef9..6332fcd 100644
--- a/lib/fileutils.rb
+++ b/lib/fileutils.rb
@@ -1320,6 +1320,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1320
       else
         File.chmod mode, path()
       end
+    rescue Errno::EOPNOTSUPP
     end
 
     def chown(uid, gid)
@@ -1411,7 +1412,7 @@ module FileUtils https://github.com/ruby/ruby/blob/trunk/lib/fileutils.rb#L1412
       if st.symlink?
         begin
           File.lchmod mode, path
-        rescue NotImplementedError
+        rescue NotImplementedError, Errno::EOPNOTSUPP
         end
       else
         File.chmod mode, path
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index f8e4937..750fabf 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -824,7 +824,7 @@ class TestPathname < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/pathname/test_pathname.rb#L824
       old = path.lstat.mode
       begin
         path.lchmod(0444)
-      rescue NotImplementedError
+      rescue NotImplementedError, Errno::EOPNOTSUPP
         next
       end
       assert_equal(0444, path.lstat.mode & 0777)
diff --git a/test/ruby/test_notimp.rb b/test/ruby/test_notimp.rb
index ddebb65..daa5a82 100644
--- a/test/ruby/test_notimp.rb
+++ b/test/ruby/test_notimp.rb
@@ -13,11 +13,11 @@ class TestNotImplement < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_notimp.rb#L13
 
   def test_respond_to_lchmod
     assert_include(File.methods, :lchmod)
-    if /linux/ =~ RUBY_PLATFORM
-      assert_equal(false, File.respond_to?(:lchmod))
-    end
-    if /freebsd/ =~ RUBY_PLATFORM
+    case RUBY_PLATFORM
+    when /freebsd/, /linux-musl/
       assert_equal(true, File.respond_to?(:lchmod))
+    when /linux/
+      assert_equal(false, File.respond_to?(:lchmod))
     end
   end
 
@@ -57,9 +57,14 @@ class TestNotImplement < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_notimp.rb#L57
         File.open(f, "w") {}
         File.symlink f, g
         newmode = 0444
-        File.lchmod newmode, "#{d}/g"
-        snew = File.lstat(g)
-        assert_equal(newmode, snew.mode & 0777)
+        begin
+          File.lchmod newmode, "#{d}/g"
+        rescue Errno::EOPNOTSUPP
+          skip $!
+        else
+          snew = File.lstat(g)
+          assert_equal(newmode, snew.mode & 0777)
+        end
       }
     end
   end
diff --git a/version.h b/version.h
index 2409c2b..dc472d5 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L1
 #define RUBY_VERSION "2.6.7"
 #define RUBY_RELEASE_DATE "2021-03-02"
-#define RUBY_PATCHLEVEL 166
+#define RUBY_PATCHLEVEL 167
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 3
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]