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 eryksun
Recipients cmckain, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2017-03-28.10:00:30
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1490695230.46.0.275804987849.issue29908@psf.upfronthosting.co.za>
In-reply-to
Content
I can confirm that the CRT function construct_environment_block() does cause an access violation sometimes when no "=x:" shell variables are defined in the current environment. These "=x:" environment variables are the way that Windows emulates DOS per-drive working directories in a shell. The API itself never sets these variables; it only uses them if they're defined.

You should be able to avoid this bug by defining the environment variable "=C:". The simplest way to do this in Python is via os.chdir. For example:

    import os

    cwd = os.getcwd()
    try:
        os.chdir('C:')
    finally:
        os.chdir(cwd)

The implementation of os.chdir calls SetCurrentDirectoryW, which, for a drive-relative path such as "C:", will first look for an "=x:" environment variable and otherwise default to the root directory. After it changes the process current working directory, chdir() calls GetCurrentDirectoryW and SetEnvironmentVariableW to set the new value of the "=x:" variable.
History
Date User Action Args
2017-03-28 10:00:30eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, cmckain
2017-03-28 10:00:30eryksunsetmessageid: <1490695230.46.0.275804987849.issue29908@psf.upfronthosting.co.za>
2017-03-28 10:00:30eryksunlinkissue29908 messages
2017-03-28 10:00:30eryksuncreate