Mercurial > genshi > mirror
changeset 943:657f9ecffa3c trunk
Fix bug in _speedups where it differed from behaviour of Python implementation and add a test for this case (fixes #439). Fix and test contributed by cboos.
author | hodgestar |
---|---|
date | Wed, 03 Aug 2011 17:38:37 +0000 |
parents | 2eb4b394709c |
children | d1edb246cc61 |
files | genshi/_speedups.c genshi/tests/core.py |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/genshi/_speedups.c +++ b/genshi/_speedups.c @@ -201,7 +201,12 @@ return NULL; } if (PyObject_Not(text)) { - return type->tp_new(type, args, NULL); + args = PyTuple_New(0); + if (args == NULL) + return NULL; + text = type->tp_new(type, args, NULL); + Py_DECREF(args); + return text; } if (PyObject_TypeCheck(text, type)) { Py_INCREF(text);
--- a/genshi/tests/core.py +++ b/genshi/tests/core.py @@ -84,6 +84,11 @@ assert type(markup) is Markup self.assertEquals(string, unescape(markup)) + def test_Markup_escape_None_noquotes(self): + markup = Markup.escape(None, False) + assert type(markup) is Markup + self.assertEquals('', markup) + def test_add_str(self): markup = Markup('<b>foo</b>') + '<br/>' assert type(markup) is Markup