# 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 <!-- gh-linked-prs --> ### Linked PRs * gh-142777 * gh-142988 * gh-142989 <!-- /gh-linked-prs -->
Activity
pythongh-142776: Ensure fp file descriptor is closed on all code path…
pythongh-142776: Ensure fp file descriptor is closed on all code path…
pythongh-142776: Ensure fp file descriptor is closed on all code path…
fixup! pythongh-142776: Ensure fp file descriptor is closed on all co…
gh-142776: Ensure fp file descriptor is closed on all code paths in i…
brettcannon commentedon Dec 19, 2025
Fixed in
main, but the backports to 3.14 and 3.13 failed.pythongh-142776: Ensure fp file descriptor is closed on all code path…
pythongh-142776: Ensure fp file descriptor is closed on all code path…
[3.13] gh-142776: Ensure fp file descriptor is closed on all code pat…
[3.14] gh-142776: Ensure fp file descriptor is closed on all code pat…
pythongh-142776: Ensure fp file descriptor is closed on all code path…