gh-99300: Use Py_NewRef() in PC/ directory (#99479)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the PC/ directory.
This commit is contained in:
Victor Stinner 2022-11-14 18:49:51 +01:00 committed by GitHub
parent 1089bdc81a
commit f5e326e2b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -701,8 +701,7 @@ _msi_SummaryInformation_GetProperty_impl(msiobj *self, int field)
result = PyBytes_FromStringAndSize(sval, ssize); result = PyBytes_FromStringAndSize(sval, ssize);
break; break;
case VT_EMPTY: case VT_EMPTY:
Py_INCREF(Py_None); result = Py_NewRef(Py_None);
result = Py_None;
break; break;
default: default:
PyErr_Format(PyExc_NotImplementedError, "result of type %d", type); PyErr_Format(PyExc_NotImplementedError, "result of type %d", type);

View File

@ -308,8 +308,7 @@ static PyHKEYObject *
winreg_HKEYType___enter___impl(PyHKEYObject *self) winreg_HKEYType___enter___impl(PyHKEYObject *self)
/*[clinic end generated code: output=52c34986dab28990 input=c40fab1f0690a8e2]*/ /*[clinic end generated code: output=52c34986dab28990 input=c40fab1f0690a8e2]*/
{ {
Py_XINCREF(self); return (PyHKEYObject*)Py_XNewRef(self);
return self;
} }
@ -784,8 +783,7 @@ Reg2Py(BYTE *retDataBuf, DWORD retDataSize, DWORD typ)
support it natively, we should handle the bits. */ support it natively, we should handle the bits. */
default: default:
if (retDataSize == 0) { if (retDataSize == 0) {
Py_INCREF(Py_None); obData = Py_NewRef(Py_None);
obData = Py_None;
} }
else else
obData = PyBytes_FromStringAndSize( obData = PyBytes_FromStringAndSize(