HEX
Server: Apache
System: Linux zacp120.webway.host 4.18.0-553.50.1.lve.el8.x86_64 #1 SMP Thu Apr 17 19:10:24 UTC 2025 x86_64
User: govancoz (1003)
PHP: 8.3.26
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: //usr/local/lib/python3.10/test/__pycache__/test_int.cpython-310.pyc
o

�iHq�@s�ddlZddlZddlZddlmZddlmZmZdddddd	d
ddd
eej	�ej	fde
fdde
fde
fde
fde
fde
fgZGdd�de�Z
Gdd�dej�ZGdd�dej�ZGdd�de�Zedkrle��dSdS)�N)�support)�VALID_UNDERSCORE_LITERALS�INVALID_UNDERSCORE_LITERALS)�0r)�1�)�9�	)�10�
)Z99�c)�100�d)Z314�:)z 314r)z314 r)z  		  314  		  rz  1x)z  1  rz  1  �� �  		  uȀc@�eZdZdS)�IntSubclassN��__name__�
__module__�__qualname__�rr�*/usr/local/lib/python3.10/test/test_int.pyr�rc@s�eZdZdd�Zdd�Zejdd��Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#S)$�IntTestCasescCsB	|�td�d�|�td�d�|�td�d�|�td�d�|�td�d�|�td�d�|�td	�d�|�td
�d�|�td�d�|�td�d�|�td
d�d�tD]4\}}dD]-}dD](}|||}|}|dkrz|turz|}z
|�t|�|�Wqety�Yqewqaq[tdtj�}t|�}|�|dtj�|�|t�|�t|dd��tjd�td�}|�|t�td�}|�|t�dtj}|�|d?|d�td�}|�|t�|�t	tdd�|�tdd�d�|�tdd�d�|�ttdd�|�ttdd�|�ttdd �|�ttdd�|�ttd!d�|�ttd!d�|�td"d�d#�|�td$d�d#�|�td%d&�d#�|�td'd(�d#�|�td)d*�d#�|�td+d,�d#�|�td-d �d#�|�td.d/�d#�|�td0d1�d#�|�td2d3�d#�|�td4d�d#�|�td5d6�d#�|�td7d8�d#�|�td9d:�d#�|�td;d�d#�|�td<d=�d#�|�td>d?�d#�|�td@dA�d#�|�tdBdC�d#�|�tdDdE�d#�|�tdFdG�d#�|�tdHdI�d#�|�tdJdK�d#�|�tdLdM�d#�|�tdNdO�d#�|�tdPdQ�d#�|�tdRdS�d#�|�tdTdU�d#�|�tdVdW�d#�|�tdXdY�d#�|�tdZd[�d#�|�td\d]�d#�|�td^d_�d#�|�td`da�d#�|�tdbdc�d#�|�tddd�d�|�tddd�d�|�tded�d�|�tdd�d�|�tdd�d�|�tdfd�d&�|�tdgd�d�|�tdhd�d�|�tdid�d&�|�tdj�dk�|�tdjd1�dk�|�tdd�d�|�tdd �d�|�tdfd�d&�|�tdld�d�|�tdmd �d�|�tdnd�d&�|�ttdod�|�ttdpd�|�ttdqd�|�ttdrd�|�ttdsd �|�ttdtd �|�ttdud �|�ttdvd �|�ttdwd�|�ttdxd�|�ttdyd�|�ttdzd�|�td{d�d|�|�td}d�d|�|�td~d&�d|�|�tdd(�d|�|�td�d*�d|�|�td�d,�d|�|�td�d �d|�|�td�d/�d|�|�td�d1�d|�|�td�d3�d|�|�td�d�d|�|�td�d6�d|�|�td�d8�d|�|�td�d:�d|�|�td�d�d|�|�td�d=�d|�|�td�d?�d|�|�td�dA�d|�|�td�dC�d|�|�td�dE�d|�|�td�dG�d|�|�td�dI�d|�|�td�dK�d|�|�td�dM�d|�|�td�dO�d|�|�td�dQ�d|�|�td�dS�d|�|�td�dU�d|�|�td�dW�d|�|�td�dY�d|�|�td�d[�d|�|�td�d]�d|�|�td�d_�d|�|�td�da�d|�|�td�dc�d|�dS)�Nrg��Q�	@�g��Q�	����g333333@g333333�g@g�z-3z -3 u -3 r
�)r�+�-)rr�	rr!���rg}Ô%�I�Tg}Ô%�I���AX111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111�Z0o123r�SZ0x123i#�0xZ0o�Z0bZ!100000000000000000000000000000000lZ102002022201221111211Z10000000000000000�Z32244002423141�Z
1550104015504�Z211301422354�Z40000000000Z12068657454r	Z
4294967296rZ
1904440554�Z	9ba461594Z	535a79889�
Z	2ca5b7464�Z	1a20dcd81�Z	100000000Za7ffda91�Z704he7g4�Z4f5aff66�Z3723ai4g�Z281d55i4�Z1fj8b184�Z1606k7ic�Zmb994ag�Zhek2mgl�Zdnchbnm�Zb28jpdm�Z8pfgih4�Z76beigg�Z5qmcpqg�Z4q0jto4�Z4000000� Z3aokq94�!Z2qhxjli�"Z2br45qb�#Z1z141z4�$z 0o123  Z000Z0b100z	 0O123   z 0X123  z 0B100 Z0123�{Z0X123Z0O123Z0B100Z0b2Z0b02Z0B2Z0B02Z0o8Z0o08Z0O8Z0O08Z0xgZ0x0gZ0XgZ0X0gZ!100000000000000000000000000000001lZ102002022201221111212Z10000000000000001Z32244002423142Z
1550104015505Z211301422355Z40000000001Z12068657455Z
4294967297Z
1904440555Z	9ba461595Z	535a7988aZ	2ca5b7465Z	1a20dcd82Z	100000001Za7ffda92Z704he7g5Z4f5aff67Z3723ai4hZ281d55i5Z1fj8b185Z1606k7idZmb994ahZhek2mgmZdnchbnnZb28jpdnZ8pfgih5Z76beighZ5qmcpqhZ4q0jto5Z4000001Z3aokq95Z2qhxjljZ2br45qcZ1z141z5)
�assertEqual�int�L�
ValueError�repr�sys�maxsizeZassertIsInstance�assertRaises�	TypeError)�self�s�v�sign�prefix�ssZvv�xrrr�
test_basic#s$���
zIntTestCases.test_basicc	s�tD])�t�fdd�dD��rq|�t�d�t���|�t�d�t��dd�d��qtD]�t�fdd�dD��r<q.|�tt�d�q.|�tdd	�d
�|�td�d�|�td
�d�|�ttd�|�ttd�|�ttd�|�ttd�dS)Nc3��|]}|�vVqdS�Nr��.0Zch�Zlitrr�	<genexpr>���z0IntTestCases.test_underscores.<locals>.<genexpr>z.eEjJr�_rc3rWrXrrYr[rrr\�r]Z1_00rr	Z0_100rs1_00Z_100z+_100Z1__00Z100_)	r�anyrFrG�eval�replacerrMrI�rOrr[r�test_underscores�s "zIntTestCases.test_underscorescCsD|�td�d�|�td�d�|�td�d�|�td�d�dS)Nr
rz-1r#s10s-1)�assertIsrGrbrrr�test_small_ints�szIntTestCases.test_small_intscCs|�t�d�dS)Nr�rFrGrbrrr�test_no_args��zIntTestCases.test_no_argscCs�|�tddd�d�|�td��
tdd�Wd�n1s wY|�td��tddd�Wd�n1s<wY|jttd	d�|jttd
d�dS)Nr
r$��baser)zkeyword argumentg333333�?)rU)rUrjrr)rFrG�assertRaisesRegexrNrMrbrrr�test_keyword_args�s��zIntTestCases.test_keyword_argscCsN|�tdd�d�|�t��
tdd�Wd�n1swY|�t��
tdd�Wd�n1s8wY|�t��
tdd�Wd�n1sRwY|�t��tdddd	d
�Wd�n1sqwY|�t��tddd	d
�Wd�n1s�wYtdd�D]}|�td|d
�d�q�dS)z9Testing the supported limits of the int() base parameter.rr*rrN�%is���r$��ri)rFrGrMrI�range�rOrjrrr�test_int_base_limitss&������z!IntTestCases.test_int_base_limitscCsn|�t��
tdd�Wd�n1swY|�t��tdd�Wd�dS1s0wYdS)z2Not integer types are not valid bases; issue16772.rg@Ng@)rMrNrGrbrrr�test_int_base_bad_typess�"�z$IntTestCases.test_int_base_bad_typesc	Cs�Gdd�dt�}ddddddfD]}|�t��
td|�Wd�n1s*wYq|�td|d�d	�d
�|�td|d�d	�d�|�td|d
�d	�d�dS)Nc@�eZdZdd�Zdd�ZdS)z9IntTestCases.test_int_base_indexable.<locals>.MyIndexablecSs
||_dSrX��value)rOrurrr�__init__s
zBIntTestCases.test_int_base_indexable.<locals>.MyIndexable.__init__cSs|jSrXrtrbrrr�	__index__�zCIntTestCases.test_int_base_indexable.<locals>.MyIndexable.__index__N)rrrrvrwrrrr�MyIndexable�ryr$rrrmZ43Z101rir*r�erDi)�objectrMrIrGrF)rOryrjrrr�test_int_base_indexables��z$IntTestCases.test_int_base_indexablec
shGdd�dt��Gdd�dt�}Gdd�dt�}tt�fdd�||tg}zd	d
lm�Wn	ty5Yn
w|��fdd��|D]p}|d�}|�t|���[|�	t
|�d
�t|tttf�ri|�	t
|d�d�nd}|�t
|��
t
|d�Wd�n1s�wY|�td��t
|d��Wd�n1s�wYWd�n1s�wYqAdS)Nc@r)z<IntTestCases.test_non_numeric_input_types.<locals>.CustomStrNrrrrr�	CustomStr.�r~c@r)z>IntTestCases.test_non_numeric_input_types.<locals>.CustomBytesNrrrrr�CustomBytes/rr�c@r)zBIntTestCases.test_non_numeric_input_types.<locals>.CustomByteArrayNrrrrr�CustomByteArray0rr�cs�|���SrX)�decode��b)r~rr�<lambda>5rz;IntTestCases.test_non_numeric_input_types.<locals>.<lambda>r��arraycs
�d|�S)N�Brr�r�rrr�?s
s100rr$r)zcan't convert non-stringzinvalid literalsAAAAAAAAAAAAAAAA)�str�bytes�	bytearray�
memoryviewr��ImportError�append�subTest�typerFrG�
isinstancerkrNrI)rOr�r�Z	factories�frU�msgr)r~r�r�test_non_numeric_input_types+sB
��������z)IntTestCases.test_non_numeric_input_typescCs�|�ttd�dd��d�|�ttd�dd��d�|�ttd�dd��d�|�ttd�dd��d�|�ttd�dd��d�dS)	Ns123rrr7�123s123 s123As1234)rFrGr�rbrrr�test_int_memoryviewNs
 z IntTestCases.test_int_memoryviewcCs|�ttd�dS)Nz1.2)rMrIrGrbrrr�test_string_floatUrhzIntTestCases.test_string_floatcsZGdd�d�}|�tt|��Gdd�dt�}|�tt|��Gdd�d�}|�t|��d�Gdd	�d	�}t|fD]�}Gd
d�d|�}|�t|��d�Gdd
�d
|�}|�t|��d�Gdd�d|�}|�t��
t|��Wd�n1s{wYt|fD]�}	Gdd�d|	��G�fdd�d|�}
|�t|
��d�Gdd�d|	��G�fdd�d|�}|�t|
��d�G�fdd�d|	��G�fdd�d|�}zt|��Wnty�}
z|�t|
�d�WYd}
~
nd}
~
ww|�d||	ff�Gdd�d|	��G�fd d!�d!|�}|�t��
t|��Wd�n	1�s$wYq�q:dS)"Nc@r)z>IntTestCases.test_intconversion.<locals>.ClassicMissingMethodsNrrrrr�ClassicMissingMethodsZrr�c@r)z7IntTestCases.test_intconversion.<locals>.MissingMethodsNrrrrr�MissingMethods^rr�c@�eZdZdd�ZdS)z-IntTestCases.test_intconversion.<locals>.Foo0cS�dS�N�*rrbrrr�__int__c�z5IntTestCases.test_intconversion.<locals>.Foo0.__int__N�rrrr�rrrr�Foo0b�r�r�c@r)z0IntTestCases.test_intconversion.<locals>.ClassicNrrrrr�Classichrr�c@rs)z:IntTestCases.test_intconversion.<locals>.IntOverridesTrunccSr�r�rrbrrrr�lr�zBIntTestCases.test_intconversion.<locals>.IntOverridesTrunc.__int__cSr�)Ni�rrbrrr�	__trunc__nr�zDIntTestCases.test_intconversion.<locals>.IntOverridesTrunc.__trunc__N)rrrr�r�rrrr�IntOverridesTrunckrzr�c@r�)z2IntTestCases.test_intconversion.<locals>.JustTrunccSr�r�rrbrrrr�sr�z<IntTestCases.test_intconversion.<locals>.JustTrunc.__trunc__N�rrrr�rrrr�	JustTruncrr�r�c@r�)z9IntTestCases.test_intconversion.<locals>.ExceptionalTrunccSsdddS)Nrrrrbrrrr�xszCIntTestCases.test_intconversion.<locals>.ExceptionalTrunc.__trunc__Nr�rrrr�ExceptionalTruncwr�r�c@r�)z.IntTestCases.test_intconversion.<locals>.IndexcSr�r�rrbrrrrwr�z8IntTestCases.test_intconversion.<locals>.Index.__index__N�rrrrwrrrr�Index~r�r�c�eZdZ�fdd�ZdS)z;IntTestCases.test_intconversion.<locals>.TruncReturnsNonIntc���SrXrrb�r�rrr��rxzEIntTestCases.test_intconversion.<locals>.TruncReturnsNonInt.__trunc__Nr�rr�rr�TruncReturnsNonInt��r�c@r�)z0IntTestCases.test_intconversion.<locals>.IntablecSr�r�rrbrrrr��r�z8IntTestCases.test_intconversion.<locals>.Intable.__int__Nr�rrrr�Intable�r�r�cr�)z=IntTestCases.test_intconversion.<locals>.TruncReturnsNonIndexcr�rXrrb�r�rrr��rxzGIntTestCases.test_intconversion.<locals>.TruncReturnsNonIndex.__trunc__Nr�rr�rr�TruncReturnsNonIndex�r�r�cr�)z4IntTestCases.test_intconversion.<locals>.NonIntegralcr�rXrrb��NonIntegralrrr��sz>IntTestCases.test_intconversion.<locals>.NonIntegral.__trunc__Nr�rr�rrr��r�r�cr�)z@IntTestCases.test_intconversion.<locals>.TruncReturnsNonIntegralcr�rXrrbr�rrr��rxzJIntTestCases.test_intconversion.<locals>.TruncReturnsNonIntegral.__trunc__Nr�rr�rr�TruncReturnsNonIntegral�r�r�z2__trunc__ returned non-Integral (type NonIntegral)z!Failed to raise TypeError with %sc@r�)z/IntTestCases.test_intconversion.<locals>.BadIntcSr��NgE@rrbrrrr��r�z7IntTestCases.test_intconversion.<locals>.BadInt.__int__Nr�rrrr�BadInt�r�r�cr�)z;IntTestCases.test_intconversion.<locals>.TruncReturnsBadIntcr�rXrrb�r�rrr��rxzEIntTestCases.test_intconversion.<locals>.TruncReturnsBadInt.__trunc__Nr�rr�rr�TruncReturnsBadInt�r�r�)rMrNrGr|rF�ZeroDivisionErrorr�Zfail)rOr�r�r�r�rjr�r�r�Ztrunc_result_baser�r�r��er�r)r�r�r�r�r�test_intconversionXsX�
��������zIntTestCases.test_intconversioncCsZGdd�dt�}Gdd�dt�}|d�}|�|d�|�t|�d�|�t|��d�dS)Nc@r�)z:IntTestCases.test_int_subclass_with_index.<locals>.MyIndexcSr�r�rrbrrrrw�r�zDIntTestCases.test_int_subclass_with_index.<locals>.MyIndex.__index__Nr�rrrr�MyIndex�r�r�c@r�)z;IntTestCases.test_int_subclass_with_index.<locals>.BadIndexcSr�r�rrbrrrrw�r�zEIntTestCases.test_int_subclass_with_index.<locals>.BadIndex.__index__Nr�rrrr�BadIndex�r�r�r,r)rGrF)rOr�r��my_intrrr�test_int_subclass_with_index�sz)IntTestCases.test_int_subclass_with_indexcCsjGdd�dt�}Gdd�dt�}|d�}|�|d�|�t|�d�|d�}|�|d�|�tt|�dS)Nc@r�)z6IntTestCases.test_int_subclass_with_int.<locals>.MyIntcSr�r�rrbrrrr��r�z>IntTestCases.test_int_subclass_with_int.<locals>.MyInt.__int__Nr�rrrr�MyInt�r�r�c@r�)z7IntTestCases.test_int_subclass_with_int.<locals>.BadIntcSr�r�rrbrrrr��r�z?IntTestCases.test_int_subclass_with_int.<locals>.BadInt.__int__Nr�rrrrr��r�r�r,r�)rGrFrMrN)rOr�r�r�rrr�test_int_subclass_with_int�sz'IntTestCases.test_int_subclass_with_intc	sNGdd�d��Gdd�dt�}Gdd�d��Gdd�dt�}G�fd	d
�d
�}G�fdd�d�}Gd
d�d�}��}|�t��t|�}Wd�n1sNwY|�|d�|�t|�t�|�}t|�}|�|d�|�t|�t���}|�t��t|�}Wd�n1s�wY|�|d�|�t|�t�|�}|�t��t|�}Wd�n1s�wY|�|d�|�t|�t�|�}|�t��t|�}Wd�n1s�wY|�|d�|�t|�t�|�}|�tt|�|�}t|�}|�|d�|�t|�t�t|�}|�|d�|�t|�t�dS)Nc@r�)z<IntTestCases.test_int_returns_int_subclass.<locals>.BadIndexcSr��NTrrbrrrrw�r�zFIntTestCases.test_int_returns_int_subclass.<locals>.BadIndex.__index__Nr�rrrrr��r�r�c@r�)z=IntTestCases.test_int_returns_int_subclass.<locals>.BadIndex2cSr�r�rrbrrrrw�r�zGIntTestCases.test_int_returns_int_subclass.<locals>.BadIndex2.__index__Nr�rrrr�	BadIndex2�r�r�c@r�)z:IntTestCases.test_int_returns_int_subclass.<locals>.BadIntcSr�r�rrbrrrr��r�zBIntTestCases.test_int_returns_int_subclass.<locals>.BadInt.__int__Nr�rrrrr��r�r�c@r�)z;IntTestCases.test_int_returns_int_subclass.<locals>.BadInt2cSr�r�rrbrrrr��r�zCIntTestCases.test_int_returns_int_subclass.<locals>.BadInt2.__int__Nr�rrrr�BadInt2�r�r�cr�)zHIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIndexcr�rXrrb�r�rrr��rxzRIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIndex.__trunc__Nr�rr�rr�TruncReturnsBadIndex�r�r�cr�)zFIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIntcr�rXrrbr�rrr��rxzPIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadInt.__trunc__Nr�rr�rrr��r�r�c@r�)zKIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsIntSubclasscSr�r�rrbrrrr��r�zUIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsIntSubclass.__trunc__Nr�rrrr�TruncReturnsIntSubclass�r�r�rr)	rGZassertWarns�DeprecationWarningrFrdr�rMrNr)	rOr�r�r�r�r�Zbad_int�nZgood_intr)r�r�r�test_int_returns_int_subclass�sX
�
�
�
�z*IntTestCases.test_int_returns_int_subclasscs�d�fdd�	}|d�|d�|d�|d�|dd�|dd	�|dd
�|dd	�|dd
�|d�|dd�|d
�|d
d�|d�|dd�dS)Ncs~�jtd||fd��}|durt|�nt||�Wd�n1s$wY��|jjdd|dur7dn||f�dS)Nzint(%r, %r))r�rz*invalid literal for int() with base %d: %rr)rMrIrGrF�	exception�args)rPrj�cmrbrr�checks
�

����z.IntTestCases.test_error_message.<locals>.check�½u123½z  123 456  z123rz123 245r4rz123245r�s123�u123�rXr)rOr�rrbr�test_error_messages 






zIntTestCases.test_error_messagecCsL|�tdd�d�|�tdd�d�|�tdd�d	�|�td
d�d�dS)
NZ=1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1_0_1r$iUUUUZ1_2_3_4_5_6_7_0_1_2_3r(iSp�SZ1_2_3_4_5_6_7_8_9rl�g�FZ
1_2_3_4_5_6_7r@i�2Drfrbrrr�test_issue316194s�zIntTestCases.test_issue31619N)rrrrVrcrZcpython_onlyrergrlrqrrr}r�r�r�r�r�r�r�r�r�rrrrr!s(8

#VE!rcs�eZdZeZ�fdd�Z�fdd�Zdd�Zdd�Zdd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Z�ZS)�IntStrDigitLimitsTestscs"t���t��|_t�d�dS)Ni)�super�setUprK�get_int_max_str_digits�_previous_limit�set_int_max_str_digitsrb��	__class__rrr�@s

zIntStrDigitLimitsTests.setUpcst�|j�t���dSrX)rKr�r�r��tearDownrbr�rrr�EszIntStrDigitLimitsTests.tearDowncCs�|�t��d�|�t��d�t�d��|�t��d�|�dd�}t|�Wd�n1s3wY|�t��d�dS)Nri Nr)	Z
assertGreaterrKr��
assertLessr�adjust_int_max_str_digitsrF�	int_classr�)rO�irrr�test_disabled_limitIs
�z*IntStrDigitLimitsTests.test_disabled_limitcCsz|j}t��}|d|�|dd|�|d|d�|dd|�|dd|�|�ttd|d��|�dS)z&Ignore the +/- sign and space padding.rrr r!rrN)r�rKr�rF�lenr�)rOr��	maxdigitsrrr�test_max_str_digits_edge_casesRs z5IntStrDigitLimitsTests.test_max_str_digits_edge_casesNcCs`|�t��!|dur|�|�n|�||�Wd�dSWd�dS1s)wYdSrX)rMrIr�)rOr�rjrrrr�^s�"�zIntStrDigitLimitsTests.checkcCs�t��}|�d|d�|�dd|d�|�d|dd�|�dd|d�|�dd|d�|�d|d�d|}|�t��
t|�Wd�dS1s[wYdS)Nrrrr r!r)rKr�r�rMrIr�)rOr�r�rrr�test_max_str_digitses
"�z*IntStrDigitLimitsTests.test_max_str_digitsc	Cs�t��}|dksJ|��tj}|�dkrtj}tddd��dd�}d}t�|��|�}t|�}Wd	�n1s;wY|�|}|�	t
|�|�|d
krZt�d|�d���t�td
|���)|�
t��}|�}t|�Wd	�n1s{wY|�|}	Wd	�n1s�wY|�dt|j��|�|	|d�tddd��dd�}
|�
t��}|�}t|
�Wd	�n1s�wY|�|}|�dt|j��|�||d�d	S)�?Regression test: ensure we fail before performing O(N**2) work.iP�rr'�ci�rrii�1N��?�"slow" conversion took only �	 seconds.gףp=
��?�
conversionr$i �)rKr��time�process_time�	monotonicrGrr�r�rFr��unittest�SkipTestrMrI�assertInr��assertLessEqualr�)rOr��get_timeZhuge_int�digits�startZhuge_decimal�seconds_to_convert�err�seconds_to_fail_hugeZextra_huge_int�seconds_to_fail_extra_hugerrr�+test_denial_of_service_prevented_int_to_strssD

�

�
��
�
zBIntStrDigitLimitsTests.test_denial_of_service_prevented_int_to_strc	Cs�t��}|dksJ|��tj}|�dkrtj}d}d|}t�|��|�}t|�Wd�n1s4wY|�|}|dkrKt�	d|�d���t�|d	��)|�
t��}|�}t|�Wd�n1sjwY|�|}Wd�n1s~wY|�d
t
|j��|�||d�dd
}	|�
t��}|�}t|	�Wd�n1s�wY|�|}
|�d
t
|j��|�|
|d�dS)r�順riD
�8Nr�r�r�rr�r$�7i�O)rKr�r�r�r�rr�rGr�r�rMrIr�r�r�r�)rOr�r�r�Zhuger�r�r�r�Z
extra_huger�rrr�+test_denial_of_service_prevented_str_to_int�sB

�

�
��
�
zBIntStrDigitLimitsTests.test_denial_of_service_prevented_str_to_intc	Csrt��}dD]0}|j|d�� |�d|d|�|dksJ�|�dd|�Wd�n1s1wYqdS)z-The limit does not apply to power of 2 bases.)r$r)r(rr@rirrr�N)rKr�r�r�)rOr�rjrrr�!test_power_of_two_bases_unlimited�s���z8IntStrDigitLimitsTests.test_power_of_two_bases_unlimitedcCsXt��}|d}d|}d|}|�|�|�|�|�|�d��|�|�d��dS)NrZ111Z1_11Z_111)rKr�r�r�)rOr�ZtriplesrPZs_rrr�test_underscores_ignored�s

z/IntStrDigitLimitsTests.test_underscores_ignoredcCsh|j}t��}d|}||�}|d|���}||ksJ�|d|���}||ks*J�t|�t|�dS)N�5r r!)r�rKr�r�)rOr��
max_digitsrPr�Zpos_iZneg_irrr�test_sign_not_counted�sz,IntStrDigitLimitsTests.test_sign_not_countedcCs�|j}t��}d|}|||�}|dkr.|�t��t|�Wd�n1s(wYn|dkr6t|�|�t��}||�d�|�Wd�dS1sOwYdS)N�2rr)r�rKr�rMrIr�)rOrjr�rrPr�r�rrr�_other_base_helper�s

��"�z)IntStrDigitLimitsTests._other_base_helpercCszd}|j|d��
|�|�Wd�n1swYd}|j|d��|�|�Wd�dS1s6wYdS)NrrirD)r�rrprrr�test_int_from_other_bases�s�"�z0IntStrDigitLimitsTests.test_int_from_other_basesrX)rrrrGr�r�r�r�r�r�r�r�r�r�r�rrr�
__classcell__rrr�rr�<s	
+(

r�c@seZdZeZdS)�IntSubclassStrDigitLimitsTestsN)rrrrr�rrrrr�sr�__main__)rKr�r��testrZtest.test_grammarrrrJrLrIrHrGrZTestCaserr�rr�mainrrrr�<module>sH�B�