https://github.com/python/cpython/commit/3c38feb2a21aacdb009eea8baa2a6a3daf4b4932
commit: 3c38feb2a21aacdb009eea8baa2a6a3daf4b4932
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2026-03-13T19:44:51+01:00
summary:
gh-129813: Document that PyBytesWriter_GetData() cannot fail (#145900)
Document that PyBytesWriter_GetData() and PyBytesWriter_GetSize()
getter functions cannot fail
files:
M Doc/c-api/bytes.rst
M Modules/binascii.c
diff --git a/Doc/c-api/bytes.rst b/Doc/c-api/bytes.rst
index 82c2557368371f..b3cd26a8504715 100644
--- a/Doc/c-api/bytes.rst
+++ b/Doc/c-api/bytes.rst
@@ -371,6 +371,8 @@ Getters
Get the writer size.
+ The function cannot fail.
+
.. c:function:: void* PyBytesWriter_GetData(PyBytesWriter *writer)
Get the writer data: start of the internal buffer.
@@ -378,6 +380,8 @@ Getters
The pointer is valid until :c:func:`PyBytesWriter_Finish` or
:c:func:`PyBytesWriter_Discard` is called on *writer*.
+ The function cannot fail.
+
Low-level API
^^^^^^^^^^^^^
diff --git a/Modules/binascii.c b/Modules/binascii.c
index 3f3695d50f2754..c076b12fb149b2 100644
--- a/Modules/binascii.c
+++ b/Modules/binascii.c
@@ -923,9 +923,6 @@ binascii_a2b_ascii85_impl(PyObject *module, Py_buffer
*data, int foldspaces,
return NULL;
}
unsigned char *bin_data = PyBytesWriter_GetData(writer);
- if (bin_data == NULL) {
- goto error;
- }
uint32_t leftchar = 0;
int group_pos = 0;
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]