Skip to content

Instantly share code, notes, and snippets.

@devdanzin
Created March 18, 2026 10:07
Show Gist options
  • Select an option

  • Save devdanzin/d9975354c27e57f2589acfd0a777a2f1 to your computer and use it in GitHub Desktop.

Select an option

Save devdanzin/d9975354c27e57f2589acfd0a777a2f1 to your computer and use it in GitHub Desktop.
_interpchannelsmodule.c: Missing PyErr_NoMemory in channel creation

_interpchannelsmodule.c: Missing PyErr_NoMemory in channel creation

Summary

_channel_new (line 1117) returns NULL from PyMem_NEW without calling PyErr_NoMemory(). Assertion fires in handle_channel_error.

Reproducer

import _testcapi, _interpchannels as ch
for n in range(1, 80):
    _testcapi.set_nomemory(n, 0)
    try:
        cid = ch.create()
        _testcapi.remove_mem_hooks()
        ch.destroy(cid)
        break
    except MemoryError:
        _testcapi.remove_mem_hooks()
    except:
        _testcapi.remove_mem_hooks()
# Assertion in handle_channel_error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment