[#100309] How to use backport custom field — Jun Aruga <jaruga@...>
Please allow my ignorance.
9 messages
2020/10/06
[#100310] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
IkJhY2twb3J0IGN1c3RvbSBmaWVsZCIgaXMgb25seSBhdmFpbGFibGUgZm9yIHRpY2tldHMgd2hv
[#100311] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/06
On Tue, Oct 6, 2020 at 4:44 PM NARUSE, Yui <[email protected]> wrote:
[#100314] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
VGhhbmsgeW91IGZvciBjb25maXJtYXRpb24uCkkgY2hlY2tlZCBhZ2FpbiBhbmQgdG8gZWRpdCBi
[#100322] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Tue, Oct 6, 2020 at 7:25 PM NARUSE, Yui <[email protected]> wrote:
[#100326] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/07
SSBhZGRlZCB5b3UgdG8gIlJlcG9ydGVyIiByb2xlIGluIHRoZSBwcm9qZWN0CgoyMDIw5bm0MTDm
[#100327] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Wed, Oct 7, 2020 at 1:42 PM NARUSE, Yui <[email protected]> wrote:
[ruby-core:100451] [Ruby master Misc#17199] id outputed by inspect and to_s output does not allow to find actual object_id and vice-versa
From:
nate.berkopec@...
Date:
2020-10-20 20:15:03 UTC
List:
ruby-core #100451
Issue #17199 has been updated by nateberkopec (Nate Berkopec).
This looks like an oversight to me? I agree with Benoit - showing object_id everywhere we used to show address seems the best way forward.
----------------------------------------
Misc #17199: id outputed by inspect and to_s output does not allow to find actual object_id and vice-versa
https://bugs.ruby-lang.org/issues/17199#change-88070
* Author: Annih (Baptiste Courtois)
* Status: Open
* Priority: Normal
----------------------------------------
Hello, here is my first ruby issue sorry in advance if it is incorrectly filled.
# Issue
The value returned by `#object_id` is not aligned anymore with displayed info in `#inspect` and `#to_s` methods.
## with ruby < 2.7
``` ruby
Object.new.tap { |o| p "#to_s=#{o.to_s}, #inspect=#{o.inspect}, #__id__=#{o.__id__}, shifted_id=#{(o.__id__ << 1).to_s(16)}" }
"#to_s=#<Object:0x0000000000d202a8>, #inspect=#<Object:0x0000000000d202a8>, #__id__=6881620, shifted_id=d202a8"
```
## with ruby >= 2.7
``` ruby
Object.new.tap { |o| p "#to_s=#{o.to_s}, #inspect=#{o.inspect}, #__id__=#{o.__id__}, shifted_id=#{(o.__id__ << 1).to
s(16)}" }
"#to_s=#<Object:0x0000555dc8640b88>, #inspect=#<Object:0x0000555dc8640b88>, #__id__=220, shifted_id=1b8"
```
# Consequences
It makes harder:
- to implement a clean override of the `#inspect` method. i.e. How to keep the same output without ability to compute to the same "object_id" value.
- to debug the object using the inspect output. i.e. `ObjectSpace._id2ref(id_from_inspect >> 1)` used to work, now it doesn't (`RangeError: <xXx> is not id value`).
# Suggestion
IMHO either:
- the `#to_s` and `#inspect` documentation are obsolete `The default [...] [shows|prints] [...] an encoding of the object id` and the change could have been a bit more advertised
- they should use the result of `#object_id` instead of displaying the object pointer address
Another solution could be to provide a method to get access to the address, but I'm not sure you want that.
P.S. While debugging my problem I found [this ruby-forum thread](https://www.ruby-forum.com/t/understanding-object-id-in-ruby-2-7/260268/4) where people dived a bit more than me into ruby's code.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>