CARVIEW |
Select Language
HTTP/2 200
x-amz-id-2: BsjM6jWsPE+IZFof3NMRIj0iS9wvZVnbvNAHrxeCkbBql1P7/hQbEzPIo4aWG2Tj5s/fUuZWna0=
x-amz-request-id: N0Y4ZY69YQYJM0VW
last-modified: Fri, 18 Jul 2025 17:51:45 GMT
etag: "01af7ff2048592ca7870877cfebe18db"
x-amz-server-side-encryption: AES256
server: AmazonS3
content-encoding: gzip
via: 1.1 varnish, 1.1 varnish
content-type: text/plain; charset=utf-8
accept-ranges: bytes
age: 0
date: Mon, 28 Jul 2025 02:43:06 GMT
x-served-by: cache-tyo11945-TYO, cache-bom-vanm7210027-BOM
x-cache: MISS, MISS
x-cache-hits: 0, 0
x-timer: S1753670586.333425,VS0,VE382
vary: Accept-Encoding
content-length: 913
From: "herwin (Herwin W) via ruby-core"
Date: 2025-07-18T17:44:26+00:00
Subject: [ruby-core:122817] [Ruby Bug#21517] Behaviour of StringIO#readpartial with multibyte differs from IO#readpartial
Issue #21517 has been reported by herwin (Herwin W).
----------------------------------------
Bug #21517: Behaviour of StringIO#readpartial with multibyte differs from IO#readpartial
https://bugs.ruby-lang.org/issues/21517
* Author: herwin (Herwin W)
* Status: Open
* ruby -v: ruby 3.4.5 (2025-07-16 revision 20cda200d3) +PRISM [x86_64-linux] (+ others)
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
The specs for `IO#readpartial` have the following test (https://github.com/ruby/spec/blob/ed254bae321221f5cd24280beb37e5bddaff6bb6/core/io/readpartial_spec.rb#L41-L47):
```ruby
before :each do
@rd, @wr = IO.pipe
@rd.binmode
@wr.binmode
end
it "reads after ungetc with multibyte characters in the buffer" do
@wr.write("�����/���x = ga��t��")
c = @rd.getc
@rd.ungetc(c)
@rd.readpartial(3).should == "\xE2\x88\x82"
@rd.readpartial(3).should == "\xCF\x86/"
end
```
This behaviour is different in `StringIO#readpartial`. If I add this as a spec:
```ruby
it "reads after ungetc with multibyte characters in the buffer" do
@string = StringIO.new(+"�����/���x = ga��t��")
c = @string.getc
@string.ungetc(c)
@string.readpartial(3).should == "\xE2\x88\x82"
@string.readpartial(3).should == "\xCF\x86/"
end
```
it fails with every supported Ruby version, and even with 3.5-dev of today, with the message `Expected "\xE2\x88\x82" == "���"`
The `getc` + `ungetc` can be removed, but this does not change the behaviour.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/