On Wed, Jun 02, 2004 at 11:26:30PM -0400, Adam Preble wrote: > It seems to me that in 1.0b2 there's an inconsistency between > _c_htmltext and _py_htmltext when using the mod (%) operator to format > in a long integer. Namely, the _py_htmltext version handles it, while > _c_htmltext does not. Good catch. The fix is attached. Neil --- src/_c_htmltext.c (revision 24361) +++ src/_c_htmltext.c (working copy) @@ -130,6 +130,14 @@ quote_wrapper_new(PyObject *o) { QuoteWrapperObject *self; + if (htmltextObject_Check(o) || + PyInt_Check(o) || + PyFloat_Check(o) || + PyLong_Check(o)) { + /* no need for wrapper */ + Py_INCREF(o); + return o; + } self = PyObject_New(QuoteWrapperObject, &QuoteWrapper_Type); if (self == NULL) return NULL; @@ -148,48 +156,28 @@ static PyObject * quote_wrapper_repr(QuoteWrapperObject *self) { + PyObject *qs; PyObject *s = PyObject_Repr(self->obj); if (s == NULL) return NULL; - if (htmltextObject_Check(self->obj)) { - return s; - } - else { - PyObject *qs = escape_string(s); - Py_DECREF(s); - return qs; - } + qs = escape_string(s); + Py_DECREF(s); + return qs; } static PyObject * quote_wrapper_str(QuoteWrapperObject *self) { + PyObject *qs; PyObject *s = PyObject_Str(self->obj); if (s == NULL) return NULL; - if (htmltextObject_Check(self->obj)) { - return s; - } - else { - PyObject *qs = escape_string(s); - Py_DECREF(s); - return qs; - } + qs = escape_string(s); + Py_DECREF(s); + return qs; } static PyObject * -quote_wrapper_int(QuoteWrapperObject *self) -{ - return PyNumber_Int(self->obj); -} - -static PyObject * -quote_wrapper_float(QuoteWrapperObject *self) -{ - return PyNumber_Float(self->obj); -} - -static PyObject * dict_wrapper_new(PyObject *o) { DictWrapperObject *self; @@ -813,9 +801,9 @@ 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_coerce*/ - (unaryfunc)quote_wrapper_int, /*nb_int*/ + 0, /*nb_int*/ 0, /*nb_long*/ - (unaryfunc)quote_wrapper_float, /*nb_float*/ + 0, /*nb_float*/ }; static PyTypeObject QuoteWrapper_Type = {