This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: _Pickler_CommitFrame() always returns 0 and its return code is checked needlessly
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.10
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: remi.lapeyre
Priority: normal Keywords:

Created on 2020-06-02 11:05 by remi.lapeyre, last changed 2022-04-11 14:59 by admin.

Messages (1)
msg370603 - (view) Author: Rémi Lapeyre (remi.lapeyre) * Date: 2020-06-02 11:05
I'm currently investigating a SystemError one of our workers returned:

   <method 'dump' of '_pickle.Pickler' objects> returned NULL without setting an error


While doing so I came across the _Pickler_CommitFrame() function:


static int
_Pickler_CommitFrame(PicklerObject *self)
{
    size_t frame_len;
    char *qdata;

    if (!self->framing || self->frame_start == -1)
        return 0;
    frame_len = self->output_len - self->frame_start - FRAME_HEADER_SIZE;
    qdata = PyBytes_AS_STRING(self->output_buffer) + self->frame_start;
    if (frame_len >= FRAME_SIZE_MIN) {
        qdata[0] = FRAME;
        _write_size64(qdata + 1, frame_len);
    }
    else {
        memmove(qdata, qdata + FRAME_HEADER_SIZE, frame_len);
        self->output_len -= FRAME_HEADER_SIZE;
    }
    self->frame_start = -1;
    return 0;
}


Is there a reason for this function to return an int if it is always 0? I checked all call sites (_Pickler_GetString(), _Pickler_OpcodeBoundary(), _Pickler_write_bytes() and dump()) and they all check the return code but it seems useless.
History
Date User Action Args
2022-04-11 14:59:31adminsetgithub: 85019
2020-06-02 11:05:38remi.lapeyresettitle: _Pickler_CommitFrame() always returns 0 but it's return code is checked -> _Pickler_CommitFrame() always returns 0 and its return code is checked needlessly
2020-06-02 11:05:03remi.lapeyrecreate