https://github.com/python/cpython/commit/74be9e2c7624d117d4d77f6bf67546a05b64b25c
commit: 74be9e2c7624d117d4d77f6bf67546a05b64b25c
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: gpshead <[email protected]>
date: 2026-04-12T18:13:53-07:00
summary:

[3.13] tests: use errno.EBADF instead of hardcoded number in _close_file() 
(GH-148345) (#148411)

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 <[email protected]>

files:
M Lib/test/test_interpreters/utils.py

diff --git a/Lib/test/test_interpreters/utils.py 
b/Lib/test/test_interpreters/utils.py
index 980289f7ee7075..add156d0e36dab 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 io
 import logging
@@ -55,7 +56,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.
 

_______________________________________________
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]

Reply via email to