FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-110392: Fix tty functions by serhiy-storchaka · Pull Request #110642 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
8 changes: 6 additions & 2 deletions Lib/test/test_tty.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def test_cfmakecbreak(self):
self.assertEqual(mode[5], self.mode[5])

def test_setraw(self):
mode = tty.setraw(self.fd)
mode0 = termios.tcgetattr(self.fd)
mode1 = tty.setraw(self.fd)
self.assertEqual(mode1, mode0)
mode2 = termios.tcgetattr(self.fd)
self.check_raw(mode2)
mode3 = tty.setraw(self.fd, termios.TCSANOW)
Expand All @@ -67,7 +69,9 @@ def test_setraw(self):
tty.setraw(fd=self.fd, when=termios.TCSANOW)

def test_setcbreak(self):
mode = tty.setcbreak(self.fd)
mode0 = termios.tcgetattr(self.fd)
mode1 = tty.setcbreak(self.fd)
self.assertEqual(mode1, mode0)
mode2 = termios.tcgetattr(self.fd)
self.check_cbreak(mode2)
mode3 = tty.setcbreak(self.fd, termios.TCSANOW)
Expand Down
2 changes: 2 additions & 0 deletions Lib/tty.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def cfmakeraw(mode):
# Case B: MIN>0, TIME=0
# A pending read shall block until MIN (here 1) bytes are received,
# or a signal is received.
mode[CC] = list(mode[CC])
mode[CC][VMIN] = 1
mode[CC][VTIME] = 0

Expand All @@ -54,6 +55,7 @@ def cfmakecbreak(mode):
# Case B: MIN>0, TIME=0
# A pending read shall block until MIN (here 1) bytes are received,
# or a signal is received.
mode[CC] = list(mode[CC])
mode[CC][VMIN] = 1
mode[CC][VTIME] = 0

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix :func:`tty.setraw` and :func:`tty.setcbreak`: previously they returned
partially modified list of the original tty attributes.
:func:`tty.cfmakeraw` and :func:`tty.cfmakecbreak` now make a copy of the
list of special characters before modifying it.

Back | FazBrowse Home | New Git URL