Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion IPython/core/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def __init__(self, **kwargs):
# ensure current working directory exists
try:
os.getcwd()
except:
except Exception:
# exit if cwd doesn't exist
self.log.error("Current working directory doesn't exist.")
self.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion IPython/core/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,7 @@ def python_func_kw_matches(self, text):
for namedArg in set(namedArgs) - usedNamedArgs:
if namedArg.startswith(text):
argMatches.append("%s=" %namedArg)
except:
except Exception:
pass

return argMatches
Expand Down
2 changes: 1 addition & 1 deletion IPython/core/completerlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def try_import(mod: str, only_modules=False) -> List[str]:
mod = mod.rstrip('.')
try:
m = import_module(mod)
except:
except Exception:
return []

m_is_init = '__init__' in (getattr(m, '__file__', '') or '')
Expand Down
4 changes: 2 additions & 2 deletions IPython/core/crashhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def __call__(
# and generate a complete report on disk
try:
report = open(report_name, "w", encoding="utf-8")
except:
except Exception:
print('Could not create crash report on disk.', file=sys.stderr)
return

Expand Down Expand Up @@ -220,7 +220,7 @@ def make_report(self, traceback: str) -> str:
rpt_add("Application name: %s\n\n" % self.app.name)
rpt_add("Current user configuration structure:\n\n")
rpt_add(config)
except:
except Exception:
pass
rpt_add(sec_sep+'Crash traceback:\n\n' + traceback)

Expand Down
2 changes: 1 addition & 1 deletion IPython/core/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ def do_list(self, arg):
last = first + last
else:
first = max(1, int(x) - 5)
except:
except Exception:
print("*** Error in argument:", repr(arg), file=self.stdout)
return
elif self.lineno is None or arg == ".":
Expand Down
2 changes: 1 addition & 1 deletion IPython/core/debugger_backport.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ def default(self, line): # type: ignore[no-untyped-def]
sys.stdout = save_stdout
sys.stdin = save_stdin
sys.displayhook = save_displayhook
except:
except Exception:
self._error_exc()
2 changes: 1 addition & 1 deletion IPython/core/doctb.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def format_exception(self, etype: Any, evalue: Any) -> Any:
# Get (safely) a string form of the exception info
try:
etype_str, evalue_str = map(str, (etype, evalue))
except:
except Exception:
# User exception is improperly defined.
etype, evalue = str, sys.exc_info()[:2]
etype_str, evalue_str = map(str, (etype, evalue))
Expand Down
2 changes: 1 addition & 1 deletion IPython/core/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def format(self, obj, include=None, exclude=None):
md = None
try:
data = formatter(obj)
except:
except Exception:
# FIXME: log the exception
raise

Expand Down
28 changes: 14 additions & 14 deletions IPython/core/interactiveshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,7 @@ def push(self, variables, interactive=True):
for name in vlist:
try:
vdict[name] = eval(name, cf.f_globals, cf.f_locals)
except:
except Exception:
print('Could not get variable %s from %s' %
(name,cf.f_code.co_name))
else:
Expand Down Expand Up @@ -1777,7 +1777,7 @@ def _ofind(
obj = obj[int(part)]
else:
obj = getattr(obj, part)
except:
except Exception:
# Blanket except b/c some badly implemented objects
# allow __getattr__ to raise exceptions other than
# AttributeError, which then crashes IPython.
Expand Down Expand Up @@ -2071,7 +2071,7 @@ def wrapped(self,etype,value,tb,tb_offset=None):
try:
stb = handler(self,etype,value,tb,tb_offset=tb_offset)
return validate_stb(stb)
except:
except Exception:
# clear custom handler immediately
self.set_custom_exc((), None)
print("Custom TB Handler failed, unregistering", file=sys.stderr)
Expand Down Expand Up @@ -2273,7 +2273,7 @@ def showsyntaxerror(self, filename=None, running_compiled_code=False):
if filename and issubclass(etype, SyntaxError):
try:
value.filename = filename
except:
except Exception:
# Not the format we expect; leave it alone
pass

Expand Down Expand Up @@ -2906,7 +2906,7 @@ def user_expressions(self, expressions):
for key, expr in expressions.items():
try:
value = self._format_user_obj(eval(expr, global_ns, user_ns))
except:
except Exception:
value = self._user_obj_error()
out[key] = value
return out
Expand Down Expand Up @@ -2960,7 +2960,7 @@ def safe_execfile(self, fname, *where, exit_ignore=False, raise_exceptions=False
try:
with fname.open("rb"):
pass
except:
except Exception:
warn('Could not open file <%s> for safe execution.' % fname)
return

Expand Down Expand Up @@ -2990,7 +2990,7 @@ def safe_execfile(self, fname, *where, exit_ignore=False, raise_exceptions=False
raise
if not exit_ignore:
self.showtraceback(exception_only=True)
except:
except Exception:
if raise_exceptions:
raise
# tb offset is 2 because we wrap execfile
Expand Down Expand Up @@ -3018,7 +3018,7 @@ def safe_execfile_ipy(self, fname, shell_futures=False, raise_exceptions=False):
try:
with fname.open("rb"):
pass
except:
except Exception:
warn('Could not open file <%s> for safe execution.' % fname)
return

Expand Down Expand Up @@ -3048,7 +3048,7 @@ def get_cells():
result.raise_error()
elif not result.success:
break
except:
except Exception:
if raise_exceptions:
raise
self.showtraceback()
Expand Down Expand Up @@ -3078,7 +3078,7 @@ def safe_run_module(self, mod_name, where):
except SystemExit as status:
if status.code:
raise
except:
except Exception:
self.showtraceback()
warn('Unknown failure executing module: <%s>' % mod_name)

Expand Down Expand Up @@ -3235,7 +3235,7 @@ def _run_cell(
result = ExecutionResult(info)
result.error_in_exec = e
self.showtraceback(running_compiled_code=True)
except:
except Exception:
pass
return result

Expand Down Expand Up @@ -3482,7 +3482,7 @@ def _format_exception_for_storage(
if filename and isinstance(evalue, SyntaxError):
try:
evalue.filename = filename
except:
except Exception:
pass # Keep the original filename if modification fails

# Extract traceback if the error happened during compiled code execution
Expand Down Expand Up @@ -3691,7 +3691,7 @@ def compare(code):
if softspace(sys.stdout, 0):
print()

except:
except Exception:
# It's possible to have exceptions raised here, typically by
# compilation of odd code (such as a naked 'return' outside a
# function) that did parse but isn't valid. Typically the exception
Expand Down Expand Up @@ -3763,7 +3763,7 @@ async def run_code(self, code_obj, result=None, *, async_=False):
if result is not None:
result.error_in_exec = value
self.CustomTB(etype, value, tb)
except:
except Exception:
if result is not None:
result.error_in_exec = sys.exc_info()[1]
self.showtraceback(running_compiled_code=True)
Expand Down
2 changes: 1 addition & 1 deletion IPython/core/magics/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ def xmode_switch_err(name):
try:
shell.InteractiveTB.set_mode(mode=new_mode)
print('Exception reporting mode:',shell.InteractiveTB.mode)
except:
except Exception:
raise
xmode_switch_err('user')

Expand Down
2 changes: 1 addition & 1 deletion IPython/core/magics/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ class DataIsObject(Exception): pass
last_call[0] = shell.displayhook.prompt_count
if not opts_prev:
last_call[1] = args
except:
except Exception:
pass


Expand Down
4 changes: 2 additions & 2 deletions IPython/core/magics/execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __str__(self):
try:
"\xb1".encode(sys.stdout.encoding)
pm = "\xb1"
except:
except Exception:
pass
return "{mean} {pm} {std} per loop (mean {pm} std. dev. of {runs} run{run_plural}, {loops:,} loop{loop_plural} each)".format(
pm=pm,
Expand Down Expand Up @@ -1697,7 +1697,7 @@ def _format_time(timespan, precision=3):
try:
"μ".encode(sys.stdout.encoding)
units = ["s", "ms", "μs", "ns"]
except:
except Exception:
pass
scaling = [1, 1e3, 1e6, 1e9]

Expand Down
4 changes: 2 additions & 2 deletions IPython/core/magics/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def logstart(self, parameter_s=''):
if par:
try:
logfname,logmode = par.split()
except:
except Exception:
logfname = par
logmode = 'backup'
else:
Expand All @@ -125,7 +125,7 @@ def logstart(self, parameter_s=''):
try:
logger.logstart(logfname, loghead, logmode, log_output, timestamp,
log_raw_input)
except:
except Exception:
self.shell.logfile = old_logfile
warn("Couldn't start log: %s" % sys.exc_info()[1])
else:
Expand Down
4 changes: 2 additions & 2 deletions IPython/core/magics/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def psearch(self, parameter_s=''):
try:
psearch(args,shell.ns_table,ns_search,
show_all=opt('a'),ignore_case=ignore_case, list_types=list_types)
except:
except Exception:
shell.showtraceback()

@skip_doctest
Expand Down Expand Up @@ -477,7 +477,7 @@ def type_name(v):
except UnicodeEncodeError:
vstr = var.encode(DEFAULT_ENCODING,
'backslashreplace')
except:
except Exception:
vstr = "<object with id %d (str() failed)>" % id(var)
vstr = vstr.replace('\n', '\\n')
if len(vstr) < 50:
Expand Down
2 changes: 1 addition & 1 deletion IPython/core/magics/osm.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ def dhist(self, parameter_s=''):
if parameter_s:
try:
args = map(int,parameter_s.split())
except:
except Exception:
self.arg_err(self.dhist)
return
if len(args) == 1:
Expand Down
6 changes: 3 additions & 3 deletions IPython/core/magics/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ def kill_bg_processes(self):
if p.returncode is None:
try:
p.send_signal(signal.SIGINT)
except:
except Exception:
pass
time.sleep(0.1)
self._gc_bg_processes()
Expand All @@ -387,7 +387,7 @@ def kill_bg_processes(self):
if p.returncode is None:
try:
p.terminate()
except:
except Exception:
pass
time.sleep(0.1)
self._gc_bg_processes()
Expand All @@ -397,7 +397,7 @@ def kill_bg_processes(self):
if p.returncode is None:
try:
p.kill()
except:
except Exception:
pass
self._gc_bg_processes()

Expand Down
10 changes: 5 additions & 5 deletions IPython/core/oinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def _getdef(self,obj,oname='') -> Union[str,None]:
return None
try:
return _render_signature(signature(obj), oname)
except:
except Exception:
return None

def __head(self, h: str) -> str:
Expand Down Expand Up @@ -907,7 +907,7 @@ def info(self, obj, oname="", info=None, detail_level=0) -> InfoDict:
if not callable(obj):
try:
ds = "Alias to the system command:\n %s" % obj[1]
except:
except Exception:
ds = "Alias: " + str(obj)
else:
ds = "Alias to " + str(obj)
Expand Down Expand Up @@ -937,7 +937,7 @@ def info(self, obj, oname="", info=None, detail_level=0) -> InfoDict:
try:
bclass = obj.__class__
out['base_class'] = str(bclass)
except:
except Exception:
pass

# String form, but snip if too long in ? form (full in ??)
Expand All @@ -952,7 +952,7 @@ def info(self, obj, oname="", info=None, detail_level=0) -> InfoDict:
q.strip() for q in ostr.split("\n")
)
out["string_form"] = ostr
except:
except Exception:
pass

if ospace:
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def info(self, obj, oname="", info=None, detail_level=0) -> InfoDict:
if ds:
try:
cls = getattr(obj,'__class__')
except:
except Exception:
class_ds = None
else:
class_ds = getdoc(cls)
Expand Down
6 changes: 3 additions & 3 deletions IPython/core/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,12 @@ def page_file(fname, start=0, pager_cmd=None):
if os.environ['TERM'] in ['emacs','dumb']:
raise EnvironmentError
system(pager_cmd + ' ' + fname)
except:
except Exception:
try:
if start > 0:
start -= 1
page(open(fname, encoding="utf-8").read(), start)
except:
except Exception:
print('Unable to show file',repr(fname))


Expand All @@ -298,7 +298,7 @@ def get_pager_cmd(pager_cmd=None):
if pager_cmd is None:
try:
pager_cmd = os.environ['PAGER']
except:
except Exception:
pager_cmd = default_pager_cmd

if pager_cmd == 'less' and '-r' not in os.environ.get('LESS', '').lower():
Expand Down
Loading
Loading