Skip to content

Conversation

@nobu
Copy link
Member

@nobu nobu commented Dec 6, 2025

  • Define to_path alias directly
  • Use File.path for conversion to path name
  • Freeze and hide internal constants

nobu added 4 commits December 6, 2025 18:00
The constant `TO_PATH` was defined for 1.9 compatibility but the code
for it was dropped 10 years ago.
This method has been defined since 1.9, as the standard conversion
procedure.
@nobu nobu merged commit 89b5f44 into ruby:master Dec 6, 2025
21 checks passed
end

@path = path.dup
@path = File.path(path).dup
Copy link
Member

@eregon eregon Dec 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most changes look good except this, because it makes the error less clear:

ruby -Ilib -rpathname -e 'Pathname.new(42)'
/home/eregon/code/pathname/lib/pathname_builtin.rb:217:in 'File.path': no implicit conversion of Integer into String (TypeError)

    @path = File.path(path).dup
                      ^^^^
	from /home/eregon/code/pathname/lib/pathname_builtin.rb:217:in 'Pathname#initialize'
	from -e:1:in 'Class#new'
	from -e:1:in '<main>'

And also ignoring TruffleRuby in CI is not nice, although I understand it's unfortunate it doesn't do the null check this change doesn't seem worth breaking it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#74

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants