summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLib/trace.py3
-rw-r--r--Misc/NEWS.d/next/Library/2023-09-22-22-17-45.gh-issue-38807.m9McRN.rst3
2 files changed, 4 insertions, 2 deletions
diff --git a/Lib/trace.py b/Lib/trace.py
index 7cb6f89..7886959 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -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
diff --git a/Misc/NEWS.d/next/Library/2023-09-22-22-17-45.gh-issue-38807.m9McRN.rst b/Misc/NEWS.d/next/Library/2023-09-22-22-17-45.gh-issue-38807.m9McRN.rst
new file mode 100644
index 0000000..4219723
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2023-09-22-22-17-45.gh-issue-38807.m9McRN.rst
@@ -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``.