Skip to contentSkip to conversation

python: fix importing readline with probably escape sequence output

PATCH Superseded Hongxu Jia 2 participants 6 messages Jul 19, 2013 – Jul 22, 2013

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Hongxu Jia

author
#0 lore raw

v2 cover python: fix importing readline with probably escape sequence output

Change from V1: explicitly set meta key off rather than hardcore the terminal to 'dumb'.

Also remove the duplicated sitecustomize.py in python-native.

//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 (2):
python: fix importing readline with probably escape sequence output
python-native: remove unused and duplicated sitecustomize.py

 .../python/python-native/sitecustomize.py          | 45 ----------------------
 meta/recipes-devtools/python/python.inc            |  4 +-
 ...-to-avoid-probable-escape-sequence-output.patch | 43 +++++++++++++++++++++
 3 files changed, 46 insertions(+), 46 deletions(-)
 delete mode 100644 meta/recipes-devtools/python/python-native/sitecustomize.py
 create mode 100644 meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch
Signature · 1 line
1.8.1.2
author
#1 lore raw

PATCH v2 1/2 python: fix importing readline with probably escape sequence output

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 such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked as a solid diamond. It almost doesn't exist in our keyboard, so it has no side effect to disable it.
'smm' means turn on the meta key if this terminal has one.

Explicitly set meta key off to avoid probable escape sequence output while gnu readline library initialization.

[YOCTO #4835]
[YOCTO #4732]

---
 meta/recipes-devtools/python/python.inc            |  4 +-
 ...-to-avoid-probable-escape-sequence-output.patch | 43 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch
meta/recipes-devtools/python/python.inc +3 -1
index 80609a8..9f787c9 100644
@@ -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-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch \
+"
  
 SRC_URI[md5sum] = "c57477edd6d18bd9eeca2f21add73919"
 SRC_URI[sha256sum] = "726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c"
meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
1.8.1.2
#2 lore raw
Quoted 4 lines · Hongxu Jia

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'.

Quoted 9 lines

'km' means the terminal has a meta key which is a special key on MIT keyboards such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked as a solid diamond. It almost doesn't exist in our keyboard, so it has no side effect to disable it.
'smm' means turn on the meta key if this terminal has one.

Explicitly set meta key off to avoid probable escape sequence output while gnu readline library initialization.

I am still not sure about this change, there was some discussion that the readline library would do be making a similar change and we should back port that change. I contacted the readline maintainer to find out about that.

I am going to hold off until I hear from him.

Sau!

Quoted 75 lines

[YOCTO #4835]
[YOCTO #4732]

---
  meta/recipes-devtools/python/python.inc            |  4 +-
  ...-to-avoid-probable-escape-sequence-output.patch | 43 ++++++++++++++++++++++
  2 files changed, 46 insertions(+), 1 deletion(-)

create mode 100644 meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

meta/recipes-devtools/python/python.inc +3 -1
index 80609a8..9f787c9 100644
@@ -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-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch \
+"
 
  SRC_URI[md5sum] = "c57477edd6d18bd9eeca2f21add73919"
  SRC_URI[sha256sum] = "726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c"
meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch new file +43 -0
new file mode 100644
index 0000000..104fc36
@@ -0,0 +1,43 @@
+readline:explicitly set meta key off to avoid probable escape sequence output
+
+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
+such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked
+as a solid diamond. It almost doesn't exist in our keyboard, so it has no side
+effect to disable it.
+'smm' means turn on the meta key if this terminal has one.
+
+Explicitly set meta key off to avoid probable escape sequence output
+while gnu readline library initialization.
+
+Signed-off-by: Hongxu Jia <[email protected]>
+Upstream-Status: inappropriate [oe specific]
+---
+ Modules/readline.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/Modules/readline.c b/Modules/readline.c
+--- a/Modules/readline.c
++++ b/Modules/readline.c
+@@ -909,6 +909,15 @@ setup_readline(void)
+ 	rl_read_init_file(NULL);
+     else
+ #endif /* __APPLE__ */
++
++    /* Explicitly set meta key off to avoid probable escape sequence output
++     * while gnu readline library initialization. The meta key is a special
++     * key in MIT keyboards such as the space-cadet keyboard, and on Sun
++     * Microsystems keyboards, marked as a solid diamond. It almost doesn't
++     * exist in our keyboards, so it has no side effect to disable it.
++     */
++    rl_variable_bind("enable-meta-key", "off");
++
+         rl_initialize();
+
+     RESTORE_LOCALE(saved_locale)
+--
+1.8.1.2
+
#3 lore raw
Quoted 17 lines · Saul Wold
Quoted 13 lines · Hongxu Jia

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
such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked
as a solid diamond. It almost doesn't exist in our keyboard, so it has no side
effect to disable it.
'smm' means turn on the meta key if this terminal has one.

Quoted 3 lines

Explicitly set meta key off to avoid probable escape sequence output while gnu readline library initialization.

Quoted 7 lines

I am still not sure about this change, there was some discussion that the readline library would do be making a similar change and we should back port that change. I contacted the readline maintainer to find out about that.

I am going to hold off until I hear from him.

Hongxu, please look at the "Bash" Git for readline library and see if you can find the changes that Chet made to back port.

http://git.savannah.gnu.org/cgit/bash.git/?h=devel

Thanks

Quoted 105 lines

Sau!

Quoted 91 lines

[YOCTO #4835]
[YOCTO #4732]

---
  meta/recipes-devtools/python/python.inc            |  4 +-
  ...-to-avoid-probable-escape-sequence-output.patch | 43
++++++++++++++++++++++
  2 files changed, 46 insertions(+), 1 deletion(-)

create mode 100644
meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

meta/recipes-devtools/python/python.inc +0 -0
index 80609a8..9f787c9 100644
@@ -7,7 +7,9 @@ INC_PR = "r0"
 
  LIC_FILES_CHKSUM =

"file://LICENSE;md5=ed3abfd1059e2d3a36a8cff3986f9bb6"

meta/recipes-devtools/python/python.inc +2 -1
-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-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch \
+"

SRC_URI[md5sum] = "c57477edd6d18bd9eeca2f21add73919"
SRC_URI[sha256sum] =
"726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c"
diff --git a/meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch b/meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

new file mode 100644
index 0000000..104fc36
--- /dev/null
+++
b/meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

meta/recipes-devtools/python/python.inc +1 -0
@@ -0,0 +1,43 @@
+readline:explicitly set meta key off to avoid probable escape

sequence output

meta/recipes-devtools/python/python.inc +3 -0
+
+While imports readline in python, if TERM in terminfo is available and
+it contains the variable 'km' and 'smm', the readline initialization

will

meta/recipes-devtools/python/python.inc +3 -0
+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
+such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked
+as a solid diamond. It almost doesn't exist in our keyboard, so it has no side

meta/recipes-devtools/python/python.inc +21 -0
+effect to disable it.
+'smm' means turn on the meta key if this terminal has one.
+
+Explicitly set meta key off to avoid probable escape sequence output
+while gnu readline library initialization.
+
+Signed-off-by: Hongxu Jia <[email protected]>
+Upstream-Status: inappropriate [oe specific]
+---
+ Modules/readline.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/Modules/readline.c b/Modules/readline.c
+--- a/Modules/readline.c
++++ b/Modules/readline.c
+@@ -909,6 +909,15 @@ setup_readline(void)
+     rl_read_init_file(NULL);
+     else
+ #endif /* __APPLE__ */
++
++    /* Explicitly set meta key off to avoid probable escape sequence

output
++ * while gnu readline library initialization. The meta key is a
special
++ * key in MIT keyboards such as the space-cadet keyboard, and on
Sun
++ * Microsystems keyboards, marked as a solid diamond. It almost
doesn't
++ * exist in our keyboards, so it has no side effect to disable it.
++ */
++ rl_variable_bind("enable-meta-key", "off");
++

meta/recipes-devtools/python/python.inc

Quoted 6 lines
meta/recipes-devtools/python/python.inc +6 -0
+         rl_initialize();
+
+     RESTORE_LOCALE(saved_locale)
+--
+1.8.1.2
+

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#4 lore raw
Quoted 23 lines · Saul Wold
Quoted 22 lines · Saul Wold
Quoted 13 lines · Hongxu Jia

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
such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked
as a solid diamond. It almost doesn't exist in our keyboard, so it has no side
effect to disable it.
'smm' means turn on the meta key if this terminal has one.

Quoted 3 lines

Explicitly set meta key off to avoid probable escape sequence output while gnu readline library initialization.

I am still not sure about this change, there was some discussion that the readline library would do be making a similar change and we should back port that change. I contacted the readline maintainer to find out about that.

Quoted 7 lines
Quoted 2 lines

I am going to hold off until I hear from him.

Hongxu, please look at the "Bash" Git for readline library and see if you can find the changes that Chet made to back port.

http://git.savannah.gnu.org/cgit/bash.git/?h=devel

Got it.

//Hongxu

Quoted 114 lines

Thanks

Quoted 113 lines

Sau!

Quoted 99 lines

[YOCTO #4835]
[YOCTO #4732]

---
  meta/recipes-devtools/python/python.inc            |  4 +-
  ...-to-avoid-probable-escape-sequence-output.patch | 43
++++++++++++++++++++++
  2 files changed, 46 insertions(+), 1 deletion(-)

create mode 100644
meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

meta/recipes-devtools/python/python.inc +0 -0
index 80609a8..9f787c9 100644
@@ -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-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

\
+"

SRC_URI[md5sum] = "c57477edd6d18bd9eeca2f21add73919"
SRC_URI[sha256sum] =
"726457e11cb153adc3f428aaf1901fc561a374c30e5e7da6742c0742a338663c"
diff --git a/meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

b/meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

new file mode 100644
index 0000000..104fc36
--- /dev/null
+++
b/meta/recipes-devtools/python/python/readline-set-meta-key-off-to-avoid-probable-escape-sequence-output.patch

meta/recipes-devtools/python/python.inc +1 -0
@@ -0,0 +1,43 @@
+readline:explicitly set meta key off to avoid probable escape

sequence output

meta/recipes-devtools/python/python.inc +3 -0
+
+While imports readline in python, if TERM in terminfo is available and
+it contains the variable 'km' and 'smm', the readline initialization

will

meta/recipes-devtools/python/python.inc +3 -0
+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
+such as the space-cadet keyboard, and on Sun Microsystems keyboards, marked
+as a solid diamond. It almost doesn't exist in our keyboard, so it has no side

meta/recipes-devtools/python/python.inc +21 -0
+effect to disable it.
+'smm' means turn on the meta key if this terminal has one.
+
+Explicitly set meta key off to avoid probable escape sequence output
+while gnu readline library initialization.
+
+Signed-off-by: Hongxu Jia <[email protected]>
+Upstream-Status: inappropriate [oe specific]
+---
+ Modules/readline.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/Modules/readline.c b/Modules/readline.c
+--- a/Modules/readline.c
++++ b/Modules/readline.c
+@@ -909,6 +909,15 @@ setup_readline(void)
+     rl_read_init_file(NULL);
+     else
+ #endif /* __APPLE__ */
++
++    /* Explicitly set meta key off to avoid probable escape sequence

output
++ * while gnu readline library initialization. The meta key is a
special
++ * key in MIT keyboards such as the space-cadet keyboard, and on
Sun
++ * Microsystems keyboards, marked as a solid diamond. It almost
doesn't
++ * exist in our keyboards, so it has no side effect to disable
it.
++ */
++ rl_variable_bind("enable-meta-key", "off");
++

meta/recipes-devtools/python/python.inc

Quoted 6 lines
meta/recipes-devtools/python/python.inc +6 -0
+         rl_initialize();
+
+     RESTORE_LOCALE(saved_locale)
+--
+1.8.1.2
+

_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

author
#5 lore raw

PATCH v2 2/2 python-native: remove unused and duplicated sitecustomize.py

In reply to Hongxu Jia

python-native doesn't use sitecustomize.py and there is another duplicated one in meta/recipes-devtools/python/python.

---
 .../python/python-native/sitecustomize.py          | 45 ----------------------
 1 file changed, 45 deletions(-)
 delete mode 100644 meta/recipes-devtools/python/python-native/sitecustomize.py
meta/recipes-devtools/python/python-native/sitecustomize.py deleted +0 -45
deleted file mode 100644
index 2739018..0000000
@@ -1,45 +0,0 @@
-# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <[email protected]>
-# GPLv2 or later
-# Version: 20081123
-# Features:
-# * set proper default encoding
-# * enable readline completion in the interactive interpreter
-# * load command line history on startup
-# * save command line history on exit 
-
-import os
-
-def __exithandler():
-    try:
-        readline.write_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
-    except IOError:
-        pass
-
-def __registerExitHandler():
-    import atexit
-    atexit.register( __exithandler )
-
-def __enableReadlineSupport():
-    readline.set_history_length( 1000 )
-    readline.parse_and_bind( "tab: complete" )
-    try:
-        readline.read_history_file( "%s/.python-history" % os.getenv( "HOME", "/tmp" ) )
-    except IOError:
-        pass
-
-def __enableDefaultEncoding():
-    import sys
-    try:
-        sys.setdefaultencoding( "utf8" )
-    except LookupError:
-        pass
-
-import sys
-try:
-    import rlcompleter, readline
-except ImportError:
-    pass
-else:
-    __enableDefaultEncoding()
-    __registerExitHandler()
-    __enableReadlineSupport()
Signature · 1 line
1.8.1.2