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.

Author StreakyCobra
Recipients StreakyCobra
Date 2017-02-23.18:40:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1487875229.83.0.0508905375261.issue29635@psf.upfronthosting.co.za>
In-reply-to
Content
When using bash, the `cd` function does not follow symlinks by default, but `cd -P` does. The `os.chdir` function behaves like `cd -P` preventing to be able to change directory to a symlink folder.

Initial setup (make a `/tmp/to/dst` symlink pointing to `/tmp/from/src`):

    cd /tmp
    mkdir from from/src to
    ln -s ../from/src to/dst

Here is an example, when using python's `os.chdir` function:

    [fabien@asus ~]$ python
    >>> import os
    >>> os.chdir('/tmp/to/dst')
    >>> os.system('/usr/bin/pwd')
    /tmp/from/src
    0
    >>> os.system('/usr/bin/pwd -P')
    /tmp/from/src
    0
    >>> os.system('/usr/bin/pwd -L')
    /tmp/from/src
    0
    >>> os.getcwd()
    '/tmp/from/src'
    >>> 

And here is an example when the folder is first changed with bash:


    [fabien@asus ~]$ cd /tmp/to/dst/
    [fabien@asus dst]$ python
    >>> import os
    >>> os.system('/usr/bin/pwd')
    /tmp/from/src
    0
    >>> os.system('/usr/bin/pwd -P')
    /tmp/from/src
    0
    >>> os.system('/usr/bin/pwd -L')
    /tmp/to/dst
    0
    >>> os.getcwd()
    '/tmp/from/src'
    >>>
History
Date User Action Args
2017-02-23 18:40:29StreakyCobrasetrecipients: + StreakyCobra
2017-02-23 18:40:29StreakyCobrasetmessageid: <1487875229.83.0.0508905375261.issue29635@psf.upfronthosting.co.za>
2017-02-23 18:40:29StreakyCobralinkissue29635 messages
2017-02-23 18:40:29StreakyCobracreate