summaryrefslogtreecommitdiff
path: root/lib/pp.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-22 09:29:53 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-10-22 09:29:53 +0000
commit4292fd7798b6fe31aec8dd2da9c8acab1f2bb518 (patch)
tree33690aeb5eea7b81ed20fc792a97a50527767ff7 /lib/pp.rb
parent5b91ab1f2e55bbd2965e702830404fadd90043cd (diff)
* lib/pp.rb (object_address_group): Use Kernel#to_s to obtain the class
name and object address. This fix a problem caused by %p in C generates variable length address. Reported by ko1 via IRC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43387 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/pp.rb')
-rw-r--r--lib/pp.rb16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/pp.rb b/lib/pp.rb
index 5bd378714c..0091ddf74c 100644
--- a/lib/pp.rb
+++ b/lib/pp.rb
@@ -197,22 +197,12 @@ class PP < PrettyPrint
group(1, '#<' + obj.class.name, '>', &block)
end
- # A mask used in formating object_id's into a hexadecimal id
- PointerMask = (1 << ([""].pack("p").size * 8)) - 1
-
- case Object.new.inspect
- when /\A\#<Object:0x([0-9a-f]+)>\z/
- # String Formating for hexadecimal id
- PointerFormat = "%0#{$1.length}x"
- else
- PointerFormat = "%x"
- end
-
# A convenience method, like object_group, but also reformats the Object's
# object_id.
def object_address_group(obj, &block)
- id = PointerFormat % (obj.object_id * 2 & PointerMask)
- group(1, "\#<#{obj.class}:0x#{id}", '>', &block)
+ str = Kernel.instance_method(:to_s).bind(obj).call
+ str.chomp!('>')
+ group(1, str, '>', &block)
end
# A convenience method which is same as follows: