[Python-Dev] strange warnings from tempfile.mkstemped.__del__ on HP
Tim Peters
tim.one@comcast.net
Wed, 14 Aug 2002 00:53:14 -0400
[Guido]
> Lysator's snake-farm, which does regular builds of CVS Python
> checkouts on a variety of uncommon platforms, has started reporting
> two warnings that I don't understand. (Never mind the gettext.py
> warnings; they're shallow; someone should fix them.)
I submitted a patch for that to SF and assigned it to Barry (I have no idea
how to test gettext.py).
> The problem is the two exceptions ignored in __del__ methods. If I
> look at the code of the new tempfile.py module and its
> test_tempfile.py unittests, I see that there's a class mkstemped
> defined in test_tempfile.py, which has a __del__ method that closes
> the file descriptor. The only way I can see this failing with an
> AttributeError exception is if the instance never makes it through its
> __init__ call.
I agree, and, indeed, that's what would happen if it did fail during the
call to mkstemped.__init__(). So the call to tempfile._mkstemp_inner()
fails in two test cases (there were two distinct instances of the "no
attribute 'fd'" message), but we don't know which ones.
> ...
> But in that case I would have expect a failure reported; the only
> instantiation of mkstemped() is inside a try/except where the
> exceptclause calls self.failOnException() which causes the
> unit tests to fail. But the unittest doesn't report any failures?!
Well, I didn't see *any* test output in the report, neither successes nor
failures, just Python-produced exceptions and warnings. Maybe the script
only captures stderr? A failing unittest run *under* regrtest.py doesn't
normally print anything to stderr. It would have printed this to stdout,
though:
"""
...
test_tempfile
test test_tempfile failed -- errors occurred; run in verbose mode for
details
...
1 test failed:
test_tempfile
"""
So even if we had that, it wouldn't have helped. stdout from a regrtest -v
run is what we need, or from running test_tempfile.py directly (w/o
regrtest).