[ python-Bugs-1646838 ] os.path, %HOME% set: realpath contradicts expanduser on '~'

SourceForge.net noreply at sourceforge.net
Mon Jan 29 09:07:41 CET 2007


Bugs item #1646838, was opened at 2007-01-29 09:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1646838&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: wrstl prmpft (wrstlprmpft)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path, %HOME% set: realpath contradicts expanduser on '~'

Initial Comment:
This might be intentional, but it is still confusing.

On Windows XP (german)::

  Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]
  ...
  In [1]: import os.path as path
  
  In [2]: import os; os.environ['HOME']
  
  Out[2]: 'D:\\HOME'
  
  In [3]: path.realpath('~')
  
  Out[3]: 'C:\\Dokumente und Einstellungen\\wrstl\\~'
  
  In [4]: path.expanduser('~')
  
  Out[4]: 'D:\\HOME'


The cause:
realpath uses path._getfullpathname which seems to do the '~' expansion, while path.expanduser has special code to look for HOME* environment variables.

I would expect that the HOME setting should always be honored if expansion is done.

cheers,
stefan


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1646838&group_id=5470


More information about the Python-bugs-list mailing list