summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2008-09-02 02:46:59 (GMT)
committerBrett Cannon <bcannon@gmail.com>2008-09-02 02:46:59 (GMT)
commitec92e181fb912e9dc0935fc10bd61bfd4fb237d7 (patch)
tree8999cbe9dd96050511ae253f6bfc3f14183c734f /Python
parent3a2bd7d5c5c4af6e7916823d107e524c7f5aaa5a (diff)
downloadcpython-ec92e181fb912e9dc0935fc10bd61bfd4fb237d7.zip
cpython-ec92e181fb912e9dc0935fc10bd61bfd4fb237d7.tar.gz
cpython-ec92e181fb912e9dc0935fc10bd61bfd4fb237d7.tar.bz2
Merge in r66135. Doing also required removing a stale DeprecationWarning along
with moving warnings.catch_warnings() over to keyword-only parameters for its constructor (as documented in the 2.6 docs).
Diffstat (limited to 'Python')
-rw-r--r--Python/_warnings.c54
1 files changed, 14 insertions, 40 deletions
diff --git a/Python/_warnings.c b/Python/_warnings.c
index fd3f629..a08219e 100644
--- a/Python/_warnings.c
+++ b/Python/_warnings.c
@@ -386,49 +386,23 @@ warn_explicit(PyObject *category, PyObject *message,
show_warning(filename, lineno, text, category, sourceline);
}
else {
- const char *msg = "functions overriding warnings.showwarning() "
- "must support the 'line' argument";
- const char *text_char = _PyUnicode_AsString(text);
-
- if (strcmp(msg, text_char) == 0) {
- /* Prevent infinite recursion by using built-in implementation
- of showwarning(). */
- show_warning(filename, lineno, text, category, sourceline);
- }
- else {
- PyObject *check_fxn;
- PyObject *defaults;
- PyObject *res;
-
- if (PyMethod_Check(show_fxn))
- check_fxn = PyMethod_Function(show_fxn);
- else if (PyFunction_Check(show_fxn))
- check_fxn = show_fxn;
- else {
- PyErr_SetString(PyExc_TypeError,
- "warnings.showwarning() must be set to a "
- "function or method");
- Py_DECREF(show_fxn);
- goto cleanup;
- }
+ PyObject *res;
- defaults = PyFunction_GetDefaults(check_fxn);
- /* 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;
- }
- }
- res = PyObject_CallFunctionObjArgs(show_fxn, message, category,
- filename, lineno_obj,
- NULL);
+ if (!PyMethod_Check(show_fxn) && !PyFunction_Check(show_fxn)) {
+ PyErr_SetString(PyExc_TypeError,
+ "warnings.showwarning() must be set to a "
+ "function or method");
Py_DECREF(show_fxn);
- Py_XDECREF(res);
- if (res == NULL)
- goto cleanup;
+ goto cleanup;
}
+
+ res = PyObject_CallFunctionObjArgs(show_fxn, message, category,
+ filename, lineno_obj,
+ NULL);
+ Py_DECREF(show_fxn);
+ Py_XDECREF(res);
+ if (res == NULL)
+ goto cleanup;
}
}
else /* if (rc == -1) */