Sitelet https://web.archive.org/web/20211016054638/https://github.com/RustPython/RustPython/pull/2932
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

Find key from only its attributes #2932

Conversation

@moreal
Copy link
Contributor

@moreal moreal commented Aug 22, 2021

Overview

Currently, there is a bug to find a key from itself and the base types not only its attributes. If there was user defined class named A, "__setattr__" in A.__dict__ returns True because object has __setattr__ though A class doesn't.

RustPython

>>>>> "__setattr__" in type.__dict__
True
>>>>> "__setattr__" in object.__dict__
True
>>>>> class A: ...
>>>>> "__setattr__" in A.__dict__
True

CPython 3.8

>>>>> "__setattr__" in type.__dict__
True
>>>>> "__setattr__" in object.__dict__
True
>>>>> class A: ...
>>>>> "__setattr__" in A.__dict__
False
@moreal moreal changed the title Find key from only attributes Find key from only its attributes Aug 22, 2021
@moreal moreal force-pushed the bugfix/dict-contains-check-from-its-attributes branch from fc47ff0 to e544f65 Aug 22, 2021
moreal added 3 commits Aug 22, 2021
At 'enum.py' 223 line, there is the code to check `member_type` contains
some methods. But it was fixed to find attribute from base types, in
RustPython#2932. So it seems
appeared.

```
if not any(m in member_type.__dict__ for m in methods):
```
@moreal moreal force-pushed the bugfix/dict-contains-check-from-its-attributes branch from 8b83124 to 91734d4 Aug 22, 2021
@moreal moreal marked this pull request as draft Aug 23, 2021
@moreal moreal force-pushed the bugfix/dict-contains-check-from-its-attributes branch from 91734d4 to 3b744c9 Aug 23, 2021
@moreal moreal marked this pull request as ready for review Aug 23, 2021
Lib/test/support/__init__.py Outdated Show resolved Hide resolved
@youknowone youknowone requested a review from coolreader18 Aug 23, 2021
@moreal moreal force-pushed the bugfix/dict-contains-check-from-its-attributes branch from 3b744c9 to 0548fa1 Aug 23, 2021
@moreal moreal requested a review from youknowone Aug 23, 2021
@youknowone youknowone merged commit 1b20dd5 into RustPython:main Aug 23, 2021
10 checks passed
@moreal moreal mentioned this pull request Aug 31, 2021
eldpswp99 added a commit to eldpswp99/RustPython that referenced this issue Sep 5, 2021
At 'enum.py' 223 line, there is the code to check `member_type` contains
some methods. But it was fixed to find attribute from base types, in
RustPython#2932. So it seems
appeared.

```
if not any(m in member_type.__dict__ for m in methods):
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants