python shell silently ignores termios.tcsetattr()

Nobody nobody at nowhere.com
Thu Oct 21 17:56:54 EDT 2010


On Wed, 20 Oct 2010 16:18:57 +0000, kj wrote:

> I tried to fix the problem by applying the equivalent of "stty -echo"
> within a python interactive session, but discovered that this setting is
> immediately (and silently) overwritten.

FWIW, I don't see this behaviour with Python 2.6.5 on Linux. If I change
the tty settings from within an interactive Python session, they stay
changed. The only reference to tcsetattr() I can find in the Python source
code is in the termios module.

I suspect that it may be related to the "readline" module. My Python is
built with readline support (I normally use XEmacs' comint-based modes
rather than e.g. xterm, and readline either doesn't help or gets in the
way). Also, the implementation of the readline module is platform-specific:

	<http://docs.python.org/library/readline.html>

	The readline  module defines a number of functions to facilitate
	completion and reading/writing of history files from the Python
	interpreter. This module can be used directly or via the rlcompleter
	module. Settings made using this module affect the behaviour of both the
	interpreter's interactive prompt and the prompts offered by the
	raw_input()  and input() built-in functions. 

	Note: On MacOS X the readline module can be implemented using the libedit
	library instead of GNU readline. 




More information about the Python-list mailing list