File: rlcompleter-invalidterminal

package info (click to toggle)
pypy3 7.3.11%2Bdfsg-2%2Bdeb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 201,024 kB
  • sloc: python: 1,950,308; ansic: 517,580; sh: 21,417; asm: 14,419; cpp: 4,263; makefile: 4,228; objc: 761; xml: 530; exp: 499; javascript: 314; pascal: 244; lisp: 45; csh: 11; awk: 4
file content (43 lines) | stat: -rw-r--r-- 1,394 bytes parent folder | download
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