Skip to content

Commit 4a4ee44

Browse files
authored
Merge pull request #721 from Carreau/bare-e
Do not use bare except
2 parents 5422b90 + c7b593f commit 4a4ee44

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

ipykernel/comm/comm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def open(self, data=None, metadata=None, buffers=None):
9494
target_module=self.target_module,
9595
)
9696
self._closed = False
97-
except:
97+
except Exception:
9898
comm_manager.unregister_comm(self)
9999
raise
100100

ipykernel/comm/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def comm_open(self, stream, ident, msg):
9494
# Failure.
9595
try:
9696
comm.close()
97-
except:
97+
except Exception:
9898
self.log.error("""Could not close comm during `comm_open` failure
9999
clean-up. The comm may not have been opened yet.""", exc_info=True)
100100

ipykernel/debugger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def _handle_event(self, msg):
241241
elif msg['event'] == 'continued':
242242
try:
243243
self.stopped_threads.remove(msg['body']['threadId'])
244-
except:
244+
except Exception:
245245
pass
246246
self.event_callback(msg)
247247

ipykernel/eventloops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def handle_int(etype, value, tb):
327327
if kernel.shell_stream.flush(limit=1):
328328
# events to process, return control to kernel
329329
return
330-
except:
330+
except BaseException:
331331
raise
332332
except KeyboardInterrupt:
333333
# Ctrl-C shouldn't crash the kernel

ipykernel/kernelapp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ def initialize(self, argv=None):
630630
self.init_io()
631631
try:
632632
self.init_signal()
633-
except:
633+
except Exception:
634634
# Catch exception when initializing signal fails, eg when running the
635635
# kernel on a separate thread
636636
if self.log_level < logging.CRITICAL:

ipykernel/kernelbase.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ async def process_control(self, msg):
257257
idents, msg = self.session.feed_identities(msg, copy=False)
258258
try:
259259
msg = self.session.deserialize(msg, content=True, copy=False)
260-
except:
260+
except Exception:
261261
self.log.error("Invalid Control Message", exc_info=True)
262262
return
263263

@@ -309,7 +309,7 @@ async def dispatch_shell(self, msg):
309309
idents, msg = self.session.feed_identities(msg, copy=False)
310310
try:
311311
msg = self.session.deserialize(msg, content=True, copy=False)
312-
except:
312+
except Exception:
313313
self.log.error("Invalid Message", exc_info=True)
314314
return
315315

@@ -624,7 +624,7 @@ async def execute_request(self, stream, ident, parent):
624624
store_history = content.get('store_history', not silent)
625625
user_expressions = content.get('user_expressions', {})
626626
allow_stdin = content.get('allow_stdin', False)
627-
except:
627+
except Exception:
628628
self.log.error("Got bad msg: ")
629629
self.log.error("%s", parent)
630630
return
@@ -847,7 +847,7 @@ async def apply_request(self, stream, ident, parent):
847847
content = parent['content']
848848
bufs = parent['buffers']
849849
msg_id = parent['header']['msg_id']
850-
except:
850+
except Exception:
851851
self.log.error("Got bad msg: %s", parent, exc_info=True)
852852
return
853853

ipykernel/parentpoller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
try:
55
import ctypes
6-
except:
6+
except ImportError:
77
ctypes = None
88
import os
99
import platform

0 commit comments

Comments
 (0)