Skip to content

Commit

Permalink
[GR-59866] Make Thread::{Queue,SizedQueue}#freeze raise TypeError (#3730
Browse files Browse the repository at this point in the history
)

PullRequest: truffleruby/4415
  • Loading branch information
andrykonchin committed Dec 3, 2024
2 parents b1fa560 + d1407ea commit 1fbf3cf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
8 changes: 8 additions & 0 deletions lib/truffle/thread.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion spec/tags/core/queue/freeze_tags.txt

This file was deleted.

1 change: 0 additions & 1 deletion spec/tags/core/sizedqueue/freeze_tags.txt

This file was deleted.

0 comments on commit 1fbf3cf

Please sign in to comment.