diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-09-13 18:10:15 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-09-13 18:10:15 +0000 |
commit | dbbcb19507c558ba7e14e42b62f58cb0dcae39a9 (patch) | |
tree | 6f1cbf6e7c08d8132eb1583866d0224bc0adc58c | |
parent | e326938a1621e63506a0ea12f761781d84641837 (diff) | |
download | portage-dbbcb19507c558ba7e14e42b62f58cb0dcae39a9.tar.gz portage-dbbcb19507c558ba7e14e42b62f58cb0dcae39a9.tar.bz2 portage-dbbcb19507c558ba7e14e42b62f58cb0dcae39a9.zip |
Bug #237526 - Use portage.util.grablines() for exception handling when
reading the unread file.
svn path=/main/trunk/; revision=11510
-rw-r--r-- | pym/portage/news.py | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/pym/portage/news.py b/pym/portage/news.py index 203ce3fec..e366287bb 100644 --- a/pym/portage/news.py +++ b/pym/portage/news.py @@ -10,7 +10,8 @@ __all__ = ["NewsManager", "NewsItem", "DisplayRestriction", import errno import os import re -from portage.util import ensure_dirs, apply_permissions, normalize_path, grabfile, write_atomic +from portage.util import apply_permissions, ensure_dirs, grabfile, \ + grablines, normalize_path, write_atomic from portage.data import portage_gid from portage.locks import lockfile, unlockfile from portage.exception import OperationNotPermitted @@ -141,19 +142,9 @@ class NewsManager(object): if os.access(os.path.dirname(unreadfile), os.W_OK): # TODO: implement shared readonly locks unread_lock = lockfile(unreadfile) - try: - f = open(unreadfile) - try: - unread = f.readlines() - finally: - f.close() - except EnvironmentError, e: - if e.errno != errno.ENOENT: - raise - del e - return 0 - if len(unread): - return len(unread) + + return len(grablines(unreadfile)) + finally: if unread_lock: unlockfile(unread_lock) |