[Python-bugs-list] [ python-Bugs-494589 ] os.path.expandvars deletes things on w32

noreply@sourceforge.net noreply@sourceforge.net
Tue, 18 Dec 2001 22:56:06 -0800


Bugs item #494589, was opened at 2001-12-18 06:29
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=494589&group_id=5470

Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Michael McCandless (mikemccand)
>Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.expandvars deletes things on w32

Initial Comment:

Try this:

  import os.path
  print os.path.expandvars('foo$doesnotexist')

On FreeBSD, Python 2.1, I get:

  'foo$doesnotexist'

But on WIN32, Python 2.1, I get:

  'foo'

The docs explicitly states that variables that are not 
found will be left in place ... but on win32 that 
appears to not be the case.

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

>Comment By: Tim Peters (tim_one)
Date: 2001-12-18 22:56

Message:
Logged In: YES 
user_id=31435

Another bug:  with two adjacent envars that do exist, only 
the first is expanded (on Windows):

>>> os.path.expandvars('$TMP$TMP')
'c:\windows\TEMP$TMP'
>>>

Another bug:  the Windows expandvars doesn't expand envars 
in single quotes, but the posixpath flavor does:

>>> ntpath.expandvars("'$TMP'")
"'$TMP'"
>>> posixpath.expandvars("'$TMP'")
"'c:\windows\TEMP'"
>>>

Another bug:  $$ is an escape sequence (meaning a single $) 
on Windows but not on Unix:

>>> ntpath.expandvars('$$')
'$'
>>> posixpath.expandvars('$$')
'$$'
>>>

Unassigning from me, as this is a bottomless pit spanning 
platforms and bristling with backward-compatibility traps 
no matter what's done about it.  Somebody who cares enough 
should write a PEPlet to sort out the mess, else I'd just 
leave it alone.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-18 06:43

Message:
Logged In: YES 
user_id=6380

Hm, I do understand it, the code is broken (compared to the
spec).

No time to fix it.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2001-12-18 06:35

Message:
Logged In: YES 
user_id=6380

Confirmed, also in 2.2. I don't understand it, the code
looks OK.

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

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