Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions lib/pathname.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,14 @@
# For documentation, see class Pathname.
#

if defined?(::Pathname) # Clear builtin Pathname
# :stopdoc:
class ::Object
remove_const :Pathname
end
return if RUBY_VERSION >= '4.1'

# Remove module_function Pathname
class << ::Kernel
undef Pathname
end
module ::Kernel
undef Pathname
end
unless RUBY_VERSION >= '4'
require 'pathname.so' if RUBY_ENGINE == 'ruby'
Comment on lines +13 to +16
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

Using return at the top level of a required file will raise LocalJumpError: unexpected return (i.e., the file won’t load). To make the file a no-op on Ruby >= 4.1, wrap the remainder of the file in a version guard (e.g., if RUBY_VERSION < '4.1' ... end) instead of using return.

Copilot uses AI. Check for mistakes.

$".delete('pathname.so')
# :startdoc:
require_relative 'pathname_builtin'
end

require 'pathname.so' if RUBY_ENGINE == 'ruby'

require_relative 'pathname_builtin'

class Pathname # * Find *
#
# Iterates over the directory tree in a depth first manner, yielding a
Expand Down
Loading