Pass sys.stdin.buffer to json.load() in Python 3

When running with Python 3 json.load() will only work with sys.stdin if
we pass there its buffer property. This commit implements that in
kuryr-cni.

Implements: blueprint goal-python36
Change-Id: Ic05f9071a792e30e56e002d9af61387a25eaa5c0
Closes-Bug: 1792191
This commit is contained in:
Michał Dulko 2018-09-12 11:06:00 -06:00
parent a42e63a4a9
commit d008293e3a

View File

@ -15,6 +15,7 @@
import os
import signal
import six
import sys
import os_vif
@ -39,7 +40,11 @@ def run():
# REVISIT(ivc): current CNI implementation provided by this package is
# experimental and its primary purpose is to enable development of other
# components (e.g. functional tests, service/LBaaSv2 support)
cni_conf = utils.CNIConfig(jsonutils.load(sys.stdin))
if six.PY3:
d = jsonutils.load(sys.stdin.buffer)
else:
d = jsonutils.load(sys.stdin)
cni_conf = utils.CNIConfig(d)
args = ['--config-file', cni_conf.kuryr_conf]
try: