From: shyouhei@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:90721] [Ruby trunk Bug#15460] Behaviour of String#setbyte changed
Date: Wed, 26 Dec 2018 00:48:59 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-75898.20181226004857.f6abaeb19ad7ed52@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-15460.20181225102238@ruby-lang.org
Issue #15460 has been updated by shyouhei (Shyouhei Urabe).
I feel sorry for the situation. I didn't expect any actual usage of that corner case.
However the previous behaviour was strange. It did actually raise exception when you pass a very huge number to it:
```
% ruby -v -e 'p IO.pipe[0].ungetbyte(18446744073709551616)'
ruby 1.9.3p551 (2014-11-13) [x86_64-darwin15.6.0]
-e:1:in `ungetbyte': can't convert Bignum into String (TypeError)
from -e:1:in `<main>'
```
The "TypeError" in the error message is because the testing ruby is old. Now that Bignum is wiped out, I don't think this restriction is reasonable.
----------------------------------------
Bug #15460: Behaviour of String#setbyte changed
https://bugs.ruby-lang.org/issues/15460#change-75898
* Author: gettalong (Thomas Leitner)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
I just installed Ruby 2.6.0 for benchmarking reasons and found that the change [string.c: setbyte silently ignores upper bits](https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/65804) broke my library/application HexaPDF.
Before using String#setbyte I tested how it would respond to values lower than 0 or greater than 255 and found that it automatically performed the needed modulo 256 operation (at least up to Ruby 2.5.3). Therefore I left out the explicit modulo operation for performance reasons.
Would it make sense to change the String#setbyte implementation to perform the modulo operation? This would restore compatibility with prior Ruby versions and may be what people would expect.
--
https://bugs.ruby-lang.org/
next prev parent reply other threads:[~2018-12-26 0:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <redmine.issue-15460.20181225102238@ruby-lang.org>
2018-12-25 10:22 ` [ruby-core:90700] [Ruby trunk Bug#15460] Behaviour of String#setbyte changed t_leitner
2018-12-26 0:38 ` [ruby-core:90720] " ko1
2018-12-26 0:48 ` shyouhei [this message]
2018-12-26 1:24 ` [ruby-core:90722] " shyouhei
2018-12-26 1:44 ` [ruby-core:90723] " shyouhei
2018-12-26 11:59 ` [ruby-core:90730] " eregontp
2018-12-28 8:32 ` [ruby-core:90772] " t_leitner
2019-01-11 14:33 ` [ruby-core:91023] [Ruby trunk Bug#15460][Assigned] " shyouhei
2019-01-17 21:36 ` [ruby-core:91144] [Ruby trunk Bug#15460] " naruse
2019-12-02 0:41 ` [ruby-core:96049] [Ruby master " nobu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-75898.20181226004857.f6abaeb19ad7ed52@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).