From d1407eaef6f7a352d1835905af27c2972b712010 Mon Sep 17 00:00:00 2001 From: The Major Date: Thu, 28 Nov 2024 19:32:42 +0000 Subject: [PATCH] Make Thread::{Queue,SizedQueue}#freeze raise TypeError --- CHANGELOG.md | 2 ++ lib/truffle/thread.rb | 8 ++++++++ spec/tags/core/queue/freeze_tags.txt | 1 - spec/tags/core/sizedqueue/freeze_tags.txt | 1 - 4 files changed, 10 insertions(+), 2 deletions(-) delete mode 100644 spec/tags/core/queue/freeze_tags.txt delete mode 100644 spec/tags/core/sizedqueue/freeze_tags.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index 37e8e83be97d..ff1cc95d10d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,8 @@ Compatibility: * Support serializing of `Data` instances into Marshal format (#3726, @andrykonchin). * `Array#pack` now raises `ArgumentError` for unknown directives (#3681, @Th3-M4jor). * `String#unpack` now raises `ArgumentError` for unknown directives (#3681, @Th3-M4jor). +* `Thread::Queue#freeze` now raises `TypeError` when called (#3681, @Th3-M4jor). +* `Thread::SizedQueue#freeze` now raises `TypeError` when called (#3681, @Th3-M4jor). Performance: diff --git a/lib/truffle/thread.rb b/lib/truffle/thread.rb index e4cfbbe53fcc..538d27405669 100644 --- a/lib/truffle/thread.rb +++ b/lib/truffle/thread.rb @@ -41,6 +41,10 @@ def pop(non_block = false, timeout: nil) end alias_method :shift, :pop alias_method :deq, :pop + + def freeze + raise TypeError, "cannot freeze #{self}" + end end class SizedQueue @@ -62,5 +66,9 @@ def push(value, non_block = false, timeout: nil) end alias_method :<<, :push alias_method :enq, :push + + def freeze + raise TypeError, "cannot freeze #{self}" + end end end diff --git a/spec/tags/core/queue/freeze_tags.txt b/spec/tags/core/queue/freeze_tags.txt deleted file mode 100644 index ccad9d99dea1..000000000000 --- a/spec/tags/core/queue/freeze_tags.txt +++ /dev/null @@ -1 +0,0 @@ -fails:Queue#freeze raises an exception when freezing diff --git a/spec/tags/core/sizedqueue/freeze_tags.txt b/spec/tags/core/sizedqueue/freeze_tags.txt deleted file mode 100644 index 060e32826807..000000000000 --- a/spec/tags/core/sizedqueue/freeze_tags.txt +++ /dev/null @@ -1 +0,0 @@ -fails:SizedQueue#freeze raises an exception when freezing