Skip to content

PEP 688: Crash if __release_buffer__ is called while an exception is active #104371

@JelleZijlstra

Description

@JelleZijlstra
class A:
    def __buffer__(self, flags):
            return memoryview(bytes(8))
    def __release_buffer__(self, view):
            pass # do not need to do anything here, just needs to exist

b = bytearray(8)
m = memoryview(b) # now b.extend will raise an exception due to exports
b.extend(A())

In a debug build this crashes with Assertion failed: (!PyErr_Occurred()), function _PyType_Lookup, file typeobject.c, line 4707.

Reported by @chilaxan. I'll work on a fix later today.

Most likely, the fix will be to call PyErr_Fetch/PyErr_Restore around calls to Python __release_buffer__ methods.

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy