You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Fix up better_repr tuple and list for singletions
This commit is contained in:
@@ -30,8 +30,13 @@ def better_repr(v):
|
|||||||
# The below is however round-tripable, and Python's repr() isn't.
|
# The below is however round-tripable, and Python's repr() isn't.
|
||||||
return "complex(%s, %s)" % (real, imag)
|
return "complex(%s, %s)" % (real, imag)
|
||||||
elif isinstance(v, tuple):
|
elif isinstance(v, tuple):
|
||||||
|
if len(v) == 1:
|
||||||
|
return "(%s,)" % better_repr(v[0])
|
||||||
return "(%s)" % ", ".join(better_repr(i) for i in v)
|
return "(%s)" % ", ".join(better_repr(i) for i in v)
|
||||||
elif isinstance(v, list):
|
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)
|
return "[%s]" % ", ".join(better_repr(i) for i in v)
|
||||||
# TODO: elif deal with sets and dicts
|
# TODO: elif deal with sets and dicts
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user