From 946b28116572ca1b22cd702da3cc8f9e016cfd7a Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 20 Oct 2020 14:29:48 -0700 Subject: [PATCH] Use the object id in the default implementation of inspect [Misc #17199] --- object.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/object.c b/object.c index 68f7dc2653..d8d663807d 100644 --- a/object.c +++ b/object.c @@ -677,8 +677,10 @@ rb_any_to_s(VALUE obj) { VALUE str; VALUE cname = rb_class_name(CLASS_OF(obj)); + VALUE object_id = rb_obj_id(obj); - str = rb_sprintf("#<%"PRIsVALUE":%p>", cname, (void*)obj); + str = rb_sprintf("#<%"PRIsVALUE":0x%%x>", cname); + str = rb_str_format(1, &object_id, str); return str; } @@ -784,8 +786,10 @@ rb_obj_inspect(VALUE obj) if (rb_ivar_count(obj) > 0) { VALUE str; VALUE c = rb_class_name(CLASS_OF(obj)); + VALUE object_id = rb_obj_id(obj); - str = rb_sprintf("-<%"PRIsVALUE":%p", c, (void*)obj); + str = rb_sprintf("-<%"PRIsVALUE":0x%%x", c); + str = rb_str_format(1, &object_id, str); return rb_exec_recursive(inspect_obj, obj, str); } else { -- 2.26.2