Skip to content

Commit

Permalink
Merge pull request #88 from jvikman/issue87
Browse files Browse the repository at this point in the history
Fixed issue #87 by catching the error
  • Loading branch information
lordmauve committed Jul 28, 2018
2 parents 24eb16f + cb37f64 commit da9b1a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions examples/asteroids/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ def on_key_down(key):
if key == keys.BACKSPACE:
game.initials = game.initials[:-1]
elif key == keys.RETURN and game.initials:
with open('leaderboard.json', 'r') as lb:
try:
try:
with open('leaderboard.json', 'r') as lb:
leader_board = json.load(lb)
except ValueError:
leader_board = []
except (ValueError, FileNotFoundError):
leader_board = []
leader_board.append((game.initials, game.score))
with open('leaderboard.json', 'w') as lb:
json.dump(leader_board, lb)
Expand Down

0 comments on commit da9b1a5

Please sign in to comment.