Skip to content

Commit

Permalink
in a finally to close a urllib.urlopen'ed file, check to make sure th…
Browse files Browse the repository at this point in the history
…e file object is not None.
  • Loading branch information
Jeremy Hoon committed Feb 9, 2011
1 parent 9ebc56d commit 9c9cc13
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion updatemanager.py
Expand Up @@ -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
Expand Down

0 comments on commit 9c9cc13

Please sign in to comment.