Skip to content
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.

thriftpy/thrift.py grammar mistakes ? #323

Open
zhangzhenhu opened this issue Jan 17, 2018 · 2 comments
Open

thriftpy/thrift.py grammar mistakes ? #323

zhangzhenhu opened this issue Jan 17, 2018 · 2 comments

Comments

@zhangzhenhu
Copy link

zhangzhenhu commented Jan 17, 2018

thriftpy/thrift.py:292
else and raise ???

def handle_exception(self, e, result):
        for k in sorted(result.thrift_spec):
            if result.thrift_spec[k][1] == "success":
                continue
            _, exc_name, exc_cls, _ = result.thrift_spec[k]
            if isinstance(e, exc_cls):
                setattr(result, exc_name, e)
                break
        else:
            raise
@microdog
Copy link
Contributor

If no expressions are present, raise re-raises the last exception that was active in the current scope.[1][2]

You can find more information from this PR: #206.

[1] https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement
[2] https://docs.python.org/2/reference/simple_stmts.html#the-raise-statement

@microdog
Copy link
Contributor

microdog commented Jan 17, 2018

Some linters may report this line as an error because it is not placed in an except block directly. But handle_exception() will only be invoked in the outer except block, so this should not be a problem.

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

No branches or pull requests

2 participants