Skip to content

Conversation

jepler
Copy link

@jepler jepler commented Mar 25, 2018

This was a failing test for several reasons. One of the reasons was the #705 crash, another was lack of handling of properties and descriptors by super() objects. Fix both problems and put core_class_superproperty.py into the set of tests that get run.

jepler added 2 commits March 25, 2018 15:11
This fixes a crash running the cpydiff/core_class_superproperty.py
test, but it does not fix the difference to cpython3.

Closes: adafruit#705
.. in the presence of properties and descriptors
@jepler
Copy link
Author

jepler commented Mar 25, 2018

@tannewt I'm not sure of the impact of the change in gc_long_lived.c. From my basic understanding, it seems the closure objects that you get when you have an @property which uses super() may not be properly made long-lived. However, I don't understand what would be necessary to allow them to become long-lived objects.

@tannewt tannewt self-requested a review March 26, 2018 06:14
@tannewt
Copy link
Member

tannewt commented Mar 26, 2018

Thank you for finding and fixing this error!

This makes the super().p case match CPython now right? Could you please update/remove the comment in the test because it implies its still incompatible.

Your change to gc_long_lived is more correct. make_obj_long_lived is already smart enough to long-live the fun_bc as it did before. The closure object itself will be made long lived (aka moved) but any pointers within it will not. This will fragment the heap a bit but its not the end of the world, the objects will be preserved and it'll work.

You could add closure support to make_obj_long_lived so it knows how to recurse correctly. I wouldn't bother doing that in this PR though. It'll take some testing to ensure it doesn't lead to cycles (since I assume closures refer back to dictionaries.)

@jepler jepler force-pushed the core-class-superproperty branch from 2f9e8f1 to 047a4f5 Compare March 26, 2018 23:47
@jepler
Copy link
Author

jepler commented Mar 26, 2018

@tannewt I revised the doc-comment at the top of tests/basics/core_class_superproperty.py to reflect that we now match cpython3's behavior here.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you thank you!

@tannewt tannewt merged commit 4517ab8 into adafruit:master Mar 27, 2018
@jepler jepler deleted the core-class-superproperty branch August 2, 2018 01:23
@jepler jepler restored the core-class-superproperty branch August 2, 2018 01:23
@jepler jepler deleted the core-class-superproperty branch August 2, 2018 01:23
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.

2 participants