SVN: r25356 - in trunk/quixote: src test
Neil Schemenauer <nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected]> Thu, 14 Oct 2004 16:24:45 -0400
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: nascheme
Date: 2004-10-14 16:23:29 -0400 (Thu, 14 Oct 2004)
New Revision: 25356
Modified:
trunk/quixote/src/_c_htmltext.c
trunk/quixote/test/utest_html.py
Log:
Fix two bugs in _c_htmltext. First, htmltext_add should not force str
objects to become unicode. Second, htmltext_join needs to get the
items from the correct list.
Modified: trunk/quixote/src/_c_htmltext.c
===================================================================
--- trunk/quixote/src/_c_htmltext.c 2004-10-14 19:42:56 UTC (rev 25355)
+++ trunk/quixote/src/_c_htmltext.c 2004-10-14 20:23:29 UTC (rev 25356)
@@ -529,9 +529,16 @@
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
- rv = PyUnicode_Concat(qv, qw);
- Py_DECREF(qv);
- Py_DECREF(qw);
+ if (PyString_Check(qv)) {
+ PyString_ConcatAndDel(&qv, qw);
+ rv = qv;
+ }
+ else {
+ assert (PyUnicode_Check(qv));
+ rv = PyUnicode_Concat(qv, qw);
+ Py_DECREF(qv);
+ Py_DECREF(qw);
+ }
return htmltext_from_string(rv);
}
@@ -555,7 +562,7 @@
return NULL;
for (i=0; i < PyList_Size(quoted_args); i++) {
PyObject *value, *qvalue;
- value = PyList_GET_ITEM(args, i);
+ value = PyList_GET_ITEM(quoted_args, i);
if (value == NULL) {
goto error;
}
Modified: trunk/quixote/test/utest_html.py
===================================================================
--- trunk/quixote/test/utest_html.py 2004-10-14 19:42:56 UTC (rev 25355)
+++ trunk/quixote/test/utest_html.py 2004-10-14 20:23:29 UTC (rev 25356)
@@ -110,6 +110,10 @@
1 + s
assert 0
except TypeError: pass
+ # mixing unicode and str
+ assert repr(htmltext('a') + htmltext('b')) == "<htmltext 'ab'>"
+ assert repr(htmltext(u'a') + htmltext('b')) == "<htmltext u'ab'>"
+ assert repr(htmltext('a') + htmltext(u'b')) == "<htmltext u'ab'>"
def check_repeat(self):
s = htmltext('a')