I think this code reads a bit more nicely if you pull all the errors off
first, and then call `_handle_error_code`.


On Sat, Feb 1, 2014 at 8:24 AM, Alex Stapleton <notifications@github.com>wrote:

> In cryptography/hazmat/backends/openssl/backend.py:
>
> > @@ -182,12 +182,24 @@ def _handle_error(self, mode):
> >          if not code and isinstance(mode, GCM):
> >              raise InvalidTag
> >          assert code != 0
> > +
> > +        try:
> > +            return self._handle_error_code(code)
> > +        finally:
> > +            # consume any remaining errors on the stack
> > +            while code != 0:
> > +                code = self._lib.ERR_get_error()
>
> It can push lots of errors from a single API call. Only actually checking
> the first thing on the stack matches the current behaviour with the extra
> bonus of not breaking all future error checks. Obviously at some point we
> are likely to want to inspect the stack in greater detail.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/pyca/cryptography/pull/541/files#r9366120>
> .
>



-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero
GPG Key fingerprint: 125F 5C67 DFE9 4084