* [ruby-core:123176] [Ruby Bug#21562] IO#each_codepoint raises using with IO#ungetc
@ 2025-09-04 11:05 YO4 (Yoshinao Muramatsu) via ruby-core
2025-09-06 6:25 ` [ruby-core:123182] " YO4 (Yoshinao Muramatsu) via ruby-core
0 siblings, 1 reply; 2+ messages in thread
From: YO4 (Yoshinao Muramatsu) via ruby-core @ 2025-09-04 11:05 UTC (permalink / raw)
To: ruby-core; +Cc: YO4 (Yoshinao Muramatsu)
Issue #21562 has been reported by YO4 (Yoshinao Muramatsu).
----------------------------------------
Bug #21562: IO#each_codepoint raises using with IO#ungetc
https://bugs.ruby-lang.org/issues/21562
* Author: YO4 (Yoshinao Muramatsu)
* Status: Open
* ruby -v: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [x64-mingw-ucrt]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Using IO#each_codepoint together with IO#ungetc causes ```byte oriented read for character buffered IO (IOError)``` when encoding conversion is active.
```
C:\>ruby -e "open('NUL', 'rt') { _1.ungetc('aa'); _1.each_codepoint { |c| p c }}"
97
-e:1:in 'IO#each_codepoint': byte oriented read for character buffered IO (IOError)
from -e:1:in 'block in <main>'
from -e:1:in 'Kernel#open'
from -e:1:in '<main>'
```
note: 'rt' enables newline conversion for input, and it uses the encoding conversion mechanism.
When encoding conversion is not used, similar operations complete successfully.
```
C:\>ruby -e "open('NUL', 'rb') { _1.ungetc('aa'); _1.each_codepoint { |c| p c }}"
97
97
```
Since both IO#each_codepoint and IO#ungetc handle characters, I believe IO#each_codepoint should work on both cases.
--
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
* [ruby-core:123182] [Ruby Bug#21562] IO#each_codepoint raises using with IO#ungetc
2025-09-04 11:05 [ruby-core:123176] [Ruby Bug#21562] IO#each_codepoint raises using with IO#ungetc YO4 (Yoshinao Muramatsu) via ruby-core
@ 2025-09-06 6:25 ` YO4 (Yoshinao Muramatsu) via ruby-core
0 siblings, 0 replies; 2+ messages in thread
From: YO4 (Yoshinao Muramatsu) via ruby-core @ 2025-09-06 6:25 UTC (permalink / raw)
To: ruby-core; +Cc: YO4 (Yoshinao Muramatsu)
Issue #21562 has been updated by YO4 (Yoshinao Muramatsu).
PR here
https://github.com/ruby/ruby/pull/14455
----------------------------------------
Bug #21562: IO#each_codepoint raises using with IO#ungetc
https://bugs.ruby-lang.org/issues/21562#change-114513
* Author: YO4 (Yoshinao Muramatsu)
* Status: Open
* ruby -v: ruby 3.4.4 (2025-05-14 revision a38531fd3f) +PRISM [x64-mingw-ucrt]
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
Using IO#each_codepoint together with IO#ungetc causes ```byte oriented read for character buffered IO (IOError)``` when encoding conversion is active.
```
C:\>ruby -e "open('NUL', 'rt') { _1.ungetc('aa'); _1.each_codepoint { |c| p c }}"
97
-e:1:in 'IO#each_codepoint': byte oriented read for character buffered IO (IOError)
from -e:1:in 'block in <main>'
from -e:1:in 'Kernel#open'
from -e:1:in '<main>'
```
note: 'rt' enables newline conversion for input, and it uses the encoding conversion mechanism.
When encoding conversion is not used, similar operations complete successfully.
```
C:\>ruby -e "open('NUL', 'rb') { _1.ungetc('aa'); _1.each_codepoint { |c| p c }}"
97
97
```
Since both IO#each_codepoint and IO#ungetc handle characters, I believe IO#each_codepoint should work on both cases.
--
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-09-06 6:26 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-04 11:05 [ruby-core:123176] [Ruby Bug#21562] IO#each_codepoint raises using with IO#ungetc YO4 (Yoshinao Muramatsu) via ruby-core
2025-09-06 6:25 ` [ruby-core:123182] " YO4 (Yoshinao Muramatsu) via ruby-core
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 NNTP newsgroup(s).