`deque_clear` clears `MemoryError`
Open
@rhettinger is already working on this.
Since Jun 26, 2026.
extension-modules
type-bug
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
This is a sub-issue for gh-146102 with the gist here.
In the case that there is no memory, deque_clear calls PyErr_Clear():
https://github.com/python/cpython/blob/7928a8b730b0334c9f97c2144ab00fe0d88f1e97/Modules/_collectionsmodule.c#L749-L753
This was done to clear the error that newblock raises. However, if there was originally an exception, deque_clear clears it.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-152018
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.