> What is the probability of replacing os.lstat, os.close or os.rmdir from > another thread at just the right time?
If the thead does "import os", and its start is logically connected to calling _rmtree_safe_fd(), I'd say it's a very good chance! That is, again, granted that the reference to os.lstat *can* be modified in this way. But, before we keep guessing any further, it'd be best if OP could get us the info on what's stored in "func" and "os.lstat" at the time the assertion fails. -- https://mail.python.org/mailman/listinfo/python-list