Skip to content

Regression with native descriptors from ae93dd71c378161ff3643c9a1f708f66f97f3b5d #340

Description

@brettlangdon

ae93dd7

Introduced a regression for native descriptors.

PyFunction func_descr_get is fine with the change, it treats NULL and Py_None as equal:

https://github.com/python/cpython/blob/cc48cfca7178c2131075b88b78592fed83a82a0c/Objects/funcobject.c#L1190-L1198

But there are other tp_descr_get's which fast path on NULL and skip the type checking:

descr_check is what is doing type checking against Py_None and failing for these cases.

Basic reproduction example:

import wrapt


@wrapt.decorator
def passthrough(wrapped, instance, args, kwargs):
    return wrapped(*args, **kwargs)


wrapped = passthrough(str.upper)

# Simulate tp_descr_get call
wrapped.__get__(None, str)  # TypeError on 2.2.0

Short term we should revert ae93dd7 and release 2.2.1.

I am working on a PR now to add the missing test coverage which would have caught this regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions