Solaris 9 and earlier fail to conform to POSIX, in that stat("FILE/") succeeds even when FILE is not a directory. POSIX says that in this case it should fail. This problem causes os.path.exists("FILE/") to succeed when it should fail, which makes it harder to write portable Python code. One of my students ran into this problem when doing a Django-based project: his code ran fine on his Linux box, but failed when he attempted to run it on the Solaris 8 server that is the standard platform for our students. To reproduce the problem, on Solaris 8 (or 9): $ touch file $ ls -l file -rw-rw-r-- 1 eggert csfac 0 Dec 7 14:19 file $ python Python 2.5 (r25:51908, Dec 7 2006, 13:14:10) [GCC 4.1.1] on sunos5 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.path.exists("file/") True It should be False. I'll attach a patch that works around the problem at run-time. If you prefer something that tests for it at compile time please let me know.
I think it would be sufficient to put a #ifdef <solaris 9> ... #endif around the additional check. We don't want to make all platforms do extra system calls in order to avoid a Solaris 9 bug. Or you could write a configure test to check for this bug, but that's more complicated a task.
Here's an updated version of the patch. It at least compiles and runs on MacOS, but I don't have a Solaris installation to check whether it still fixes the problem on Solaris 9. Note that, according to http://en.wikipedia.org/wiki/Solaris_(operating_system)#Version_history, Solaris 9 will only be supported until October 2014.