https://github.com/python/cpython/commit/897a36baddb3611865a839c6345315da689c52a1 commit: 897a36baddb3611865a839c6345315da689c52a1 branch: main author: yihong <[email protected]> committer: picnixz <[email protected]> date: 2025-10-11T12:32:57Z summary:
gh-139935: fix `test_os.test_getlogin` on some platforms (#139936) This amends 4e7e2dd043c1da85b0c157d3ed24866b77e83a4f to catch errors that `os.getlogin` can raise as specified by POSIX and Linux/glibc [1]. [1]: https://man7.org/linux/man-pages/man3/getlogin.3.html#ERRORS --------- Signed-off-by: yihong0618 <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]> files: M Lib/test/test_os/test_os.py diff --git a/Lib/test/test_os/test_os.py b/Lib/test/test_os/test_os.py index 371771087aaf88..95b175db6fcdcb 100644 --- a/Lib/test/test_os/test_os.py +++ b/Lib/test/test_os/test_os.py @@ -3203,7 +3203,14 @@ def test_getlogin(self): try: user_name = os.getlogin() except OSError as exc: - if exc.errno in (errno.ENOTTY, errno.ENXIO): + # See https://man7.org/linux/man-pages/man3/getlogin.3.html#ERRORS. + allowed_errors = ( + # defined by POSIX + errno.EMFILE, errno.ENFILE, errno.ENXIO, errno.ERANGE, + # defined by Linux/glibc + errno.ENOENT, errno.ENOMEM, errno.ENOTTY, + ) + if exc.errno in allowed_errors: self.skipTest(str(exc)) else: raise _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]
