#NEWLINE# def _compat_to_bytes( intval , length , endianess ) : #NEWLINE# #INDENT# assert isinstance ( length , _compat_int_types ) #NEWLINE# assert ( endianess == 'big' ) #NEWLINE# if ( length == 4 ) : #NEWLINE# #INDENT# if ( ( intval < 0 ) or ( intval >= ( 2 ** 32 ) ) ) : #NEWLINE# #INDENT# raise struct . error ( "integer out of range for 'I' format code" ) #NEWLINE# #UNINDENT# return struct . pack ( b'!I' , intval ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( length == 16 ) : #NEWLINE# #INDENT# if ( ( intval < 0 ) or ( intval >= ( 2 ** 128 ) ) ) : #NEWLINE# #INDENT# raise struct . error ( "integer out of range for 'QQ' format code" ) #NEWLINE# #UNINDENT# return struct . pack ( b'!QQ' , ( intval >> 64 ) , ( intval & 18446744073709551615 ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise NotImplementedError ( )