Code Monkey home page Code Monkey logo

Comments (3)

shanjng avatar shanjng commented on July 18, 2024 1

I received the same error when using visit_Call() then doing astor.to_source(). The issue can be fixed with 'return ast.Expr(value=None)' instead of 'return None'

from astor.

aron-bordin avatar aron-bordin commented on July 18, 2024

I tested using only ast, and I see that it works with def visit_Expr instead of def visit_Call.
So the problem is on my transformer, sorry πŸ˜•

But using only ast, this transformer was not working on python2 and not working on py3; with astor, it works on py2. I'm closing the issue, because it seems to be a problem with my transformer(this is my first usage of ast), but if there is anything that I can help, I'd love to help ;)

Thx

from astor.

pmaupin avatar pmaupin commented on July 18, 2024

Without thinking too hard about your code and what is going on, you could certainly replace the statement:

def visit_Expr(self, node):
    set_precedence(node, node.value)
    ...

With:

def visit_Expr(self, node):
    if hasattr(node, 'value'):
        set_precedence(node, node.value)
    ...

to see if that helps. But if you want to open a PR, you'd need to explain carefully what this is good for, with a good example (and preferably a test case).

Regards,
Pat

from astor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.