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.

classification
Title: os.path.exists("file/") failure on Solaris 9
Type: behavior Stage: resolved
Components: Build, Library (Lib) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: akuchling, eggert, jcea, neologix, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2006-12-07 22:25 by eggert, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-stat-patch.diff eggert, 2006-12-07 22:25 patch for Python stat on Solaris 9 and earlier
python-stat-patch-2.diff eggert, 2006-12-22 07:56 Revised patch, with configure-time test.
python-stat-patch-3.diff akuchling, 2013-06-14 01:56 Revised patch, updated against the default branch review
Messages (6)
msg30760 - (view) Author: Paul Eggert (eggert) Date: 2006-12-07 22:25
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.
msg30761 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2006-12-20 13:37
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.
msg30762 - (view) Author: Paul Eggert (eggert) Date: 2006-12-22 07:56
OK, I'll attach a revised patch that uses a configure test to check for this bug.
File Added: python-stat-patch-2.diff
msg179067 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-01-04 18:49
The patch need be revised for 3.3+.
msg191102 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2013-06-14 01:56
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.
msg191120 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2013-06-14 12:20
I don't like the idea of adding such a kludge to workaround an OS bug - especially since Solaris 9 won't be supported for too long.
History
Date User Action Args
2022-04-11 14:56:21adminsetgithub: 44316
2013-12-01 13:33:30neologixsetstatus: pending -> closed
resolution: rejected
stage: patch review -> resolved
2013-08-02 08:30:36neologixsetstatus: open -> pending
2013-06-14 12:20:09neologixsetnosy: + neologix
messages: + msg191120
2013-06-14 01:56:17akuchlingsetfiles: + python-stat-patch-3.diff
keywords: + patch
messages: + msg191102
2013-01-04 18:49:00serhiy.storchakasetnosy: + jcea, serhiy.storchaka

messages: + msg179067
versions: + Python 3.3, Python 3.4, - Python 3.1
2010-08-25 14:34:25BreamoreBoysetstage: test needed -> patch review
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6, Python 3.0
2009-03-30 17:39:38ajaksu2setstage: test needed
type: behavior
components: + Build
versions: + Python 2.6, Python 3.0, - Python 2.5
2006-12-07 22:25:27eggertcreate