Skip to content

Commit

Permalink
Normalize the environment while copying. (#139)
Browse files Browse the repository at this point in the history
On MSYS under Windows, os.environ contains a mix of unicode and plain
strings, so we convert during the copy to normalize them and make
Windows StartProcess happy.
  • Loading branch information
metajack authored and jgraham committed Nov 3, 2016
1 parent 00a578d commit 4591aeb
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sslutils/openssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ def __call__(self, cmd, *args, **kwargs):
self.cmd += ["-config", self.conf_path]
self.cmd += list(args)

env = os.environ.copy()
# Copy the environment, converting to plain strings. Windows
# StartProcess is picky about all the keys/values being plain strings,
# but at least in MSYS shells, the os.environ dictionary can be mixed.
env = {}
for k, v in os.environ.iteritems():
env[k.encode("utf8")] = v.encode("utf8")

if self.base_conf_path is not None:
env["OPENSSL_CONF"] = self.base_conf_path.encode("utf8")

Expand Down

0 comments on commit 4591aeb

Please sign in to comment.