| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5740,15 +5740,9 @@ _ctypes_add_objects(PyObject *mod) | |||
| 5740 | 5740 | { | |
| 5741 | 5741 | #define MOD_ADD(name, expr) \ | |
| 5742 | 5742 | do { \ | |
| 5743 | - PyObject *obj = (expr); \ | ||
| 5744 | - if (obj == NULL) { \ | ||
| 5743 | + if (PyModule_Add(mod, name, (expr)) < 0) { \ | ||
| 5745 | 5744 | return -1; \ | |
| 5746 | 5745 | } \ | |
| 5747 | - if (PyModule_AddObjectRef(mod, name, obj) < 0) { \ | ||
| 5748 | - Py_DECREF(obj); \ | ||
| 5749 | - return -1; \ | ||
| 5750 | - } \ | ||
| 5751 | - Py_DECREF(obj); \ | ||
| 5752 | 5746 | } while (0) | |
| 5753 | 5747 | ||
| 5754 | 5748 | MOD_ADD("_pointer_type_cache", Py_NewRef(_ctypes_ptrtype_cache)); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2189,7 +2189,6 @@ hashlib_init_constructors(PyObject *module) | |||
| 2189 | 2189 | */ | |
| 2190 | 2190 | PyModuleDef *mdef; | |
| 2191 | 2191 | PyMethodDef *fdef; | |
| 2192 | - PyObject *proxy; | ||
| 2193 | 2192 | PyObject *func, *name_obj; | |
| 2194 | 2193 | _hashlibstate *state = get_hashlib_state(module); | |
| 2195 | 2194 | ||
@@ -2224,17 +2223,8 @@ hashlib_init_constructors(PyObject *module) | |||
| 2224 | 2223 | } | |
| 2225 | 2224 | } | |
| 2226 | 2225 | ||
| 2227 | - proxy = PyDictProxy_New(state->constructs); | ||
| 2228 | - if (proxy == NULL) { | ||
| 2229 | - return -1; | ||
| 2230 | - } | ||
| 2231 | - | ||
| 2232 | - int rc = PyModule_AddObjectRef(module, "_constructors", proxy); | ||
| 2233 | - Py_DECREF(proxy); | ||
| 2234 | - if (rc < 0) { | ||
| 2235 | - return -1; | ||
| 2236 | - } | ||
| 2237 | - return 0; | ||
| 2226 | + return PyModule_Add(module, "_constructors", | ||
| 2227 | + PyDictProxy_New(state->constructs)); | ||
| 2238 | 2228 | } | |
| 2239 | 2229 | ||
| 2240 | 2230 | static int | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1756,22 +1756,12 @@ static int | |||
| 1756 | 1756 | _json_exec(PyObject *module) | |
| 1757 | 1757 | { | |
| 1758 | 1758 | PyObject *PyScannerType = PyType_FromSpec(&PyScannerType_spec); | |
| 1759 | - if (PyScannerType == NULL) { | ||
| 1760 | - return -1; | ||
| 1761 | - } | ||
| 1762 | - int rc = PyModule_AddObjectRef(module, "make_scanner", PyScannerType); | ||
| 1763 | - Py_DECREF(PyScannerType); | ||
| 1764 | - if (rc < 0) { | ||
| 1759 | + if (PyModule_Add(module, "make_scanner", PyScannerType) < 0) { | ||
| 1765 | 1760 | return -1; | |
| 1766 | 1761 | } | |
| 1767 | 1762 | ||
| 1768 | 1763 | PyObject *PyEncoderType = PyType_FromSpec(&PyEncoderType_spec); | |
| 1769 | - if (PyEncoderType == NULL) { | ||
| 1770 | - return -1; | ||
| 1771 | - } | ||
| 1772 | - rc = PyModule_AddObjectRef(module, "make_encoder", PyEncoderType); | ||
| 1773 | - Py_DECREF(PyEncoderType); | ||
| 1774 | - if (rc < 0) { | ||
| 1764 | + if (PyModule_Add(module, "make_encoder", PyEncoderType) < 0) { | ||
| 1775 | 1765 | return -1; | |
| 1776 | 1766 | } | |
| 1777 | 1767 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3195,12 +3195,7 @@ do { \ | |||
| 3195 | 3195 | ||
| 3196 | 3196 | #define ADD_ULONG_CONSTANT(module, name, value) \ | |
| 3197 | 3197 | do { \ | |
| 3198 | - PyObject *o = PyLong_FromUnsignedLong(value); \ | ||
| 3199 | - if (!o) \ | ||
| 3200 | - goto error; \ | ||
| 3201 | - int res = PyModule_AddObjectRef(module, name, o); \ | ||
| 3202 | - Py_DECREF(o); \ | ||
| 3203 | - if (res < 0) { \ | ||
| 3198 | + if (PyModule_Add(module, name, PyLong_FromUnsignedLong(value)) < 0) { \ | ||
| 3204 | 3199 | goto error; \ | |
| 3205 | 3200 | } \ | |
| 3206 | 3201 | } while (0) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5773,13 +5773,7 @@ static int | |||
| 5773 | 5773 | sslmodule_add_option(PyObject *m, const char *name, uint64_t value) | |
| 5774 | 5774 | { | |
| 5775 | 5775 | Py_BUILD_ASSERT(sizeof(unsigned long long) >= sizeof(value)); | |
| 5776 | - PyObject *obj = PyLong_FromUnsignedLongLong(value); | ||
| 5777 | - if (obj == NULL) { | ||
| 5778 | - return -1; | ||
| 5779 | - } | ||
| 5780 | - int res = PyModule_AddObjectRef(m, name, obj); | ||
| 5781 | - Py_DECREF(obj); | ||
| 5782 | - return res; | ||
| 5776 | + return PyModule_Add(m, name, PyLong_FromUnsignedLongLong(value)); | ||
| 5783 | 5777 | } | |
| 5784 | 5778 | ||
| 5785 | 5779 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -692,13 +692,11 @@ _PyTestCapi_Init_Mem(PyObject *mod) | |||
| 692 | 692 | ||
| 693 | 693 | PyObject *v; | |
| 694 | 694 | #ifdef WITH_PYMALLOC | |
| 695 | - v = Py_NewRef(Py_True); | ||
| 695 | + v = Py_True; | ||
| 696 | 696 | #else | |
| 697 | - v = Py_NewRef(Py_False); | ||
| 697 | + v = Py_False; | ||
| 698 | 698 | #endif | |
| 699 | - int rc = PyModule_AddObjectRef(mod, "WITH_PYMALLOC", v); | ||
| 700 | - Py_DECREF(v); | ||
| 701 | - if (rc < 0) { | ||
| 699 | + if (PyModule_AddObjectRef(mod, "WITH_PYMALLOC", v) < 0) { | ||
| 702 | 700 | return -1; | |
| 703 | 701 | } | |
| 704 | 702 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -516,13 +516,7 @@ static PyFunction_WatchCallback func_watcher_callbacks[NUM_TEST_FUNC_WATCHERS] = | |||
| 516 | 516 | static int | |
| 517 | 517 | add_func_event(PyObject *module, const char *name, PyFunction_WatchEvent event) | |
| 518 | 518 | { | |
| 519 | - PyObject *value = PyLong_FromLong(event); | ||
| 520 | - if (value == NULL) { | ||
| 521 | - return -1; | ||
| 522 | - } | ||
| 523 | - int ok = PyModule_AddObjectRef(module, name, value); | ||
| 524 | - Py_DECREF(value); | ||
| 525 | - return ok; | ||
| 519 | + return PyModule_Add(module, name, PyLong_FromLong(event)); | ||
| 526 | 520 | } | |
| 527 | 521 | ||
| 528 | 522 | static PyObject * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -137,13 +137,7 @@ init_module(PyObject *module, module_state *state) | |||
| 137 | 137 | } | |
| 138 | 138 | ||
| 139 | 139 | double d = _PyTime_AsSecondsDouble(state->initialized); | |
| 140 | - PyObject *initialized = PyFloat_FromDouble(d); | ||
| 141 | - if (initialized == NULL) { | ||
| 142 | - return -1; | ||
| 143 | - } | ||
| 144 | - int rc = PyModule_AddObjectRef(module, "_module_initialized", initialized); | ||
| 145 | - Py_DECREF(initialized); | ||
| 146 | - if (rc < 0) { | ||
| 140 | + if (PyModule_Add(module, "_module_initialized", PyFloat_FromDouble(d)) < 0) { | ||
| 147 | 141 | return -1; | |
| 148 | 142 | } | |
| 149 | 143 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1812,16 +1812,13 @@ add_errors_module(PyObject *mod) | |||
| 1812 | 1812 | goto error; | |
| 1813 | 1813 | } | |
| 1814 | 1814 | ||
| 1815 | - int rc = PyModule_AddObjectRef(errors_module, "codes", codes_dict); | ||
| 1816 | - Py_CLEAR(codes_dict); | ||
| 1817 | - if (rc < 0) { | ||
| 1818 | - goto error; | ||
| 1815 | + if (PyModule_Add(errors_module, "codes", codes_dict) < 0) { | ||
| 1816 | + Py_DECREF(rev_codes_dict); | ||
| 1817 | + return -1; | ||
| 1819 | 1818 | } | |
| 1820 | 1819 | ||
| 1821 | - rc = PyModule_AddObjectRef(errors_module, "messages", rev_codes_dict); | ||
| 1822 | - Py_CLEAR(rev_codes_dict); | ||
| 1823 | - if (rc < 0) { | ||
| 1824 | - goto error; | ||
| 1820 | + if (PyModule_Add(errors_module, "messages", rev_codes_dict) < 0) { | ||
| 1821 | + return -1; | ||
| 1825 | 1822 | } | |
| 1826 | 1823 | ||
| 1827 | 1824 | return 0; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7425,9 +7425,7 @@ socket_exec(PyObject *m) | |||
| 7425 | 7425 | sock_free_api(capi); | |
| 7426 | 7426 | goto error; | |
| 7427 | 7427 | } | |
| 7428 | - int rc = PyModule_AddObjectRef(m, PySocket_CAPI_NAME, capsule); | ||
| 7429 | - Py_DECREF(capsule); | ||
| 7430 | - if (rc < 0) { | ||
| 7428 | + if (PyModule_Add(m, PySocket_CAPI_NAME, capsule) < 0) { | ||
| 7431 | 7429 | goto error; | |
| 7432 | 7430 | } | |
| 7433 | 7431 | ||
@@ -8818,13 +8816,7 @@ socket_exec(PyObject *m) | |||
| 8818 | 8816 | }; | |
| 8819 | 8817 | int i; | |
| 8820 | 8818 | for (i = 0; i < Py_ARRAY_LENGTH(codes); ++i) { | |
| 8821 | - PyObject *tmp = PyLong_FromUnsignedLong(codes[i]); | ||
| 8822 | - if (tmp == NULL) { | ||
| 8823 | - goto error; | ||
| 8824 | - } | ||
| 8825 | - int rc = PyModule_AddObjectRef(m, names[i], tmp); | ||
| 8826 | - Py_DECREF(tmp); | ||
| 8827 | - if (rc < 0) { | ||
| 8819 | + if (PyModule_Add(m, names[i], PyLong_FromUnsignedLong(codes[i])) < 0) { | ||
| 8828 | 8820 | goto error; | |
| 8829 | 8821 | } | |
| 8830 | 8822 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments