This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lkcl
Recipients lkcl
Date 2009-01-25.11:39:14
SpamBayes Score 1.9408512e-06
Marked as misclassified No
Message-id <1232883558.71.0.175097990327.issue5051@psf.upfronthosting.co.za>
In-reply-to
Content
class EnvironTests(mapping_tests.BasicTestMappingProtocol):
    """check that os.environ object conform to mapping protocol"""
    type2test = None
    def _reference(self):
        return {"KEY1":"VALUE1", "KEY2":"VALUE2", "KEY3":"VALUE3"}
    def _empty_mapping(self):
                   vvvvvv
        os.environ.clear() <<<<<---------- *******
                   ^^^^^^
        return os.environ
    def setUp(self):
        self.__save = dict(os.environ)
        os.environ.clear()
    def tearDown(self):
        os.environ.clear()
        os.environ.update(self.__save)

    # Bug 1110478
    def test_update2(self):
        if os.path.exists("/bin/sh"):
            os.environ.update(HELLO="World")
                       vvvvv
            value = os.popen("/bin/sh -c 'echo $HELLO'").read().strip()
                       ^^^^^ finds os.environ['COMSPEC'] to be empty! 
            self.assertEquals(value, "World")


this test will obviously fail, see _PyPopenCreateProcess in
posixmodule.c.

    if (i = GetEnvironmentVariable("COMSPEC",NULL,0)) {
        char *comshell;

    }
    /* Could be an else here to try cmd.exe / command.com in the path
       Now we'll just error out.. */
    else {
        PyErr_SetString(PyExc_RuntimeError,
            "Cannot locate a COMSPEC environment variable to "
            "use as the shell");
        return FALSE;
    }


the environment variables having been destroyed, there _is_ no
COMSPEC to obtain a working cmd.exe or command.com in order to
execute the /bin/sh (or /bin/sh.exe in the case of having installed
msys and created a symlink from c:/msys/bin to c:/bin).
History
Date User Action Args
2009-01-25 11:39:19lkclsetrecipients: + lkcl
2009-01-25 11:39:18lkclsetmessageid: <1232883558.71.0.175097990327.issue5051@psf.upfronthosting.co.za>
2009-01-25 11:39:17lkcllinkissue5051 messages
2009-01-25 11:39:14lkclcreate