mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +00:00
gh-102471: Change PyLongWriter_Discard(NULL) to do nothing (#129339)
It's convenient to be able to call PyLongWriter_Discard(NULL) in error handling code.
This commit is contained in:
parent
11148e91e3
commit
7ec17429d4
2 changed files with 5 additions and 1 deletions
|
|
@ -824,6 +824,6 @@ The :c:type:`PyLongWriter` API can be used to import an integer.
|
|||
|
||||
Discard a :c:type:`PyLongWriter` created by :c:func:`PyLongWriter_Create`.
|
||||
|
||||
*writer* must not be ``NULL``.
|
||||
If *writer* is ``NULL``, no operation is performed.
|
||||
|
||||
The writer instance and the *digits* array are invalid after the call.
|
||||
|
|
|
|||
|
|
@ -6953,6 +6953,10 @@ PyLongWriter_Create(int negative, Py_ssize_t ndigits, void **digits)
|
|||
void
|
||||
PyLongWriter_Discard(PyLongWriter *writer)
|
||||
{
|
||||
if (writer == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
PyLongObject *obj = (PyLongObject *)writer;
|
||||
assert(Py_REFCNT(obj) == 1);
|
||||
Py_DECREF(obj);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue