Environment inheritance under Windows NT 4, Attempt 2

James C. Ahlstrom jim at interet.com
Fri Jun 25 16:57:50 CEST 1999


"Milton L. Hankins" wrote:
> 
> Since I've not yet gotten a response to my first post, here's an
> elaboration.
> 
> Windows NT Workstation 4.00.1381, SP5.
> C:\>echo %WINDIR%
> C:\WINNT
> 
> C:\>python -c "import os; print os.environ['windir']"
> C:\WINNT
> 
> C:\>set WINDIR=foo
> 
> C:\>echo %WINDIR%
> foo
> 
> C:\>python -c "import os; print os.environ['windir']"
> C:\WINNT
> 
> -----------------------------------------------------

I don't get this behavior on NT 4.00.1381.  This was copied from
cmd.exe:

N:\python\Python-1.5.2\PCbuild>ver

Windows NT Version 4.0

N:\python\Python-1.5.2\PCbuild>./python -c "import os; print
os.environ['WINDIR']"
C:\WINNT35

N:\python\Python-1.5.2\PCbuild>set WINDIR=foo

N:\python\Python-1.5.2\PCbuild>echo %WINDIR%
foo

N:\python\Python-1.5.2\PCbuild>./python -c "import os; print
os.environ['WINDIR']"
foo

N:\python\Python-1.5.2\PCbuild>

I think I am at service pack 4.  I am using Python 1.5.2.  What is your
Python version (not that it should matter).  Very peculiar.

The code seems to be getting the environment from char **environ.  The
VC 6.0 docs say to use _environ, and I don't see a reference to
_environ.
The docs also say getenv() uses _environ.

Although I can't duplicate the behavior you describe, it seems to
me Python should be using _environ instead of environ.  Does anyone
know what environ is on NT?  I see "#define environ _environ" in
stdlib.h, but it is inside a bunch of #ifdef's.

Jim Ahlstrom




More information about the Python-list mailing list