From d46eeafa99f68415d24b969424504d4c78325837 Mon Sep 17 00:00:00 2001 From: Marius Mauch Date: Thu, 18 Jan 2007 20:06:50 +0000 Subject: [PATCH] Unified try-except-finally only works with python-2.5 svn path=/main/trunk/; revision=5711 --- pym/portage_news.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/pym/portage_news.py b/pym/portage_news.py index d3e5ea4f7..26d2607c7 100644 --- a/pym/portage_news.py +++ b/pym/portage_news.py @@ -123,17 +123,18 @@ class NewsManager(object): unreadfile = os.path.join( self.UNREAD_PATH, "news-"+ repoid +".unread" ) try: - unread_lock = lockfile(unreadfile) - # Set correct permissions on the news-repoid.unread file - apply_permissions( filename=unreadfile, - uid=int(self.config["PORTAGE_INST_UID"]), gid=portage_gid, mode=0664 ) - - if os.path.exists( unreadfile ): - unread = open( unreadfile ).readlines() - if len(unread): - return len(unread) - except FileNotFound: - pass # unread file may not exist + try; + unread_lock = lockfile(unreadfile) + # Set correct permissions on the news-repoid.unread file + apply_permissions( filename=unreadfile, + uid=int(self.config["PORTAGE_INST_UID"]), gid=portage_gid, mode=0664 ) + + if os.path.exists( unreadfile ): + unread = open( unreadfile ).readlines() + if len(unread): + return len(unread) + except FileNotFound: + pass # unread file may not exist finally: if unread_lock: unlockfile(unread_lock) -- 2.26.2