# HG changeset patch
# User hodgestar
# Date 1312393407 0
# Node ID 5c7d69204287a276a5395db9e4ff2cc7b333da73
# Parent 303af96ec546f88fcc6010935fe774f11cf51258
Merge r1168 from trunk (fix error in dealing with None in the implemenation of Markup.escape in _speedups.c, see #439).
diff --git a/genshi/_speedups.c b/genshi/_speedups.c
--- a/genshi/_speedups.c
+++ b/genshi/_speedups.c
@@ -194,7 +194,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
@@ -86,6 +86,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