python / python/cpython

`deque_clear` clears `MemoryError`

Open
#152,017 3 comments 0 reactions 1 assignee View on GitHub

@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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.