[issue8349] os.environ.get returns incorrect data

Dan Brandow report at bugs.python.org
Thu Apr 8 23:37:23 CEST 2010


New submission from Dan Brandow <dan.brandow at gmail.com>:

I have a Windows 7 64 bit machine, which means it has a few different environment variables concerning the program files location:
PROGRAMFILES=C:\Program Files (x86)
ProgramFiles(x86)=C:\Program Files (x86)

Note that both env variables have "(x86)" at the end.

When I do an os.environ.get I get the following results:

Python 2.6.5 (r265:79096, Mar 19 2010, 18:02:59) [MSC v.1500 64 bit (AMD64)] on win32
>>> import os
>>> print os.environ.get('ProgramFiles(x86)')
C:\Program Files (x86)
>>> print os.environ.get('PROGRAMFILES')
C:\Program Files
>>> print os.environ.get('ProgramFiles')
C:\Program Files
>>>

Note the missing "(x86)" on the last two test cases.

I tried it on the 64-bit version of 2.5.4 as well:

Python 2.5.4 (r254:67916, Dec 23 2008, 15:19:34) [MSC v.1400 64 bit (AMD64)] on win32
>>> import os
>>> print os.environ.get('ProgramFiles(x86)')
C:\Program Files (x86)
>>> print os.environ.get('PROGRAMFILES')
C:\Program Files
>>> print os.environ.get('ProgramFiles')
C:\Program Files
>>>

Same result.  So I tried the 32-bit version of 2.5.4:

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32
>>> import os
>>> print os.environ.get('ProgramFiles(x86)')
C:\Program Files (x86)
>>> print os.environ.get('PROGRAMFILES')
C:\Program Files (x86)
>>> print os.environ.get('ProgramFiles')
C:\Program Files (x86)
>>>

...which gave the correct strings...

----------
components: Extension Modules
messages: 102646
nosy: dbrandow
severity: normal
status: open
title: os.environ.get returns incorrect data
versions: Python 2.6

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


More information about the Python-bugs-list mailing list