This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author John.Malmberg
Recipients John.Malmberg, vstinner
Date 2014-08-31.14:14:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1409494474.0.0.474130075046.issue22310@psf.upfronthosting.co.za>
In-reply-to
Content
The existing Python text is uppercase D for Ctrl-D, so I maintained it.
stty documentation also uses upper case for control characters.

The EOF character can be viewed or set via the stty utility or the tcsetattr() or equivalent routine.  Some platforms may not allow setting specific control characters.

user@solar:~$ stty susp ^D eof ^Z
user@solar:~$ stty
speed 38400 baud; line = 0;
eof = ^Z; susp = ^D;
-brkint -imaxbel

Changing the characters can be a matter of personal choice or could be an issue where something in the communications path is intercepting a control character, or the underlying platform may have different characters.

Note that Linux has erase=^? and most commercial Unix has erase=^H.

The constant 64 is from (ord('A') - 1).

The termios.tcgetattr(sys.stdin)[6][termios.VEOF] returns the byte for the current EOF character.

From the samme session above where I swapped susp and eof

>>> print("Ctrl-%s" % chr(ord(termios.tcgetattr(sys.stdin[6[termios.VEOF]) + 64))
Ctrl-Z

I was unable to find a symbolic constant for the array element[6] which has contains that control characters.  Existing code found on the web just used [6], which can be derived from looking at documentation for the C library tcgetattr.

An alternative would be always to to try termios.tcgetattr() before and only fall back to the default EOF character for a platform if that does not work.
History
Date User Action Args
2014-08-31 14:14:34John.Malmbergsetrecipients: + John.Malmberg, vstinner
2014-08-31 14:14:34John.Malmbergsetmessageid: <1409494474.0.0.474130075046.issue22310@psf.upfronthosting.co.za>
2014-08-31 14:14:33John.Malmberglinkissue22310 messages
2014-08-31 14:14:33John.Malmbergcreate