Skip to content

Fix __class__ #619

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

Merged
merged 4 commits into from
Mar 8, 2019
Merged

Conversation

BenLewis-Seequent
Copy link

Fixes #583

Moves the __class__ property to object, so lookup of it works properly, this matches CPython. Also to make lookup work the property has to have a __set__ method, at this point it always raises an exception.

@codecov-io
Copy link

codecov-io commented Mar 7, 2019

Codecov Report

Merging #619 into master will increase coverage by 0.12%.
The diff coverage is 42.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #619      +/-   ##
==========================================
+ Coverage      41%   41.12%   +0.12%     
==========================================
  Files          76       76              
  Lines       17184    17207      +23     
  Branches     4514     4508       -6     
==========================================
+ Hits         7046     7077      +31     
- Misses       8140     8177      +37     
+ Partials     1998     1953      -45
Impacted Files Coverage Δ
vm/src/obj/objtype.rs 44.95% <ø> (-0.02%) ⬇️
vm/src/obj/objobject.rs 43.66% <31.25%> (+2.66%) ⬆️
vm/src/obj/objfunction.rs 38.62% <33.33%> (-2.15%) ⬇️
vm/src/pyobject.rs 61.31% <61.9%> (+1.81%) ⬆️
vm/src/obj/objfloat.rs 38.69% <0%> (-6.38%) ⬇️
vm/src/obj/objbool.rs 39.02% <0%> (-3.66%) ⬇️
vm/src/obj/objrange.rs 34.85% <0%> (-1.86%) ⬇️
vm/src/obj/objsequence.rs 30.7% <0%> (-0.6%) ⬇️
vm/src/function.rs 70% <0%> (-0.28%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d7f8961...4b1cd72. Read the comment docs.

@cthulahoops
Copy link
Collaborator

Are member descriptor and data descriptor actually different things or were member descriptors just missing the set (and hence not working correctly in this case)?

@BenLewis-Seequent
Copy link
Author

They are different, member descriptors shouldn't have __set__ as the presence of it affects the lookup.

In CPython:

>>> type(object.__dict__['__class__'])
<class 'getset_descriptor'>
>>> type(type.__dict__['__mro__'])
<class 'member_descriptor'>

I'm been thinking of a nicer way to do this in rust, instead of having different new_xxx_descriptor methods, instead a builder, which would statically work out the python type needed.

vm.new_property()
     .add_getter(...)
     .add_setter(...)
     .build()

@cthulahoops
Copy link
Collaborator

Great.

The builder sounds nice, probably reasonable to add that later and merge this as is.

@cthulahoops cthulahoops merged commit 406ec46 into RustPython:master Mar 8, 2019
@BenLewis-Seequent BenLewis-Seequent deleted the class_property branch March 29, 2019 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants