
    <e|v                     V   d dl Z d dlZd dlZd dlmZ d dlmZmZ dddddd	d
ddd ee j	                  e j	        fde
fdde
fde
fde
fde
fde
fgZ G d de          Z G d dej                  Z G d dej                  Z G d de          Zedk    r ej                     dS dS )    N)support)VALID_UNDERSCORE_LITERALSINVALID_UNDERSCORE_LITERALS)0r   )1   )9	   )10
   )99c   )100d   )314:  )z 314r   )z314 r   )z  		  314  		  r   z  1x)z  1  r   z  1      		  u   Ȁc                       e Zd ZdS )IntSubclassN__name__
__module____qualname__     $/usr/lib/python3.11/test/test_int.pyr   r      s        Dr   r   c                       e Zd Zd Zd Zd Zd Zej        d             Z	d Z
d Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )IntTestCasesc                 %   |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d	          d           |                      t          d
          d           |                      t          d          d           |                      t          d          d           |                      t          dd          d           t          D ]_\  }}dD ]W}dD ]R}||z   |z   }|}|dk    r|t          ur| }	 |                      t          |          |           C# t          $ r Y Ow xY wX`t	          dt
          j        z
            }t          |          }|                      |dz   t
          j                    |                     |t                     |                      t          |dd                    t
          j        dz              t          d          }|                     |t                     t          d          }|                     |t                     dt
          j        z
  }|                      |dz	  |dz             t          d          }|                     |t                     |                     t          t          dd           |                      t          dd          d           |                      t          dd          d           |                     t          t          dd           |                     t          t          dd           |                     t          t          dd            |                     t          t          dd           |                     t          t          d!d           |                     t          t          d!d           |                      t          d"d          d#           |                      t          d$d          d#           |                      t          d%d&          d#           |                      t          d'd(          d#           |                      t          d)d*          d#           |                      t          d+d,          d#           |                      t          d-d           d#           |                      t          d.d/          d#           |                      t          d0d1          d#           |                      t          d2d3          d#           |                      t          d4d          d#           |                      t          d5d6          d#           |                      t          d7d8          d#           |                      t          d9d:          d#           |                      t          d;d          d#           |                      t          d<d=          d#           |                      t          d>d?          d#           |                      t          d@dA          d#           |                      t          dBdC          d#           |                      t          dDdE          d#           |                      t          dFdG          d#           |                      t          dHdI          d#           |                      t          dJdK          d#           |                      t          dLdM          d#           |                      t          dNdO          d#           |                      t          dPdQ          d#           |                      t          dRdS          d#           |                      t          dTdU          d#           |                      t          dVdW          d#           |                      t          dXdY          d#           |                      t          dZd[          d#           |                      t          d\d]          d#           |                      t          d^d_          d#           |                      t          d`da          d#           |                      t          dbdc          d#           |                      t          ddd          d           |                      t          ddd          d           |                      t          ded          d           |                      t          dd          d           |                      t          dd          d           |                      t          dfd          d&           |                      t          dgd          d           |                      t          dhd          d           |                      t          did          d&           |                     t                    5  t          djd           d d d            n# 1 swxY w Y   |                      t          dk          dl           |                      t          dkd1          dl           |                      t          dd          d           |                      t          dd           d           |                      t          dfd          d&           |                      t          dmd          d           |                      t          dnd           d           |                      t          dod          d&           |                     t          t          dpd           |                     t          t          dqd           |                     t          t          drd           |                     t          t          dsd           |                     t          t          dtd            |                     t          t          dud            |                     t          t          dvd            |                     t          t          dwd            |                     t          t          dxd           |                     t          t          dyd           |                     t          t          dzd           |                     t          t          d{d           |                      t          d|d          d}           |                      t          d~d          d}           |                      t          dd&          d}           |                      t          dd(          d}           |                      t          dd*          d}           |                      t          dd,          d}           |                      t          dd           d}           |                      t          dd/          d}           |                      t          dd1          d}           |                      t          dd3          d}           |                      t          dd          d}           |                      t          dd6          d}           |                      t          dd8          d}           |                      t          dd:          d}           |                      t          dd          d}           |                      t          dd=          d}           |                      t          dd?          d}           |                      t          ddA          d}           |                      t          ddC          d}           |                      t          ddE          d}           |                      t          ddG          d}           |                      t          ddI          d}           |                      t          ddK          d}           |                      t          ddM          d}           |                      t          ddO          d}           |                      t          ddQ          d}           |                      t          ddS          d}           |                      t          ddU          d}           |                      t          ddW          d}           |                      t          ddY          d}           |                      t          dd[          d}           |                      t          dd]          d}           |                      t          dd_          d}           |                      t          dda          d}           |                      t          ddc          d}           d S )Nr   gQ	@   gQ	g333333@g333333g      @g      z-3z -3 u    -3 r      )r   +-)r   r   	r   r&   r   g}Ô%ITg}Ô%I   X  111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111   0o123r   S   0x123i#  0x0o   0b!100000000000000000000000000000000l        10200202220122111121110000000000000000   32244002423141   1550104015504   211301422354   4000000000012068657454r
   
4294967296r   
1904440554   	9ba461594	535a79889   	2ca5b7464   	1a20dcd81   	100000000a7ffda91   704he7g4   4f5aff66   3723ai4g   281d55i4   1fj8b184   1606k7ic   mb994ag   hek2mgl   dnchbnm   b28jpdm   8pfgih4   76beigg   5qmcpqg   4q0jto4   4000000    3aokq94!   2qhxjli"   2br45qb#   1z141z4$   z 0o123  0000b100z	 0O123   z 0X123  z 0B100 0100123{   0X1230O1230B1000b20b020B20B020o80o080O80O080xg0x0g0Xg0X0g!100000000000000000000000000000001l       102002022201221111212100000000000000013224400242314215501040155052113014223554000000000112068657455
4294967297
1904440555	9ba461595	535a7988a	2ca5b7465	1a20dcd82	100000001a7ffda92704he7g54f5aff673723ai4h281d55i51fj8b1851606k7idmb994ahhek2mgmdnchbnnb28jpdn8pfgih576beigh5qmcpqh4q0jto540000013aokq952qhxjlj2br45qc1z141z5)
assertEqualintL
ValueErrorreprsysmaxsizeassertIsInstanceassertRaises	TypeError)selfsvsignprefixssvvxs           r   
test_basiczIntTestCases.test_basic#   s   S3'''TA&&&UR(((S1%%%TB'''S1%%%TB'''TB'''Vb)))9::B???T"r*** 
	 
	DAq$ 	 	7  F$*BBs{{q
':':R((R"5555%   	 CK  FF1s{l+++a%%%QqrrUS[]333 JJa%%%KKa%%% s{NaA&&&	NNa%%% 	)S!R000Wa"---Wb))3/// 	*c4444*c4333*c4333*c4333*c4333*c4333 	@!DDjQQQ4a88*EEE0!44jAAA-q11:>>>_a00*===^Q//<<<]A..
;;;]A..
;;;\2..
;;;\2..
;;;["--z:::["--z:::["--z:::["--z:::["--z:::Z,,j999Z,,j999Z,,j999Z,,j999Z,,j999Z,,j999Z,,j999Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888 	Z++R000Z++R000UA***Wa"---Wa#...Wa!,,,[!,,b111Z++S111Y**A...z** 	 	qMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Vc***VR#... 	Wb))3///Wa"---Wa!,,,Wb))3///Wa"---Wa!,,, 	*c5!444*c61555*c5!444*c61555*c5!444*c61555*c5!444*c61555*c5"555*c62666*c5"555*c62666 	@!DDjQQQ4a88*EEE0!44jAAA-q11:>>>_a00*===^Q//<<<]A..
;;;]A..
;;;\2..
;;;\2..
;;;["--z:::["--z:::["--z:::["--z:::["--z:::Z,,j999Z,,j999Z,,j999Z,,j999Z,,j999Z,,j999Z,,j999Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z888Y++Z88888s$   4#G
G%	$G%	5kkkc                    |                      t                    5  t          d           d d d            n# 1 swxY w Y   |                      t                    5  t          d           d d d            n# 1 swxY w Y   |                      t                    5  t          d           d d d            n# 1 swxY w Y   |                      t                    5  t          d           d d d            n# 1 swxY w Y   |                      t                    5  t          d           d d d            d S # 1 swxY w Y   d S )Nr%   r&   z- 1z+ 1z + 1 r   r   r   r   s    r   test_invalid_signszIntTestCases.test_invalid_signs   sU   z** 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	HHH	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	JJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	JJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	LLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	sT   7;;A88A<?A<B99B= B=C::C>C>D<<E E c                 "   |                      t          d          d           |                      t          d          d           |                      t          dd          d           |                      t          dd          d           d S )Nu(   १२३४५६७८९०1234567890l   
>V3&Z
 u   ١٢٣٤٥٦٧٨٩٠iIr   r   r   r   s    r   test_unicodezIntTestCases.test_unicode   s    GHHJ^___344jAAAGKKMabbb3Q77DDDDDr   c           
         t           D ]t          fddD                       r|                     t          d          t	                               |                     t          d          t                              dd          d                     t          D ]@t          fddD                       r|                     t          t          d           A|                     t          dd          d	           |                     t          d
          d           |                     t          d          d           |                     t          t          d           |                     t          t          d           |                     t          t          d           |                     t          t          d           d S )Nc              3       K   | ]}|v V  	d S Nr   .0chlits     r   	<genexpr>z0IntTestCases.test_underscores.<locals>.<genexpr>   '      //29//////r   z.eEjJr   _r   c              3       K   | ]}|v V  	d S r   r   r   s     r   r   z0IntTestCases.test_underscores.<locals>.<genexpr>   r   r   1_00r"   r
   0_100r   s   1_00_100z+_1001__00100_)	r   anyr   r   evalreplacer   r   r   )r   r   s    @r   test_underscoreszIntTestCases.test_underscores   s   , 	H 	HC////w///// Sa[[$s))444Sa[[#ckk#r.B.BA*F*FGGGG. 	7 	7C////w///// j#sA6666VQ+++Ws+++Ws+++*c6222*c7333*c7333*c622222r   c                    |                      t          d          d           |                      t          d          d           |                      t          d          d           |                      t          d          d           d S )Nr   r   z-1r(   s   10s   -1)assertIsr   r   s    r   test_small_intszIntTestCases.test_small_ints  sr     	c$ii$$$c$ii$$$c%jj"%%%c%jj"%%%%%r   c                 J    |                      t                      d           d S )Nr   r   r   s    r   test_no_argszIntTestCases.test_no_args	  s"    """""r   c                    |                      t          dd          d           |                     t          d          5  t          d           d d d            n# 1 swxY w Y   |                     t          d          5  t          dd           d d d            n# 1 swxY w Y   |                     t          t          d	           |                     t          t          d
           d S )Nr   r)   baser6   zkeyword argumentg333333?)r   )r   r   r   r   )r   r   assertRaisesRegexr   r   r   s    r   test_keyword_argszIntTestCases.test_keyword_args  sY   U+++Q///##I/ABB 	 	#JJJJ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	##I/ABB 	! 	!%a    	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	! 	!)Sr222)Sq11111s$   AA"%A"B""B&)B&c                 h   |                      t          dd          d           |                     t                    5  t          dd           ddd           n# 1 swxY w Y   |                     t                    5  t          dd           ddd           n# 1 swxY w Y   |                     t                    5  t          dd           ddd           n# 1 swxY w Y   |                     t                    5  t          dddd	z  z
  
           ddd           n# 1 swxY w Y   |                     t                    5  t          ddd	z  
           ddd           n# 1 swxY w Y   t	          dd          D ]'}|                      t          d|
          d           (dS )z9Testing the supported limits of the int() base parameter.r   r8   r   r   N%   isr)      r   )r   r   r   r   ranger   r   s     r   test_int_base_limitsz!IntTestCases.test_int_base_limits  s   S!a(((z** 	 	QKKK	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	RLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	 	TNNN	 	 	 	 	 	 	 	 	 	 	 	 	 	 	z** 	& 	&!QV*%%%%	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&z** 	" 	"!S&!!!!	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" !BKK 	5 	5DS4000!4444	5 	5sY   AA #A BB"%B"C  C$'C$D))D-0D-E//E36E3c                    |                      t                    5  t          dd           ddd           n# 1 swxY w Y   |                      t                    5  t          dd           ddd           dS # 1 swxY w Y   dS )z2Not integer types are not valid bases; issue16772.r   g      @Ng      @)r   r   r   r   s    r   test_int_base_bad_typesz$IntTestCases.test_int_base_bad_types'  s    y)) 	 	SMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	y)) 	 	SMMM	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   8<<A;;A?A?c                     G d dt                     }ddz  ddz   ddfD ]D}|                     t                    5  t          d|           d d d            n# 1 swxY w Y   E|                     t          d |d          	          d
           |                     t          d |d          	          d           |                     t          d |d          	          d           d S )Nc                       e Zd Zd Zd ZdS )9IntTestCases.test_int_base_indexable.<locals>.MyIndexablec                     || _         d S r   value)r   r   s     r   __init__zBIntTestCases.test_int_base_indexable.<locals>.MyIndexable.__init__0  s    "


r   c                     | j         S r   r   r   s    r   	__index__zCIntTestCases.test_int_base_indexable.<locals>.MyIndexable.__index__2  s
    z!r   N)r   r   r   r   r   r   r   r   MyIndexabler   /  s2        # # #" " " " "r   r   r)   r   r   r   43101r   r8   r   e   rq   i  )objectr   r   r   r   )r   r   r   s      r   test_int_base_indexablez$IntTestCases.test_int_base_indexable.  sP   	" 	" 	" 	" 	"& 	" 	" 	" sFQVGQ* 	  	 D"":..    D$                              	UQ888!<<<UR9993???UR9999EEEEEs   AA	!A	c                     G d dt                      G d dt                    } G d dt                    }t          t          fd||t          g}	 dd	lm |                    fd
           n# t          $ r Y nw xY w|D ]B} |d          }|                     t          |                    5  | 	                    t          |          d           t          |t           t          t          f          r%| 	                    t          |d          d           nEd}|                     t          |          5  t          |d           d d d            n# 1 swxY w Y   |                     t          d          5  t           |d                     d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   Dd S )Nc                       e Zd ZdS )<IntTestCases.test_non_numeric_input_types.<locals>.CustomStrNr   r   r   r   	CustomStrr   B            r   r   c                       e Zd ZdS )>IntTestCases.test_non_numeric_input_types.<locals>.CustomBytesNr   r   r   r   CustomBytesr   C  r   r   r   c                       e Zd ZdS )BIntTestCases.test_non_numeric_input_types.<locals>.CustomByteArrayNr   r   r   r   CustomByteArrayr  D  r   r   r  c                 >     |                                            S r   )decode)br   s    r   <lambda>z;IntTestCases.test_non_numeric_input_types.<locals>.<lambda>I  s    ii

++ r   r   )arrayc                      d|           S )NBr   )r  r  s    r   r  z;IntTestCases.test_non_numeric_input_types.<locals>.<lambda>S  s    uuS!}} r   s   100r   r)   r6   zcan't convert non-stringzinvalid literals   AAAAAAAAAAAAAAAA)strbytes	bytearray
memoryviewr  appendImportErrorsubTesttyper   r   
isinstancer   r   r   )	r   r   r  	factoriesfr   msgr   r  s	          @@r   test_non_numeric_input_typesz)IntTestCases.test_non_numeric_input_types?  s    	#"""""""&&&&&%&&&.....i... ++++
		6###### 44445555  	 	 	D	
  	( 	(A&		Ad1gg&& 	( 	(  Q---a#ui!899 "$$SAYY22224C//	3?? " "Aq			" " " " " " " " " " " " " " "++J8IJJ ( (+'''( ( ( ( ( ( ( ( ( ( ( ( ( ( (	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(	( 	(sm   A6 6
BB8BF? EF?E!!F?$E!%F?F(F?(F,,F?/F,0F??G	G	c                 6   |                      t          t          d          dd                   d           |                      t          t          d          dd                   d           |                      t          t          d          dd                   d           |                      t          t          d          dd                   d           |                      t          t          d          dd                   d           d S )	Ns   123r   r"   rW      123 s   123 s   123As   1234)r   r   r  r   s    r   test_int_memoryviewz IntTestCases.test_int_memoryviewb  s    Z//!455r:::Z
33AaC8992>>>Z001566;;;Z001566;;;Z001566;;;;;r   c                 H    |                      t          t          d           d S )Nz1.2r   r   s    r   test_string_floatzIntTestCases.test_string_floati  s     *c511111r   c           	          G d d          }|                      t          t           |                        G d dt                    }|                      t          t           |                        G d d          }|                     t           |                      d            G d d	          }t          |fD ]} G d
 d|          }|                     t           |                      d            G d d|          }|                     t                    5  |                     t           |                      d           d d d            n# 1 swxY w Y    G d d|          }|                      t                    5  |                     t                    5  t           |                       d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          |fD ]Q}	 G d d|	           G fdd|          }
|                     t                    5  |                     t           |
                      d           d d d            n# 1 swxY w Y    G d d|	           G fdd|          }|                     t                    5  |                     t           |
                      d           d d d            n# 1 swxY w Y    G fdd|	           G fdd|          }	 |                     t                    5  t           |                       d d d            n# 1 swxY w Y   |                     d||	f           n:# t          $ r-}|                     t          |          d           Y d }~nd }~ww xY w G d d|	           G fd d!|          }|                      t                    5  |                     t                    5  t           |                       d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   Sd S )"Nc                       e Zd ZdS )>IntTestCases.test_intconversion.<locals>.ClassicMissingMethodsNr   r   r   r   ClassicMissingMethodsr  n          Dr   r  c                       e Zd ZdS )7IntTestCases.test_intconversion.<locals>.MissingMethodsNr   r   r   r   MissingMethodsr"  r  r   r   r#  c                       e Zd Zd ZdS )-IntTestCases.test_intconversion.<locals>.Foo0c                     dS N*   r   r   s    r   __int__z5IntTestCases.test_intconversion.<locals>.Foo0.__int__w      rr   Nr   r   r   r)  r   r   r   Foo0r%  v  #            r   r,  r(  c                       e Zd ZdS )0IntTestCases.test_intconversion.<locals>.ClassicNr   r   r   r   Classicr/  |  r   r   r0  c                       e Zd Zd Zd ZdS ):IntTestCases.test_intconversion.<locals>.IntOverridesTruncc                     dS r'  r   r   s    r   r)  zBIntTestCases.test_intconversion.<locals>.IntOverridesTrunc.__int__      2r   c                     dS )Nir   r   s    r   	__trunc__zDIntTestCases.test_intconversion.<locals>.IntOverridesTrunc.__trunc__  s    3r   N)r   r   r   r)  r6  r   r   r   IntOverridesTruncr2    s2              r   r7  c                       e Zd Zd ZdS )2IntTestCases.test_intconversion.<locals>.JustTruncc                     dS r'  r   r   s    r   r6  z<IntTestCases.test_intconversion.<locals>.JustTrunc.__trunc__  r4  r   Nr   r   r   r6  r   r   r   	JustTruncr9    s#            r   r<  c                       e Zd Zd ZdS )9IntTestCases.test_intconversion.<locals>.ExceptionalTruncc                     ddz   d S )Nr   r   r   r   s    r   r6  zCIntTestCases.test_intconversion.<locals>.ExceptionalTrunc.__trunc__  s    EEEEr   Nr;  r   r   r   ExceptionalTruncr>    s#            r   r@  c                       e Zd Zd ZdS ).IntTestCases.test_intconversion.<locals>.Indexc                     dS r'  r   r   s    r   r   z8IntTestCases.test_intconversion.<locals>.Index.__index__      !rr   Nr   r   r   r   r   r   r   IndexrB    #        " " " " "r   rF  c                       e Zd Z fdZdS );IntTestCases.test_intconversion.<locals>.TruncReturnsNonIntc                                  S r   r   )r   rF  s    r   r6  zEIntTestCases.test_intconversion.<locals>.TruncReturnsNonInt.__trunc__  s    $uwwr   Nr;  )rF  s   r   TruncReturnsNonIntrI    s.        ' ' ' ' ' ' 'r   rK  c                       e Zd Zd ZdS )0IntTestCases.test_intconversion.<locals>.Intablec                     dS r'  r   r   s    r   r)  z8IntTestCases.test_intconversion.<locals>.Intable.__int__  rD  r   Nr+  r   r   r   IntablerM    rG  r   rO  c                       e Zd Z fdZdS )=IntTestCases.test_intconversion.<locals>.TruncReturnsNonIndexc                                  S r   r   )r   rO  s    r   r6  zGIntTestCases.test_intconversion.<locals>.TruncReturnsNonIndex.__trunc__  s    &wyy(r   Nr;  )rO  s   r   TruncReturnsNonIndexrQ    s.        ) ) ) ) ) ) )r   rS  c                       e Zd Z fdZdS )4IntTestCases.test_intconversion.<locals>.NonIntegralc                                  S r   r   r   NonIntegrals    r   r6  z>IntTestCases.test_intconversion.<locals>.NonIntegral.__trunc__  s    *{}},r   Nr;  rX  s   r   rX  rU    s.        - - - - - - -r   rX  c                       e Zd Z fdZdS )@IntTestCases.test_intconversion.<locals>.TruncReturnsNonIntegralc                                  S r   r   rW  s    r   r6  zJIntTestCases.test_intconversion.<locals>.TruncReturnsNonIntegral.__trunc__  s    *{}},r   Nr;  rY  s   r   TruncReturnsNonIntegralr[    s.        - - - - - - -r   r]  zFailed to raise TypeError with z2__trunc__ returned non-Integral (type NonIntegral)c                       e Zd Zd ZdS )/IntTestCases.test_intconversion.<locals>.BadIntc                     dS Ng      E@r   r   s    r   r)  z7IntTestCases.test_intconversion.<locals>.BadInt.__int__  s    #tr   Nr+  r   r   r   BadIntr_    s#        $ $ $ $ $r   rb  c                       e Zd Z fdZdS );IntTestCases.test_intconversion.<locals>.TruncReturnsBadIntc                                  S r   r   r   rb  s    r   r6  zEIntTestCases.test_intconversion.<locals>.TruncReturnsBadInt.__trunc__  s    %vxxr   Nr;  rb  s   r   TruncReturnsBadIntrd    s.        ( ( ( ( ( ( (r   rh  )
r   r   r   r   r   assertWarnsDeprecationWarningZeroDivisionErrorfailr
  )r   r  r#  r,  r0  r   r7  r<  r@  trunc_result_baserK  rS  r]  erh  rb  rF  rO  rX  s                  @@@@r   test_intconversionzIntTestCases.test_intconversionl  sG   	 	 	 	 	 	 	 	)S*?*?*A*ABBB	 	 	 	 	V 	 	 	)S..*:*:;;;	 	 	 	 	 	 	 	 	TTVVb)))	 	 	 	 	 	 	 	W% H	. H	.D    D   
 S!2!2!4!455r:::    D    !!"455 7 7  YY[[!1!126667 7 7 7 7 7 7 7 7 7 7 7 7 7 7    4    ""#455 ( (!!"455( ($$&&'''( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( '-g%6 3. 3.!" " " " "- " " "' ' ' ' ' ' ' ' ' ' %%&899 D D$$S););)=)=%>%>CCCD D D D D D D D D D D D D D D" " " " "/ " " ") ) ) ) ) ) )4 ) ) ) %%&899 D D$$S););)=)=%>%>CCCD D D D D D D D D D D D D D D- - - - - - -"3 - - -
- - - - - - -d - - -	<))*<== 7 733556667 7 7 7 7 7 7 7 7 7 7 7 7 7 7 III $&788; < < < < ! = = =$$SVV'<= = = = = = = ==$ $ $ $ $. $ $ $( ( ( ( ( ( ( ( ( ( &&y11 . .%%&899. .**,,---. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .c3.+H	. H	.s   ),E!!E%	(E%	G*/GG*GG*GG**G.	1G.	9,I11I58I54,K,,K03K0M<2M
M<MM<MM<<
N3#N..N3.Q	P-	!Q-P11Q4P15QQQc                 0    G d dt                     } G d dt                     } |d          }|                     |d           |                     t          |          d           |                     t           |                      d           d S )Nc                       e Zd Zd ZdS ):IntTestCases.test_int_subclass_with_index.<locals>.MyIndexc                     dS r'  r   r   s    r   r   zDIntTestCases.test_int_subclass_with_index.<locals>.MyIndex.__index__  r*  r   NrE  r   r   r   MyIndexrr    r-  r   rt  c                       e Zd Zd ZdS );IntTestCases.test_int_subclass_with_index.<locals>.BadIndexc                     dS ra  r   r   s    r   r   zEIntTestCases.test_int_subclass_with_index.<locals>.BadIndex.__index__      tr   NrE  r   r   r   BadIndexrv    #            r   ry  r<   r   )r   r   )r   rt  ry  my_ints       r   test_int_subclass_with_indexz)IntTestCases.test_int_subclass_with_index  s    	 	 	 	 	c 	 	 		 	 	 	 	s 	 	 	 ###Va(((XXZZ!,,,,,r   c                 ^    G d dt                     } G d dt                     } |d          }|                     |d           |                     t          |          d            |d          }|                     |d           |                     t          t           |           d S )Nc                       e Zd Zd ZdS )6IntTestCases.test_int_subclass_with_int.<locals>.MyIntc                     dS r'  r   r   s    r   r)  z>IntTestCases.test_int_subclass_with_int.<locals>.MyInt.__int__  r*  r   Nr+  r   r   r   MyIntr    r-  r   r  c                       e Zd Zd ZdS )7IntTestCases.test_int_subclass_with_int.<locals>.BadIntc                     dS ra  r   r   s    r   r)  z?IntTestCases.test_int_subclass_with_int.<locals>.BadInt.__int__  rx  r   Nr+  r   r   r   rb  r    rz  r   rb  r<   r(  )r   r   r   r   )r   r  rb  r{  s       r   test_int_subclass_with_intz'IntTestCases.test_int_subclass_with_int  s    	 	 	 	 	C 	 	 		 	 	 	 	S 	 	 	 q###Vb)))###)S&11111r   c                   	
  G d d          	 G d dt                     } G d d          
 G d dt                     } G 	fd	d
          } G 
fdd          } G d d          } 	            }|                     t                    5  t          |          }d d d            n# 1 swxY w Y   |                     |d           |                     t          |          t                       |            }t          |          }|                     |d           |                     t          |          t                       
            }|                     t                    5  t          |          }d d d            n# 1 swxY w Y   |                     |d           |                     t          |          t                       |            }|                     t                    5  t          |          }d d d            n# 1 swxY w Y   |                     |d           |                     t          |          t                       |            }|                     t                    5  t          |          }d d d            n# 1 swxY w Y   |                     |d           |                     t          |          t                       |            }|                     t                    5  |                     t          t           |           d d d            n# 1 swxY w Y    |            }|                     t                    5  t          |          }d d d            n# 1 swxY w Y   |                     |d           |                     t          |          t                      |                     t                    5  t          |          }d d d            n# 1 swxY w Y   |                     |d           |                     t          |          t                     d S )Nc                       e Zd Zd ZdS )<IntTestCases.test_int_returns_int_subclass.<locals>.BadIndexc                     dS NTr   r   s    r   r   zFIntTestCases.test_int_returns_int_subclass.<locals>.BadIndex.__index__  rx  r   NrE  r   r   r   ry  r    rz  r   ry  c                       e Zd Zd ZdS )=IntTestCases.test_int_returns_int_subclass.<locals>.BadIndex2c                     dS r  r   r   s    r   r   zGIntTestCases.test_int_returns_int_subclass.<locals>.BadIndex2.__index__  rx  r   NrE  r   r   r   	BadIndex2r    rz  r   r  c                       e Zd Zd ZdS ):IntTestCases.test_int_returns_int_subclass.<locals>.BadIntc                     dS r  r   r   s    r   r)  zBIntTestCases.test_int_returns_int_subclass.<locals>.BadInt.__int__  rx  r   Nr+  r   r   r   rb  r    rz  r   rb  c                       e Zd Zd ZdS );IntTestCases.test_int_returns_int_subclass.<locals>.BadInt2c                     dS r  r   r   s    r   r)  zCIntTestCases.test_int_returns_int_subclass.<locals>.BadInt2.__int__  rx  r   Nr+  r   r   r   BadInt2r    rz  r   r  c                       e Zd Z fdZdS )HIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIndexc                                  S r   r   )r   ry  s    r   r6  zRIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIndex.__trunc__  s    xzz!r   Nr;  )ry  s   r   TruncReturnsBadIndexr    s.        " " " " " " "r   r  c                       e Zd Z fdZdS )FIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadIntc                                  S r   r   rf  s    r   r6  zPIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsBadInt.__trunc__  s    vxxr   Nr;  rg  s   r   rh  r    s.                     r   rh  c                       e Zd Zd ZdS )KIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsIntSubclassc                     dS r  r   r   s    r   r6  zUIntTestCases.test_int_returns_int_subclass.<locals>.TruncReturnsIntSubclass.__trunc__  rx  r   Nr;  r   r   r   TruncReturnsIntSubclassr    rz  r   r  r   r   )	r   ri  rj  r   r   r  r   r   r   )r   r  r  r  rh  r  bad_intngood_intry  rb  s            @@r   test_int_returns_int_subclassz*IntTestCases.test_int_returns_int_subclass  s1   	 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	 	 	 		 	 	 	 	c 	 	 		" 	" 	" 	" 	" 	" 	" 	" 	" 	"	  	  	  	  	  	  	  	  	  	 	 	 	 	 	 	 	 	 (**011 	 	GA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Ad1ggs###)++LLAd1ggs###&((011 	 	GA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Ad1ggs###'))011 	 	GA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Ad1ggs###&&((011 	 	GA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Ad1ggs###$$&&011 	7 	7ig666	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 	7 +*,,011 	 	HA	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Ad1ggs###011 	& 	&H%%A	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	& 	&Ad1gg{+++++s~   B..B25B22FFF;HHHJ  J$'J$"L;;L?L?*NN
N
)PP	P	c                 n    d fd	} |d            |d            |d            |d            |dd            |dd            |dd	            |d
d            |d
d	            |d            |dd            |d            |dd            |d            |dd           d S )Nc                                          t          d| d|d          5 }|t          |            nt          | |           d d d            n# 1 swxY w Y                       |j        j        d         d|dn|| fz             d S )Nzint(z, ))r  r   z*invalid literal for int() with base %d: %rr   )r   r   r   r   	exceptionargs)r   r   cmr   s      r   checkz.IntTestCases.test_error_message.<locals>.check1  s    ""::89444'@ # B B !EG<FFFF4LLL! ! ! ! ! ! ! ! ! ! ! ! ! ! ! R\.q1<|q123 3 3 3 3s   #AAA   ½u   123½z  123 456  z123 r   z123  245rQ   r$   z123 245r  s   123u   123r   r   )r   r  s   ` r   test_error_messagezIntTestCases.test_error_message0  s&   		3 		3 		3 		3 		3 		3 	fimiimR   mR   lBlBjj"jj"kk2r   c                 &   |                      t          dd          d           |                      t          dd          d           |                      t          dd          d	           |                      t          d
d          d           d S )N=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)   iUUUU1_2_3_4_5_6_7_0_1_2_3r1   iSpS1_2_3_4_5_6_7_8_9r$   l   gF 1_2_3_4_5_6_7ri   i2Dr   r   s    r   test_issue31619zIntTestCases.test_issue31619Q  s    \^_``:	< 	< 	<4a88-HHH0"55{CCC_b11:>>>>>r   N)r   r   r   r   r   r   r   r   cpython_onlyr   r   r   r   r   r   r  r  r  ro  r|  r  r  r  r  r   r   r   r    r    !   sU       w9 w9 w9r
 
 
E E E3 3 3& & & &# # #2 2 25 5 5"  F F F"!( !( !(F< < <2 2 2Z. Z. Z.x- - -2 2 2"F, F, F,P  B? ? ? ? ?r   r    c                   p     e Zd ZeZ fdZ fdZd Zd ZddZ	d Z
d Zd	 Zd
 Zd Zd Zd Zd Z xZS )IntStrDigitLimitsTestsc                     t                                                       t          j                    | _        t          j        d           d S )Ni   )supersetUpr   get_int_max_str_digits_previous_limitset_int_max_str_digitsr   	__class__s    r   r  zIntStrDigitLimitsTests.setUp]  s<    "9;;"4(((((r   c                 z    t          j        | j                   t                                                       d S r   )r   r  r  r  tearDownr  s    r   r  zIntStrDigitLimitsTests.tearDownb  s3    "4#7888r   c                    |                      t          j                    d           |                     t          j                    d           t	          j        d          5  |                     t          j                    d           |                     ddz            }t          |           d d d            n# 1 swxY w Y   |                      t          j                    d           d S )Nr   i N  r   )	assertGreaterr   r  
assertLessr   adjust_int_max_str_digitsr   	int_classr
  )r   is     r   test_disabled_limitz*IntStrDigitLimitsTests.test_disabled_limitf  s
   3577;;;244f===.q11 	 	S7991===sV|,,AFFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	3577;;;;;s   #AB>>CCc           	      J   | j         }t          j                    } |d|z              |dd|z  z               |d|z  dz               |dd|z  z               |dd|z  z              |                     t	          t          d|dz
  z                      |           dS )z&Ignore the +/- sign and space padding.r   r   r%   r&   r   r   N)r  r   r  r   lenr
  )r   r  	maxdigitss      r   test_max_str_digits_edge_casesz5IntStrDigitLimitsTests.test_max_str_digits_edge_caseso  s    N	.00		#	/"""	#i'(((	#	/C'(((	#i'(((	#i'(((S	A!67788)DDDDDr   Nc                     |                      t                    5  ||                     |           n|                     ||           d d d            d S # 1 swxY w Y   d S r   )r   r   r  )r   r  r   s      r   r  zIntStrDigitLimitsTests.check{  s    z** 	( 	(|q!!!!q$'''		( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	(s   /AAAc                    t          j                    }|                     d|dz   z             |                     dd|dz   z  z              |                     d|dz   z  dz              |                     dd|dz   z  z              |                     dd|dz   z  z              |                     d|dz   z             d|z  }|                     t                    5  t          |           d d d            d S # 1 swxY w Y   d S )Nr   r   r   r%   r&   r   )r   r  r  r   r   r
  )r   r  r  s      r   test_max_str_digitsz*IntStrDigitLimitsTests.test_max_str_digits  sR   .00	

3)a-()))

3	A..///

3)a-(3.///

3	A..///

3	A..///

3)a-())))Oz** 	 	FFF	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   !C>>DDc                    t          j                    }t          j        } |            dk    rt          j        }t          dddz   d          }d}t          j        |          5   |            }t          |          }ddd           n# 1 swxY w Y    |            |z
  }| 	                    t          |          |           |d	k     rt          j        d
| d          t          j        t          d|z                      5  |                     t                    5 } |            }t          |           ddd           n# 1 swxY w Y    |            |z
  }	ddd           n# 1 swxY w Y   |                     dt          |j                             |                     |	|dz             t          dddz   d          }
|                     t                    5 } |            }t          |
           ddd           n# 1 swxY w Y    |            |z
  }|                     dt          |j                             |                     ||dz             dS )?Regression test: ensure we fail before performing O(N**2) work.r   r/   ci  r$   r   i1 N      ?"slow" conversion took only 	 seconds.gףp=
?
conversionr)   i  )r   r  timeprocess_time	monotonicr   r   r  r
  r   r  unittestSkipTestr   r   assertInr  assertLessEqualr  )r   r  get_timehuge_intdigitsstarthuge_decimalseconds_to_converterrseconds_to_fail_hugeextra_huge_intseconds_to_fail_extra_huges               r   +test_denial_of_service_prevented_int_to_strzBIntStrDigitLimitsTests.test_denial_of_service_prevented_int_to_str  sq   .00	$8::??~H(CJ((r222.v66 	) 	)HJJEx==L	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) 	) &XZZ%/\**F333 $$# %E'9%E %E %E F F F
 .s4&=/A/ABB 	6 	6"":.. # 

H               $,8::#5 		6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6
 	lC$6$677713Ea3GHHH /#g+//b999z** 	 cHJJE	  	  	  	  	  	  	  	  	  	  	  	  	  	  	  &.XZZ%%7"lC$6$677724Fq4HIIIIIsZ   'BBB
E/%E?E/E	E/E	E//E36E3,HHHc                 2   t          j                    }t          j        } |            dk    rt          j        }d}d|z  }t          j        |          5   |            }t          |           ddd           n# 1 swxY w Y    |            |z
  }|dk     rt          j	        d| d          t          j        |dz
            5  | 
                    t                    5 } |            }t          |           ddd           n# 1 swxY w Y    |            |z
  }ddd           n# 1 swxY w Y   |                     d	t          |j                             |                     ||d
z             ddz  }	| 
                    t                    5 } |            }t          |	           ddd           n# 1 swxY w Y    |            |z
  }
|                     d	t          |j                             |                     |
|d
z             dS )r  r   iD
 8Nr  r  r  r   r  r)   7iO )r   r  r  r  r  r   r  r   r  r  r   r   r  r
  r  r  )r   r  r  r  huger  r  r  r  
extra_huger  s              r   +test_denial_of_service_prevented_str_to_intzBIntStrDigitLimitsTests.test_denial_of_service_prevented_str_to_int  s   .00	$8::??~H6z.v66 	 	HJJEIII	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &XZZ%/ $$# %E'9%E %E %E F F F .vz:: 	6 	6"":.. # 

D			               $,8::#5 		6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6
 	lC$6$677713Ea3GHHH ]
z** 	cHJJE
OOO	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 &.XZZ%%7"lC$6$677779KA9MNNNNNsZ   A;;A?A?D-#D	=D-	D	D-D	D--D14D1F>>GGc                     t          j                    }dD ]e}|                     |          5  |                     d|dz   z  |           |                     ddz  |           ddd           n# 1 swxY w Y   fdS )z-The limit does not apply to power of 2 bases.)r)   r6   r1   r$   ri   r   r   r   i N)r   r  r  r  )r   r  r   s      r   !test_power_of_two_bases_unlimitedz8IntStrDigitLimitsTests.test_power_of_two_bases_unlimited  s    .00	% 	4 	4D4(( 4 4si!m4d;;;sW}d3334 4 4 4 4 4 4 4 4 4 4 4 4 4 4	4 	4s   6A00A4	7A4	c                     t          j                    }|dz  }d|z  }d|z  }|                     |           |                     |           |                     | d           |                     | d           d S )Nr"   1111_11_111)r   r  r  r  )r   r  triplesr   s_s        r   test_underscores_ignoredz/IntStrDigitLimitsTests.test_underscores_ignored  s    .00	q.GOgqr

a999

b;;;r   c                     | j         }t          j                    }d|z  } ||          } |d|           } |d|           }t          |           t          |           d S )N5r%   r&   )r  r   r  r
  )r   r  
max_digitsr   r  pos_ineg_is          r   test_sign_not_countedz,IntStrDigitLimitsTests.test_sign_not_counted  sr    N	/11
*IaLL	'a''""	'a''""E


E




r   c                    | j         }t          j                    }d|z  } |||          }|dk    rB|                     t                    5  t          |           d d d            n# 1 swxY w Y   n|dk     rt          |           |                     t                    5 } || d|           d d d            d S # 1 swxY w Y   d S )N2r   r   )r  r   r  r   r   r
  )r   r   r  r  r   r  r  s          r   _other_base_helperz)IntStrDigitLimitsTests._other_base_helper  sQ   N	/11
*Ia"99"":..  A              BYYFFFz** 	%cIgggt$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%s$   A((A,/A,#C  CCc                    d}|                      |          5  |                     |           d d d            n# 1 swxY w Y   d}|                      |          5  |                     |           d d d            d S # 1 swxY w Y   d S )Nr"   r   rq   )r  r  r   s     r   test_int_from_other_basesz0IntStrDigitLimitsTests.test_int_from_other_bases  s   \\t\$$ 	* 	*##D)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*\\t\$$ 	* 	*##D)))	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	* 	*s   ;??BBBr   )r   r   r   r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  __classcell__)r  s   @r   r  r  Y  s       I) ) ) ) )
    < < <
E 
E 
E( ( ( (  )J )J )JV&O &O &OP4 4 4	  	  	 
 
 
% % %* * * * * * *r   r  c                       e Zd ZeZdS )IntSubclassStrDigitLimitsTestsN)r   r   r   r   r  r   r   r   r  r    s        IIIr   r  __main__)r   r  r  testr   test.test_grammarr   r   r   r   r   r   r   r   TestCaser    r  r  r   mainr   r   r   <module>r
     s   



        < < < < < < < < 	$	ck		CK(		Z 	Z	j	Z 	:%*	 	 	 	 	# 	 	 	u? u? u? u? u?8$ u? u? u?p~* ~* ~* ~* ~*X. ~* ~* ~*B    %;    zHMOOOOO r   