From 97570da1e433558f3fffec0f67b6d15a8d36bc05 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 8 Nov 2021 14:25:25 +0100 Subject: Adding upstream version 3.0.20. Signed-off-by: Daniel Baumann --- ptpython/completer.py | 11 +++++++++-- ptpython/py.typed | 0 ptpython/repl.py | 15 +++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) delete mode 100644 ptpython/py.typed (limited to 'ptpython') diff --git a/ptpython/completer.py b/ptpython/completer.py index 285398c..51a4086 100644 --- a/ptpython/completer.py +++ b/ptpython/completer.py @@ -505,6 +505,10 @@ class DictionaryCompleter(Completer): display=f"[{k_repr}]", display_meta=abbr_meta(self._do_repr(result[k])), ) + except KeyError: + # `result[k]` lookup failed. Trying to complete + # broken object. + pass except ReprFailedError: pass @@ -521,6 +525,10 @@ class DictionaryCompleter(Completer): display=f"[{k_repr}]", display_meta=abbr_meta(self._do_repr(result[k])), ) + except KeyError: + # `result[k]` lookup failed. Trying to complete + # broken object. + pass except ReprFailedError: pass @@ -545,9 +553,8 @@ class DictionaryCompleter(Completer): def get_suffix(name: str) -> str: try: obj = getattr(result, name, None) - if inspect.isfunction(obj): + if inspect.isfunction(obj) or inspect.ismethod(obj): return "()" - if isinstance(obj, dict): return "{}" if isinstance(obj, (list, tuple)): diff --git a/ptpython/py.typed b/ptpython/py.typed deleted file mode 100644 index e69de29..0000000 diff --git a/ptpython/repl.py b/ptpython/repl.py index 220c673..b55b5d5 100644 --- a/ptpython/repl.py +++ b/ptpython/repl.py @@ -135,6 +135,12 @@ class PythonRepl(PythonInput): text = self.read() except EOFError: return + except BaseException as e: + # Something went wrong while reading input. + # (E.g., a bug in the completer that propagates. Don't + # crash the REPL.) + traceback.print_exc() + continue # Run it; display the result (or errors if applicable). self.run_and_show_expression(text) @@ -192,6 +198,12 @@ class PythonRepl(PythonInput): text = await loop.run_in_executor(None, self.read) except EOFError: return + except BaseException: + # Something went wrong while reading input. + # (E.g., a bug in the completer that propagates. Don't + # crash the REPL.) + traceback.print_exc() + continue # Eval. await self.run_and_show_expression_async(text) @@ -333,6 +345,9 @@ class PythonRepl(PythonInput): # not used. try: import black + + if not hasattr(black, "Mode"): + raise ImportError except ImportError: pass # no Black package in your installation else: -- cgit v1.2.3