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.

classification
Title: CTRL-Y, yank, behaves as CTRL-Z with curses on OS X
Type: behavior Stage: resolved
Components: Extension Modules, Library (Lib), macOS Versions: Python 2.7, Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: agiz, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2012-12-24 15:50 by agiz, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg178065 - (view) Author: Ziga (agiz) Date: 2012-12-24 15:50
`getch()` interprets CTRL-Y as CTRL-Z on OS X 10.7.3.
Tested with python 2.5, 2.6, 2.7 32-bit and 64-bit.

How to recreate behavior:
>>> import curses
>>> stdscr = curses.initscr()
# CTRL-Y works as expected until now.

>>> stdscr.getch()
# press <CTRL+Y>
$ [1]  + 407 suspended  python
msg178069 - (view) Author: Ziga (agiz) Date: 2012-12-24 16:15
Same behavior with:

>>> import sys
>>> sys.stdin.read(1)
# press <CTRL+Y>
[1]  + 1024 suspended  python
msg178112 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2012-12-25 06:11
What you are seeing is platform-specific behavior, a difference between BSD-based systems including OS X and other systems including Linux.  The difference is that the former systems support the DSUSP (suspend on reading input) terminal character in addition to the normal SUSP (suspend immediately) terminal character.  The default value for DSUSP is CTRL-Y which you can see in the output of stty(1):

$ stty -a
[..]
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
	eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V;
	min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
	stop = ^S; susp = ^Z; time = 0; werase = ^W;

You should see the same CTRL-Y suspend behavior with other utilities reading from standard input, like cat(1), unless they handle that signal.  You can modify the behavior of CTRL-Y by disabling the DSUSP character, for example:

$ stty dsusp undef

See the OS X stty(1) man page and other references like:
http://www.gnu.org/software/libc/manual/html_node/Signal-Characters.html
History
Date User Action Args
2022-04-11 14:57:39adminsetgithub: 60972
2012-12-25 06:11:38ned.deilysetstatus: open -> closed

nosy: + ned.deily
messages: + msg178112

resolution: not a bug
stage: resolved
2012-12-24 16:15:12agizsetmessages: + msg178069
2012-12-24 15:50:46agizcreate