mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
PyErr_Warn is deprecated in 2.5 - goes away for 3.0
This commit is contained in:
parent
447e7c3981
commit
46fc337395
11 changed files with 40 additions and 55 deletions
|
@ -296,16 +296,6 @@ error indicator for each thread.
|
||||||
command line documentation. There is no C API for warning control.
|
command line documentation. There is no C API for warning control.
|
||||||
\end{cfuncdesc}
|
\end{cfuncdesc}
|
||||||
|
|
||||||
\begin{cfuncdesc}{int}{PyErr_Warn}{PyObject *category, char *message}
|
|
||||||
Issue a warning message. The \var{category} argument is a warning
|
|
||||||
category (see below) or \NULL; the \var{message} argument is a
|
|
||||||
message string. The warning will appear to be issued from the function
|
|
||||||
calling \cfunction{PyErr_Warn()}, equivalent to calling
|
|
||||||
\cfunction{PyErr_WarnEx()} with a \var{stacklevel} of 1.
|
|
||||||
|
|
||||||
Deprecated; use \cfunction{PyErr_WarnEx()} instead.
|
|
||||||
\end{cfuncdesc}
|
|
||||||
|
|
||||||
\begin{cfuncdesc}{int}{PyErr_WarnExplicit}{PyObject *category,
|
\begin{cfuncdesc}{int}{PyErr_WarnExplicit}{PyObject *category,
|
||||||
const char *message, const char *filename, int lineno,
|
const char *message, const char *filename, int lineno,
|
||||||
const char *module, PyObject *registry}
|
const char *module, PyObject *registry}
|
||||||
|
|
|
@ -213,9 +213,6 @@ PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg,
|
||||||
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
|
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
|
||||||
const char *, int,
|
const char *, int,
|
||||||
const char *, PyObject *);
|
const char *, PyObject *);
|
||||||
/* PyErr_Warn is only for backwards compatability and will be removed.
|
|
||||||
Use PyErr_WarnEx instead. */
|
|
||||||
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
|
|
||||||
|
|
||||||
/* In sigcheck.c or signalmodule.c */
|
/* In sigcheck.c or signalmodule.c */
|
||||||
PyAPI_FUNC(int) PyErr_CheckSignals(void);
|
PyAPI_FUNC(int) PyErr_CheckSignals(void);
|
||||||
|
|
|
@ -546,7 +546,7 @@ static int makeDBError(int err)
|
||||||
}
|
}
|
||||||
_db_errmsg[0] = 0;
|
_db_errmsg[0] = 0;
|
||||||
#ifdef HAVE_WARNINGS
|
#ifdef HAVE_WARNINGS
|
||||||
exceptionRaised = PyErr_Warn(PyExc_RuntimeWarning, errTxt);
|
exceptionRaised = PyErr_WarnEx(PyExc_RuntimeWarning, errTxt, 1);
|
||||||
#else
|
#else
|
||||||
fprintf(stderr, errTxt);
|
fprintf(stderr, errTxt);
|
||||||
fprintf(stderr, "\n");
|
fprintf(stderr, "\n");
|
||||||
|
@ -859,8 +859,10 @@ DB_dealloc(DBObject* self)
|
||||||
MYDB_END_ALLOW_THREADS;
|
MYDB_END_ALLOW_THREADS;
|
||||||
#ifdef HAVE_WARNINGS
|
#ifdef HAVE_WARNINGS
|
||||||
} else {
|
} else {
|
||||||
PyErr_Warn(PyExc_RuntimeWarning,
|
PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||||
"DB could not be closed in destructor: DBEnv already closed");
|
"DB could not be closed in destructor:"
|
||||||
|
" DBEnv already closed",
|
||||||
|
1);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
self->db = NULL;
|
self->db = NULL;
|
||||||
|
@ -1031,8 +1033,10 @@ DBTxn_dealloc(DBTxnObject* self)
|
||||||
txn_abort(self->txn);
|
txn_abort(self->txn);
|
||||||
#endif
|
#endif
|
||||||
MYDB_END_ALLOW_THREADS;
|
MYDB_END_ALLOW_THREADS;
|
||||||
PyErr_Warn(PyExc_RuntimeWarning,
|
PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||||
"DBTxn aborted in destructor. No prior commit() or abort().");
|
"DBTxn aborted in destructor. "
|
||||||
|
" No prior commit() or abort().",
|
||||||
|
1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -225,8 +225,9 @@ if (x == NULL) _AddTraceback(what, __FILE__, __LINE__ - 1), PyErr_Print()
|
||||||
else if (keep == Py_None) /* Nothing to keep */
|
else if (keep == Py_None) /* Nothing to keep */
|
||||||
Py_DECREF(keep);
|
Py_DECREF(keep);
|
||||||
else if (setfunc != getentry("O")->setfunc) {
|
else if (setfunc != getentry("O")->setfunc) {
|
||||||
if (-1 == PyErr_Warn(PyExc_RuntimeWarning,
|
if (-1 == PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||||
"memory leak in callback function."))
|
"memory leak in callback function.",
|
||||||
|
1))
|
||||||
PyErr_WriteUnraisable(callable);
|
PyErr_WriteUnraisable(callable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -998,8 +998,9 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
|
||||||
XXX: fileno == 0 is a valid fd, but was accepted prior to 2.5.
|
XXX: fileno == 0 is a valid fd, but was accepted prior to 2.5.
|
||||||
XXX: Should this code be added?
|
XXX: Should this code be added?
|
||||||
if (fileno == 0)
|
if (fileno == 0)
|
||||||
PyErr_Warn(PyExc_DeprecationWarning,
|
PyErr_WarnEx(PyExc_DeprecationWarning,
|
||||||
"don't use 0 for anonymous memory");
|
"don't use 0 for anonymous memory",
|
||||||
|
1);
|
||||||
*/
|
*/
|
||||||
if (fileno != -1 && fileno != 0) {
|
if (fileno != -1 && fileno != 0) {
|
||||||
fh = (HANDLE)_get_osfhandle(fileno);
|
fh = (HANDLE)_get_osfhandle(fileno);
|
||||||
|
|
|
@ -5344,8 +5344,9 @@ posix_tempnam(PyObject *self, PyObject *args)
|
||||||
if (!PyArg_ParseTuple(args, "|zz:tempnam", &dir, &pfx))
|
if (!PyArg_ParseTuple(args, "|zz:tempnam", &dir, &pfx))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (PyErr_Warn(PyExc_RuntimeWarning,
|
if (PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||||
"tempnam is a potential security risk to your program") < 0)
|
"tempnam is a potential security risk to your program",
|
||||||
|
1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
|
@ -5391,8 +5392,9 @@ posix_tmpnam(PyObject *self, PyObject *noargs)
|
||||||
char buffer[L_tmpnam];
|
char buffer[L_tmpnam];
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
if (PyErr_Warn(PyExc_RuntimeWarning,
|
if (PyErr_WarnEx(PyExc_RuntimeWarning,
|
||||||
"tmpnam is a potential security risk to your program") < 0)
|
"tmpnam is a potential security risk to your program",
|
||||||
|
1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#ifdef USE_TMPNAM_R
|
#ifdef USE_TMPNAM_R
|
||||||
|
|
|
@ -5990,15 +5990,16 @@ PyObject *PyUnicode_RichCompare(PyObject *left,
|
||||||
if (!PyErr_ExceptionMatches(PyExc_UnicodeDecodeError))
|
if (!PyErr_ExceptionMatches(PyExc_UnicodeDecodeError))
|
||||||
return NULL;
|
return NULL;
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (PyErr_Warn(PyExc_UnicodeWarning,
|
if (PyErr_WarnEx(PyExc_UnicodeWarning,
|
||||||
(op == Py_EQ) ?
|
(op == Py_EQ) ?
|
||||||
"Unicode equal comparison "
|
"Unicode equal comparison "
|
||||||
"failed to convert both arguments to Unicode - "
|
"failed to convert both arguments to Unicode - "
|
||||||
"interpreting them as being unequal" :
|
"interpreting them as being unequal"
|
||||||
"Unicode unequal comparison "
|
:
|
||||||
"failed to convert both arguments to Unicode - "
|
"Unicode unequal comparison "
|
||||||
"interpreting them as being unequal"
|
"failed to convert both arguments to Unicode - "
|
||||||
) < 0)
|
"interpreting them as being unequal",
|
||||||
|
1) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
result = (op == Py_NE);
|
result = (op == Py_NE);
|
||||||
return PyBool_FromLong(result);
|
return PyBool_FromLong(result);
|
||||||
|
|
|
@ -670,17 +670,6 @@ PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* PyErr_Warn is only for backwards compatability and will be removed.
|
|
||||||
Use PyErr_WarnEx instead. */
|
|
||||||
|
|
||||||
#undef PyErr_Warn
|
|
||||||
|
|
||||||
PyAPI_FUNC(int)
|
|
||||||
PyErr_Warn(PyObject *category, char *message)
|
|
||||||
{
|
|
||||||
return PyErr_WarnEx(category, message, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Warning with explicit origin */
|
/* Warning with explicit origin */
|
||||||
int
|
int
|
||||||
PyErr_WarnExplicit(PyObject *category, const char *message,
|
PyErr_WarnExplicit(PyObject *category, const char *message,
|
||||||
|
|
|
@ -1320,8 +1320,8 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
|
||||||
sprintf(warnstr, "Not importing directory "
|
sprintf(warnstr, "Not importing directory "
|
||||||
"'%.*s': missing __init__.py",
|
"'%.*s': missing __init__.py",
|
||||||
MAXPATHLEN, buf);
|
MAXPATHLEN, buf);
|
||||||
if (PyErr_Warn(PyExc_ImportWarning,
|
if (PyErr_WarnEx(PyExc_ImportWarning,
|
||||||
warnstr)) {
|
warnstr, 1)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1339,8 +1339,8 @@ find_module(char *fullname, char *subname, PyObject *path, char *buf,
|
||||||
sprintf(warnstr, "Not importing directory "
|
sprintf(warnstr, "Not importing directory "
|
||||||
"'%.*s': missing __init__.py",
|
"'%.*s': missing __init__.py",
|
||||||
MAXPATHLEN, buf);
|
MAXPATHLEN, buf);
|
||||||
if (PyErr_Warn(PyExc_ImportWarning,
|
if (PyErr_WarnEx(PyExc_ImportWarning,
|
||||||
warnstr)) {
|
warnstr, 1)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ Py_InitModule4(const char *name, PyMethodDef *methods, const char *doc,
|
||||||
api_version_warning, name,
|
api_version_warning, name,
|
||||||
PYTHON_API_VERSION, name,
|
PYTHON_API_VERSION, name,
|
||||||
module_api_version);
|
module_api_version);
|
||||||
if (PyErr_Warn(PyExc_RuntimeWarning, message))
|
if (PyErr_WarnEx(PyExc_RuntimeWarning, message, 1))
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Make sure name is fully qualified.
|
/* Make sure name is fully qualified.
|
||||||
|
|
|
@ -90,10 +90,10 @@ PyMember_GetOne(const char *addr, PyMemberDef *l)
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define WARN(msg) \
|
#define WARN(msg) \
|
||||||
do { \
|
do { \
|
||||||
if (PyErr_Warn(PyExc_RuntimeWarning, msg) < 0) \
|
if (PyErr_WarnEx(PyExc_RuntimeWarning, msg, 1) < 0) \
|
||||||
return -1; \
|
return -1; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue