Drop what a deque with maxlen of zero is handed (#8567) · RustPython/RustPython@f9e65c0 · GitHub
Skip to content

Commit f9e65c0

Browse files
authored
Drop what a deque with maxlen of zero is handed (#8567)
append and appendleft trimmed before pushing, and the test they used, maxlen == len, holds for an empty deque whose bound is zero. The pop then had nothing to remove and the item stayed: >>> d = deque(maxlen=0) >>> d.append(1) >>> list(d) [1] Both now push first and trim after, which is the order CPython uses, so a bound of zero drops what just arrived. extend, extendleft, insert, rotate, the operators and the constructor were already right. Assisted-by: Claude Code:claude-opus-5
1 parent 4c448c4 commit f9e65c0

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

crates/vm/src/stdlib/_collections.rs

Lines changed: 10 additions & 4 deletions

extra_tests/snippets/stdlib_collections_deque.py

Lines changed: 43 additions & 0 deletions

0 commit comments

Comments
 (0)