Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 62728) +++ Objects/unicodeobject.c (working copy) @@ -8276,10 +8276,27 @@ static PyObject * unicode_mod(PyObject *v, PyObject *w) { + /* Used to ensure we don't apply the warning when called + recursively. Needed because the warning system will + call back into this function. */ + static int level = 0; + if (!PyUnicode_Check(v)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; } + + if (level == 0) { + int err; + ++level; + err = PyErr_WarnEx(PyExc_PendingDeprecationWarning, + "% formatting will be deprecated, " + "use .format() instead", 1); + --level; + if (err < 0) + return NULL; + } + return PyUnicode_Format(v, w); }