Thriftpy / thriftpy

Thriftpy has been deprecated, please migrate to https://github.com/Thriftpy/thriftpy2
MIT License
1.15k stars 288 forks source link

thriftpy/thrift.py grammar mistakes ? #323

Open zhangzhenhu opened 6 years ago

zhangzhenhu commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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.