Actions
Bug #12434
closedMarshal.dump does not dump some numbers as Fixnum
Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.4.0dev (2016-05-28 trunk 55197) [x86_64-darwin15]
Description
Marshal.dump
dumps numbers between 1073741824 and 4294967295 and between -4294967296 and -1073741825 as Bignum
, but I think that those numbers should be dumped as Fixnum
.
$ ./ruby --disable-gems -e'p Marshal.load("\x04\bi\x04\x00\x00\x00\x40")'
1073741824
$ ./ruby --disable-gems -e'p Marshal.dump(1073741824)'
"\x04\bl+\a\x00\x00\x00@"
$ ./ruby --disable-gems -e'p Marshal.load("\x04\bi\xfc\x00\x00\x00\x00")'
-4294967296
$ ./ruby --disable-gems -e'p Marshal.dump(-4294967296)'
"\x04\bl-\b\x00\x00\x00\x00\x01\x00"
I created proposed patch and submit pull request to https://github.com/ruby/ruby/pull/1366
Updated by nobu (Nobuyoshi Nakada) over 8 years ago
- Status changed from Open to Rejected
It is intentionally dumped as a Bignum for marshal data compatibility across architectures.
Current behavior:
$ arch -x86_64 ruby -e 'Marshal.dump(1073741824, STDOUT)' | arch -i386 ruby -e 'p Marshal.load(STDIN)'
1073741824
With your patch:
$ .x86_64-darwin/miniruby -e 'Marshal.dump(1073741824, STDOUT)' | .i386-darwin/miniruby -e 'p Marshal.load(STDIN)'
-1073741824
Updated by eitoball (Eito Katagiri) over 8 years ago
Thank you. I should have looked up ruby spec. https://github.com/ruby/spec/blob/master/core/marshal/dump_spec.rb#L40-L48
Actions
Like0
Like0Like0