mercurial/formatter.py
branchstable
changeset 43335 242ad45b60b3
parent 43106 d783f945a701
child 43337 7e20b705da5b
--- a/mercurial/formatter.py	Sun Oct 27 18:12:24 2019 +0100
+++ b/mercurial/formatter.py	Sun Oct 27 12:30:59 2019 +0900
@@ -136,6 +136,16 @@
 pickle = util.pickle
 
 
+def isprintable(obj):
+    """Check if the given object can be directly passed in to formatter's
+    write() and data() functions
+
+    Returns False if the object is unsupported or must be pre-processed by
+    formatdate(), formatdict(), or formatlist().
+    """
+    return isinstance(obj, (type(None), bool, int, pycompat.long, float, bytes))
+
+
 class _nullconverter(object):
     '''convert non-primitive data types to be processed by formatter'''