Skip to content

Commit

Permalink
pythongh-38807: Fix race condition in Lib/trace.py (pythonGH-110143)
Browse files Browse the repository at this point in the history
Instead of checking if a directory does not exist and thereafter
creating it, directly call os.makedirs() with the exist_ok=True.
  • Loading branch information
buermarc authored and aisk committed Feb 11, 2024
1 parent e40025a commit a97d972
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 @@ -265,8 +265,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 a97d972

Please sign in to comment.