Patchwork [1,of,4] templatefilters: drop callable support from json()

login
register
mail settings
Submitter Yuya Nishihara
Date April 2, 2017, 3:28 a.m.
Message ID <80483134bdbaeb72809a.1491103701@mimosa>
Download mbox | patch
Permalink /patch/19901/
State Accepted
Headers show

Comments

Yuya Nishihara - April 2, 2017, 3:28 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1491101209 -32400
#      Sun Apr 02 11:46:49 2017 +0900
# Node ID 80483134bdbaeb72809a3e9683a263c7e166b3c8
# Parent  35eb8f112c88669ba3297de16a9acc289aacfdcd
templatefilters: drop callable support from json()

This backs out ae5447de4c11. A callable should be evaluated beforehand
by templater.runsymbol().

Patch

diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py
--- a/mercurial/templatefilters.py
+++ b/mercurial/templatefilters.py
@@ -236,8 +236,6 @@  def json(obj):
         for i in obj:
             out.append(json(i))
         return '[' + ', '.join(out) + ']'
-    elif util.safehasattr(obj, '__call__'):
-        return json(obj())
     else:
         raise TypeError('cannot encode type %s' % obj.__class__.__name__)