From 5f42da36f3632782c71746c477f2eaa1c3602c60 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 6 Feb 2025 16:41:36 +0000 Subject: [PATCH 1/2] mitogen: Deduplicate cfmakeraw() flags refs #1121 --- mitogen/parent.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mitogen/parent.py b/mitogen/parent.py index f301a42c..3c5e48ba 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -234,12 +234,9 @@ def cfmakeraw(tflags): modified in a manner similar to the `cfmakeraw()` C library function, but additionally disabling local echo. """ - # BSD: github.com/freebsd/freebsd/blob/master/lib/libc/gen/termios.c#L162 - # Linux: github.com/lattera/glibc/blob/master/termios/cfmakeraw.c#L20 iflag, oflag, cflag, lflag, ispeed, ospeed, cc = tflags iflag &= ~flags('IMAXBEL IXOFF INPCK BRKINT PARMRK ' - 'ISTRIP INLCR ICRNL IXON IGNPAR') - iflag &= ~flags('IGNBRK BRKINT PARMRK') + 'ISTRIP INLCR ICRNL IXON IGNPAR IGNBRK') oflag &= ~flags('OPOST') lflag &= ~flags('ECHO ECHOE ECHOK ECHONL ICANON ISIG ' 'IEXTEN NOFLSH TOSTOP PENDIN') From 927fb172d8eb2af5d0635d9e4099b471309432c1 Mon Sep 17 00:00:00 2001 From: Alex Willmer Date: Thu, 6 Feb 2025 16:45:59 +0000 Subject: [PATCH 2/2] mitogen: Log skipped termios attributes refs #1121 --- docs/changelog.rst | 1 + mitogen/parent.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index dfbf1643..92cd8966 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -21,6 +21,7 @@ To avail of fixes in an unreleased version, please download a ZIP file In progress (unreleased) ------------------------ +* :gh:issue:`1121` :mod:`mitogen`: Log skipped :py:mod:`termios` attributes v0.3.22 (2025-02-04) diff --git a/mitogen/parent.py b/mitogen/parent.py index 3c5e48ba..5b397d9f 100644 --- a/mitogen/parent.py +++ b/mitogen/parent.py @@ -224,8 +224,16 @@ def flags(names): Return the result of ORing a set of (space separated) :py:mod:`termios` module constants together. """ - return sum(getattr(termios, name, 0) - for name in names.split()) + i = 0 + skipped = [] + for name in names.split(): + try: + i |= getattr(termios, name) + except AttributeError: + skipped.append(name) + if skipped: + LOG.debug('Skipped termios attributes: %s', ', '.join(skipped)) + return i def cfmakeraw(tflags):