Commit 7c0e724c authored by Michal Čihař's avatar Michal Čihař

Convert environment to string objects on Python 2 on Windows

It can not handle ascii unicode objects unlike other platforms.

Issue #1067
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent 7e254c23
......@@ -24,6 +24,7 @@ import os
import sys
import traceback
import six
from six.moves.urllib.parse import urlparse
from django.core.exceptions import ImproperlyConfigured
......@@ -212,6 +213,12 @@ def get_clean_env(extra=None):
for var in variables:
if var in os.environ:
environ[var] = os.environ[var]
# Python 2 on Windows doesn't handle Unicode objects in environment
# even if they can be converted to ASCII string, let's fix it here
if six.PY2 and sys.platform == 'win32':
return {
str(key): str(val) for key, val in environ.items()
}
return environ
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment