diff --git a/NEWS.md b/NEWS.md index 3468f479596293..24a36475360569 100644 --- a/NEWS.md +++ b/NEWS.md @@ -213,7 +213,7 @@ The following bundled gems are promoted from default gems. * pstore 0.2.0 * benchmark 0.5.0 * logger 1.7.0 -* rdoc 6.16.1 +* rdoc 6.17.0 * win32ole 1.9.2 * irb 1.15.3 * reline 0.6.3 diff --git a/gc.c b/gc.c index c660d1491f3a6d..5e3e44e726704d 100644 --- a/gc.c +++ b/gc.c @@ -4841,11 +4841,11 @@ rb_raw_obj_info_buitin_type(char *const buff, const size_t buff_size, const VALU APPEND_F("(too_complex) len:%zu", hash_len); } else { - APPEND_F("(embed) len:%d", ROBJECT_FIELDS_CAPACITY(obj)); + APPEND_F("(embed) len:%d capa:%d", RSHAPE_LEN(RBASIC_SHAPE_ID(obj)), ROBJECT_FIELDS_CAPACITY(obj)); } } else { - APPEND_F("len:%d ptr:%p", ROBJECT_FIELDS_CAPACITY(obj), (void *)ROBJECT_FIELDS(obj)); + APPEND_F("len:%d capa:%d ptr:%p", RSHAPE_LEN(RBASIC_SHAPE_ID(obj)), ROBJECT_FIELDS_CAPACITY(obj), (void *)ROBJECT_FIELDS(obj)); } } break; diff --git a/gems/bundled_gems b/gems/bundled_gems index 180e1dffcd4dae..bdda3311d0eb07 100644 --- a/gems/bundled_gems +++ b/gems/bundled_gems @@ -39,7 +39,7 @@ ostruct 0.6.3 https://github.com/ruby/ostruct pstore 0.2.0 https://github.com/ruby/pstore benchmark 0.5.0 https://github.com/ruby/benchmark logger 1.7.0 https://github.com/ruby/logger -rdoc 6.16.1 https://github.com/ruby/rdoc +rdoc 6.17.0 https://github.com/ruby/rdoc win32ole 1.9.2 https://github.com/ruby/win32ole irb 1.15.3 https://github.com/ruby/irb reline 0.6.3 https://github.com/ruby/reline diff --git a/pathname_builtin.rb b/pathname_builtin.rb index 3d78619c9e4041..878603d4d69cd0 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -195,14 +195,12 @@ class Pathname # :stopdoc: - SAME_PATHS = if File::FNM_SYSCASE.nonzero? + if File::FNM_SYSCASE.nonzero? # Avoid #zero? here because #casecmp can return nil. - proc {|a, b| a.casecmp(b) == 0} + private def same_paths?(a, b) a.casecmp(b) == 0 end else - proc {|a, b| a == b} + private def same_paths?(a, b) a == b end end - SAME_PATHS.freeze - private_constant :SAME_PATHS attr_reader :path protected :path @@ -215,8 +213,13 @@ class Pathname # def initialize(path) @path = File.path(path).dup + rescue TypeError => e + raise e.class, "Pathname.new requires a String, #to_path or #to_str", cause: nil end + # + # Freze self. + # def freeze super @path.freeze @@ -836,12 +839,12 @@ def relative_path_from(base_directory) base_prefix, basename = r base_names.unshift basename if basename != '.' end - unless SAME_PATHS[dest_prefix, base_prefix] + unless same_paths?(dest_prefix, base_prefix) raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}" end while !dest_names.empty? && !base_names.empty? && - SAME_PATHS[dest_names.first, base_names.first] + same_paths?(dest_names.first, base_names.first) dest_names.shift base_names.shift end diff --git a/prism/srcs.mk b/prism/srcs.mk index 167aa4dbe07e89..022662a00b5f30 100644 --- a/prism/srcs.mk +++ b/prism/srcs.mk @@ -14,7 +14,7 @@ prism/$(HAVE_BASERUBY:yes=.srcs.mk.time): \ distclean-prism-srcs:: $(RM) prism/.srcs.mk.time - $(RMDIR) prism + $(RMDIRS) prism || $(NULLCMD) distclean-srcs-local:: distclean-prism-srcs diff --git a/prism/srcs.mk.in b/prism/srcs.mk.in index b67ce993709ac3..cc263fd1b4ef3f 100644 --- a/prism/srcs.mk.in +++ b/prism/srcs.mk.in @@ -22,7 +22,7 @@ prism/$(HAVE_BASERUBY:yes=.srcs.mk.time): \ distclean-prism-srcs:: $(RM) prism/.srcs.mk.time - $(RMDIR) prism + $(RMDIRS) prism || $(NULLCMD) distclean-srcs-local:: distclean-prism-srcs diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index e2d6a09fb2f0c0..3114d1458d229d 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -485,6 +485,13 @@ def test_initialize p2 = Pathname.new(p1) assert_equal(p1, p2) + obj = Object.new + assert_raise_with_message(TypeError, /#to_path or #to_str/) { Pathname.new(obj) } + + obj = Object.new + def obj.to_path; "a/path"; end + assert_equal("a/path", Pathname.new(obj).to_s) + obj = Object.new def obj.to_str; "a/b"; end assert_equal("a/b", Pathname.new(obj).to_s) @@ -494,6 +501,10 @@ def test_initialize_nul assert_raise(ArgumentError) { Pathname.new("a\0") } end + def test_initialize_encoding + assert_raise(Encoding::CompatibilityError) { Pathname.new("a".encode(Encoding::UTF_32BE)) } + end + def test_global_constructor p = Pathname.new('a') assert_equal(p, Pathname('a')) diff --git a/test/pathname/test_ractor.rb b/test/pathname/test_ractor.rb index f06b7501f3448b..737e4a4111d65c 100644 --- a/test/pathname/test_ractor.rb +++ b/test/pathname/test_ractor.rb @@ -20,6 +20,11 @@ class Ractor x.join(Pathname("b"), Pathname("c")) end assert_equal(Pathname("a/b/c"), r.value) + + r = Ractor.new Pathname("a") do |a| + Pathname("b").relative_path_from(a) + end + assert_equal(Pathname("../b"), r.value) end; end end