dev-python/pyserial: fix glibc-2.42 compat

Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Sam James
2025-12-24 16:30:50 +00:00
parent 9d948f7664
commit 446498c7cc
2 changed files with 81 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
https://github.com/pyserial/pyserial/issues/805
https://github.com/pyserial/pyserial/pull/808
From 152f2639c630141b9d23f023178b619751e624a0 Mon Sep 17 00:00:00 2001
From: Alexander von Gluck IV <alex@terarocket.io>
Date: Sun, 24 Aug 2025 20:17:51 -0500
Subject: [PATCH] serial_posix: Fix custom baud rates for glibc >=2.42; solves
#805
* https://sourceware.org/pipermail/libc-alpha/2025-July/168553.html
* Based on changes recommended by JoaoBarioni in #805
* Reverts 0085e1e1d (#519)
---
serial/serialposix.py | 11 ++---------
1 file changed, 2 insertions(+), 9 deletions(-)
diff --git a/serial/serialposix.py b/serial/serialposix.py
index 0464075b..6f843918 100644
--- a/serial/serialposix.py
+++ b/serial/serialposix.py
@@ -430,15 +430,8 @@ def _reconfigure_port(self, force_update=False):
ispeed = ospeed = self.BAUDRATE_CONSTANTS[self._baudrate]
except KeyError:
#~ raise ValueError('Invalid baud rate: %r' % self._baudrate)
-
- # See if BOTHER is defined for this platform; if it is, use
- # this for a speed not defined in the baudrate constants list.
- try:
- ispeed = ospeed = BOTHER
- except NameError:
- # may need custom baud rate, it isn't in our list.
- ispeed = ospeed = getattr(termios, 'B38400')
-
+ # Use safe placeholder for tcsetattr(), try to set special baudrate later
+ ispeed = ospeed = termios.B38400
try:
custom_baud = int(self._baudrate) # store for later
except ValueError:

View File

@@ -0,0 +1,42 @@
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
DISTUTILS_USE_PEP517=setuptools
PYTHON_COMPAT=( python3_{11..14} pypy3_11 )
inherit distutils-r1 pypi
DESCRIPTION="Python Serial Port extension"
HOMEPAGE="
https://github.com/pyserial/pyserial/
https://pypi.org/project/pyserial/
"
LICENSE="BSD"
SLOT="0"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~arm64-macos ~x64-macos"
IUSE="examples"
DOCS=( CHANGES.rst README.rst )
PATCHES=(
"${FILESDIR}/${P}-unittest-fix.patch"
"${FILESDIR}/${P}-glibc-2.42.patch"
)
distutils_enable_sphinx documentation --no-autodoc
python_test() {
"${EPYTHON}" test/run_all_tests.py loop:// -v ||
die "Testing failed with ${EPYTHON}"
}
python_install_all() {
distutils-r1_python_install_all
if use examples; then
dodoc -r examples
docompress -x /usr/share/doc/${PF}/examples
fi
}