From 9f8defe8d2f406b0170a275b5d369957075ea059 Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Sun, 12 Jan 2025 20:47:25 +0800 Subject: [PATCH] [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 --- lib/irb/color_printer.rb | 5 ----- lib/irb/irb.gemspec | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/irb/color_printer.rb b/lib/irb/color_printer.rb index 31644aa7f9..6cfaefd055 100644 --- a/lib/irb/color_printer.rb +++ b/lib/irb/color_printer.rb @@ -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 diff --git a/lib/irb/irb.gemspec b/lib/irb/irb.gemspec index 6bb257c8cf..9a93382b7a 100644 --- a/lib/irb/irb.gemspec +++ b/lib/irb/irb.gemspec @@ -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