OILS / mycpp / examples / invalid_except.py View on Github | oilshell.org

38 lines, 20 significant
1#!/usr/bin/env python2
2"""
3invalid_except.py
4"""
5from __future__ import print_function
6
7
8def f():
9 # type: () -> None
10
11 # Duplicate to see if we can get THREE errors out of mycpp
12
13 try:
14 print('hi')
15 except IOError:
16 print('bad')
17
18 try:
19 print('hi')
20 except OSError as e:
21 print('bad')
22
23
24def run_tests():
25 # type: () -> None
26
27 f()
28
29 try:
30 print('hi')
31 except (IOError, OSError) as e:
32 pass
33
34 # Invalid finally, not except
35 try:
36 print('hi')
37 finally:
38 print('finally')