Ticket #202: ticket202.diff
| File ticket202.diff, 2.2 KB (added by cmlenz, 16 years ago) |
|---|
-
genshi/core.py
444 444 def __repr__(self): 445 445 return '<%s %r>' % (self.__class__.__name__, unicode(self)) 446 446 447 def __html__(self): 448 return self 449 447 450 def join(self, seq, escape_quotes=True): 448 451 """Return a `Markup` object which is the concatenation of the strings 449 452 in the given sequence, where this `Markup` object is the separator … … 486 489 return cls() 487 490 if type(text) is cls: 488 491 return text 492 if hasattr(text, '__html__'): 493 return Markup(text.__html__()) 494 489 495 text = unicode(text).replace('&', '&') \ 490 496 .replace('<', '<') \ 491 497 .replace('>', '>') -
genshi/_speedups.c
55 55 Py_INCREF(text); 56 56 return text; 57 57 } 58 if (PyObject_HasAttrString(text, "__html__")) { 59 ret = PyObject_CallMethod(text, "__html__", NULL); 60 Py_INCREF(ret); 61 args = PyTuple_New(1); 62 if (args == NULL) { 63 Py_DECREF(ret); 64 return NULL; 65 } 66 PyTuple_SET_ITEM(args, 0, ret); 67 ret = MarkupType.tp_new(&MarkupType, args, NULL); 68 Py_DECREF(args); 69 return ret; 70 } 58 71 in = (PyUnicodeObject *) PyObject_Unicode(text); 59 72 if (in == NULL) { 60 73 return NULL; … … 184 197 return self; 185 198 } 186 199 200 static PyObject * 201 Markup_html(PyObject *self) 202 { 203 Py_INCREF(self); 204 return self; 205 } 206 187 207 PyDoc_STRVAR(escape__doc__, 188 208 "Create a Markup instance from a string and escape special characters\n\ 189 209 it may contain (<, >, & and \").\n\ … … 521 541 } MarkupObject; 522 542 523 543 static PyMethodDef Markup_methods[] = { 544 {"__html__", (PyCFunction) Markup_html, METH_NOARGS, NULL}, 524 545 {"escape", (PyCFunction) Markup_escape, 525 546 METH_VARARGS|METH_CLASS|METH_KEYWORDS, escape__doc__}, 526 547 {"join", (PyCFunction)Markup_join, METH_VARARGS|METH_KEYWORDS, join__doc__},
