misc: repair dictionary attributes left as bytes (#39318)

This commit is contained in:
Frédéric Péters 2020-01-28 10:39:33 +01:00
parent 7a663969bf
commit 7bcdac0413
1 changed files with 10 additions and 0 deletions

View File

@ -409,6 +409,16 @@ class Field(object):
self.display_locations.append('listings')
changed = True
self.in_listing = None
if six.PY3:
# repair dictionary attributes that may have been kept as bytes in
# the initial python 2 -> 3 conversion.
from wcs.qommon.storage import deep_bytes2str
for key in ('prefill', 'data_source'):
value = getattr(self, key, None)
if not value:
continue
if b'type' in value:
setattr(self, key, deep_bytes2str(getattr(self, key)))
return changed
def evaluate_condition(self, dict_vars, formdef, condition):