This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author zooko
Recipients
Date 2003-07-07.01:46:30
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
There is one bug and one maybe-bug in creation of the
coverage file directory in trace.py.

The maybe-bug is that it doesn't attempt to create the
directory if it got the directory name from the name of
the .py file (instead of getting the directory name
from the --coverdir command line option).

Normally the directory will already exist, but if you
are writing out coverage files from a stored report
(or, I suppose, if someone deleted the directory after
the modules were loaded but before you wrote out the
report), then it won't.  This patch makes it so that it
always attempts to create the directory before
attempting to write files into it.  The patch also adds
a statement to that effect to the "--help" usage info.

The other bug is that it attempts to create a directory
with:

                if not os.path.exists(dir):
                    os.makedirs(dir)

, which is a race condition that will very rarely raise
a spurious exception ("File exists:") if two threads or
processes execute it at the same time.

The fix provided in this patch is to copy from my
pyutil project [1] a utility function that works around
this race condition and invoke that function.  On
request I'll provide a slimmed-down version of that
function, since we don't use all of its options in
trace.py.

This patch hasn't been tested at ALL.  In fact, I
haven't tested trace.py in general since before it
moved from Tools/scripts to Lib/.  As this patch ought
to go into Python 2.3, it ought to be tested, and I
promise to do so soon.

[1] http://sf.net/projects/pyutil
History
Date User Action Args
2007-08-23 15:28:14adminlinkissue766910 messages
2007-08-23 15:28:14admincreate