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

Syntax error in debug line #8

Closed
matt-kempster opened this issue Nov 2, 2018 · 3 comments
Closed

Syntax error in debug line #8

matt-kempster opened this issue Nov 2, 2018 · 3 comments
Labels

Comments

@matt-kempster
Copy link

This line:

self.filenaame, node.lineno))

erroneously references filenaame, an attribute that does not exist. Additionally, the line above it mentions values[0] when values cannot be subscripted in some cases. I found success commenting this whole statement out - in fact, my mips_to_c repository is a success story for your support of Python 3.6+ type hinting, so thank you for implementing that!

@Technologicat
Copy link
Owner

Good catch, thank you, fixed!

(Should have been self.filename.)

@matt-kempster
Copy link
Author

Any thoughts on the value[0] thing? I also had to comment that out last time I used this project. Perhaps worth checking if value first.

@Technologicat
Copy link
Owner

Ah, I missed that, sorry!

I looked at it now. I think it should work in the latest release (1.0.4).

Indeed, value is a single AST node, as documented in GTS. It's also optional. It can be missing, if the statement is used just to declare the type of the target.

However, the helper function sanitize_exprs (in pyan/anutils.py) always wraps a single node in a Python list. This simplifies the calling end, by providing a consistent API to extract the first (sometimes only) AST node from the value, since some constructs support multiple nodes (which are represented as a list in the AST), while others support only a single node (in which case there is no wrapper in the AST itself).

Also, visit_AnnAssign has a check for if node.value is not None, which should cover the case where the optional value is missing. If I recall correctly, I added this check later - it probably was not there in the first attempt to support AnnAssign.

Could you try the latest release (1.0.4), and if it still crashes, provide a short example for testing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants