[ruby/irb] Drop ColorPrinter's workaround for BasicObject

(https://github.com/ruby/irb/pull/1051)

`pp` 0.6.0+ includes https://github.com/ruby/pp/pull/26 to handle BasicObject,
so we can drop the workaround.

https://github.com/ruby/irb/commit/08908d43c7
This commit is contained in:
Stan Lo 2025-01-12 20:47:25 +08:00 committed by git
parent e2f1f7c567
commit 9f8defe8d2
2 changed files with 1 additions and 5 deletions

View File

@ -4,9 +4,6 @@ require_relative 'color'
module IRB
class ColorPrinter < ::PP
METHOD_RESPOND_TO = Object.instance_method(:respond_to?)
METHOD_INSPECT = Object.instance_method(:inspect)
class << self
def pp(obj, out = $>, width = screen_width)
q = ColorPrinter.new(out, width)
@ -28,8 +25,6 @@ module IRB
if String === obj
# Avoid calling Ruby 2.4+ String#pretty_print that splits a string by "\n"
text(obj.inspect)
elsif !METHOD_RESPOND_TO.bind(obj).call(:inspect)
text(METHOD_INSPECT.bind(obj).call)
else
super
end

View File

@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "reline", ">= 0.4.2"
spec.add_dependency "rdoc", ">= 4.0.0"
spec.add_dependency "pp", ">= 0.6.0"
end