File: try_except_pass.py

package info (click to toggle)
bandit 1.7.10-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,796 kB
  • sloc: python: 19,688; makefile: 23; sh: 14
file content (36 lines) | stat: -rw-r--r-- 266 bytes parent folder | download | duplicates (7)
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
# bad
try:
    a = 1
except:
    pass


# bad
try:
    a = 1
except Exception:
    pass


# bad
try:
    a = 1
except ZeroDivisionError:
    pass
except:
    a = 2


# good
try:
    a = 1
except:
    a = 2


# silly, but ok
try:
    a = 1
except:
    pass
    a = 2