1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# PMAT-1105 (b)+(c) (skeptic pass PMAT-1098, C-F2/C-F3): the Exception-vs-
# BaseException split and refusal honesty. (b) SystemExit derives
# BaseException only, so `except Exception:` must let it propagate (CPython:
# stderr `bye`, exit 1) while a bare `except:` catches it. (c) WORST-CLASS:
# xpile's own capability/honesty panics (e.g. the C-PY-INT-ARITH i64-overflow
# refusal) are NOT Python exceptions — no exception exists on the Python side
# at all (CPython computes 92233720368547758000) — so EVERY handler,
# including bare `except:` and `except Exception:`, must re-raise them; the
# old unconditional catch-all arm silently DEFEATED the loud-refusal
# guarantee. Cross-checked vs python3.
def exc_no_systemexit() -> int:
r = 0
try:
raise SystemExit("bye")
except Exception:
r = 1
return r
def bare_catches_systemexit() -> int:
r = 0
try:
raise SystemExit("bye")
except:
r = 2
return r
def exc_catches_valueerror() -> int:
r = 0
try:
raise ValueError("x")
except Exception:
r = 3
return r
def refusal_not_swallowed(a: int) -> int:
r = 0
try:
r = a * 1000
except Exception:
r = -1
return r
def bare_refusal(a: int) -> int:
r = 0
try:
r = a * 1000
except:
r = -1
return r