New submission from Fabien Dubosson:
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'
>>>
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue29635>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com