bpo-39573: Add Py_SET_TYPE() function (GH-18394)

Add Py_SET_TYPE() function to set the type of an object.
This commit is contained in:
Victor Stinner 2020-02-07 09:17:07 +01:00 committed by GitHub
parent daa9756cb6
commit d2ec81a8c9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 77 additions and 48 deletions

View file

@ -778,16 +778,19 @@ PyInit__sha512(void)
{
PyObject *m;
Py_TYPE(&SHA384type) = &PyType_Type;
if (PyType_Ready(&SHA384type) < 0)
Py_SET_TYPE(&SHA384type, &PyType_Type);
if (PyType_Ready(&SHA384type) < 0) {
return NULL;
Py_TYPE(&SHA512type) = &PyType_Type;
if (PyType_Ready(&SHA512type) < 0)
}
Py_SET_TYPE(&SHA512type, &PyType_Type);
if (PyType_Ready(&SHA512type) < 0) {
return NULL;
}
m = PyModule_Create(&_sha512module);
if (m == NULL)
if (m == NULL) {
return NULL;
}
Py_INCREF((PyObject *)&SHA384type);
PyModule_AddObject(m, "SHA384Type", (PyObject *)&SHA384type);