Skip to content

return-in-finally in multiprocessing/connection.py #131233

Closed
@iritkatriel

Description

@iritkatriel

https://github.com/python/cpython/blob/7fd61607cd28ec466717c78adfb1eb5b63add1f0/Lib/multiprocessing/connection.py#L330C1-L340C68

This is clearly a bug, because the except: clause contains a naked raise, i.e., asks for the exception to propagate on. But the return in finally swallows that exception.

                    try:
                              ...
                    except:
                        ov.cancel()
                        raise
                    finally:
                        nread, err = ov.GetOverlappedResult(True)
                        if err == 0:
                            f = io.BytesIO()
                            f.write(ov.getbuffer())
                            return f
                        elif err == _winapi.ERROR_MORE_DATA:
                            return self._get_more_data(ov, maxsize)

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions