Skip to content

Find key from only its attributes - #2932

Merged
youknowone merged 4 commits into
RustPython:mainfrom
moreal:bugfix/dict-contains-check-from-its-attributes
Aug 23, 2021
Merged

youknowone merged 4 commits into
RustPython:mainfrom
moreal:bugfix/dict-contains-check-from-its-attributes

Conversation

@moreal

@moreal moreal commented Aug 22, 2021

Copy link
Copy Markdown
Contributor

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 Compare August 22, 2021 07:33
moreal added 3 commits August 23, 2021 08:54
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 Compare August 22, 2021 23:54
@moreal
moreal marked this pull request as draft August 23, 2021 04:31
@moreal
moreal force-pushed the bugfix/dict-contains-check-from-its-attributes branch from 91734d4 to 3b744c9 Compare August 23, 2021 11:00
@moreal
moreal marked this pull request as ready for review August 23, 2021 11:46
Comment thread Lib/test/support/__init__.py Outdated
@moreal
moreal force-pushed the bugfix/dict-contains-check-from-its-attributes branch from 3b744c9 to 0548fa1 Compare August 23, 2021 13:01
@moreal
moreal requested a review from youknowone August 23, 2021 13:02
@youknowone
youknowone merged commit 1b20dd5 into RustPython:main Aug 23, 2021
@moreal moreal mentioned this pull request Aug 31, 2021
eldpswp99 pushed a commit to eldpswp99/RustPython that referenced this pull request 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):
```
@youknowone youknowone added the z-ca-2021 Tag to track contrubution-academy 2021 label Oct 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

z-ca-2021 Tag to track contrubution-academy 2021

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants