From b67e10257ce3ab18b9a75b7e0f1eee8a9bb0ab48 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 15 Jul 2025 14:35:15 +0900 Subject: [PATCH 01/10] pathname.rbinc conflicts with `lib/pathname.rb` in our test suite. We can use `pathname.rb` after merging `lib/pathname.rb` to `pathname_builtin.rb`. --- common.mk | 6 +++--- inits.c | 2 +- pathname.c | 2 +- pathname.rb => pathname_builtin.rb | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename pathname.rb => pathname_builtin.rb (100%) diff --git a/common.mk b/common.mk index 8f5c52879a7de3..2085401ff208d4 100644 --- a/common.mk +++ b/common.mk @@ -1228,7 +1228,7 @@ BUILTIN_RB_SRCS = \ $(srcdir)/array.rb \ $(srcdir)/hash.rb \ $(srcdir)/kernel.rb \ - $(srcdir)/pathname.rb \ + $(srcdir)/pathname_builtin.rb \ $(srcdir)/ractor.rb \ $(srcdir)/symbol.rb \ $(srcdir)/timev.rb \ @@ -11247,7 +11247,7 @@ miniinit.$(OBJEXT): {$(VPATH)}numeric.rb miniinit.$(OBJEXT): {$(VPATH)}onigmo.h miniinit.$(OBJEXT): {$(VPATH)}oniguruma.h miniinit.$(OBJEXT): {$(VPATH)}pack.rb -miniinit.$(OBJEXT): {$(VPATH)}pathname.rb +miniinit.$(OBJEXT): {$(VPATH)}pathname_builtin.rb miniinit.$(OBJEXT): {$(VPATH)}prelude.rb miniinit.$(OBJEXT): {$(VPATH)}prism/ast.h miniinit.$(OBJEXT): {$(VPATH)}prism/diagnostic.h @@ -13037,7 +13037,7 @@ pathname.$(OBJEXT): {$(VPATH)}missing.h pathname.$(OBJEXT): {$(VPATH)}onigmo.h pathname.$(OBJEXT): {$(VPATH)}oniguruma.h pathname.$(OBJEXT): {$(VPATH)}pathname.c -pathname.$(OBJEXT): {$(VPATH)}pathname.rbinc +pathname.$(OBJEXT): {$(VPATH)}pathname_builtin.rbinc pathname.$(OBJEXT): {$(VPATH)}ruby.h pathname.$(OBJEXT): {$(VPATH)}st.h pathname.$(OBJEXT): {$(VPATH)}subst.h diff --git a/inits.c b/inits.c index f9dd926836dfcf..29087a6306481b 100644 --- a/inits.c +++ b/inits.c @@ -99,7 +99,7 @@ rb_call_builtin_inits(void) BUILTIN(ast); BUILTIN(trace_point); BUILTIN(pack); - BUILTIN(pathname); + BUILTIN(pathname_builtin); BUILTIN(warning); BUILTIN(array); BUILTIN(hash); diff --git a/pathname.c b/pathname.c index 88519130f754c0..c872ad9d7cff12 100644 --- a/pathname.c +++ b/pathname.c @@ -1311,7 +1311,7 @@ path_f_pathname(VALUE self, VALUE str) return rb_class_new_instance(1, &str, rb_cPathname); } -#include "pathname.rbinc" +#include "pathname_builtin.rbinc" /* * diff --git a/pathname.rb b/pathname_builtin.rb similarity index 100% rename from pathname.rb rename to pathname_builtin.rb From ea880e624e25bba6bbcf7a46dd0a2cdf220f3832 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Tue, 15 Jul 2025 16:24:07 +0900 Subject: [PATCH 02/10] [ruby/etc] Bump up v1.4.6 https://github.com/ruby/etc/commit/c9c9b9d15e --- ext/etc/etc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/etc/etc.c b/ext/etc/etc.c index e2d621547e9bef..66ef8fc9a4f3d0 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -56,7 +56,7 @@ static VALUE sGroup; #endif RUBY_EXTERN char *getlogin(void); -#define RUBY_ETC_VERSION "1.4.5" +#define RUBY_ETC_VERSION "1.4.6" #define SYMBOL_LIT(str) ID2SYM(rb_intern_const(str "")) From e27c1152aa7b8b9f69c56142b4f50e132bba29dd Mon Sep 17 00:00:00 2001 From: git Date: Tue, 15 Jul 2025 07:25:26 +0000 Subject: [PATCH 03/10] Update default gems list at ea880e624e25bba6bbcf7a46dd0a2c [ci skip] --- NEWS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS.md b/NEWS.md index 9d6be3d6bab94e..8d9c34f9326579 100644 --- a/NEWS.md +++ b/NEWS.md @@ -141,6 +141,7 @@ The following default gems are updated. * RubyGems 3.7.0.dev * bundler 2.7.0.dev * erb 5.0.1 +* etc 1.4.6 * io-console 0.8.1 * io-nonblock 0.3.2 * json 2.12.2 From 562599e6bcb3797c540283328e7969f0aa60a0e6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 15 Jul 2025 16:52:03 +0900 Subject: [PATCH 04/10] Skip `URI::TestMailTo#test_email_regexp` for now --- test/.excludes/URI/TestMailTo.rb | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/.excludes/URI/TestMailTo.rb diff --git a/test/.excludes/URI/TestMailTo.rb b/test/.excludes/URI/TestMailTo.rb new file mode 100644 index 00000000000000..c9b1f94fe28a68 --- /dev/null +++ b/test/.excludes/URI/TestMailTo.rb @@ -0,0 +1 @@ +exclude :test_email_regexp, "still flaky with --repeat-count option" From 6fd108dd6b9a890269aa3b962a44ac3c36bd8c69 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 15 Jul 2025 11:34:54 +0200 Subject: [PATCH 05/10] id_table.c: reduce duplication in managed_id_table methods --- id_table.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/id_table.c b/id_table.c index 4c9ebf123b3089..c831524ff87996 100644 --- a/id_table.c +++ b/id_table.c @@ -358,6 +358,9 @@ static const rb_data_type_t managed_id_table_type = { static inline struct rb_id_table * managed_id_table_ptr(VALUE obj) { + RUBY_ASSERT(RB_TYPE_P(obj, T_DATA)); + RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(obj), &managed_id_table_type)); + return RTYPEDDATA_GET_DATA(obj); } @@ -381,12 +384,9 @@ managed_id_table_dup_i(ID id, VALUE val, void *data) VALUE rb_managed_id_table_dup(VALUE old_table) { - RUBY_ASSERT(RB_TYPE_P(old_table, T_DATA)); - RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(old_table), &managed_id_table_type)); - struct rb_id_table *new_tbl; VALUE obj = TypedData_Make_Struct(0, struct rb_id_table, &managed_id_table_type, new_tbl); - struct rb_id_table *old_tbl = RTYPEDDATA_GET_DATA(old_table); + struct rb_id_table *old_tbl = managed_id_table_ptr(old_table); rb_id_table_init(new_tbl, old_tbl->num + 1); rb_id_table_foreach(old_tbl, managed_id_table_dup_i, new_tbl); return obj; @@ -395,35 +395,23 @@ rb_managed_id_table_dup(VALUE old_table) int rb_managed_id_table_lookup(VALUE table, ID id, VALUE *valp) { - RUBY_ASSERT(RB_TYPE_P(table, T_DATA)); - RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type)); - - return rb_id_table_lookup(RTYPEDDATA_GET_DATA(table), id, valp); + return rb_id_table_lookup(managed_id_table_ptr(table), id, valp); } int rb_managed_id_table_insert(VALUE table, ID id, VALUE val) { - RUBY_ASSERT(RB_TYPE_P(table, T_DATA)); - RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type)); - - return rb_id_table_insert(RTYPEDDATA_GET_DATA(table), id, val); + return rb_id_table_insert(managed_id_table_ptr(table), id, val); } size_t rb_managed_id_table_size(VALUE table) { - RUBY_ASSERT(RB_TYPE_P(table, T_DATA)); - RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type)); - - return rb_id_table_size(RTYPEDDATA_GET_DATA(table)); + return rb_id_table_size(managed_id_table_ptr(table)); } void rb_managed_id_table_foreach(VALUE table, rb_id_table_foreach_func_t *func, void *data) { - RUBY_ASSERT(RB_TYPE_P(table, T_DATA)); - RUBY_ASSERT(rb_typeddata_inherited_p(RTYPEDDATA_TYPE(table), &managed_id_table_type)); - - rb_id_table_foreach(RTYPEDDATA_GET_DATA(table), func, data); + rb_id_table_foreach(managed_id_table_ptr(table), func, data); } From 4fab4cfe35640f11ea832dd94346d2106318bc02 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 15 Jul 2025 11:44:53 +0900 Subject: [PATCH 06/10] [ruby/pathname] Fix Init and InitVM https://github.com/ruby/pathname/commit/2b63d44453 --- pathname.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pathname.c b/pathname.c index c872ad9d7cff12..64bed3d5987f14 100644 --- a/pathname.c +++ b/pathname.c @@ -1313,6 +1313,8 @@ path_f_pathname(VALUE self, VALUE str) #include "pathname_builtin.rbinc" +static void init_ids(void); + /* * * Pathname represents the name of a file or directory on the filesystem, @@ -1503,8 +1505,13 @@ Init_pathname(void) rb_ext_ractor_safe(true); #endif + init_ids(); InitVM(pathname); +} +void +InitVM_pathname(void) +{ rb_cPathname = rb_define_class("Pathname", rb_cObject); rb_define_method(rb_cPathname, "initialize", path_initialize, 1); rb_define_method(rb_cPathname, "freeze", path_freeze, 0); @@ -1596,7 +1603,7 @@ Init_pathname(void) } void -InitVM_pathname(void) +init_ids(void) { #undef rb_intern id_at_path = rb_intern("@path"); From 03800bff6999fd03076c03a3dec50fc4d1220824 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Tue, 15 Jul 2025 11:46:55 +0200 Subject: [PATCH 07/10] Make Pathname#mkpath builtin [Feature #17473] --- lib/pathname.rb | 10 ---------- pathname_builtin.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/pathname.rb b/lib/pathname.rb index 999ab1002d2045..a0da5ed93f1dab 100644 --- a/lib/pathname.rb +++ b/lib/pathname.rb @@ -38,16 +38,6 @@ def find(ignore_error: true) # :yield: pathname class Pathname # * FileUtils * - # Creates a full path, including any intermediate directories that don't yet - # exist. - # - # See FileUtils.mkpath and FileUtils.mkdir_p - def mkpath(mode: nil) - require 'fileutils' - FileUtils.mkpath(@path, mode: mode) - self - end - # Recursively deletes a directory, including all directories beneath it. # # See FileUtils.rm_rf diff --git a/pathname_builtin.rb b/pathname_builtin.rb index b07bcb939b3386..17ec1557040f96 100644 --- a/pathname_builtin.rb +++ b/pathname_builtin.rb @@ -44,6 +44,34 @@ class Pathname # :startdoc: + # Creates a full path, including any intermediate directories that don't yet + # exist. + # + # See FileUtils.mkpath and FileUtils.mkdir_p + def mkpath(mode: nil) + path = @path == '/' ? @path : @path.chomp('/') + + stack = [] + until File.directory?(path) || File.dirname(path) == path + stack.push path + path = File.dirname(path) + end + + stack.reverse_each do |dir| + dir = dir == '/' ? dir : dir.chomp('/') + if mode + Dir.mkdir dir, mode + File.chmod mode, dir + else + Dir.mkdir dir + end + rescue SystemCallError + raise unless File.directory?(dir) + end + + self + end + # chop_basename(path) -> [pre-basename, basename] or nil def chop_basename(path) # :nodoc: base = File.basename(path) From b896f80598cc096c84d57b2024813e994637af3b Mon Sep 17 00:00:00 2001 From: Daisuke Aritomo Date: Tue, 15 Jul 2025 20:38:57 +0900 Subject: [PATCH 08/10] [Bug #21512] Socket.tcp_with_fast_fallback: Pass proper addr family to getaddrinfo (#13878) Socket.tcp_with_fast_fallback: Pass proper addr family to getaddrinfo Addrinfo.getaddrinfo expects Socket::AF_INET or Socket::AF_INET6 as its third argument (family). However Socket.tcp_with_fast_fallback was incorrectly passing :ipv4 or :ipv6. Repro: require 'socket' Socket.tcp_with_fast_fallback('example.com', 80, '127.0.0.1') Expected behavior: Returns a Socket object Actual: Raises unknown socket domain: ipv4 (SocketError) --- ext/socket/lib/socket.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb index 7c3f6f5b91baa9..da168c9a2964b1 100644 --- a/ext/socket/lib/socket.rb +++ b/ext/socket/lib/socket.rb @@ -704,7 +704,7 @@ def self.tcp_with_fast_fallback(host, port, local_host = nil, local_port = nil, if resolving_family_names.size == 1 family_name = resolving_family_names.first - addrinfos = Addrinfo.getaddrinfo(host, port, family_name, :STREAM, timeout: resolv_timeout) + addrinfos = Addrinfo.getaddrinfo(host, port, ADDRESS_FAMILIES[:family_name], :STREAM, timeout: resolv_timeout) resolution_store.add_resolved(family_name, addrinfos) hostname_resolution_result = nil hostname_resolution_notifier = nil From 8a31a0792b8aa539be8e39587529b829fe63e593 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 15 Jul 2025 20:26:27 +0900 Subject: [PATCH 09/10] [DOC] Include pathname_builtin.rb documents --- .document | 1 + ext/.document | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.document b/.document index 2345776518b087..82ca602bfb74fe 100644 --- a/.document +++ b/.document @@ -22,6 +22,7 @@ marshal.rb numeric.rb nilclass.rb pack.rb +pathname_builtin.rb ractor.rb string.rb symbol.rb diff --git a/ext/.document b/ext/.document index 0efd511a61c450..0d6c97ff73e0d8 100644 --- a/ext/.document +++ b/ext/.document @@ -76,8 +76,6 @@ openssl/ossl_x509name.c openssl/ossl_x509req.c openssl/ossl_x509revoked.c openssl/ossl_x509store.c -pathname/lib -pathname/pathname.c psych/lib psych/psych.c psych/psych_emitter.c From 061d479b21403366ef0986d4c614f85f2a770c23 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Tue, 15 Jul 2025 20:40:51 +0900 Subject: [PATCH 10/10] [DOC] RDoc is not in ./lib now It is already a bundled gem, and only the non-built-in parts remain in pathname.rb in ./lib and cannot work in old versions. --- .github/workflows/check_misc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_misc.yml b/.github/workflows/check_misc.yml index 630ba3e4dca3de..72fcbe69964ab1 100644 --- a/.github/workflows/check_misc.yml +++ b/.github/workflows/check_misc.yml @@ -64,7 +64,7 @@ jobs: - name: Generate docs id: docs run: | - ruby -W0 --disable-gems -I./lib tool/rdoc-srcdir -q --op html . + ruby -W0 --disable-gems tool/rdoc-srcdir -q --op html . echo htmlout=ruby-html-${GITHUB_SHA:0:10} >> $GITHUB_OUTPUT # Generate only when document commit/PR if: >-