[issue29635] os.chdir() acts like `cd -P` by default, it should offer an option to not follow symlinks

Fabien Dubosson report at bugs.python.org
Thu Feb 23 13:49:34 EST 2017


Fabien Dubosson added the comment:

The previous example (sorry, first time using this platform, I'm a little bit messy here), shows that `os.chdir` resolves symlinks by default, as opposed to what `cd` does in bash. This means it is not possible to change the directory to a symlink folder.

A solution would be a keyword argument in `os.chdir` and `os.getcwd` that would mimic the `-P` and `-L` arguments of `cd` and `pwd`, like:

    os.chdir(logical=False)  # or follow_symlinks=True maybe
    os.getcwd(logical=False)

I don't know what should be the default values for these args, but at least having an option to change the behavior would be nice.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29635>
_______________________________________


More information about the Python-bugs-list mailing list