This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pkgutil.get_data() leaks open files in Python 2.7
Type: resource usage Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: Elvis.Pranskevichus, eric.araujo
Priority: normal Keywords: patch

Created on 2017-10-03 19:39 by Elvis.Pranskevichus, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3875 merged Elvis.Pranskevichus, 2017-10-03 19:44
Messages (2)
msg303642 - (view) Author: Elvis Pranskevichus (Elvis.Pranskevichus) * (Python triager) Date: 2017-10-03 19:39
pkgutil.get_data() does this:

     def get_data(self, pathname):
        return open(pathname, "rb").read()

which very obviously leaks open file descriptors.  This has been fixed in 3.x by https://github.com/python/cpython/commit/1ab58dfb12dedb7, but never backported to 2.7.
msg303965 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2017-10-09 14:55
New changeset cfe1aefcbd2534ddc1059a7332842644e6c8d1e4 by Éric Araujo (Elvis Pranskevichus) in branch '2.7':
bpo-31681: Make sure pkgutil.get_data closes files properly (#3875)
https://github.com/python/cpython/commit/cfe1aefcbd2534ddc1059a7332842644e6c8d1e4
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 75862
2017-11-06 18:44:09berker.peksagsetpull_requests: - pull_request4016
2017-10-19 07:40:29gwksetpull_requests: + pull_request4016
2017-10-09 15:22:09eric.araujosetstatus: open -> closed
assignee: eric.araujo
resolution: fixed
stage: patch review -> resolved
2017-10-09 14:55:56eric.araujosetnosy: + eric.araujo
messages: + msg303965
2017-10-03 19:44:11Elvis.Pranskevichussetkeywords: + patch
stage: patch review
pull_requests: + pull_request3854
2017-10-03 19:39:44Elvis.Pranskevichuscreate