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

re-raise the original exception, not a copy of it #2764

Merged
merged 1 commit into from May 14, 2017

Conversation

Projects
None yet
2 participants
@evgeni
Copy link
Contributor

commented May 14, 2017

Pull Request Checklist

  • I’ve read the guidelines for contributing.
  • I updated AUTHORS.txt and CHANGES.txt (if the change is non-trivial) and documentation (if applicable).
  • I tested my changes.

Description

otherwise the resulting traceback will have the raise line as the offending one, not the really problematic one.

example:

>>> try:
...     import nothing
... except ImportError as e:
...     raise e
Traceback (most recent call last):
  File "<input>", line 5, in <module>
    raise e
ImportError: No module named nothing

>>> try:
...     import nothing
... except ImportError as e:
...     raise
Traceback (most recent call last):
  File "<input>", line 2, in <module>
    import nothing
ImportError: No module named nothing
re-raise the original exception, not a copy of it
otherwise the resulting traceback will have the `raise` line as the
offending one, not the really problematic one.

example:

    >>> try:
    ...     import nothing
    ... except ImportError as e:
    ...     raise e
    Traceback (most recent call last):
      File "<input>", line 5, in <module>
        raise e
    ImportError: No module named nothing

    >>> try:
    ...     import nothing
    ... except ImportError as e:
    ...     raise
    Traceback (most recent call last):
      File "<input>", line 2, in <module>
        import nothing
    ImportError: No module named nothing

@evgeni evgeni force-pushed the evgeni:raise branch from 17e7606 to 60a86ff May 14, 2017

@ralsina
Copy link
Member

left a comment

Thanks for the fix!

@ralsina ralsina merged commit 119ca73 into getnikola:master May 14, 2017

3 checks passed

codacy/pr Good work! A positive pull request.
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
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
You can’t perform that action at this time.