Skip to content

Commit f4c23c4

Browse files
committed
Update exception catching syntax to please pep8
1 parent 27fa56b commit f4c23c4

File tree

11 files changed

+18
-18
lines changed

11 files changed

+18
-18
lines changed

django/archives/mailarchives/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def latest(request, listname):
4141
if 'n' in request.GET:
4242
try:
4343
limit = int(request.GET['n'])
44-
except:
44+
except Exception:
4545
limit = 0
4646
else:
4747
limit = 50

django/archives/mailarchives/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def hiddenreason(self):
5656
return None
5757
try:
5858
return hide_reasons[self.hiddenstatus]
59-
except:
59+
except Exception:
6060
# Weird value
6161
return 'This message has been hidden.'
6262

django/archives/mailarchives/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def search(request):
720720
'names': request.POST['ln'].split(','),
721721
})
722722
lists = [x for x, in curs.fetchall()]
723-
except:
723+
except Exception:
724724
# If failing to parse list of lists, just search all
725725
lists = None
726726
else:

loader/generate_mbox.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def generate_single_mbox(conn, listid, year, month, destination):
3535
try:
3636
x = msg.as_string(unixfrom=True)
3737
f.write(x)
38-
except UnicodeEncodeError as e:
38+
except UnicodeEncodeError:
3939
print("Not including {0}, unicode error".format(msg['message-id']))
4040
except Exception as e:
4141
print("Not including {0}, exception {1}".format(msg['message-id'], e))
@@ -69,7 +69,7 @@ def generate_single_mbox(conn, listid, year, month, destination):
6969
cfg.read(os.path.join(os.path.realpath(os.path.dirname(sys.argv[0])), 'archives.ini'))
7070
try:
7171
connstr = cfg.get('db', 'connstr')
72-
except:
72+
except Exception:
7373
connstr = 'need_connstr'
7474

7575
conn = psycopg2.connect(connstr)

loader/hide_message.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
4343
try:
4444
connstr = cfg.get('db', 'connstr')
45-
except:
45+
except Exception:
4646
connstr = 'need_connstr'
4747

4848
conn = psycopg2.connect(connstr)
@@ -75,7 +75,7 @@
7575
else:
7676
try:
7777
print("Hiding message for reason: %s" % reasons[reason])
78-
except:
78+
except Exception:
7979
continue
8080
break
8181
if previous == reason:

loader/lib/parser.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def is_msgid(self, msgid):
3030
try:
3131
if self.clean_messageid(self.decode_mime_header(self.get_mandatory('Message-ID'))) == msgid:
3232
return True
33-
except Exception as e:
33+
except Exception:
3434
return False
3535

3636
def analyze(self, date_override=None):
@@ -527,7 +527,7 @@ def _decode_mime_header(self, hdr, email_workaround):
527527

528528
try:
529529
return " ".join([self._maybe_decode(s, charset) for s, charset in decode_header(hdr)])
530-
except HeaderParseError as e:
530+
except HeaderParseError:
531531
# Parser error is typically someone specifying an encoding,
532532
# but then not actually using that encoding. We'll do the best
533533
# we can, which is cut it down to ascii and ignore errors
@@ -553,13 +553,13 @@ def get_mandatory(self, fieldname):
553553
if x is None:
554554
raise Exception()
555555
return x
556-
except:
556+
except Exception:
557557
raise IgnorableException("Mandatory field '%s' is missing" % fieldname)
558558

559559
def get_optional(self, fieldname):
560560
try:
561561
return self.msg[fieldname]
562-
except:
562+
except Exception:
563563
return ''
564564

565565
def html_clean(self, html):
@@ -585,7 +585,7 @@ def html_clean(self, html):
585585
cleaner = HTMLCleaner()
586586
cleaner.feed(html)
587587
return cleaner.get_text()
588-
except Exception as e:
588+
except Exception:
589589
# Failed to parse the html, thus failed to clean it. so we must
590590
# give up...
591591
return None

loader/pglister_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
2121
try:
2222
connstr = cfg.get('db', 'connstr')
23-
except:
23+
except Exception:
2424
connstr = 'need_connstr'
2525

2626
if cfg.has_option('pglister', 'subscribers') and cfg.getint('pglister', 'subscribers'):

loader/purge_frontend_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
3535
try:
3636
connstr = cfg.get('db', 'connstr')
37-
except:
37+
except Exception:
3838
connstr = 'need_connstr'
3939

4040
conn = psycopg2.connect(connstr)

loader/reparse_message.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def ResultIter(cursor):
6464
cfg.read('%s/archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
6565
try:
6666
connstr = cfg.get('db', 'connstr')
67-
except:
67+
except Exception:
6868
connstr = 'need_connstr'
6969

7070
conn = psycopg2.connect(connstr)

loader/tools/edit_raw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
cfg.read('%s/../archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
3333
try:
3434
connstr = cfg.get('db', 'connstr')
35-
except:
35+
except Exception:
3636
connstr = 'need_connstr'
3737

3838
conn = psycopg2.connect(connstr)
@@ -92,6 +92,6 @@
9292
finally:
9393
try:
9494
f.close()
95-
except:
95+
except Exception:
9696
pass
9797
os.unlink(f.name)

loader/tools/fix_from.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
cfg.read('%s/../archives.ini' % os.path.realpath(os.path.dirname(sys.argv[0])))
1919
try:
2020
connstr = cfg.get('db', 'connstr')
21-
except:
21+
except Exception:
2222
connstr = 'need_connstr'
2323

2424
conn = psycopg2.connect(connstr)

0 commit comments

Comments
 (0)