Why doesn't Python remember the initial directory?

Neil Hodgson nhodgson at iinet.net.au
Mon Aug 20 21:39:19 EDT 2012


Nobody:

> Maybe. On Unix, it's possible that the current directory no longer
> has a pathname.

    Its also possible that you do not have permission to successfully 
call getcwd. One example of this I have experienced is the OS X sandbox 
where you can run Python starting in a directory where you have only 
limited permissions.

    getcwd works by calling readdir and lstat and looping up from the 
current directory to the root to build the whole path so will break 
without read permissions on directories:
http://www.opensource.apple.com/source/Libc/Libc-763.13/gen/FreeBSD/getcwd.c

    Neil



More information about the Python-list mailing list