diff options
Diffstat (limited to 'Modules/getpath.c')
-rw-r--r-- | Modules/getpath.c | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/Modules/getpath.c b/Modules/getpath.c index ceacf36..13db010 100644 --- a/Modules/getpath.c +++ b/Modules/getpath.c @@ -125,8 +125,7 @@ getpath_isabs(PyObject *Py_UNUSED(self), PyObject *args) r = _Py_isabs(path) ? Py_True : Py_False; PyMem_Free((void *)path); } - Py_XINCREF(r); - return r; + return Py_XNewRef(r); } @@ -153,11 +152,10 @@ getpath_hassuffix(PyObject *Py_UNUSED(self), PyObject *args) wcscmp(&path[len - suffixLen], suffix) != 0 #endif ) { - r = Py_False; + r = Py_NewRef(Py_False); } else { - r = Py_True; + r = Py_NewRef(Py_True); } - Py_INCREF(r); PyMem_Free((void *)suffix); } PyMem_Free((void *)path); @@ -187,8 +185,7 @@ getpath_isdir(PyObject *Py_UNUSED(self), PyObject *args) #endif PyMem_Free((void *)path); } - Py_XINCREF(r); - return r; + return Py_XNewRef(r); } @@ -213,8 +210,7 @@ getpath_isfile(PyObject *Py_UNUSED(self), PyObject *args) #endif PyMem_Free((void *)path); } - Py_XINCREF(r); - return r; + return Py_XNewRef(r); } @@ -247,8 +243,7 @@ getpath_isxfile(PyObject *Py_UNUSED(self), PyObject *args) #endif PyMem_Free((void *)path); } - Py_XINCREF(r); - return r; + return Py_XNewRef(r); } @@ -488,8 +483,7 @@ done: goto done; } if (!S_ISLNK(st.st_mode)) { - Py_INCREF(pathobj); - r = pathobj; + r = Py_NewRef(pathobj); goto done; } wchar_t resolved[MAXPATHLEN+1]; @@ -504,8 +498,7 @@ done: return r; #endif - Py_INCREF(pathobj); - return pathobj; + return Py_NewRef(pathobj); } @@ -591,8 +584,7 @@ wchar_to_dict(PyObject *dict, const char *key, const wchar_t *s) return 0; } } else { - u = Py_None; - Py_INCREF(u); + u = Py_NewRef(Py_None); } r = PyDict_SetItemString(dict, key, u) == 0; Py_DECREF(u); @@ -617,8 +609,7 @@ decode_to_dict(PyObject *dict, const char *key, const char *s) return 0; } } else { - u = Py_None; - Py_INCREF(u); + u = Py_NewRef(Py_None); } r = PyDict_SetItemString(dict, key, u) == 0; Py_DECREF(u); |