From 62113fc6dabec39f06a1f86f4ea6f73975f0acdf Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sun, 2 Mar 2014 05:12:14 +0100 Subject: [PATCH] Fixed stringwrap iteration bug. --- wrw/util.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/wrw/util.py b/wrw/util.py index 8eed5a0..7c42eae 100644 --- a/wrw/util.py +++ b/wrw/util.py @@ -7,16 +7,6 @@ def wsgiwrap(callable): wrapper.__wrapped__ = callable return wrapper -def stringwrap(charset): - def dec(callable): - def wrapper(*args, **kwargs): - bk = callable(*args, **kwargs) - for string in bk: - yield string.encode(charset) - wrapper.__wrapped__ = callable - return wrapper - return dec - def formparams(callable): spec = inspect.getargspec(callable) def wrapper(req): @@ -120,6 +110,16 @@ def pregen(callable): wrapper.__wrapped__ = callable return wrapper +def stringwrap(charset): + def dec(callable): + @pregen + def wrapper(*args, **kwargs): + for string in callable(*args, **kwargs): + yield string.encode(charset) + wrapper.__wrapped__ = callable + return wrapper + return dec + class sessiondata(object): @classmethod def get(cls, req, create=True): -- 2.11.0