Show More
@@ -1,32 +1,33 b'' | |||||
1 | """Error script. DO NOT EDIT FURTHER! It will break exception doctests!!!""" |
|
1 | """Error script. DO NOT EDIT FURTHER! It will break exception doctests!!!""" | |
2 | import sys |
|
2 | import sys | |
3 |
|
3 | |||
4 | def div0(): |
|
4 | def div0(): | |
5 | "foo" |
|
5 | "foo" | |
6 | x = 1 |
|
6 | x = 1 | |
7 | y = 0 |
|
7 | y = 0 | |
8 | x/y |
|
8 | x/y | |
9 |
|
9 | |||
10 | def sysexit(stat, mode): |
|
10 | def sysexit(stat, mode): | |
11 |
raise SystemExit(stat, f |
|
11 | raise SystemExit(stat, f"Mode = {mode}") | |
|
12 | ||||
12 |
|
13 | |||
13 | def bar(mode): |
|
14 | def bar(mode): | |
14 | "bar" |
|
15 | "bar" | |
15 | if mode=='div': |
|
16 | if mode=='div': | |
16 | div0() |
|
17 | div0() | |
17 | elif mode=='exit': |
|
18 | elif mode=='exit': | |
18 | try: |
|
19 | try: | |
19 | stat = int(sys.argv[2]) |
|
20 | stat = int(sys.argv[2]) | |
20 | except: |
|
21 | except: | |
21 | stat = 1 |
|
22 | stat = 1 | |
22 | sysexit(stat, mode) |
|
23 | sysexit(stat, mode) | |
23 | else: |
|
24 | else: | |
24 | raise ValueError('Unknown mode') |
|
25 | raise ValueError('Unknown mode') | |
25 |
|
26 | |||
26 | if __name__ == '__main__': |
|
27 | if __name__ == '__main__': | |
27 | try: |
|
28 | try: | |
28 | mode = sys.argv[1] |
|
29 | mode = sys.argv[1] | |
29 | except IndexError: |
|
30 | except IndexError: | |
30 | mode = 'div' |
|
31 | mode = 'div' | |
31 |
|
32 | |||
32 | bar(mode) |
|
33 | bar(mode) |
General Comments 0
You need to be logged in to leave comments.
Login now