From 3d90561038a74afc563ae464856ceedcfad418b3 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 9 Jan 2020 15:10:59 +0100 Subject: [PATCH 01/11] storage: handle tuple likes in deep_bytes2str It fixes a throws with wcs.wf.create_formdata.Mapping which is a collections.mamedtuple(). --- wcs/qommon/storage.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/wcs/qommon/storage.py b/wcs/qommon/storage.py index 4c8ce59a..73161004 100644 --- a/wcs/qommon/storage.py +++ b/wcs/qommon/storage.py @@ -122,6 +122,10 @@ def deep_bytes2str(obj, seen=None): return obj if isinstance(obj, list): return [deep_bytes2str(x, seen) for x in obj] + if type(obj) is tuple: # real tuple + return type(obj)(deep_bytes2str(x, seen) for x in obj) + elif isinstance(obj, tuple) and hasattr(type(obj), '_replace'): # namedtuple + return type(obj)(*[deep_bytes2str(x, seen) for x in obj]) if id(obj) in seen: return obj seen[id(obj)] = True -- 2.24.0