Mercurial > cpython-lru_cache-weakref
diff Objects/moduleobject.c @ 63949:fa2d9720a66c
Issue #9425: Create PyErr_WarnFormat() function
Similar to PyErr_WarnEx() but use PyUnicode_FromFormatV() to format the warning
message.
Strip also some trailing spaces.
| author | Victor Stinner <victor.stinner@haypocalc.com> |
|---|---|
| date | Fri, 13 Aug 2010 14:03:48 +0000 |
| parents | 7fc48ad16087 |
| children | ee765a67c0b1 |
line wrap: on
line diff
--- a/Objects/moduleobject.c Fri Aug 13 13:47:18 2010 +0000 +++ b/Objects/moduleobject.c Fri Aug 13 14:03:48 2010 +0000 @@ -56,10 +56,6 @@ return NULL; } -static char api_version_warning[] = -"Python C API version mismatch for module %.100s:\ - This Python has API version %d, module %.100s has version %d."; - PyObject * PyModule_Create2(struct PyModuleDef* module, int module_api_version) { @@ -79,12 +75,13 @@ } name = module->m_name; if (module_api_version != PYTHON_API_VERSION) { - char message[512]; - PyOS_snprintf(message, sizeof(message), - api_version_warning, name, - PYTHON_API_VERSION, name, - module_api_version); - if (PyErr_WarnEx(PyExc_RuntimeWarning, message, 1)) + int err; + err = PyErr_WarnFormat(PyExc_RuntimeWarning, 1, + "Python C API version mismatch for module %.100s: " + "This Python has API version %d, module %.100s has version %d.", + name, + PYTHON_API_VERSION, name, module_api_version); + if (err) return NULL; } /* Make sure name is fully qualified.
