[server/schemaserial] fix extra_props on py3k
authorJulien Cristau <julien.cristau@logilab.fr>
Tue, 13 Oct 2015 11:34:37 +0200
changeset 10789 d5671a61f281
parent 10788 416840faf119
child 10790 117a6bbefbfd
[server/schemaserial] fix extra_props on py3k json.dumps returns unicode, and json.load eats unicode, so add explicit encoding/decoding.
server/schemaserial.py
--- a/server/schemaserial.py	Tue Oct 13 11:30:48 2015 +0200
+++ b/server/schemaserial.py	Tue Oct 13 11:34:37 2015 +0200
@@ -243,7 +243,7 @@
              'order', 'description', 'indexed', 'fulltextindexed',
              'internationalizable', 'default', 'formula'), values))
         typeparams = extra_props.get(attrs['rdefeid'])
-        attrs.update(json.load(typeparams) if typeparams else {})
+        attrs.update(json.loads(typeparams.getvalue().decode('ascii')) if typeparams else {})
         default = attrs['default']
         if default is not None:
             if isinstance(default, Binary):
@@ -590,7 +590,7 @@
             value = Binary.zpickle(value)
         values[amap.get(prop, prop)] = value
     if extra:
-        values['extra_props'] = Binary(json.dumps(extra))
+        values['extra_props'] = Binary(json.dumps(extra).encode('ascii'))
     relations = ['X %s %%(%s)s' % (attr, attr) for attr in sorted(values)]
     return relations, values