Fix unicode in environment variables for python2.
Signed-off-by: Daniel Nephin <dnephin@docker.com>
This commit is contained in:
parent
6f78271b82
commit
ae47435425
4 changed files with 15 additions and 5 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import codecs
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -455,6 +456,8 @@ def parse_environment(environment):
|
|||
|
||||
|
||||
def split_env(env):
|
||||
if isinstance(env, six.binary_type):
|
||||
env = env.decode('utf-8')
|
||||
if '=' in env:
|
||||
return env.split('=', 1)
|
||||
else:
|
||||
|
|
@ -477,7 +480,7 @@ def env_vars_from_file(filename):
|
|||
if not os.path.exists(filename):
|
||||
raise ConfigurationError("Couldn't find env file: %s" % filename)
|
||||
env = {}
|
||||
for line in open(filename, 'r'):
|
||||
for line in codecs.open(filename, 'r', 'utf-8'):
|
||||
line = line.strip()
|
||||
if line and not line.startswith('#'):
|
||||
k, v = split_env(line)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue