117 static PyObject*
118 escape(PyObject *self, PyObject *text)
119 {
120 PyObject *s = NULL, *rv = NULL, *html;
121
122 /* we don't have to escape integers, bools or floats */
123 if (PyLong_CheckExact(text) ||
taking False path
taking False path
124 #if PY_MAJOR_VERSION < 3
125 PyInt_CheckExact(text) ||
taking False path
126 #endif
127 PyFloat_CheckExact(text) || PyBool_Check(text) ||
taking False path
taking False path
128 text == Py_None)
129 return PyObject_CallFunctionObjArgs(markup, text, NULL);
130
131 /* if the object has an __html__ method that performs the escaping */
132 html = PyObject_GetAttrString(text, "__html__");
when PyObject_GetAttrString() fails
133 if (html) {
taking False path
134 rv = PyObject_CallObject(html, NULL);
135 Py_DECREF(html);
136 return rv;
137 }
138
139 /* otherwise make the object unicode if it isn't, then escape */
140 PyErr_Clear();
calling PyErr_Clear()
141 if (!PyUnicode_Check(text)) {
when considering value == (long int)0 from markupsafe/_speedups.c:141
taking True path
142 #if PY_MAJOR_VERSION < 3
143 PyObject *unicode = PyObject_Unicode(text);
when PyObject_Unicode() succeeds
144 #else
145 PyObject *unicode = PyObject_Str(text);
146 #endif
147 if (!unicode)
taking False path
148 return NULL;
149 s = escape_unicode((PyUnicodeObject*)unicode);
when escape_unicode() fails
150 Py_DECREF(unicode);
when taking True path
151 }
152 else
153 s = escape_unicode((PyUnicodeObject*)text);
154
155 /* convert the unicode string into a markup object. */
156 rv = PyObject_CallFunctionObjArgs(markup, (PyObject*)s, NULL);
when PyObject_CallFunctionObjArgs() succeeds
157 Py_DECREF(s);
dereferencing NULL (s->ob_refcnt) at markupsafe/_speedups.c:157
found 5 similar trace(s) to this
158 return rv;
159 }