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

Instead of checking if a directory does not exist and thereafter
creating it, directly call os.makedirs() with the exist_ok=True.
(cherry picked from commit 78fcde039a)

Co-authored-by: buermarc <44375277+buermarc@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2024-01-17 21:35:00 +01:00 committed by GitHub
parent a735fea6b1
commit 24d23929d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View file

@ -258,8 +258,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``.