All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] python: fix importing readline with probably escape sequence output
@ 2013-07-18 10:54 Hongxu Jia
  2013-07-18 10:55 ` [PATCH 1/1] " Hongxu Jia
  0 siblings, 1 reply; 3+ messages in thread
From: Hongxu Jia @ 2013-07-18 10:54 UTC (permalink / raw)
  To: openembedded-core

While imports readline in python, if TERM in terminfo is available and 
it contains the variable 'km' and 'smm', the readline initialization will
output the value of 'smm' which is the escape sequence '\E[?1034h'.

'km' means the terminal has a meta key which is a special key on MIT keyboards,
'smm' means turn on the meta key if this terminal has one.

There are 4 solutions to fix this issue:

1) Preserving TERM and unsetting TERM, or setting TERM with a terminal
   without 'smm' (such as terminal 'dumb'). This is the most common 
   approach. But the effect is global even we don't import readline.
   https://bugzilla.redhat.com/show_bug.cgi?id=304181
   http://bugs.python.org/issue11390
   http://lists.gnu.org/archive/html/bug-readline/2013-06/msg00000.html

2) Modify readline.c in python, mandatory let readline use a term
   without 'smm' as terminal (such as 'dumb'), it is similar to the
   above solution, but it localizes the effect in readline. The reason
   why choose 'dumb' is GNU Readline library use 'dumb' as default term
   when TERM is unset.

3) Modify terminfo.src in ncurses, let terminfo database doesn't
   contian 'smm', but the number of terms we supported is limited.

4) Modify terminal.c and readline.c in GNU Readline library to explicitly
   disable meta key, or just comment out the outputting code.
   
This patch implements solution 2, I think it has the least side effect.

Thanks
Hongxu

The following changes since commit 3dee534f1e25109e0bdb681de0746c336f4b8840:

  lib/oeqa: fix dependecy check (2013-07-16 10:04:17 +0100)

are available in the git repository at:

  git://git.pokylinux.org/poky-contrib hongxu/fix-python-readlne
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-python-readlne

Hongxu Jia (1):
  python: fix importing readline with probably escape sequence output

 meta/recipes-devtools/python/python.inc            |  4 ++-
 ...e-explicitly-use-dumb-as-default-terminal.patch | 35 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch

-- 
1.8.1.2



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/1] python: fix importing readline with probably escape sequence output
  2013-07-18 10:54 [PATCH 0/1] python: fix importing readline with probably escape sequence output Hongxu Jia
@ 2013-07-18 10:55 ` Hongxu Jia
  2013-07-18 16:36   ` Saul Wold
  0 siblings, 1 reply; 3+ messages in thread
From: Hongxu Jia @ 2013-07-18 10:55 UTC (permalink / raw)
  To: openembedded-core

While imports readline in python, if the term in terminfo is available and
it contains the variable 'km' and 'smm', the readline initialization will
output the value of 'smm' which is the escape sequence '\E[?1034h'.

'km' means the terminal has a meta key which is a special key on MIT keyboards,
'smm' means turn on the meta key if this terminal has one. They don't exist in
term 'dumb'.

Explicitly use dumb as default terminal to avoid probably escape sequence
output. The dumb is used to label tty lines when you don't know what kind
of terminal is on it. The characteristics of an unknown terminal are the
lowest common denominator.

[YOCTO #4835]
[YOCTO #4732]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-devtools/python/python.inc            |  4 ++-
 ...e-explicitly-use-dumb-as-default-terminal.patch | 35 ++++++++++++++++++++++
 2 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch

diff --git a/meta/recipes-devtools/python/python.inc b/meta/recipes-devtools/python/python.inc
index 80609a8..2fc894d 100644
--- a/meta/recipes-devtools/python/python.inc
+++ b/meta/recipes-devtools/python/python.inc
@@ -7,7 +7,9 @@ INC_PR = "r0"
 
 LIC_FILES_CHKSUM = "file://LICENSE;md5=ed3abfd1059e2d3a36a8cff3986f9bb6"
 
-SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.bz2"
+SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.bz2 \
+           file://readline-explicitly-use-dumb-as-default-terminal.patch \
+"
  
 SRC_URI[md5sum] = "c57477edd6d18bd9eeca2f21add73919"
 SRC_URI[sha256sum] = "726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c"
diff --git a/meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch b/meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch
new file mode 100644
index 0000000..11928d1
--- /dev/null
+++ b/meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch
@@ -0,0 +1,35 @@
+readline: explicitly use dumb as default terminal
+
+Explicitly use dumb as default terminal to avoid probably
+escape sequence output. The dumb is used to label tty lines
+when you don't know what kind of terminal is on it. The
+characteristics of an unknown terminal are the lowest common
+denominator.
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+Upstream-Status: inappropriate [oe specific] 
+---
+ Modules/readline.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/Modules/readline.c b/Modules/readline.c
+--- a/Modules/readline.c
++++ b/Modules/readline.c
+@@ -882,6 +882,14 @@ setup_readline(void)
+ #endif
+     /* Force rebind of TAB to insert-tab */
+     rl_bind_key('\t', rl_insert);
++
++    /* Explicitly use dumb as default terminal to avoid probably
++     * escape sequence output. The dumb is used to label tty lines
++     * when you don't know what kind of terminal is on it. The
++     * characteristics of an unknown terminal are the lowest common
++     * denominator.
++     */
++    rl_terminal_name = "dumb";
+     /* Bind both ESC-TAB and ESC-ESC to the completion function */
+     rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
+     rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
+-- 
+1.8.1.2
+
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] python: fix importing readline with probably escape sequence output
  2013-07-18 10:55 ` [PATCH 1/1] " Hongxu Jia
@ 2013-07-18 16:36   ` Saul Wold
  0 siblings, 0 replies; 3+ messages in thread
From: Saul Wold @ 2013-07-18 16:36 UTC (permalink / raw)
  To: Hongxu Jia; +Cc: openembedded-core

On 07/18/2013 03:55 AM, Hongxu Jia wrote:
> While imports readline in python, if the term in terminfo is available and
> it contains the variable 'km' and 'smm', the readline initialization will
> output the value of 'smm' which is the escape sequence '\E[?1034h'.
>
> 'km' means the terminal has a meta key which is a special key on MIT keyboards,
> 'smm' means turn on the meta key if this terminal has one. They don't exist in
> term 'dumb'.
>
> Explicitly use dumb as default terminal to avoid probably escape sequence
> output. The dumb is used to label tty lines when you don't know what kind
> of terminal is on it. The characteristics of an unknown terminal are the
> lowest common denominator.
>
> [YOCTO #4835]
> [YOCTO #4732]
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>   meta/recipes-devtools/python/python.inc            |  4 ++-
>   ...e-explicitly-use-dumb-as-default-terminal.patch | 35 ++++++++++++++++++++++
>   2 files changed, 38 insertions(+), 1 deletion(-)
>   create mode 100644 meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch
>
> diff --git a/meta/recipes-devtools/python/python.inc b/meta/recipes-devtools/python/python.inc
> index 80609a8..2fc894d 100644
> --- a/meta/recipes-devtools/python/python.inc
> +++ b/meta/recipes-devtools/python/python.inc
> @@ -7,7 +7,9 @@ INC_PR = "r0"
>
>   LIC_FILES_CHKSUM = "file://LICENSE;md5=ed3abfd1059e2d3a36a8cff3986f9bb6"
>
> -SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.bz2"
> +SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.bz2 \
> +           file://readline-explicitly-use-dumb-as-default-terminal.patch \
> +"
>
>   SRC_URI[md5sum] = "c57477edd6d18bd9eeca2f21add73919"
>   SRC_URI[sha256sum] = "726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c"
> diff --git a/meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch b/meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch
> new file mode 100644
> index 0000000..11928d1
> --- /dev/null
> +++ b/meta/recipes-devtools/python/python/readline-explicitly-use-dumb-as-default-terminal.patch
> @@ -0,0 +1,35 @@
> +readline: explicitly use dumb as default terminal
> +
> +Explicitly use dumb as default terminal to avoid probably
> +escape sequence output. The dumb is used to label tty lines
> +when you don't know what kind of terminal is on it. The
> +characteristics of an unknown terminal are the lowest common
> +denominator.
> +
> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> +Upstream-Status: inappropriate [oe specific]
> +---
> + Modules/readline.c | 8 ++++++++
> + 1 file changed, 8 insertions(+)
> +
> +diff --git a/Modules/readline.c b/Modules/readline.c
> +--- a/Modules/readline.c
> ++++ b/Modules/readline.c
> +@@ -882,6 +882,14 @@ setup_readline(void)
> + #endif
> +     /* Force rebind of TAB to insert-tab */
> +     rl_bind_key('\t', rl_insert);
> ++
> ++    /* Explicitly use dumb as default terminal to avoid probably
> ++     * escape sequence output. The dumb is used to label tty lines
> ++     * when you don't know what kind of terminal is on it. The
> ++     * characteristics of an unknown terminal are the lowest common
> ++     * denominator.
> ++     */
> ++    rl_terminal_name = "dumb";
I don't think this will work, since it will force all terminal 
interactions that use python to be dumb, how will the bitbake knotty 
interface behave with dumb terminal.

Sau!

> +     /* Bind both ESC-TAB and ESC-ESC to the completion function */
> +     rl_bind_key_in_map ('\t', rl_complete, emacs_meta_keymap);
> +     rl_bind_key_in_map ('\033', rl_complete, emacs_meta_keymap);
> +--
> +1.8.1.2
> +
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-07-18 16:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-18 10:54 [PATCH 0/1] python: fix importing readline with probably escape sequence output Hongxu Jia
2013-07-18 10:55 ` [PATCH 1/1] " Hongxu Jia
2013-07-18 16:36   ` Saul Wold

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.