summaryrefslogtreecommitdiff
path: root/puzzles/seq_try_except_finally.py
diff options
context:
space:
mode:
Diffstat (limited to 'puzzles/seq_try_except_finally.py')
-rw-r--r--puzzles/seq_try_except_finally.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/puzzles/seq_try_except_finally.py b/puzzles/seq_try_except_finally.py
index d63ab10..ea17a16 100644
--- a/puzzles/seq_try_except_finally.py
+++ b/puzzles/seq_try_except_finally.py
@@ -1,8 +1,11 @@
-def foo() -> None:
+def f() -> None:
file = None
try:
file = open('test.json')
except Exception:
return None
finally:
- file.name # error
+ if file:
+ file.close()
+
+ file.name