| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -262,6 +262,7 @@ createfunc_nonmodule(PyObject *spec, PyModuleDef *def) | |||
| 262 | 262 | return NULL; | |
| 263 | 263 | } | |
| 264 | 264 | PyDict_SetItemString(dct, "three", three); | |
| 265 | + Py_DECREF(three); | ||
| 265 | 266 | ||
| 266 | 267 | ns = _PyNamespace_New(dct); | |
| 267 | 268 | Py_DECREF(dct); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -311,6 +311,7 @@ PyModule_FromDefAndSpec2(struct PyModuleDef* def, PyObject *spec, int module_api | |||
| 311 | 311 | } | |
| 312 | 312 | } | |
| 313 | 313 | ||
| 314 | + Py_DECREF(nameobj); | ||
| 314 | 315 | return m; | |
| 315 | 316 | ||
| 316 | 317 | error: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2694,6 +2694,7 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) | |||
| 2694 | 2694 | { | |
| 2695 | 2695 | PyHeapTypeObject *res = (PyHeapTypeObject*)PyType_GenericAlloc(&PyType_Type, 0); | |
| 2696 | 2696 | PyTypeObject *type, *base; | |
| 2697 | + PyObject *modname; | ||
| 2697 | 2698 | char *s; | |
| 2698 | 2699 | char *res_start = (char*)res; | |
| 2699 | 2700 | PyType_Slot *slot; | |
@@ -2807,11 +2808,15 @@ PyType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases) | |||
| 2807 | 2808 | ||
| 2808 | 2809 | /* Set type.__module__ */ | |
| 2809 | 2810 | s = strrchr(spec->name, '.'); | |
| 2810 | - if (s != NULL) | ||
| 2811 | - _PyDict_SetItemId(type->tp_dict, &PyId___module__, | ||
| 2812 | - PyUnicode_FromStringAndSize( | ||
| 2813 | - spec->name, (Py_ssize_t)(s - spec->name))); | ||
| 2814 | - else { | ||
| 2811 | + if (s != NULL) { | ||
| 2812 | + modname = PyUnicode_FromStringAndSize( | ||
| 2813 | + spec->name, (Py_ssize_t)(s - spec->name)); | ||
| 2814 | + if (modname == NULL) { | ||
| 2815 | + goto fail; | ||
| 2816 | + } | ||
| 2817 | + _PyDict_SetItemId(type->tp_dict, &PyId___module__, modname); | ||
| 2818 | + Py_DECREF(modname); | ||
| 2819 | + } else { | ||
| 2815 | 2820 | if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, | |
| 2816 | 2821 | "builtin type %.200s has no __module__ attribute", | |
| 2817 | 2822 | spec->name)) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments