stratakis · GitHub

Bug report

Bug description:

Hello,

Our internal coverity scan instance identified two code paths which leak a file descriptor in import.c in the _imp_create_dynamic_impl function:

https://github.com/python/cpython/blame/bef63d2fb81ae28760040157ea589541bed47d02/Python/import.c#L4820-L4829

https://github.com/python/cpython/blame/bef63d2fb81ae28760040157ea589541bed47d02/Python/import.c#L4842-L4844

If goto finally is reached fp will remain open.

There is also a related comment on the cleanup block:
https://github.com/python/cpython/blame/bef63d2fb81ae28760040157ea589541bed47d02/Python/import.c#L4849

CPython versions tested on:

3.15, 3.14, 3.13

Operating systems tested on:

Linux

Linked PRs

Read the original on github.com ↗