Skip to content

Commit

Permalink
Do not use bare except
Browse files Browse the repository at this point in the history
Part of the ipython#717 PR-group.

Bare excepts replaced by except Exception/BaseException
  • Loading branch information
Carreau committed Jul 12, 2021
1 parent b2f1a79 commit c7b593f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ipykernel/comm/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def open(self, data=None, metadata=None, buffers=None):
target_module=self.target_module,
)
self._closed = False
except:
except Exception:
comm_manager.unregister_comm(self)
raise

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/comm/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def comm_open(self, stream, ident, msg):
# Failure.
try:
comm.close()
except:
except Exception:
self.log.error("""Could not close comm during `comm_open` failure
clean-up. The comm may not have been opened yet.""", exc_info=True)

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _handle_event(self, msg):
elif msg['event'] == 'continued':
try:
self.stopped_threads.remove(msg['body']['threadId'])
except:
except Exception:
pass
self.event_callback(msg)

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/eventloops.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def handle_int(etype, value, tb):
if kernel.shell_stream.flush(limit=1):
# events to process, return control to kernel
return
except:
except BaseException:
raise
except KeyboardInterrupt:
# Ctrl-C shouldn't crash the kernel
Expand Down
2 changes: 1 addition & 1 deletion ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def initialize(self, argv=None):
self.init_io()
try:
self.init_signal()
except:
except Exception:
# Catch exception when initializing signal fails, eg when running the
# kernel on a separate thread
if self.log_level < logging.CRITICAL:
Expand Down
8 changes: 4 additions & 4 deletions ipykernel/kernelbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ async def process_control(self, msg):
idents, msg = self.session.feed_identities(msg, copy=False)
try:
msg = self.session.deserialize(msg, content=True, copy=False)
except:
except Exception:
self.log.error("Invalid Control Message", exc_info=True)
return

Expand Down Expand Up @@ -309,7 +309,7 @@ async def dispatch_shell(self, msg):
idents, msg = self.session.feed_identities(msg, copy=False)
try:
msg = self.session.deserialize(msg, content=True, copy=False)
except:
except Exception:
self.log.error("Invalid Message", exc_info=True)
return

Expand Down Expand Up @@ -624,7 +624,7 @@ async def execute_request(self, stream, ident, parent):
store_history = content.get('store_history', not silent)
user_expressions = content.get('user_expressions', {})
allow_stdin = content.get('allow_stdin', False)
except:
except Exception:
self.log.error("Got bad msg: ")
self.log.error("%s", parent)
return
Expand Down Expand Up @@ -847,7 +847,7 @@ async def apply_request(self, stream, ident, parent):
content = parent['content']
bufs = parent['buffers']
msg_id = parent['header']['msg_id']
except:
except Exception:
self.log.error("Got bad msg: %s", parent, exc_info=True)
return

Expand Down
2 changes: 1 addition & 1 deletion ipykernel/parentpoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

try:
import ctypes
except:
except ImportError:
ctypes = None
import os
import platform
Expand Down

0 comments on commit c7b593f

Please sign in to comment.