Permalink
Browse files

in a finally to close a urllib.urlopen'ed file, check to make sure th…

…e file object is not None.
  • Loading branch information...
Jeremy Hoon
Jeremy Hoon committed Feb 9, 2011
1 parent 9ebc56d commit 9c9cc13273652cf39bc2b17e7c86d9f93151c780
Showing with 2 additions and 1 deletion.
  1. +2 −1 updatemanager.py
View
@@ -64,7 +64,8 @@ def github_last_commit(sUser,sRepo,sBranch):
infile = urllib.urlopen(sUrl)
dictJson = json.load(infile)
finally:
- infile.close()
+ if infile is not None:
+ infile.close()
listCommit = map(Commit.from_json, dictJson["commits"])
listCommit.sort(lambda a,b: -cmp(a.dt,b.dt))
return (listCommit and listCommit[0]) or None

0 comments on commit 9c9cc13

Please sign in to comment.