◐ Shell
clean mode source ↗

Message 325218 - Python tracker

Did you attempt to use the 3-line change I posted earlier?  I stepped through to test line-by-line to find the offending piece of code.  And it was indeed the open() call causing the test-tree to be processed prior to it being completed.  Thus making the .py file seen before the directory of same name would exist.