Skip to content

Licensing.parse: Raise ExpressionParseError instead of ParseError#36

Merged
pombredanne merged 3 commits intoaboutcode-org:masterfrom
carmenbianca:expressionerror
May 31, 2019
Merged

Licensing.parse: Raise ExpressionParseError instead of ParseError#36
pombredanne merged 3 commits intoaboutcode-org:masterfrom
carmenbianca:expressionerror

Conversation

@carmenbianca
Copy link
Contributor

Fixes #35.

I also removed the except TypeError statement inside of the method. It didn't appear to do much that I could see. It didn't light up any tests when I removed it, either.

ExpressionParseError is a subclass of both ParseError and
ExpressionError. This allows the user to do `except ParseError`
as they had done before, and nothing will break. If the user does
`except ExpressionError`, the ParseErrors will now also be caught.

The advantage of doing this is that `except ExpressionError` now
catches all exceptions coming out of this method.

This is therefore a breaking change.

Signed-off-by: Carmen Bianca Bakker <carmen@carmenbianca.eu>

ExpressionParseError is a subclass of both ParseError and
ExpressionError. This allows the user to do `except ParseError`
as they had done before, and nothing will break. If the user does
`except ExpressionError`, the ParseErrors will now also be caught.

The advantage of doing this is that `except ExpressionError` now
catches all exceptions coming out of this method.

This is therefore a breaking change.

Signed-off-by: Carmen Bianca Bakker <carmen@carmenbianca.eu>
Signed-off-by: Carmen Bianca Bakker <carmen@carmenbianca.eu>
@carmenbianca
Copy link
Contributor Author

This Python 3.6 test is broken: https://travis-ci.org/nexB/license-expression/jobs/535835832

Not sure why, but pyenv install -s 3.6.1 fails.

The Python 2 tests are also broken because I use raise ... from. That should be an easy fix if you want to keep Python 2 compatibility, but Python 2 is almost EOL.

@pombredanne
Copy link
Member

@carmenbianca Thank you ++
We definitely want to keep this compatible with Python2 for now, if anything at least until ScanCode is ported to Python 3 (which is something that will happen soon, starting next week as a GSoC-sponsored project).

As for the Pyenv issue, sounds like the pyenv version on macOS is old... and your forced usage of Python 3 idioms brought that issue to light!

The solution would be to update pyenv to the latest version as part of CI run.

Signed-off-by: Carmen Bianca Bakker <carmen@carmenbianca.eu>
@carmenbianca
Copy link
Contributor Author

I have changed the code to be compatible with Python 2.7

I unfortunately do not know how to solve the pyenv issue.

@pombredanne
Copy link
Member

Sounds like we are affected by travis-ci/travis-ci#9929

@pombredanne
Copy link
Member

@carmenbianca while @Abhishek-Dev09 is working out a way yo get Azure pipelines for proper testing on Scancode (that we can then reuse here too), I am merging this anyway as this should not be held by these issues.

@pombredanne pombredanne merged commit 619a871 into aboutcode-org:master May 31, 2019
@pombredanne
Copy link
Member

Thank you ++

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.

Licensing.parse() raises too many exceptions

2 participants