summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-15 01:09:10 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-15 01:09:10 +0000
commit780e7d0951aefa64264e21d15d8deefeded6465f (patch)
tree871f68a1eb5e21cb290165a3372d31eac3745bab /lib
parente1aa72d44104297b51d0fd05dfb5858f3ccd8522 (diff)
Revert r36699 and r36700. [Feature #6130]
Revert "Kernel#inspect: improve consistency and do not call #to_s." Revert "update PP with recent Kernel#inspect change. Patch by Yusuke Endoh." r36699 cause test-all failure on test/drb/test_drb.rb and test/drb/test_drbssl.rb. Run test-all before commit. Moreover its ChangeLog formst is wrong: see CommitterHowto https://bugs.ruby-lang.org/projects/ruby/wiki/CommitterHowto#ChangeLog git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/pp.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 6e0c797d2e..94269abe65 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -265,7 +265,8 @@ class PP < PrettyPrint
module ObjectMixin
# 1. specific pretty_print
# 2. specific inspect
- # 3. generic pretty_print
+ # 3. specific to_s
+ # 4. generic pretty_print
# A default pretty printing method for general objects.
# It calls #pretty_print_instance_variables to list instance variables.
@@ -282,10 +283,18 @@ class PP < PrettyPrint
inspect_method = method_method.call(:inspect)
rescue NameError
end
+ begin
+ to_s_method = method_method.call(:to_s)
+ rescue NameError
+ end
if inspect_method && /\(Kernel\)#/ !~ inspect_method.inspect
q.text self.inspect
elsif !inspect_method && self.respond_to?(:inspect)
q.text self.inspect
+ elsif to_s_method && /\(Kernel\)#/ !~ to_s_method.inspect
+ q.text self.to_s
+ elsif !to_s_method && self.respond_to?(:to_s)
+ q.text self.to_s
else
q.pp_object(self)
end