3
kZ @ s d Z ddlZddlZddlZejd dkZer8eZeZ ne
ZeZ ee fZy
ejZ
W n ek
rn dd Z
Y nX eeddrdd Znd d ZdS )
z
The `compat` module provides support for backwards compatibility with older
versions of python, and compatibility wrappers around optional packages.
N c C sL t | t |krdS d}x*t| |D ]\}}|t|t|A O }q$W |dkS )z
Returns True if the two strings are equal, False otherwise.
The time taken is independent of the number of characters that match.
Fr )lenzipord)Zval1Zval2resultxy r /usr/lib/python3.6/compat.pyconstant_time_compare s r to_bytesc C s6 | }d}x|dkr$|d? }|d7 }q
W | j |dddS )Nr ZbigF)Zsigned)r )valZ remainingZbyte_lengthr r r
bytes_from_int. s
r c C sF g }x | r$t | d\} }|j| qW |j tjdt| f| S )N z%sB)divmodappendreversestructpackr )r ZbufZ remainderr r r
r 8 s )__doc__Zhmacr sysversion_infoZPY3strZ text_typebytesZbinary_typeZunicodeZstring_typesZcompare_digestr AttributeErrorgetattrintr r r r r