gh-99300: Use Py_NewRef() in Modules/ directory (#99468)

Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
This commit is contained in:
Victor Stinner 2022-11-14 13:44:56 +01:00 committed by GitHub
parent 9a7e9f9921
commit c340cbb7f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 92 additions and 173 deletions

View file

@ -87,8 +87,7 @@ _PySSL_msg_callback(int write_p, int version, int content_type,
static PyObject *
_PySSLContext_get_msg_callback(PySSLContext *self, void *c) {
if (self->msg_cb != NULL) {
Py_INCREF(self->msg_cb);
return self->msg_cb;
return Py_NewRef(self->msg_cb);
} else {
Py_RETURN_NONE;
}
@ -107,8 +106,7 @@ _PySSLContext_set_msg_callback(PySSLContext *self, PyObject *arg, void *c) {
"not a callable object");
return -1;
}
Py_INCREF(arg);
self->msg_cb = arg;
self->msg_cb = Py_NewRef(arg);
SSL_CTX_set_msg_callback(self->ctx, _PySSL_msg_callback);
}
return 0;
@ -166,8 +164,7 @@ _PySSL_keylog_callback(const SSL *ssl, const char *line)
static PyObject *
_PySSLContext_get_keylog_filename(PySSLContext *self, void *c) {
if (self->keylog_filename != NULL) {
Py_INCREF(self->keylog_filename);
return self->keylog_filename;
return Py_NewRef(self->keylog_filename);
} else {
Py_RETURN_NONE;
}
@ -203,8 +200,7 @@ _PySSLContext_set_keylog_filename(PySSLContext *self, PyObject *arg, void *c) {
"Can't malloc memory for keylog file");
return -1;
}
Py_INCREF(arg);
self->keylog_filename = arg;
self->keylog_filename = Py_NewRef(arg);
/* Write a header for seekable, empty files (this excludes pipes). */
PySSL_BEGIN_ALLOW_THREADS