diff options
author | Brett Cannon <bcannon@gmail.com> | 2008-09-02 01:25:16 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2008-09-02 01:25:16 (GMT) |
commit | 1eaf0742d877fd9d84d6ed82a04bc33b027e9ad0 (patch) | |
tree | 1c1ee3a5dee04f5f4657b707e9d54ca2e28b1505 /Python | |
parent | 86533776c291c031853609ceaeda96eb2808e4ee (diff) | |
download | cpython-1eaf0742d877fd9d84d6ed82a04bc33b027e9ad0.zip cpython-1eaf0742d877fd9d84d6ed82a04bc33b027e9ad0.tar.gz cpython-1eaf0742d877fd9d84d6ed82a04bc33b027e9ad0.tar.bz2 |
Move test.test_support.catch_warning() to the warnings module, rename it
catch_warnings(), and clean up the API.
While expanding the test suite, a bug was found where a warning about the
'line' argument to showwarning() was not letting functions with '*args' go
without a warning.
Closes issue 3602.
Code review by Benjamin Peterson.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/_warnings.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c index 5ed8b55..331ad6c 100644 --- a/Python/_warnings.c +++ b/Python/_warnings.c @@ -1,4 +1,5 @@ #include "Python.h" +#include "code.h" /* For DeprecationWarning about adding 'line'. */ #include "frameobject.h" #define MODULE_NAME "_warnings" @@ -416,11 +417,16 @@ warn_explicit(PyObject *category, PyObject *message, /* A proper implementation of warnings.showwarning() should have at least two default arguments. */ if ((defaults == NULL) || (PyTuple_Size(defaults) < 2)) { - if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1) < 0) { - Py_DECREF(show_fxn); - goto cleanup; + PyCodeObject *code = (PyCodeObject *) + PyFunction_GetCode(check_fxn); + if (!(code->co_flags & CO_VARARGS)) { + if (PyErr_WarnEx(PyExc_DeprecationWarning, msg, 1) < + 0) { + Py_DECREF(show_fxn); + goto cleanup; + } } - } + } res = PyObject_CallFunctionObjArgs(show_fxn, message, category, filename, lineno_obj, NULL); |