# HG changeset patch # User hodgestar # Date 1312393117 0 # Node ID 657f9ecffa3cd9bed14997584de54c7c3351a62b # Parent 2eb4b394709c085a7e8c6b967fa0ee41c32eb242 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. diff --git a/genshi/_speedups.c b/genshi/_speedups.c --- 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); diff --git a/genshi/tests/core.py b/genshi/tests/core.py --- 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('foo') + '
' assert type(markup) is Markup