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
Closes-Bug:
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:
