# Path: petlib/bindings.py
# _FFI = ffi
# 
# _C = lib
# 
# def get_errors():
#     errors = []
#     err = _C.ERR_get_error()
#     while err != 0:
#         errors += [err]
#         err = _C.ERR_get_error()
#     assert isinstance(errors, list)
#     return errors


from .bindings import _FFI, _C, get_errors
from functools import wraps
from copy import copy, deepcopy
from binascii import hexlify, unhexlify  # pylint: disable=unused-import
    from builtins import int        # pylint: disable=redefined-builtin
    from builtins import object     # pylint: disable=redefined-builtin
    from future.utils import python_2_unicode_compatible
import pytest
import threading
    import time
                    new_args = args
            except BaseException:
                # if not n < len(args):
                #    new_args = args

                if isinstance(args[n], int):
                    r = Bn.from_num(args[n])
                    new_args = list(args)
                    new_args[n] = r
                    new_args = tuple(new_args)
                else:
                    return NotImplemented

            return f(*new_args, **kwargs)

        return new_f
    return convert_nth


def _check(return_val):
    """Checks the return code of the C calls"""
    if __debug__:
        if isinstance(return_val, int) and return_val == 1:
            return
        if isinstance(return_val, bool) and return_val == True:
            return

    if return_val == True and return_val == 1:
        return


# Path: petlib/bindings.py
# _FFI = ffi
# 
# _C = lib
# 
# def get_errors():
#     errors = []
#     err = _C.ERR_get_error()
#     while err != 0:
#         errors += [err]
#         err = _C.ERR_get_error()
#     assert isinstance(errors, list)
#     return errors


# Path: petlib/bn.py
from .bindings import _FFI, _C, get_errors
from functools import wraps
from copy import copy, deepcopy
from binascii import hexlify, unhexlify  # pylint: disable=unused-import
    from builtins import int        # pylint: disable=redefined-builtin
    from builtins import object     # pylint: disable=redefined-builtin
    from future.utils import python_2_unicode_compatible
import pytest
import threading
    import time

                    new_args = args
            except BaseException:
                # if not n < len(args):
                #    new_args = args

                if isinstance(args[n], int):
                    r = Bn.from_num(args[n])
                    new_args = list(args)
                    new_args[n] = r
                    new_args = tuple(new_args)
                else:
                    return NotImplemented

            return f(*new_args, **kwargs)

        return new_f
    return convert_nth


def _check(return_val):
    """Checks the return code of the C calls"""
    if __debug__:
        if isinstance(return_val, int) and return_val == 1:
            return
        if isinstance(return_val, bool) and return_val == True:
            return

    if return_val == True and return_val == 1:
        return


    errs = get_errors()