Skip to content
Myr

made speedups c89 compatible.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Armin Ronacher · committed by Armin Ronacher · parent 57e25c0 · Browse files · 1 file+4 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+4 added−3 removed

  • other:+4 added−3 removed

1 file+4 added−3 removed

modified:jinja2/_speedups.c+4 added-3 removed
29 unmodified lines
3031static int32init_constants(void)33{34 PyObject *module;35 /* happing of characters to replace */36 escaped_chars_repl['"'] = UNICHR(""");37 escaped_chars_repl['\''] = UNICHR("'");38 escaped_chars_repl['&'] = UNICHR("&");
6 unmodified lines
45 escaped_chars_delta_len['&'] = 4;46 escaped_chars_delta_len['<'] = escaped_chars_delta_len['>'] = 3;47 48 /* import markup type so that we can mark the return value */48 PyObject *module = PyImport_ImportModule("jinja2.utils");49 module = PyImport_ImportModule("jinja2.utils");50 if (!module)51 return 0;52 markup = PyObject_GetAttrString(module, "Markup");53 Py_DECREF(module);
65 unmodified lines
119120static PyObject*121escape(PyObject *self, PyObject *text)122{122 PyObject *s = NULL, *rv = NULL;123 PyObject *s = NULL, *rv = NULL, *html;124125 /* we don't have to escape integers, bools or floats */126 if (PyInt_CheckExact(text) || PyLong_CheckExact(text) ||127 PyFloat_CheckExact(text) || PyBool_Check(text) ||128 text == Py_None)129 return PyObject_CallFunctionObjArgs(markup, text, NULL);130131 /* if the object has an __html__ method that performs the escaping */131 PyObject *html = PyObject_GetAttrString(text, "__html__");132 html = PyObject_GetAttrString(text, "__html__");133 if (html) {134 rv = PyObject_CallObject(html, NULL);135 Py_DECREF(html);136 return rv;
85 unmodified lines