[issue19884] Importing readline produces erroneous output
STINNER Victor
report at bugs.python.org
Thu Jun 12 11:21:51 CEST 2014
STINNER Victor added the comment:
Attached readline_disable_meta_key.patch: Implement the workaround suggested in (*), but only use the workaround if stdout is not a TTY (ex: output redirected), to limit the risk of regression.
(*) http://lists.gnu.org/archive/html/bug-readline/2011-04/msg00009.html
Extract of the patch:
+ if (!isatty(STDOUT_FILENO)) {
+ /* Issue #19884: Don't try to enable any meta modifier key the terminal
+ claims to support when it is called. On many terminals (ex:
+ xterm-256color), the meta key is used to send eight-bit characters
+ (ANSI sequence "\033[1034h"). */
+ rl_variable_bind ("enable-meta-key", "off");
+ }
This issue becomes very annoying on my Fedora 20. The output of any Mercurial command now starts with "\033.[?1034h" (Mercurial uses Python 2.7). Example:
haypo at smithers$ hg root|hexdump -C
00000000 1b 5b 3f 31 30 33 34 68 2f 68 6f 6d 65 2f 68 61 |.[?1034h/home/ha|
00000010 79 70 6f 2f 70 72 6f 67 2f 70 79 74 68 6f 6e 2f |ypo/prog/python/|
00000020 64 65 66 61 75 6c 74 0a |default.|
00000028
Fedora 18 changed the default TERM environment variable to "xterm-256color":
http://fedoraproject.org/wiki/Features/256_Color_Terminals
Workaround in your application (to run on unpatched Python): set the TERM environment variable to "dummy", or unset this variable.
----------
keywords: +patch
nosy: +haypo
Added file: http://bugs.python.org/file35589/readline_disable_meta_key.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19884>
_______________________________________
More information about the Python-bugs-list
mailing list