From: "k0kubun (Takashi Kokubun) via ruby-core" Date: 2026-07-09T18:40:08+00:00 Subject: [ruby-core:126002] [Ruby Bug#21882] IO::Buffer#locked leaves the buffer locked when the block raises Issue #21882 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: DONE, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ruby_4_0 commit:2bf4c08b84242bf5030c4088842e72f57f37f781 merged revision(s) commit:b5ccab2093c9bb19ae8564a935e6fd72ec7354cc, commit:2bf4c08b84242bf5030c4088842e72f57f37f781. ---------------------------------------- Bug #21882: IO::Buffer#locked leaves the buffer locked when the block raises https://bugs.ruby-lang.org/issues/21882#change-117980 * Author: hanazuki (Kasumi Hanazuki) * Status: Closed * ruby -v: ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [x86_64-linux] * Backport: 3.3: REQUIRED, 3.4: DONE, 4.0: DONE ---------------------------------------- `IO::Buffer#locked` should unlock the buffer even after the block raises an exception. ```ruby buf = IO::Buffer.new(100) buf.locked { fail } rescue nil buf.locked { p :ok } # expected to print :ok, but actually raises a LockedError ``` -- 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/