Skip to content

Commit 2ae2e0e

Browse files
mboersmaGabriel Monroy
authored andcommitted
fix(controller+client): utf-8 encode only string types
1 parent cd27ef4 commit 2ae2e0e

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

registry/private.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ def _put_tag(image_id, repository_path, tag):
158158

159159
# utility functions
160160

161+
def encode(obj):
162+
"""Return UTF-8 encoding for string objects."""
163+
if isinstance(obj, basestring):
164+
return obj.encode('utf-8')
165+
else:
166+
return obj
167+
161168

162169
def _construct_env(env, config):
163170
"Update current environment with latest config"
@@ -168,10 +175,10 @@ def _construct_env(env, config):
168175
if k in config:
169176
# update values defined by config
170177
v = config.pop(k)
171-
new_env.append("{}={}".format(k.encode('utf-8'), v.encode('utf-8')))
178+
new_env.append("{}={}".format(encode(k), encode(v)))
172179
# add other config ENV items
173180
for k, v in config.items():
174-
new_env.append("{}={}".format(k.encode('utf-8'), v.encode('utf-8')))
181+
new_env.append("{}={}".format(encode(k), encode(v)))
175182
return new_env
176183

177184

0 commit comments

Comments
 (0)