Skip to content

Commit 60dad9e

Browse files
committed
Replace except: with except Exception - still not great but it's less evil
1 parent 60111b7 commit 60dad9e

8 files changed

Lines changed: 10 additions & 11 deletions

File tree

cloudbot/util/cleverbot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,6 @@ def quote(s, safe='/'):
122122
safe_map[c] = (c in safe) and c or ('%%%02X' % i)
123123
try:
124124
res = list(map(safe_map.__getitem__, s))
125-
except:
125+
except Exception:
126126
return ''
127127
return ''.join(res)

cloudbot/util/formatting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ def dict_format(args, formats):
202202
m = f.format(**args)
203203
# Insert match and number of matched values (max matched values if already in dict)
204204
matches[m] = max([matches.get(m, 0), len(re.findall(r'(\{.*?\})', f))])
205-
except:
205+
except Exception:
206206
continue
207207

208208
# Return most complete match, ranked by values matched and then my match length or None
209209
try:
210210
return max(matches.items(), key=lambda x: (x[1], len(x[0])))[0]
211-
except:
211+
except Exception:
212212
return None
213213

214214

plugins/core_sieve.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def init_tasks(loop, bot):
2727
loop.call_later(600, _func)
2828

2929

30-
3130
@asyncio.coroutine
3231
@hook.sieve
3332
def sieve_suite(bot, event, _hook):

plugins/geoip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def update_db():
4242
else:
4343
try:
4444
return geoip2.database.Reader(PATH)
45-
except:
45+
except Exception:
4646
# issue loading, geo
4747
fetch_db()
4848
return geoip2.database.Reader(PATH)

plugins/imgur.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def imgur(text):
8787
# if it's an imgur meme, add the meme name
8888
try:
8989
title = "\x02{}\x02 - {}".format(item.meme_metadata["meme_name"].lower(), title)
90-
except:
90+
except Exception:
9191
# this is a super un-important thing, so if it fails we don't care, carry on
9292
pass
9393

plugins/quote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def add_quote(db, chan, target, sender, message):
4040
)
4141
db.execute(query)
4242
db.commit()
43-
except:
43+
except Exception:
4444
return "Message already stored, doing nothing."
4545
return "Quote added."
4646

plugins/twitch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def twitch_lookup(location):
5151
else:
5252
try:
5353
data = http.get_json("https://api.twitch.tv/kraken/channels/" + channel)
54-
except:
54+
except Exception:
5555
return "Unable to get channel data. Maybe channel is on justin.tv instead of twitch.tv?"
5656
title = data['status']
5757
playing = data['game']

plugins/whois.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ def whois(text):
1414
try:
1515
i = "\x02Registrar\x02: {}".format(data["registrar"][0])
1616
info.append(i)
17-
except:
17+
except Exception:
1818
pass
1919

2020
try:
2121
i = "\x02Registered\x02: {}".format(data["creation_date"][0].strftime("%d-%m-%Y"))
2222
info.append(i)
23-
except:
23+
except Exception:
2424
pass
2525

2626
try:
2727
i = "\x02Expires\x02: {}".format(data["expiration_date"][0].strftime("%d-%m-%Y"))
2828
info.append(i)
29-
except:
29+
except Exception:
3030
pass
3131

3232
info_text = ", ".join(info)

0 commit comments

Comments
 (0)