mirror of https://github.com/python/cpython
A bit of cleanup:
- When 'import exceptions' fails, don't suggest to use -v to print the traceback; this doesn't actually work. - Remove comment about fallback to string exceptions. - Remove a PyErr_Occurred() check after all is said and done that can never trigger. - Remove static function newstdexception() which is no longer called.
This commit is contained in:
parent
3d69c0e440
commit
a7cfca23e1
|
@ -2440,9 +2440,9 @@ bltin_exc[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* import exceptions module to extract class exceptions. on success,
|
/* Import exceptions module to extract class exceptions. On success,
|
||||||
* return 1. on failure return 0 which signals _PyBuiltin_Init_2 to fall
|
* return 1. On failure return 0 which signals _PyBuiltin_Init_2 to
|
||||||
* back to using old-style string based exceptions.
|
* issue a fatal error.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
init_class_exc(dict)
|
init_class_exc(dict)
|
||||||
|
@ -2457,14 +2457,7 @@ init_class_exc(dict)
|
||||||
if (m == NULL ||
|
if (m == NULL ||
|
||||||
(d = PyModule_GetDict(m)) == NULL)
|
(d = PyModule_GetDict(m)) == NULL)
|
||||||
{
|
{
|
||||||
PySys_WriteStderr("'import exceptions' failed; ");
|
PySys_WriteStderr("'import exceptions' failed\n");
|
||||||
if (Py_VerboseFlag) {
|
|
||||||
PySys_WriteStderr("traceback:\n");
|
|
||||||
PyErr_Print();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PySys_WriteStderr("use -v for traceback\n");
|
|
||||||
}
|
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
for (i = 0; bltin_exc[i].name; i++) {
|
for (i = 0; bltin_exc[i].name; i++) {
|
||||||
|
@ -2505,18 +2498,8 @@ init_class_exc(dict)
|
||||||
|
|
||||||
/* we're done with the exceptions module */
|
/* we're done with the exceptions module */
|
||||||
Py_DECREF(m);
|
Py_DECREF(m);
|
||||||
|
|
||||||
if (PyErr_Occurred()) {
|
|
||||||
PySys_WriteStderr("Cannot initialize standard class exceptions; ");
|
|
||||||
if (Py_VerboseFlag) {
|
|
||||||
PySys_WriteStderr("traceback:\n");
|
|
||||||
PyErr_Print();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
PySys_WriteStderr("use -v for traceback\n");
|
|
||||||
goto finally;
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
Py_XDECREF(m);
|
Py_XDECREF(m);
|
||||||
Py_XDECREF(args);
|
Py_XDECREF(args);
|
||||||
|
@ -2533,18 +2516,6 @@ fini_instances()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
newstdexception(dict, name)
|
|
||||||
PyObject *dict;
|
|
||||||
char *name;
|
|
||||||
{
|
|
||||||
PyObject *v = PyString_FromString(name);
|
|
||||||
if (v == NULL || PyDict_SetItemString(dict, name, v) != 0)
|
|
||||||
Py_FatalError("Cannot create string-based exceptions");
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
finierrors()
|
finierrors()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue