Skip to content

Commit

Permalink
[ruby/irb] Drop ColorPrinter's workaround for BasicObject
Browse files Browse the repository at this point in the history
(ruby/irb#1051)

`pp` 0.6.0+ includes ruby/pp#26 to handle BasicObject,
so we can drop the workaround.

ruby/irb@08908d43c7
  • Loading branch information
st0012 authored and matzbot committed Jan 12, 2025
1 parent e2f1f7c commit 9f8defe
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 0 additions & 5 deletions lib/irb/color_printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

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)
Expand All @@ -28,8 +25,6 @@ def pp(obj)
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
Expand Down
1 change: 1 addition & 0 deletions lib/irb/irb.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9f8defe

Please sign in to comment.