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

Fix for BinOp in args #96

Merged
merged 5 commits into from Oct 11, 2017
Merged

Fix for BinOp in args #96

merged 5 commits into from Oct 11, 2017

Conversation

@mbarkhau
Copy link
Contributor

@mbarkhau mbarkhau commented Oct 11, 2017

Fixes #95
Don't evaluate top level ast.BinOp arguments, treat them as strings instead.

mbarkhau added 2 commits Oct 11, 2017
Fixes #95
@googlebot
Copy link

@googlebot googlebot commented Oct 11, 2017

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again.

@googlebot
Copy link

@googlebot googlebot commented Oct 11, 2017

CLAs look good, thanks!

@dbieber
Copy link
Member

@dbieber dbieber commented Oct 11, 2017

Thanks for submitting this.
Can you confirm it doesn't break parsing negative numbers?

@mbarkhau
Copy link
Contributor Author

@mbarkhau mbarkhau commented Oct 11, 2017

I added an assertion, yes looks like negative numbers are still parsed as before to type int or float. I guess the expression must be ast.UnaryOp or something.

@@ -94,6 +94,9 @@ def _LiteralEval(value):
SyntaxError: If the value string has a syntax error.
"""
root = ast.parse(value, mode='eval')
if isinstance(root.body, ast.BinOp):
return value

This comment has been minimized.

@dbieber

dbieber Oct 11, 2017
Member

Let's raise a ValueError here instead, so that the logic of "treat this thing that doesn't parse as a string" all exists in one place (line 74).

This comment has been minimized.

@mbarkhau

mbarkhau Oct 11, 2017
Author Contributor

Ahh right, the fallback logic is to treat it as a string anyway. Good point.

@dbieber
Copy link
Member

@dbieber dbieber commented Oct 11, 2017

Thanks for adding the negative number tests in

@dbieber dbieber merged commit 7400ca8 into google:master Oct 11, 2017
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.