Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-14965: Proxy super().x = y and del super().x #26194

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

@habnabit
Copy link
Contributor

@habnabit habnabit commented May 17, 2021

Arguably this is a bugfix, and therefore should be backported into the 3.10 branch as well.

This patch was originally contributed by Daniel Urban, whose summary
follows:

I'm attaching a patch implementing super.__setattr__ (and
__delattr__).

The implementation in the patch only works, if super can find a data
descriptor in the MRO, otherwise it throws an AttributeError. As it
can be seen in the tests, in some cases this may result in
counter-intuitive behaviour. But I wasn't able to find another
behaviour, that is consistent with both super.__getattr__ and normal
__setattr__ semantics.

https://bugs.python.org/issue14965

This patch was originally contributed by Daniel Urban, whose summary
follows:

> I'm attaching a patch implementing super.__setattr__ (and
> __delattr__).

> The implementation in the patch only works, if super can find a data
> descriptor in the MRO, otherwise it throws an AttributeError. As it
> can be seen in the tests, in some cases this may result in
> counter-intuitive behaviour. But I wasn't able to find another
> behaviour, that is consistent with both super.__getattr__ and normal
> __setattr__ semantics.
@habnabit
Copy link
Contributor Author

@habnabit habnabit commented May 17, 2021

Attaching a NEWS fragment in a moment.

@habnabit
Copy link
Contributor Author

@habnabit habnabit commented May 17, 2021

File "/home/runner/work/cpython/cpython/Lib/test/test_doctest.py", line 671, in test.test_doctest.test_DocTestFinder.non_Python_modules
Failed example:
    816 < len(tests) < 836 # approximate number of objects with docstrings

This newly-failing test does appear to be related to the new method super_setattro. I'm not familiar with the new changes to the C API. Does a docstring need to be added to the new super.__setattr__?

@habnabit
Copy link
Contributor Author

@habnabit habnabit commented May 17, 2021

#python-dev suggests that this is a coincidental failure and I should increase the numbers from 816 and 836. Should I do that in this change or wait for another PR to bump it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants