gh-38807: Fix race condition in Lib/trace.py (GH-110143)

Instead of checking if a directory does not exist and thereafter
creating it, directly call os.makedirs() with the exist_ok=True.
This commit is contained in:
buermarc 2024-01-17 21:02:14 +01:00 committed by GitHub
parent 7573c44c32
commit 78fcde039a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -265,8 +265,7 @@ class CoverageResults:
modulename = _modname(filename)
else:
dir = coverdir
if not os.path.exists(dir):
os.makedirs(dir)
os.makedirs(dir, exist_ok=True)
modulename = _fullmodname(filename)
# If desired, get a list of the line numbers which represent

View File

@ -0,0 +1,3 @@
Fix race condition in :mod:`trace`. Instead of checking if a directory
exists and creating it, directly call :func:`os.makedirs` with the kwarg
``exist_ok=True``.