[svn] fixed bug in replace filter discovered by ronny
authorArmin Ronacher <armin.ronacher@active-4.com>
Mon, 2 Apr 2007 08:50:18 +0000 (10:50 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Mon, 2 Apr 2007 08:50:18 +0000 (10:50 +0200)
--HG--
branch : trunk

jinja/filters.py

index 4cb2661ef37d4c6a96ad18688c28e6a3c19109a1..197dd3eab3c0f612a2ff1f73152978e32837b1ba 100644 (file)
@@ -70,12 +70,12 @@ def do_replace(s, old, new, count=None):
        not isinstance(new, basestring):
         raise FilterArgumentError('the replace filter requires '
                                   'string replacement arguments')
-    elif not isinstance(count, (int, long)):
+    if count is None:
+        return s.replace(old, new)
+    if not isinstance(count, (int, long)):
         raise FilterArgumentError('the count parameter of the '
                                    'replace filter requires '
                                    'an integer')
-    if count is None:
-        return s.replace(old, new)
     return s.replace(old, new, count)
 do_replace = stringfilter(do_replace)