| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1494,32 +1494,37 @@ static int _PyCodecRegistry_Init(void) | |||
| 1494 | 1494 | ||
| 1495 | 1495 | PyInterpreterState *interp = _PyInterpreterState_Get(); | |
| 1496 | 1496 | PyObject *mod; | |
| 1497 | - unsigned i; | ||
| 1498 | 1497 | ||
| 1499 | 1498 | if (interp->codec_search_path != NULL) | |
| 1500 | 1499 | return 0; | |
| 1501 | 1500 | ||
| 1502 | 1501 | interp->codec_search_path = PyList_New(0); | |
| 1502 | + if (interp->codec_search_path == NULL) { | ||
| 1503 | + return -1; | ||
| 1504 | + } | ||
| 1505 | + | ||
| 1503 | 1506 | interp->codec_search_cache = PyDict_New(); | |
| 1507 | + if (interp->codec_search_cache == NULL) { | ||
| 1508 | + return -1; | ||
| 1509 | + } | ||
| 1510 | + | ||
| 1504 | 1511 | interp->codec_error_registry = PyDict_New(); | |
| 1512 | + if (interp->codec_error_registry == NULL) { | ||
| 1513 | + return -1; | ||
| 1514 | + } | ||
| 1505 | 1515 | ||
| 1506 | - if (interp->codec_error_registry) { | ||
| 1507 | - for (i = 0; i < Py_ARRAY_LENGTH(methods); ++i) { | ||
| 1508 | - PyObject *func = PyCFunction_NewEx(&methods[i].def, NULL, NULL); | ||
| 1509 | - int res; | ||
| 1510 | - if (!func) | ||
| 1511 | - Py_FatalError("can't initialize codec error registry"); | ||
| 1512 | - res = PyCodec_RegisterError(methods[i].name, func); | ||
| 1513 | - Py_DECREF(func); | ||
| 1514 | - if (res) | ||
| 1515 | - Py_FatalError("can't initialize codec error registry"); | ||
| 1516 | + for (size_t i = 0; i < Py_ARRAY_LENGTH(methods); ++i) { | ||
| 1517 | + PyObject *func = PyCFunction_NewEx(&methods[i].def, NULL, NULL); | ||
| 1518 | + if (!func) { | ||
| 1519 | + return -1; | ||
| 1516 | 1520 | } | |
| 1517 | - } | ||
| 1518 | 1521 | ||
| 1519 | - if (interp->codec_search_path == NULL || | ||
| 1520 | - interp->codec_search_cache == NULL || | ||
| 1521 | - interp->codec_error_registry == NULL) | ||
| 1522 | - Py_FatalError("can't initialize codec registry"); | ||
| 1522 | + int res = PyCodec_RegisterError(methods[i].name, func); | ||
| 1523 | + Py_DECREF(func); | ||
| 1524 | + if (res) { | ||
| 1525 | + return -1; | ||
| 1526 | + } | ||
| 1527 | + } | ||
| 1523 | 1528 | ||
| 1524 | 1529 | mod = PyImport_ImportModuleNoBlock("encodings"); | |
| 1525 | 1530 | if (mod == NULL) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments