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

Using six.raise_from wherever possible. #212

Merged
merged 3 commits into from
Nov 9, 2017

Conversation

dhermes
Copy link
Contributor

@dhermes dhermes commented Nov 9, 2017

I'm not entirely sure how worthwhile this is, I just discovered the implementation doesn't do anything helpful in Python 2 (e.g. print the traceback from the original exc):

# Python < 3.2
def raise_from(value, from_value):
    raise value
# Python == 3.2
def raise_from(value, from_value):
    try:
        if from_value is None:
            raise value
        raise value from from_value
    finally:
        value = None
# Python > 3.2
def raise_from(value, from_value):
    try:
        raise value from from_value
    finally:
        value = None

I was "inspired" to do this by #211.

@@ -85,7 +85,6 @@ def test__load_credentials_from_file_authorized_user_bad_format(tmpdir):
_default._load_credentials_from_file(str(filename))

assert excinfo.match(r'Failed to load authorized user')
assert excinfo.match(r'missing fields')

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@dhermes
Copy link
Contributor Author

dhermes commented Nov 9, 2017

@jonparrott I updated so that the wrapped exceptions were still wrapped.

@dhermes dhermes merged commit 01efcd4 into googleapis:master Nov 9, 2017
@dhermes dhermes deleted the six-raise-from branch November 9, 2017 21:00
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.

None yet

2 participants