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

wrap bare str raises with generic Exception() #2421

Merged
merged 2 commits into from May 26, 2016

Conversation

Projects
None yet
3 participants
@martenson
Copy link
Member

commented May 26, 2016

The probable cause is that Python 2.7 does not support raising bare str exceptions anymore.
TypeError: exceptions must be old-style classes or derived from BaseException, not str

We might want to backport this to 16.04? Maybe just part of it that affects live code.

Found as a part of #2419
Happens on Main: https://sentry.galaxyproject.org/sentry/main/issues/115526/

wrap bare str raises with generic Exception()
as Pyton 2.7 does not support bare str

@martenson martenson added this to the 16.07 milestone May 26, 2016

@martenson

This comment has been minimized.

Copy link
Member Author

commented May 26, 2016

Do we know why our lint does not report these? @nsoranzo @jmchilton

@dannon dannon merged commit ef41746 into galaxyproject:dev May 26, 2016

4 checks passed

api test Build finished. 213 tests run, 0 skipped, 0 failed.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
framework test Build finished. 106 tests run, 0 skipped, 0 failed.
Details
toolshed test Build finished. 581 tests run, 0 skipped, 0 failed.
Details
@dannon

This comment has been minimized.

Copy link
Member

commented May 26, 2016

Backporting seems reasonable

@jmchilton

This comment has been minimized.

Copy link
Member

commented May 26, 2016

The answer to why the linting doesn't catch it is because it is a type error and not a syntax problem I guess. The syntax for exception statements is probably something like:
exception_statement := raise <expression>
"bad thing" and Exception("bad thing") are both just expressions so the syntax is valid - type inference is needed to dig further. Clearly even a cursory attempt to infer types would cause a linter to detect this - but I guess ours doesn't do that.

@martenson martenson deleted the martenson:wrap-str-raises branch May 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.