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

Improve source visitors #17

Merged
merged 22 commits into from
Oct 24, 2018
Merged

Conversation

pkubiak
Copy link
Contributor

@pkubiak pkubiak commented Oct 21, 2018

Pull request fixing remaining bugs from #11.
Add .inside() decorator for surrounding codeblock with writes.

@pkubiak pkubiak changed the title Improve source visitors WIP: Improve source visitors Oct 21, 2018
@pkubiak pkubiak changed the title WIP: Improve source visitors Improve source visitors Oct 22, 2018
@phihos
Copy link
Collaborator

phihos commented Oct 23, 2018

Looks great.

One thing though: When I run the code against cpython with your tester it crashes in cpython/Lib/test/pickletester.py when parsing a complex number. The method visit_Num is the culprit. I already fixed it:

    def visit_Num(self, node):
        if isinstance(node.n, complex):
            cond = node.n.real < 0
        else:
            cond = node.n < 0
        with self.inside('(', ')', cond=cond):
            self.write(repr(node.n))

Could you add a fix like this and also add a test with a complex number?

Edit: I found out how to trigger the error in the tests. You can just add '0 + 0j', to the num section in the tests.

@pkubiak
Copy link
Contributor Author

pkubiak commented Oct 24, 2018

Bug should be fixed now, astmonkey-tester generate only SyntaxError and AssertionError ;)

@phihos phihos merged commit 8da9e41 into mutpy:master Oct 24, 2018
@phihos
Copy link
Collaborator

phihos commented Oct 24, 2018

Thank you for your outstanding work! Maybe some day we will reach 100% an cpython :-)

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.

None yet

2 participants