diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-12-28 22:30:09 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-12-28 22:30:09 -0800 |
commit | 5e5a5cddfdeb3aa05932114fc1dce65b5be11ae9 (patch) | |
tree | 3000e19e6917b7d1642d7c878972d5ec165e8878 /pym/portage/manifest.py | |
parent | e94233871e20fd3852e511ed1bd91c2826870f50 (diff) | |
download | portage-5e5a5cddfdeb3aa05932114fc1dce65b5be11ae9.tar.gz portage-5e5a5cddfdeb3aa05932114fc1dce65b5be11ae9.tar.bz2 portage-5e5a5cddfdeb3aa05932114fc1dce65b5be11ae9.zip |
Use 'with file' more.
This helps to minimize ResourceWarning triggered by ^C with python3.
Diffstat (limited to 'pym/portage/manifest.py')
-rw-r--r-- | pym/portage/manifest.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/pym/portage/manifest.py b/pym/portage/manifest.py index 9a85c8f6d..a75c63a69 100644 --- a/pym/portage/manifest.py +++ b/pym/portage/manifest.py @@ -184,13 +184,12 @@ class Manifest(object): """Parse a manifest. If myhashdict is given then data will be added too it. Otherwise, a new dict will be created and returned.""" try: - fd = io.open(_unicode_encode(file_path, + with io.open(_unicode_encode(file_path, encoding=_encodings['fs'], errors='strict'), mode='r', - encoding=_encodings['repo.content'], errors='replace') - if myhashdict is None: - myhashdict = {} - self._parseDigests(fd, myhashdict=myhashdict, **kwargs) - fd.close() + encoding=_encodings['repo.content'], errors='replace') as f: + if myhashdict is None: + myhashdict = {} + self._parseDigests(f, myhashdict=myhashdict, **kwargs) return myhashdict except (OSError, IOError) as e: if e.errno == errno.ENOENT: |