]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Improve the exceptions raised by PyErr_BadInternalCall(); adding the
authorFred Drake <fdrake@acm.org>
Thu, 24 Aug 2000 22:38:39 +0000 (22:38 +0000)
committerFred Drake <fdrake@acm.org>
Thu, 24 Aug 2000 22:38:39 +0000 (22:38 +0000)
filename and line number of the call site to allow esier debugging.

This closes SourceForge patch #101214.

Include/pyerrors.h
Python/errors.c

index f461068ab28fd90f4e5d2c9281c534a7a085c2da..6e6035334d4e92b42987e3165347aec2ac9b7a88 100644 (file)
@@ -82,7 +82,12 @@ extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErrWithFilename(int, const char
 extern DL_IMPORT(PyObject *) PyErr_SetFromWindowsErr(int);
 #endif
 
+/* Export the old function so that the existing API remains available: */
 extern DL_IMPORT(void) PyErr_BadInternalCall(void);
+extern DL_IMPORT(void) _PyErr_BadInternalCall(char *filename, int lineno);
+/* Mask the old API with a call to the new API for code compiled under
+   Python 2.0: */
+#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
 
 /* Function to create a new exception */
 DL_IMPORT(PyObject *) PyErr_NewException(char *name, PyObject *base,
index ffa7f82f345d115c28bf7c981cefd764839b76d9..8486423479ec349a0e4f61e1ca0ce27206767db1 100644 (file)
@@ -368,12 +368,25 @@ PyObject *PyErr_SetFromWindowsErr(int ierr)
 }
 #endif /* MS_WINDOWS */
 
+void
+_PyErr_BadInternalCall(char *filename, int lineno)
+{
+       PyErr_Format(PyExc_SystemError,
+                    "%s:%d: bad argument to internal function",
+                    filename, lineno);
+}
+
+/* Remove the preprocessor macro for PyErr_BadInternalCall() so that we can
+   export the entry point for existing object code: */
+#undef PyErr_BadInternalCall
 void
 PyErr_BadInternalCall(void)
 {
-       PyErr_SetString(PyExc_SystemError,
-                       "bad argument to internal function");
+       PyErr_Format(PyExc_SystemError,
+                    "bad argument to internal function");
 }
+#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
+
 
 
 PyObject *