[Python-Dev] cpython: Issue #18408: Fix fileio_read() on _PyBytes_Resize() failure (original) (raw)

Victor Stinner victor.stinner at gmail.com
Wed Jul 17 00:35:17 CEST 2013


2013/7/17 Serhiy Storchaka <storchaka at gmail.com>:

Oh, I meaned PyXDECREF.

Ah ok :-) Well, for this specific code, it can probably be replaced with:

     if (_PyBytes_Resize(&bytes, n) < 0)
         return NULL;

I'm not sure that _PyBytes_Resize() always decref bytes and then set bytes to NULL. I was too lazy to check this.

If someone wants to audit the code of _PyBytes_Resize(), there are many other places where Py_XDECREF / Py_CLEAR can be removed on _PyBytes_Resize() failure.

And I'm quite sure that there are still places where Py_DECREF() is still used on _PyBytes_Resize() failure ;-)

Victor



More information about the Python-Dev mailing list