Skip to content

Commit

Permalink
[3.11] gh-38807: Fix race condition in Lib/trace.py (GH-110143) (GH-1…
Browse files Browse the repository at this point in the history
…14207)

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 78fcde0)

Co-authored-by: buermarc <44375277+buermarc@users.noreply.github.com>
  • Loading branch information
miss-islington and buermarc committed Jan 17, 2024
1 parent 2b03259 commit 2dca689
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Lib/trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ def write_results(self, show_missing=True, summary=False, coverdir=None):
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
Expand Down
Original file line number Diff line number Diff line change
@@ -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``.

0 comments on commit 2dca689

Please sign in to comment.