[issue1646838] os.path, %HOME% set: realpath contradicts expanduser on '~'

Marco Buccini report at bugs.python.org
Sun Oct 18 13:06:09 CEST 2009


Marco Buccini <marcusbu at gmail.com> added the comment:

If we decide to follow paths as '~' it means that we want to follow the
POSIX standard.

Infact, it doesn't make sense calling os.path.realpath as follow:
>>> import os
>>> os.getcwd()
'/home/marco/Desktop'
>>> os.path.realpath('~')
To get something like:
'/home/marco/Desktop/$HOME' 
that would expand as:
'/home/marco/Desktop/home/marco' 

At this point we should implement a new os.path.realpath to check if the
path passed as argument exists [ See ERRORS section:
http://www.opengroup.org/onlinepubs/9699919799/functions/realpath.html
]. But this means that in the worst case, we would raise an Exception
(i.e., OSError).

As I've said [ here: http://bugs.python.org/issue6975 ] we cannot
implement a POSIX compliant os.path.realpath, since it would break with
existing code. You understand that a change like this is an API change. 

I think Python will have an own `realpath` version, not fully
POSIX-compliant, unluckly.

----------

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


More information about the Python-bugs-list mailing list