From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 13 Apr 2026 01:13:14 +0000 (+0200) Subject: [3.14] tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345... X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=82ab8fb6668e316863c7cafd1cf46f0d47527d3d;p=thirdparty%2FPython%2Fcpython.git [3.14] tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345) (#148410) tests: use errno.EBADF instead of hardcoded number in _close_file() (GH-148345) test_interpreters: use errno.EBADF instead of hardcoded number in _close_file() Replace the hardcoded `9` check in `Lib/test/test_interpreters/utils.py` with `errno.EBADF`. Using `errno.EBADF` makes the helper portable across platforms with different errno numbering while preserving the intended behavior. (cherry picked from commit cef334fd4c4c24a542ce81ad940b1426b5a7cdbd) Co-authored-by: Artem Yarulin --- diff --git a/Lib/test/test_interpreters/utils.py b/Lib/test/test_interpreters/utils.py index d5d307d4973c..784c7ebba919 100644 --- a/Lib/test/test_interpreters/utils.py +++ b/Lib/test/test_interpreters/utils.py @@ -1,5 +1,6 @@ from collections import namedtuple import contextlib +import errno import json import logging import os @@ -52,7 +53,7 @@ def _close_file(file): else: os.close(file) except OSError as exc: - if exc.errno != 9: + if exc.errno != errno.EBADF: raise # re-raise # It was closed already.