use alternative for all falsey values in format strings
… and not just None (#525) It would be better to consistently use None for all non-existent fields and/or fields without a valid value, but this is a good enough workaround for now.
This commit is contained in:
@@ -646,7 +646,7 @@ class Formatter():
|
|||||||
obj = kwdict[key]
|
obj = kwdict[key]
|
||||||
for func in funcs:
|
for func in funcs:
|
||||||
obj = func(obj)
|
obj = func(obj)
|
||||||
if obj is not None:
|
if obj:
|
||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ class TestFormatter(unittest.TestCase):
|
|||||||
self._run_test("{z|a!C:RH/C/}", "Cello World")
|
self._run_test("{z|a!C:RH/C/}", "Cello World")
|
||||||
self._run_test("{z|y|x:?</>/}", "")
|
self._run_test("{z|y|x:?</>/}", "")
|
||||||
|
|
||||||
self._run_test("{d[c]|d[b]|d[a]}", "0")
|
self._run_test("{d[c]|d[b]|d[a]}", "foo")
|
||||||
self._run_test("{d[a]|d[b]|d[c]}", "foo")
|
self._run_test("{d[a]|d[b]|d[c]}", "foo")
|
||||||
self._run_test("{d[z]|d[y]|d[x]}", "None")
|
self._run_test("{d[z]|d[y]|d[x]}", "None")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user