xinguai / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Some python tests use os.environ.clear() wrong. #154

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Mike Castle reported:

gtest_output_test.py has this bit of code:
 # Spawns cmd in a sub-process, and gets its standard I/O file objects.
 # Set and save the environment properly.
 old_env_vars = dict(os.environ)
 os.environ.update(env_cmd[0])
 stdin_file, stdout_file = os.popen2(env_cmd[1], 'b')
 os.environ.clear()
 os.environ.update(old_env_vars)

Unfortunately, that actually doesn't save the environment properly.
If another uses the same function, it will get a dubious error.

The os.environ.clear() stuff doesn't work with 2.4 like one would
expect.  Sure, it resets the content of os.environ, but it doesn't
update the stuff on the C side like it should.  That wasn't added
until Python 2.6.

That line should instead read:
for key in os.environ.keys(): del os.environ[key]

Original issue reported on code.google.com by zhanyong...@gmail.com on 15 Jun 2009 at 8:44

GoogleCodeExporter commented 9 years ago
Fixed by Vlad in r269.

Original comment by zhanyong...@gmail.com on 19 Jun 2009 at 12:25