changeset 39296:ce145f8eface

stringutil: teach pprint() to recognize generators Otherwise they get serialized as e.g. <generator object X at 0x7f543d3d68c0> Differential Revision: https://phab.mercurial-scm.org/D4396
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 22 Aug 2018 11:58:36 -0700
parents 3a60416c4fd8
children 06c976acc581
files mercurial/utils/stringutil.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)