Mercurial > public > mercurial-scm > hg-stable
diff mercurial/formatter.py @ 43335:242ad45b60b3 stable
config: fix -Tjson to not crash due to unsupported defaultvalue types
Maybe it isn't great to ignore unsupported types at all, but otherwise
"hg config -Tjson" would crash.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 27 Oct 2019 12:30:59 +0900 |
parents | d783f945a701 |
children | 7e20b705da5b |
line wrap: on
line diff
--- 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'''