[Python-Dev] os.path.exists() / os.path.isdir() inconsistency when dealing with gvfs directories (original) (raw)
Giampaolo RodolĂ g.rodola at gmail.com
Wed Jun 27 01:49:34 CEST 2012
- Previous message: [Python-Dev] Poking about issue 1677
- Next message: [Python-Dev] os.path.exists() / os.path.isdir() inconsistency when dealing with gvfs directories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've just noticed a strange behavior when dealing with gvfs filesystems:
giampaolo at ubuntu:$ python -c "import os;
print(os.path.exists('/home/giampaolo/.gvfs'))"
True
giampaolo at ubuntu:$ sudo su
root at ubuntu:~# python -c "import os;
print(os.path.exists('/home/giampaolo/.gvfs'))"
False
This is due to os.stat() which internally fails with PermissionError (EACCES). The same problem exists with os.path.isdir() which will return True as limited user and False as root. I'm not sure what's best to do here nor I know if there are other cases other than when dealing with gvfs which can produce similar behaviors but here's an idea:
make os.path.exists() return True in case of PermissionError because that's supposed to mean there's an existing path to deny access to
fix isdir(), islink(), isfile() documentation pointing out that in case of EACCES/EPERM or when dealing with exotic paths/fs it may return incorrect results.
Comments?
--- Giampaolo http://code.google.com/p/pyftpdlib/ http://code.google.com/p/psutil/ http://code.google.com/p/pysendfile/
- Previous message: [Python-Dev] Poking about issue 1677
- Next message: [Python-Dev] os.path.exists() / os.path.isdir() inconsistency when dealing with gvfs directories
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]