Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Fix/empty code fatal #26

Merged
merged 2 commits into from
Jun 21, 2017
Merged

Fix/empty code fatal #26

merged 2 commits into from
Jun 21, 2017

Conversation

juanjux
Copy link
Contributor

@juanjux juanjux commented Jun 21, 2017

Fixes #25 which could be related with SDK/#34.

- Return an AST for the module for empty files
- Dont lose the AST on errors that produced it anyway
- Updated tests, improved typing
Copy link

@alcortesm alcortesm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that I have very little experience with Python.

elif ast:
ret_ast = ast
else:
# Empty modules are still modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this function returns only errors or not. In the former case I'd say it's better to return an empty AST (or at least we should decide what to expect in that case and document it), in the latter not sure if this fallback case should be handled in this method (since its name suggests that it's for returning errors). Maybe the code is correct but the name should be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function produces and error result and sends it; it doesn't return anything as function return value. Tried returning the empty AST before in the case of the empty module but unfortunately the SDK at some point turns and empty AST into a fatal error which is actually as defined (fatal error is the lack of an AST) but undesirable in this case.

Actually, now that I think again about it, empty code shouldn't be an error - but it will still produce this "module only" AST since in Python eve binary modules can have meaning (like __init__.py in this case). So I'll change that part.

@@ -30,6 +30,14 @@ class RequestCheckException(Exception):
"""
pass

class EmptyCodeException(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that this exception replaces the RequestCheckException one (I've not seen it used at least). If that's the case, remove the old one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It replaced it. Removing the old one.

@bzz
Copy link
Contributor

bzz commented Jun 21, 2017

🎉 Would be super-happy to test it locally with https://gist.github.com/bzz/c0c3dbcab5fecbe48e22167e2ad78595 as soon as it's ready.

@juanjux juanjux merged commit fb5cd3c into bblfsh:master Jun 21, 2017
@abeaumont
Copy link
Contributor

Why has this been merged while having requested changes?

@juanjux juanjux deleted the fix/empty_code_fatal branch June 22, 2017 11:08
@juanjux
Copy link
Contributor Author

juanjux commented Jul 5, 2017

Sorry @abeaumont I missed your last message. All your feedback on both points was translated into changes as you can see. Did I miss something?

@abeaumont
Copy link
Contributor

@juanjux I didn't look at it since it was already merged, but looking at it now I see that EmptyCodeException is not raised anymore, while it's still defined and captured in an except statement, that'd be better if removed.

@juanjux
Copy link
Contributor Author

juanjux commented Jul 5, 2017

@abeaumont true, I'll remove it on a separate PR I'll do as soon as I've five minutes free to remove the MsgPack support, thanks.

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

Successfully merging this pull request may close these issues.

None yet

4 participants