summaryrefslogtreecommitdiffstats
path: root/Objects/moduleobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-08-13 14:03:48 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-08-13 14:03:48 (GMT)
commit4a2b7a1b141fcbed6da81d942c9db776874c2fa9 (patch)
tree0288e22145e35c9d5d92c051800bf1c85e5858b8 /Objects/moduleobject.c
parentb4b8eb916372dcb566740455122a28b5ed9631f9 (diff)
downloadcpython-4a2b7a1b141fcbed6da81d942c9db776874c2fa9.zip
cpython-4a2b7a1b141fcbed6da81d942c9db776874c2fa9.tar.gz
cpython-4a2b7a1b141fcbed6da81d942c9db776874c2fa9.tar.bz2
Issue #9425: Create PyErr_WarnFormat() function
Similar to PyErr_WarnEx() but use PyUnicode_FromFormatV() to format the warning message. Strip also some trailing spaces.
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r--Objects/moduleobject.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 6c6eac1..7b8e1b6 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -56,10 +56,6 @@ PyModule_New(const char *name)
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 @@ PyModule_Create2(struct PyModuleDef* module, int module_api_version)
}
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.