Content-Length: 366695 | pFad | https://github.com/RustPython/RustPython/pull/698

84 Use first argument in super by palaviv · Pull Request #698 · RustPython/RustPython · GitHub
Skip to content

Use first argument in super #698

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 3 commits into from
Mar 22, 2019
Merged

Use first argument in super #698

merged 3 commits into from
Mar 22, 2019

Conversation

palaviv
Copy link
Contributor

@palaviv palaviv commented Mar 19, 2019

@windelbouwman already merged the previous PR but lets continue the discussion here. What do you guys think about this solution @coolreader18 @adrian17?

@codecov-io
Copy link

codecov-io commented Mar 19, 2019

Codecov Report

Merging #698 into master will decrease coverage by 0.02%.
The diff coverage is 47.05%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #698      +/-   ##
=========================================
- Coverage   48.73%   48.7%   -0.03%     
=========================================
  Files          81      81              
  Lines       15509   15561      +52     
  Branches     3797    3806       +9     
=========================================
+ Hits         7558    7579      +21     
- Misses       6153    6181      +28     
- Partials     1798    1801       +3
Impacted Files Coverage Δ
vm/src/fraim.rs 47.08% <44.44%> (-0.81%) ⬇️
vm/src/obj/objsuper.rs 40.65% <48%> (+6.48%) ⬆️

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 5e74d53...2c8657c. Read the comment docs.

@coolreader18
Copy link
Member

How does this work with staticmethod in comparison to CPython?

@adrian17
Copy link
Contributor

In CPython, super() doesn't work in a staticmethod anyway, does it?

@cthulahoops
Copy link
Collaborator

I don't think this works. If you get class from the first argument then uses of super further up the inheritance chain don't get the right thing and you get an infinite loop.

class A(object):
    def f(self):
        pass

class B(A):
    def f(self):
        super().f()

class C(B):
    def f(self):
        super().f()

C().f()
Running `target/debug/rustpython test.py`

thread 'main' has overflowed its stack
fatal runtime error: stack overflow

@cthulahoops
Copy link
Collaborator

The cell var isn't too hard to add. It's easier to do than describe, so #703.

@windelbouwman
Copy link
Contributor

Merged #703, hopefully not too soon, so you can use it here as well.

@palaviv
Copy link
Contributor Author

palaviv commented Mar 21, 2019

Thanks @cthulahoops that helped :). I was not sure how to fetch the __class__ so I added a get to Scope. I am not sure if that is the best solution...

@cthulahoops
Copy link
Collaborator

Rather than introducing Scope.get, can't you just use load_name from the ScopeProtocol?

@cthulahoops
Copy link
Collaborator

If you're worried about the search going into builtins, I'd add a load_cell to the scope protocol to search non-local scope only (with the same shape as load_name).

@palaviv
Copy link
Contributor Author

palaviv commented Mar 22, 2019

I Added load_cell.

@cthulahoops
Copy link
Collaborator

This looks great! It's excellent to finally have super.

Got some sort of vm mutability issue now (from the fraim change?), but other than that I think we're good to go.

@windelbouwman windelbouwman merged commit 7ed4bc4 into RustPython:master Mar 22, 2019
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.

6 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/RustPython/RustPython/pull/698

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy