# Path: rlp/exceptions.py
# class SerializationError(RLPException):
#     """Exception raised if serialization fails.
# 
#     :ivar obj: the object that could not be serialized
#     """
# 
#     def __init__(self, message, obj):
#         super(SerializationError, self).__init__(message)
#         self.obj = obj
# 
# Path: rlp/sedes/big_endian_int.py
# class BigEndianInt(object):
#     def __init__(self, l=None):
#     def serialize(self, obj):
#     def deserialize(self, serial):
# 
# Path: rlp/utils.py
# ALL_BYTES = tuple(
#     struct.pack('B', i)
#     for i in range(256)
# )


import binascii
import pytest
    import ctypes
    import sys
    import time
from eth_utils import int_to_big_endian
from rlp import SerializationError
from rlp.sedes import big_endian_int, BigEndianInt
from rlp.utils import ALL_BYTES


def packl(lnum):
    """Packs the lnum (which must be convertable to a long) into a
       byte string 0 padded to a multiple of padmultiple bytes in size. 0
       means no padding whatsoever, so that packing 0 result in an empty
       string.  The resulting byte string is the big-endian two's
       complement representation of the passed in long."""

    if lnum == 0:
        return b'\0'
    s = hex(lnum)[2:]
    s = s.rstrip('L')
    if len(s) & 1:
        s = '0' + s
    s = binascii.unhexlify(s)
    return s


try:
    PyLong_AsByteArray = ctypes.pythonapi._PyLong_AsByteArray
    PyLong_AsByteArray.argtypes = [ctypes.py_object,
                                   ctypes.c_char_p,
                                   ctypes.c_size_t,
                                   ctypes.c_int,
                                   ctypes.c_int]
    long_start = sys.maxint + 1

    def packl_ctypes(lnum):
        if lnum < long_start:

# Path: rlp/exceptions.py
# class SerializationError(RLPException):
#     """Exception raised if serialization fails.
# 
#     :ivar obj: the object that could not be serialized
#     """
# 
#     def __init__(self, message, obj):
#         super(SerializationError, self).__init__(message)
#         self.obj = obj
# 
# Path: rlp/sedes/big_endian_int.py
# class BigEndianInt(object):
#     def __init__(self, l=None):
#     def serialize(self, obj):
#     def deserialize(self, serial):
# 
# Path: rlp/utils.py
# ALL_BYTES = tuple(
#     struct.pack('B', i)
#     for i in range(256)
# )


# Path: tests/test_big_endian.py
import binascii
import pytest
    import ctypes
    import sys
    import time
from eth_utils import int_to_big_endian
from rlp import SerializationError
from rlp.sedes import big_endian_int, BigEndianInt
from rlp.utils import ALL_BYTES



def packl(lnum):
    """Packs the lnum (which must be convertable to a long) into a
       byte string 0 padded to a multiple of padmultiple bytes in size. 0
       means no padding whatsoever, so that packing 0 result in an empty
       string.  The resulting byte string is the big-endian two's
       complement representation of the passed in long."""

    if lnum == 0:
        return b'\0'
    s = hex(lnum)[2:]
    s = s.rstrip('L')
    if len(s) & 1:
        s = '0' + s
    s = binascii.unhexlify(s)
    return s


try:
    PyLong_AsByteArray = ctypes.pythonapi._PyLong_AsByteArray
    PyLong_AsByteArray.argtypes = [ctypes.py_object,
                                   ctypes.c_char_p,
                                   ctypes.c_size_t,
                                   ctypes.c_int,
                                   ctypes.c_int]
    long_start = sys.maxint + 1

    def packl_ctypes(lnum):
        if lnum < long_start:

            return int_to_big_endian(lnum)