summaryrefslogtreecommitdiffstats
path: root/meta-phosphor
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2018-06-06 16:16:23 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2018-06-21 01:32:23 +0000
commit39beab95c635374ca0e9aa50fdce2c02e85efdca (patch)
tree9b4178cb2a85845a3d8c6b0de929cbb7efdb1d37 /meta-phosphor
parent8fc3b96386c6985b5e8fc2c7109b4929e9c25409 (diff)
downloadtalos-openbmc-39beab95c635374ca0e9aa50fdce2c02e85efdca.tar.gz
talos-openbmc-39beab95c635374ca0e9aa50fdce2c02e85efdca.zip
Fix dbus.Byte JSON encoding
dbus.Byte is not encoded by the JSON library in Python2.7 correctly. There was a hack added to dbus-python to work around this. Backport the JSON library fix from Python 3.x back to Python2.7, so we can drop the hack from dbus-python. Tested: verified encoding of dbus.Byte unchanged Change-Id: Ifc8e0d22a25f4dd52da5a136809df25771684438 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'meta-phosphor')
-rw-r--r--meta-phosphor/common/recipes-devtools/python/python/0001-json-Use-int-long.__str__-to-convert-subclasses.patch128
-rw-r--r--meta-phosphor/common/recipes-devtools/python/python_2.%.bbappend1
2 files changed, 129 insertions, 0 deletions
diff --git a/meta-phosphor/common/recipes-devtools/python/python/0001-json-Use-int-long.__str__-to-convert-subclasses.patch b/meta-phosphor/common/recipes-devtools/python/python/0001-json-Use-int-long.__str__-to-convert-subclasses.patch
new file mode 100644
index 000000000..26669d848
--- /dev/null
+++ b/meta-phosphor/common/recipes-devtools/python/python/0001-json-Use-int-long.__str__-to-convert-subclasses.patch
@@ -0,0 +1,128 @@
+From b002fd4b884b5f8cd3f429ea2002dd19e91d1d91 Mon Sep 17 00:00:00 2001
+From: Brad Bishop <bradleyb@fuzziesquirrel.com>
+Date: Thu, 7 Jun 2018 09:18:01 -0400
+Subject: [PATCH] json: Use int/long.__str__ to convert subclasses
+
+Based on changes that went into 3.x:
+
+e0805cf10ea84b44a13ad5649267edba7cb83ee9
+a4998a70416c27730e75c0a4225ee2c3552b1618
+---
+ Lib/json/encoder.py | 26 ++++++++++++++++++--------
+ Modules/_json.c | 21 +++++++++++++++++----
+ 2 files changed, 35 insertions(+), 12 deletions(-)
+
+diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
+index 97ffe8e8a2..3156682fdd 100644
+--- a/Lib/json/encoder.py
++++ b/Lib/json/encoder.py
+@@ -283,6 +283,8 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
+ long=long,
+ str=str,
+ tuple=tuple,
++ _intstr=int.__str__,
++ _longstr=long.__str__,
+ ):
+
+ def _iterencode_list(lst, _current_indent_level):
+@@ -317,8 +319,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
+ yield buf + 'true'
+ elif value is False:
+ yield buf + 'false'
+- elif isinstance(value, (int, long)):
+- yield buf + str(value)
++ elif isinstance(value, int):
++ yield buf + _intstr(value)
++ elif isinstance(value, long):
++ yield buf + _longstr(value)
+ elif isinstance(value, float):
+ yield buf + _floatstr(value)
+ else:
+@@ -374,8 +378,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
+ key = 'false'
+ elif key is None:
+ key = 'null'
+- elif isinstance(key, (int, long)):
+- key = str(key)
++ elif isinstance(key, int):
++ key = _intstr(key)
++ elif isinstance(key, long):
++ key = _longstr(key)
+ elif _skipkeys:
+ continue
+ else:
+@@ -394,8 +400,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
+ yield 'true'
+ elif value is False:
+ yield 'false'
+- elif isinstance(value, (int, long)):
+- yield str(value)
++ elif isinstance(value, int):
++ yield _intstr(value)
++ elif isinstance(value, long):
++ yield _longstr(value)
+ elif isinstance(value, float):
+ yield _floatstr(value)
+ else:
+@@ -423,8 +431,10 @@ def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,
+ yield 'true'
+ elif o is False:
+ yield 'false'
+- elif isinstance(o, (int, long)):
+- yield str(o)
++ elif isinstance(o, long):
++ yield _longstr(o)
++ elif isinstance(o, int):
++ yield _intstr(o)
+ elif isinstance(o, float):
+ yield _floatstr(o)
+ elif isinstance(o, (list, tuple)):
+diff --git a/Modules/_json.c b/Modules/_json.c
+index 39ec467b09..f429738145 100644
+--- a/Modules/_json.c
++++ b/Modules/_json.c
+@@ -1981,12 +1981,19 @@ encoder_listencode_obj(PyEncoderObject *s, PyObject *rval, PyObject *obj, Py_ssi
+ return -1;
+ return _steal_list_append(rval, encoded);
+ }
+- else if (PyInt_Check(obj) || PyLong_Check(obj)) {
+- PyObject *encoded = PyObject_Str(obj);
++ else if (PyLong_Check(obj)) {
++ PyObject *encoded = PyLong_Type.tp_str(obj);
+ if (encoded == NULL)
+ return -1;
+ return _steal_list_append(rval, encoded);
+ }
++ else if (PyInt_Check(obj)) {
++ PyObject *encoded = PyInt_Type.tp_str(obj);
++ if (encoded == NULL)
++ return -1;
++ return _steal_list_append(rval, encoded);
++ }
++
+ else if (PyFloat_Check(obj)) {
+ PyObject *encoded = encoder_encode_float(s, obj);
+ if (encoded == NULL)
+@@ -2131,11 +2138,17 @@ encoder_listencode_dict(PyEncoderObject *s, PyObject *rval, PyObject *dct, Py_ss
+ if (kstr == NULL)
+ goto bail;
+ }
+- else if (PyInt_Check(key) || PyLong_Check(key)) {
+- kstr = PyObject_Str(key);
++ else if (PyLong_Check(key)) {
++ kstr = PyLong_Type.tp_str(key);
+ if (kstr == NULL)
+ goto bail;
+ }
++ else if (PyInt_Check(key)) {
++ kstr = PyInt_Type.tp_str(key);
++ if (kstr == NULL)
++ goto bail;
++ }
++
+ else if (key == Py_True || key == Py_False || key == Py_None) {
+ kstr = _encoded_const(key);
+ if (kstr == NULL)
+--
+2.14.3
+
diff --git a/meta-phosphor/common/recipes-devtools/python/python_2.%.bbappend b/meta-phosphor/common/recipes-devtools/python/python_2.%.bbappend
index 569e75397..e591a9565 100644
--- a/meta-phosphor/common/recipes-devtools/python/python_2.%.bbappend
+++ b/meta-phosphor/common/recipes-devtools/python/python_2.%.bbappend
@@ -1,5 +1,6 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI += "file://__init__.email_min.py"
+SRC_URI += "file://0001-json-Use-int-long.__str__-to-convert-subclasses.patch"
do_install_append_class-target() {
dir=${libdir}/python${PYTHON_MAJMIN}/email
OpenPOWER on IntegriCloud