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 larry
Recipients benjamin.peterson, larry
Date 2009-04-06.19:25:15
SpamBayes Score 2.3780977e-13
Marked as misclassified No
Message-id <1239045920.49.0.912808620913.issue5676@psf.upfronthosting.co.za>
In-reply-to
Content
% rm -rf @test
rm: cannot remove `@test': Permission denied

And, before you helpfully chime in with "chmod", yes I know how to run
that too.

I stuck in and figured it out.  The bug: "test_on_error" in
"test_shutil" is out of sync with how "shutil.rmtree" runs. 
"test_on_error" deliberately constructs a directory that is not
executable to the current user, then calls "shutil.rmtree" to delete it,
passing in an "onerror" callback of "check_args_to_onerror" so it can
observe how it fails.  "check_args_to_onerror". expects to be called
twice; the first time it expects the failing function to be "os.remove".
 In fact, the first failure is "os.listdir".  This fails, throws an
exception, and the test is over.  Which means the cleanup code in
"test_on_error" (the subsequent "chmod" and "rmtree" calls) don't get
executed, the "@test" with mode 400 is left behind, and now we have
cascading errors.

Attached is a patch that fixes "check_args_to_onerror" on my machine. 
For good measure, it also changes "cleanup_test_droppings" in "regrtest"
cleanup code so it chmods a directory to 0o700 before attempting to
remove it.  The patch was written against py3k/trunk r71304.

I find it hard to believe that I'm the only person running "make test"
in py3k/trunk not on Windows and not as root.  So I theorize os.listdir
behaves differently on different OSes.  I'm on Ubuntu 9.04, and
os.listdir fails if called on a directory that is not executable. 
Perhaps, on the omnipresent Macs, this is permissible?  If so, the tests
in "check_args_on_error" when errorState is 0 should be rewritten,
either to accept any of the possible arguments or to branch on
sys.platform and accept specific arguments.
History
Date User Action Args
2009-04-06 19:25:21larrysetrecipients: + larry, benjamin.peterson
2009-04-06 19:25:20larrysetmessageid: <1239045920.49.0.912808620913.issue5676@psf.upfronthosting.co.za>
2009-04-06 19:25:18larrylinkissue5676 messages
2009-04-06 19:25:15larrycreate