stringutil: teach pprint() to recognize generators
Otherwise they get serialized as e.g.
<generator object X at 0x
7f543d3d68c0>
Differential Revision: https://phab.mercurial-scm.org/D4396
--- a/mercurial/utils/stringutil.py Mon Aug 27 16:03:00 2018 -0400
+++ b/mercurial/utils/stringutil.py Wed Aug 22 11:58:36 2018 -0700
@@ -13,6 +13,7 @@
import codecs
import re as remod
import textwrap
+import types
from ..i18n import _
from ..thirdparty import attr
@@ -64,6 +65,8 @@
pprint(k, bprefix=bprefix) for k in sorted(o)))
elif isinstance(o, tuple):
return '(%s)' % (b', '.join(pprint(a, bprefix=bprefix) for a in o))
+ elif isinstance(o, types.GeneratorType):
+ return 'gen[%s]' % (b', '.join(pprint(a, bprefix=bprefix) for a in o))
else:
return pycompat.byterepr(o)