diff markup/template.py @ 206:d122ff386411

`TypeError`s raised by `py:def` macros (and other expressions producing streams) are no longer silently ignored. Closes #44.
author cmlenz
date Tue, 29 Aug 2006 10:56:33 +0000
parents 56f5e93edc48
children 835203f3b8fd
line wrap: on
line diff
--- a/markup/template.py
+++ b/markup/template.py
@@ -961,15 +961,16 @@
                     # Test if the expression evaluated to an iterable, in which
                     # case we yield the individual items
                     try:
-                        substream = _ensure(result)
+                        substream = _ensure(iter(result))
+                    except TypeError:
+                        # Neither a string nor an iterable, so just pass it
+                        # through
+                        yield TEXT, unicode(result), pos
+                    else:
                         for filter_ in filters:
                             substream = filter_(substream, ctxt)
                         for event in substream:
                             yield event
-                    except TypeError:
-                        # Neither a string nor an iterable, so just pass it
-                        # through
-                        yield TEXT, unicode(result), pos
 
             else:
                 yield kind, data, pos
Copyright (C) 2012-2017 Edgewall Software