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

Change from V2: Backport to gnu readline library 6.2 rather than modify
                python to fix this issue.

//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-readlne
  http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-python-readlne

Hongxu Jia (2):
  readline: fix importing readline in python with probably escape
    sequence output
  python-native: remove unused and duplicated sitecustomize.py

 ...ly-enable-meta-key-for-a-single-call-read.patch | 114 +++++++++++++++++++++
 meta/recipes-core/readline/readline_6.2.bb         |   1 +
 .../python/python-native/sitecustomize.py          |  45 --------
 3 files changed, 115 insertions(+), 45 deletions(-)
 create mode 100644 meta/recipes-core/readline/readline-6.2/readline-only-enable-meta-key-for-a-single-call-read.patch
 delete mode 100644 meta/recipes-devtools/python/python-native/sitecustomize.py

-- 
1.8.1.2



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

* [PATCH 1/2] readline: fix importing readline in python with probably escape sequence output
  2013-07-22  9:43 [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
@ 2013-07-22  9:43 ` Hongxu Jia
  2013-07-22  9:43 ` [PATCH 2/2] python-native: remove unused and duplicated sitecustomize.py Hongxu Jia
  2013-07-23 11:25 ` [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
  2 siblings, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2013-07-22  9:43 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'.

The issue is caused by gnu readline library which is used by python
readline module. The bash-4.3/readline-6.3 has fixed this but it is still
on test and not released, so we find the changes and back port to 6.2.

Import patch from: http://git.savannah.gnu.org/cgit/bash.git/tag/?id=bash-4.3-alpha

[YOCTO #4835]
[YOCTO #4732]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 ...ly-enable-meta-key-for-a-single-call-read.patch | 114 +++++++++++++++++++++
 meta/recipes-core/readline/readline_6.2.bb         |   1 +
 2 files changed, 115 insertions(+)
 create mode 100644 meta/recipes-core/readline/readline-6.2/readline-only-enable-meta-key-for-a-single-call-read.patch

diff --git a/meta/recipes-core/readline/readline-6.2/readline-only-enable-meta-key-for-a-single-call-read.patch b/meta/recipes-core/readline/readline-6.2/readline-only-enable-meta-key-for-a-single-call-read.patch
new file mode 100644
index 0000000..ccfdb9f
--- /dev/null
+++ b/meta/recipes-core/readline/readline-6.2/readline-only-enable-meta-key-for-a-single-call-read.patch
@@ -0,0 +1,114 @@
+readline: only enable meta key for a single call readline().
+
+terminal.c
+  - change _rl_enable_meta_key to set a flag indicating that it sent the
+    enable-meta sequence
+  - _rl_disable_meta_key: new function to turn off meta mode after we
+    turned it on with _rl_enable_meta_key
+
+rlprivate.h
+  - extern declaration for _rl_disable_meta_key
+
+readline.c
+- _rl_internal_teardown: add call to _rl_disable_meta_key to make the
+  meta key active only for the duration of the call to readline()
+- _rl_internal_setup: move call to _rl_enable_meta_key here from
+  readline_initialize_everything so the meta key is active only for
+  the duration of the call to readline().  Suggestion from Miroslav
+  Lichvar <mlichvar@redhat.com>
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+Upstream-Status: backport
+Imported patch from: http://git.savannah.gnu.org/cgit/bash.git/tag/?id=bash-4.3-alpha
+---
+ readline.c  | 12 ++++++++----
+ rlprivate.h |  1 +
+ terminal.c  | 19 ++++++++++++++++++-
+ 3 files changed, 27 insertions(+), 5 deletions(-)
+
+diff --git a/readline.c b/readline.c
+--- a/readline.c
++++ b/readline.c
+@@ -369,6 +369,11 @@ readline_internal_setup ()
+   _rl_in_stream = rl_instream;
+   _rl_out_stream = rl_outstream;
+ 
++  /* Enable the meta key only for the duration of readline(), if this
++     terminal has one. */
++  if (_rl_enable_meta)
++    _rl_enable_meta_key ();
++
+   if (rl_startup_hook)
+     (*rl_startup_hook) ();
+ 
+@@ -437,6 +442,9 @@ readline_internal_teardown (eof)
+   if (rl_undo_list)
+     rl_free_undo_list ();
+ 
++  /* Disable the meta key, if this terminal has one. */
++  _rl_disable_meta_key ();
++
+   /* Restore normal cursor, if available. */
+   _rl_set_insert_mode (RL_IM_INSERT, 0);
+ 
+@@ -1091,10 +1099,6 @@ readline_initialize_everything ()
+   /* Try to bind a common arrow key prefix, if not already bound. */
+   bind_arrow_keys ();
+ 
+-  /* Enable the meta key, if this terminal has one. */
+-  if (_rl_enable_meta)
+-    _rl_enable_meta_key ();
+-
+   /* If the completion parser's default word break characters haven't
+      been set yet, then do so now. */
+   if (rl_completer_word_break_characters == (char *)NULL)
+diff --git a/rlprivate.h b/rlprivate.h
+index 384ff67..be2c2c6 100644
+--- a/rlprivate.h
++++ b/rlprivate.h
+@@ -339,6 +339,7 @@ extern int _rl_output_character_function PARAMS((int));
+ extern void _rl_output_some_chars PARAMS((const char *, int));
+ extern int _rl_backspace PARAMS((int));
+ extern void _rl_enable_meta_key PARAMS((void));
++extern void _rl_disable_meta_key PARAMS((void));
+ extern void _rl_control_keypad PARAMS((int));
+ extern void _rl_set_cursor PARAMS((int, int));
+ 
+diff --git a/terminal.c b/terminal.c
+index f8c2f6e..21ee031 100644
+--- a/terminal.c
++++ b/terminal.c
+@@ -683,12 +683,29 @@ rl_ding ()
+ /*								    */
+ /* **************************************************************** */
+ 
++static int enabled_meta = 0;   /* flag indicating we enabled meta mode */
++
+ void
+ _rl_enable_meta_key ()
+ {
+ #if !defined (__DJGPP__)
+   if (term_has_meta && _rl_term_mm)
+-    tputs (_rl_term_mm, 1, _rl_output_character_function);
++    {
++      tputs (_rl_term_mm, 1, _rl_output_character_function);
++      enabled_meta = 1;
++    }
++#endif
++}
++
++void
++_rl_disable_meta_key ()
++{
++#if !defined (__DJGPP__)
++  if (term_has_meta && _rl_term_mo && enabled_meta)
++    {
++      tputs (_rl_term_mo, 1, _rl_output_character_function);
++      enabled_meta = 0;
++    }
+ #endif
+ }
+ 
+-- 
+1.8.1.2
+
diff --git a/meta/recipes-core/readline/readline_6.2.bb b/meta/recipes-core/readline/readline_6.2.bb
index 45fa4e7..87636da 100644
--- a/meta/recipes-core/readline/readline_6.2.bb
+++ b/meta/recipes-core/readline/readline_6.2.bb
@@ -6,6 +6,7 @@ SRC_URI += "${GNU_MIRROR}/readline/readline-6.2-patches/readline62-001;name=patc
 ${GNU_MIRROR}/readline/readline-6.2-patches/readline62-002;name=patch2;apply=yes;striplevel=0 \
 ${GNU_MIRROR}/readline/readline-6.2-patches/readline62-003;name=patch3;apply=yes;striplevel=0 \
 ${GNU_MIRROR}/readline/readline-6.2-patches/readline62-004;name=patch4;apply=yes;striplevel=0 \
+file://readline-only-enable-meta-key-for-a-single-call-read.patch \
 "
 
 SRC_URI[archive.md5sum] = "67948acb2ca081f23359d0256e9a271c"
-- 
1.8.1.2



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

* [PATCH 2/2] python-native: remove unused and duplicated sitecustomize.py
  2013-07-22  9:43 [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
  2013-07-22  9:43 ` [PATCH 1/2] " Hongxu Jia
@ 2013-07-22  9:43 ` Hongxu Jia
  2013-07-23 11:25 ` [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
  2 siblings, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2013-07-22  9:43 UTC (permalink / raw)
  To: openembedded-core

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

[YOCTO #4889]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 .../python/python-native/sitecustomize.py          | 45 ----------------------
 1 file changed, 45 deletions(-)
 delete mode 100644 meta/recipes-devtools/python/python-native/sitecustomize.py

diff --git a/meta/recipes-devtools/python/python-native/sitecustomize.py b/meta/recipes-devtools/python/python-native/sitecustomize.py
deleted file mode 100644
index 2739018..0000000
--- a/meta/recipes-devtools/python/python-native/sitecustomize.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
-# 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()
-- 
1.8.1.2



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

* Re: [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output
  2013-07-22  9:43 [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
  2013-07-22  9:43 ` [PATCH 1/2] " Hongxu Jia
  2013-07-22  9:43 ` [PATCH 2/2] python-native: remove unused and duplicated sitecustomize.py Hongxu Jia
@ 2013-07-23 11:25 ` Hongxu Jia
  2 siblings, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2013-07-23 11:25 UTC (permalink / raw)
  To: openembedded-core

On 07/22/2013 05:43 PM, Hongxu Jia wrote:
> Change from V2: Backport to gnu readline library 6.2 rather than modify
>                  python to fix this issue.
>
> //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-readlne
>    http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-python-readlne
Fix typo:
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=hongxu/fix-readlne

//Hongxu
> Hongxu Jia (2):
>    readline: fix importing readline in python with probably escape
>      sequence output
>    python-native: remove unused and duplicated sitecustomize.py
>
>   ...ly-enable-meta-key-for-a-single-call-read.patch | 114 +++++++++++++++++++++
>   meta/recipes-core/readline/readline_6.2.bb         |   1 +
>   .../python/python-native/sitecustomize.py          |  45 --------
>   3 files changed, 115 insertions(+), 45 deletions(-)
>   create mode 100644 meta/recipes-core/readline/readline-6.2/readline-only-enable-meta-key-for-a-single-call-read.patch
>   delete mode 100644 meta/recipes-devtools/python/python-native/sitecustomize.py
>



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

* [PATCH 2/2] python-native: remove unused and duplicated sitecustomize.py
  2013-07-19  9:13 [PATCH V2 0/2] python: fix importing readline " Hongxu Jia
@ 2013-07-19  9:13 ` Hongxu Jia
  0 siblings, 0 replies; 5+ messages in thread
From: Hongxu Jia @ 2013-07-19  9:13 UTC (permalink / raw)
  To: openembedded-core

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

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 .../python/python-native/sitecustomize.py          | 45 ----------------------
 1 file changed, 45 deletions(-)
 delete mode 100644 meta/recipes-devtools/python/python-native/sitecustomize.py

diff --git a/meta/recipes-devtools/python/python-native/sitecustomize.py b/meta/recipes-devtools/python/python-native/sitecustomize.py
deleted file mode 100644
index 2739018..0000000
--- a/meta/recipes-devtools/python/python-native/sitecustomize.py
+++ /dev/null
@@ -1,45 +0,0 @@
-# OpenEmbedded sitecustomize.py (C) 2002-2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
-# 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()
-- 
1.8.1.2



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

end of thread, other threads:[~2013-07-23 11:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-22  9:43 [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
2013-07-22  9:43 ` [PATCH 1/2] " Hongxu Jia
2013-07-22  9:43 ` [PATCH 2/2] python-native: remove unused and duplicated sitecustomize.py Hongxu Jia
2013-07-23 11:25 ` [PATCH V3 0/2] readline: fix importing readline in python with probably escape sequence output Hongxu Jia
  -- strict thread matches above, loose matches on Subject: below --
2013-07-19  9:13 [PATCH V2 0/2] python: fix importing readline " Hongxu Jia
2013-07-19  9:13 ` [PATCH 2/2] python-native: remove unused and duplicated sitecustomize.py Hongxu Jia

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.