Skip to content

Commit

Permalink
Replace calls to 'Py_INCREF' with 'Py_XINCREF'
Browse files Browse the repository at this point in the history
The 'PyErr_NewException' function can return 'NULL', which means that
'Py_XINCREF' must be used instead of 'Py_INCREF'.

See https://docs.python.org/3/extending/extending.html#null-pointers for
further information.
  • Loading branch information
SkypLabs committed Apr 21, 2024
1 parent 9db428f commit 8ab53ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/python4yahdlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ PyMODINIT_FUNC PyInit_yahdlc(void)
return NULL;

Yahdlc_MessageError = PyErr_NewException("yahdlc.MessageError", NULL, NULL);
Py_INCREF(Yahdlc_MessageError);
Py_XINCREF(Yahdlc_MessageError);
if (PyModule_AddObject(m, "MessageError", Yahdlc_MessageError) < 0) {
Py_XDECREF(Yahdlc_MessageError);
Py_CLEAR(Yahdlc_MessageError);
Expand All @@ -171,7 +171,7 @@ PyMODINIT_FUNC PyInit_yahdlc(void)
}

Yahdlc_FCSError = PyErr_NewException("yahdlc.FCSError", NULL, NULL);
Py_INCREF(Yahdlc_FCSError);
Py_XINCREF(Yahdlc_FCSError);
if (PyModule_AddObject(m, "FCSError", Yahdlc_FCSError) < 0) {
Py_XDECREF(Yahdlc_FCSError);
Py_CLEAR(Yahdlc_FCSError);
Expand Down

0 comments on commit 8ab53ac

Please sign in to comment.