storage: don't track bytes/lists when converting pickles (#38863)
This commit is contained in:
parent
1668b6b7cc
commit
2e05d710c1
|
@ -111,21 +111,21 @@ def deep_bytes2str(obj, seen=None):
|
|||
seen = {}
|
||||
if obj is None or isinstance(obj, (int, float, str, time.struct_time, type(Ellipsis))):
|
||||
return obj
|
||||
if id(obj) in seen:
|
||||
return obj
|
||||
if isinstance(obj, bytes):
|
||||
try:
|
||||
return obj.decode('utf-8')
|
||||
except UnicodeDecodeError:
|
||||
return obj
|
||||
if isinstance(obj, list):
|
||||
return [deep_bytes2str(x, seen) for x in obj]
|
||||
if id(obj) in seen:
|
||||
return obj
|
||||
seen[id(obj)] = True
|
||||
if isinstance(obj, dict):
|
||||
new_d = {}
|
||||
for k, v in obj.items():
|
||||
new_d[force_str(k)] = deep_bytes2str(v, seen)
|
||||
return new_d
|
||||
if isinstance(obj, list):
|
||||
return [deep_bytes2str(x, seen) for x in obj]
|
||||
if hasattr(obj, '__class__') and obj.__class__.__module__.startswith(('wcs.', 'qommon.', 'modules.')):
|
||||
obj.__dict__ = deep_bytes2str(obj.__dict__, seen)
|
||||
return obj
|
||||
|
|
Loading…
Reference in New Issue