From d9318e9bed0ee65db6ab6b58b1d8d0ab997bc578 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 22 Dec 2019 21:22:55 -0500 Subject: [PATCH] Fix up better_repr tuple and list for singletions --- uncompyle6/util.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/uncompyle6/util.py b/uncompyle6/util.py index 7348aac5..12a60175 100644 --- a/uncompyle6/util.py +++ b/uncompyle6/util.py @@ -30,8 +30,13 @@ def better_repr(v): # The below is however round-tripable, and Python's repr() isn't. return "complex(%s, %s)" % (real, imag) elif isinstance(v, tuple): + if len(v) == 1: + return "(%s,)" % better_repr(v[0]) return "(%s)" % ", ".join(better_repr(i) for i in v) elif isinstance(v, list): + l = better_repr(v) + if len(v) == 1: + return "[%s,]" % better_repr(v[0]) return "[%s]" % ", ".join(better_repr(i) for i in v) # TODO: elif deal with sets and dicts else: