1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
From: Stefano Rivera <stefanor@debian.org>
Date: Wed, 23 Sep 2020 21:31:30 -0700
Subject: Stdlib: Handle InvalidTerminal in rlcompleter
Pypy's readline module can throw InvalidTerminal if the terminal doesn't
support "clear". This is the case for TERM=dumb, which we use for tests.
Forwarded: https://foss.heptapod.net/pypy/pypy/-/issues/3308
---
lib-python/3/rlcompleter.py | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/lib-python/3/rlcompleter.py b/lib-python/3/rlcompleter.py
index 923f5c0..5a440c1 100644
--- a/lib-python/3/rlcompleter.py
+++ b/lib-python/3/rlcompleter.py
@@ -32,6 +32,7 @@ Notes:
import atexit
import builtins
import __main__
+from pyrepl.unix_console import InvalidTerminal
__all__ = ["Completer"]
@@ -76,11 +77,13 @@ class Completer:
if not text.strip():
if state == 0:
if _readline_available:
- readline.insert_text('\t')
- readline.redisplay()
- return ''
- else:
- return '\t'
+ try:
+ readline.insert_text('\t')
+ readline.redisplay()
+ return ''
+ except InvalidTerminal:
+ pass
+ return '\t'
else:
return None
|