SVN: r20289 - in trunk/quixote: src test
nascheme-fVcApmY9cLvQ3/1i3zOLAti2O/[email protected] Mon, 20 Jan 2003 14:54:42 -0500
| Newsgroups | gmane.comp.web.quixote.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: nascheme
Date: 2003-01-20 14:54:41 -0500 (Mon, 20 Jan 2003)
New Revision: 20289
Modified:
trunk/quixote/src/_c_htmltext.c
trunk/quixote/test/test_html.py
Log:
A code review found to bugs. Handle broken repr methods when quoting format
arguments. Expand the unit tests to check this. Fix assert in TemplateIO
concat function.
Modified: trunk/quixote/src/_c_htmltext.c
==============================================================================
--- trunk/quixote/src/_c_htmltext.c (original)
+++ trunk/quixote/src/_c_htmltext.c 2003-01-20 14:54:42.000000000 -0500
@@ -138,6 +138,8 @@
quote_wrapper_repr(QuoteWrapperObject *self)
{
PyObject *s = PyObject_Repr(self->obj);
+ if (s == NULL)
+ return NULL;
if (htmltextObject_Check(self->obj)) {
return s;
}
@@ -256,18 +258,18 @@
} else if (htmltextObject_Check(a)) {
sa = htmltext_STR(a);
} else {
- goto out;
+ goto fail;
}
if (PyString_Check(b)) {
sb = b;
} else if (htmltextObject_Check(b)) {
sb = htmltext_STR(b);
} else {
- goto out;
+ goto fail;
}
return sa->ob_type->tp_richcompare(sa, sb, op);
-out:
+fail:
Py_INCREF(Py_NotImplemented);
return Py_NotImplemented;
}
@@ -606,7 +608,7 @@
self->buf = new_buf;
self->size = new_size;
}
- assert (self->pos + size < self->size);
+ assert (self->pos + size <= self->size);
memcpy(self->buf + self->pos, s, size);
self->pos += size;
Py_INCREF(self);
Modified: trunk/quixote/test/test_html.py
==============================================================================
--- trunk/quixote/test/test_html.py (original)
+++ trunk/quixote/test/test_html.py 2003-01-20 14:54:42.000000000 -0500
@@ -103,6 +103,7 @@
self.test_val("htmltext('%d') % 10", "10")
self.test_val("htmltext('%.1f') % 10", "10.0")
self.test_exc("s_fmt % Broken()", RuntimeError)
+ self.test_exc("htmltext('%r') % Broken()", RuntimeError)
self.test_exc("s_fmt % (1, 2)", TypeError)
def check_dict_format (self):