
    0hhC                     8   S SK r S SKrS SKrS SKJr  S SKJr  S SKrS SKr " S S\\R                  5      r
 " S S5      r " S S	\R                  5      r " S
 S\R                  5      r " S S\R                  5      rS r\S:X  a  \R"                  " 5         gg)    N)support)AbstractPickleTestsc                   8    \ rS rSrSS jrS rSrSrS rS r	Sr
g)	OptimizedPickleTests	   Nc                 X    [         R                  " [        R                  " X40 UD65      $ N)pickletoolsoptimizepickledumps)selfargprotokwargss       >/opt/python-3.13.8/usr/lib/python3.13/test/test_pickletools.pyr   OptimizedPickleTests.dumps   s!    ##FLL$Fv$FGG    c                 0    [         R                  " U40 UD6$ r	   )r   loads)r   bufkwdss      r   r   OptimizedPickleTests.loads   s    ||C(4((r   c                    [        S5       Vs/ s H  n[        U5      PM     nnUR                  US   5        [        [        R                  S-   5       H  n[        R
                  " X#5      n[        R                  " U5      nU R                  XR5        U R                  US   US   5        [        R                  " U5      n[        R                  " U5      nU R                  Xr5        U R                  US   US   5        U R                  [        R                  U5        U R                  [        R                  U5        M     g s  snf )Ni     )rangestrappendr   HIGHEST_PROTOCOLr   r   assertEqualassertIsr
   r   assertNotInLONG_BINGETLONG_BINPUT)r   idatar   pickled	unpickledpickled2
unpickled2s           r   test_optimize_long_binget.OptimizedPickleTests.test_optimize_long_binget   s     %c
+
1A
+DH622Q67Ell4/GW-IY-MM)B-27"++G4Hh/JZ.MM*R.*R.9V//:V//: 8 ,s   Ec                    SnU R                  [        R                  U5        [        R                  " U5      nU R	                  U/ SQ5        U R                  US   US   5        [        R                  " U5      n[        R                  " U5      nU R	                  U/ SQ5        U R                  US   US   5        U R                  [        R                  U5        g )Ns           ](spamqhamhe.)spamhamr1   r      )	assertInr   BINPUTr   r"   r#   r
   r   r$   )r   r)   r*   r+   r,   s        r    test_optimize_binput_and_memoize5OptimizedPickleTests.test_optimize_binput_and_memoize'   s    D 	fmmW-LL)	$:;ilIaL1''0\\(+
%;<jmZ]31r    r	   )__name__
__module____qualname____firstlineno__r   r   test_pickle_to_2x+test_framed_write_sizes_with_delayed_writerr-   r5   __static_attributes__r7   r   r   r   r   	   s'    H)  37/; 2r   r   c                   &    \ rS rSrS rS rS rSrg)SimpleReaderB   c                     Xl         SU l        g )Nr   r(   pos)r   r(   s     r   __init__SimpleReader.__init__C   s    	r   c                 |    U R                   U R                  U R                  U-    nU =R                  U-  sl        U$ r	   rC   )r   nr(   s      r   readSimpleReader.readG   s0    yy488a<0Ar   c                     U R                   R                  SU R                  5      S-   nU(       d  [        U R                   5      nU R                   U R                  U nXl        U$ )N   
r   )r(   findrD   len)r   nlr(   s      r   readlineSimpleReader.readlineL   sM    YY^^E488,q0TYYByy2&r   rC   N)r8   r9   r:   r;   rE   rI   rP   r>   r7   r   r   r@   r@   B   s    
r   r@   c                   >    \ rS rSrS rS rS rS rS rS r	S r
S	rg
)GenopsTestsU   c           	          [         R                  " S5      nU R                  U Vs/ s H  o"S   R                  4USS  -   PM     sn/ SQ5        g s  snf )N   (I123
KJ4Vxt.r   r   ))MARKNr   )INT{   r   )BININT1      )BININT4Vx   )TUPLEN   )STOPN   )r
   genopsr"   namer   ititems      r   test_genopsGenopsTests.test_genopsV   sN     BC"E"$7<</T!"X5"E H
 	Es   Ac           	      X   [         R                  " S5      nU R                  UR                  S5      S5        [        R
                  " U5      nU R                  U Vs/ s H  o3S   R                  4USS  -   PM     sn/ SQ5        U R                  UR                  5       S5        g s  snf )Ns   prefix(I123
KJ4Vxt.suffixr\   s   prefixr   r   ))rW   Nr\   )rX   rY      )rZ   r[      )r]   r^   rc   )r`   N   )rb   N   s   suffix)ioBytesIOr"   rI   r
   rd   re   r   frg   rh   s       r   test_from_fileGenopsTests.test_from_filea   s    JJEFI.""E"$7<</T!"X5"E H
 	 	9- Fs   B'c           	          [        S5      n[        R                  " U5      nU R                  U Vs/ s H  o3S   R                  4USS  -   PM     sn/ SQ5        g s  snf )NrV   r   r   ))rW   NN)rX   rY   N)rZ   r[   N)r]   r^   N)r`   NN)rb   NN)r@   r
   rd   r"   re   rr   s       r   test_without_posGenopsTests.test_without_poso   sX    ;<""E"$7<</T!"X5"E H
 	Es   Ac                     [         R                  " S5      n[        U5      nU R                  US   R                  S5        U R                  [        S5         [        U5        S S S 5        g ! , (       d  f       g = f)N   Nr   NONE#pickle exhausted before seeing STOPr
   rd   nextr"   re   assertRaisesRegex
ValueErrorrf   s      r   test_no_stopGenopsTests.test_no_stop{   s]    %Bxav.##J57H7 7 7   A,,
A:c                 H   [         R                  " S5      nU R                  [        S5         [	        U5        S S S 5        [         R                  " S5      nU R                  [        S5         [	        U5        S S S 5        g ! , (       d  f       NO= f! , (       d  f       g = f)Ns   I123-no newline found when trying to read stringnls   J4&not enough data in stream to read int4)r
   rd   r   r   r~   )r   rg   s     r   test_truncated_dataGenopsTests.test_truncated_data   s    (##J?AHA -##J8:H: :	A A: :s   B-B
B
B!c                     [         R                  " S5      n[        U5      nU R                  US   R                  S5        U R                  [        S5         [        U5        S S S 5        g ! , (       d  f       g = f)N   Nr   r{   &at position 1, opcode b'\\xff' unknownr}   rf   s      r   test_unknown_opcodeGenopsTests.test_unknown_opcode   s]    )Bxav.##J9;H; ; ;r   c                    [        S5      n[        R                  " U5      n[        U5      nU R	                  US   R
                  S5        U R                  [        S5         [        U5        S S S 5        g ! , (       d  f       g = f)Nr   r   r{   z.at position <unknown>, opcode b'\\xff' unknown)r@   r
   rd   r~   r"   re   r   r   rr   s       r   test_unknown_opcode_without_pos+GenopsTests.test_unknown_opcode_without_pos   sk    ""Bxav.##JACHC C Cs   "A77
Br7   N)r8   r9   r:   r;   ri   rt   rw   r   r   r   r   r>   r7   r   r   rS   rS   U   s%    	.
r   rS   c                       \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSr g)DisTests   Nc                     [         R                  " 5       n[        R                  " U4SU0UD6  U R	                  UR                  5       U5        g Nout)rp   StringIOr
   disr"   getvalue)r   r(   expectedr   r   s        r   	check_disDisTests.check_dis   s9    kkm0#002r   c                     [         R                  " 5       nU R                  [        U5         [        R
                  " U4SU0UD6  S S S 5        U R                  UR                  5       U5        g ! , (       d  f       N/= fr   )rp   r   r   r   r
   r   r"   r   )r   r(   r   expected_errorr   r   s         r   check_dis_errorDisTests.check_dis_error   sY    kkm##J?OOD4c4V4 @2 @?s   A//
A=c                 (    U R                  SS5        g )N   (N(tl.z    0: (    MARK
    1: N        NONE
    2: (        MARK
    3: t            TUPLE      (MARK at 2)
    4: l        LIST       (MARK at 0)
    5: .    STOP
highest protocol among opcodes = 0
r   r   s    r   	test_markDisTests.test_mark       y # 	r   c                 &    U R                  SSSS9  g )Nr   z    0: (    MARK
    1: N      NONE
    2: (      MARK
    3: t        TUPLE      (MARK at 2)
    4: l      LIST       (MARK at 0)
    5: .    STOP
highest protocol among opcodes = 0
r2   )indentlevelr   r   s    r   test_indentlevelDisTests.test_indentlevel   s    y #  	 	r   c                 :    U R                  [        S5      S5        g )Nr   z(    MARK
N        NONE
(        MARK
t            TUPLE      (MARK at unknown opcode offset)
l        LIST       (MARK at unknown opcode offset)
.    STOP
highest protocol among opcodes = 0
)r   r@   r   s    r   test_mark_without_posDisTests.test_mark_without_pos   s    |I. 1 	r   c                 *    U R                  SSS5        g )Ns   Nt.z@    0: N    NONE
    1: t    TUPLE      no MARK exists on stack
zno MARK exists on stackr   r   s    r   test_no_markDisTests.test_no_mark   s    V & 	 r   c                 (    U R                  SS5        g )Ns   Np0
qr   .z    0: N    NONE
    1: p    PUT        0
    4: q    BINPUT     1
    6: r    LONG_BINPUT 2
   11: \x94 MEMOIZE    (as 3)
   12: .    STOP
highest protocol among opcodes = 4
r   r   s    r   test_putDisTests.test_put   s    : = 	r   c                     U R                  SSS5        U R                  SSS5        U R                  SSS5        U R                  SS	S
5        g )Ns   Np1
p1
.zC    0: N    NONE
    1: p    PUT        1
    4: p    PUT        1
zmemo key 1 already defineds   Np1
q.zC    0: N    NONE
    1: p    PUT        1
    4: q    BINPUT     1
s
   Np1
r   .zD    0: N    NONE
    1: p    PUT        1
    4: r    LONG_BINPUT 1
s   Np1
.zH    0: N    NONE
    1: p    PUT        1
    4: \x94 MEMOIZE    (as 1)
zmemo key None already definedr   r   s    r   test_put_redefinedDisTests.test_put_redefined   sq    ] - "		#
 	^ . "		#
 	7 : "		#
 	] - %		&r   c                 *    U R                  SSS5        g )Ns   p0
z    0: p    PUT        0
z'stack is empty -- can't store into memor   r   s    r   test_put_empty_stackDisTests.test_put_empty_stack   s    W '.	0r   c                 *    U R                  SSS5        g )Ns   (p0
z.    0: (    MARK
    1: p        PUT        0
z"can't store markobject in the memor   r   s    r   test_put_markobjectDisTests.test_put_markobject   s    X ( *	+r   c                 (    U R                  SS5        g )Ns   (Np1
g1
hj   t.z    0: (    MARK
    1: N        NONE
    2: p        PUT        1
    5: g        GET        1
    8: h        BINGET     1
   10: j        LONG_BINGET 1
   15: t        TUPLE      (MARK at 0)
   16: .    STOP
highest protocol among opcodes = 1
r   r   s    r   test_getDisTests.test_get   s    < 
? 
	r   c                 v    U R                  SSS5        U R                  SSS5        U R                  SSS5        g )N   g1
.z    0: g    GET        1
z%memo key 1 has never been stored intos   h.z    0: h    BINGET     1
s   j   .z    0: j    LONG_BINGET 1
r   r   s    r   test_get_without_putDisTests.test_get_without_put  sO    X (,	. 	Y ),	. 	2 5,	.r   c                 L    0 nU R                  SSUS9  U R                  SSUS9  g )Ns   Np1
.z^    0: N    NONE
    1: p    PUT        1
    4: .    STOP
highest protocol among opcodes = 0
)memor   zM    0: g    GET        1
    3: .    STOP
highest protocol among opcodes = 0
r   )r   r   s     r   	test_memoDisTests.test_memo  sC    y #
  	 	 	x " 	 	 	r   c                 (    U R                  SS5        g )Ns   (N00N.z    0: (    MARK
    1: N        NONE
    2: 0        POP
    3: 0        POP        (MARK at 0)
    4: N    NONE
    5: .    STOP
highest protocol among opcodes = 0
r   r   s    r   test_mark_popDisTests.test_mark_pop&  r   r   c                 P    U R                  SSS5        U R                  SSS5        g )N   az    0: a    APPEND
z1tries to pop 2 items from stack with only 0 itemss   ]az*    0: ]    EMPTY_LIST
    1: a    APPEND
z1tries to pop 2 items from stack with only 1 itemsr   r   s    r   test_too_small_stackDisTests.test_too_small_stack1  s6    T $8	: 	U % 9	:r   c                 *    U R                  SSS5        g )Nrz       0: N    NONE
r|   r   r   s    r   r   DisTests.test_no_stop:  s    T $*	,r   c                 P    U R                  SSS5        U R                  SSS5        g )Ns   NI123r   r   s   NJ4r   r   r   s    r   r   DisTests.test_truncated_data?  s4    X (4	6 	] --	/r   c                 *    U R                  SSS5        g )Nr   r   r   r   r   s    r   r   DisTests.test_unknown_opcodeG  s    X (.	0r   c                 *    U R                  SSS5        g )Ns   ]N.z\    0: ]    EMPTY_LIST
    1: N    NONE
    2: .    STOP
highest protocol among opcodes = 1
z$stack not empty after STOP: \[list\]r   r   s    r   test_stop_not_empty_stack"DisTests.test_stop_not_empty_stackL  s    V &
 -	.r   c                 j    U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  g )	Ns   (Nt.a,      0: (    MARK Push markobject onto the stack.
    1: N        NONE Push None on the stack.
    2: t        TUPLE      (MARK at 0) Build a tuple out of the topmost stack slice, after markobject.
    3: .    STOP                       Stop the unpickling machine.
highest protocol among opcodes = 0
r   )annotatea>      0: (    MARK            Push markobject onto the stack.
    1: N        NONE        Push None on the stack.
    2: t        TUPLE      (MARK at 0) Build a tuple out of the topmost stack slice, after markobject.
    3: .    STOP                       Stop the unpickling machine.
highest protocol among opcodes = 0
ro   s   (((((((ttttttt.a      0: (    MARK            Push markobject onto the stack.
    1: (        MARK        Push markobject onto the stack.
    2: (            MARK    Push markobject onto the stack.
    3: (                MARK Push markobject onto the stack.
    4: (                    MARK Push markobject onto the stack.
    5: (                        MARK Push markobject onto the stack.
    6: (                            MARK Push markobject onto the stack.
    7: t                                TUPLE      (MARK at 6) Build a tuple out of the topmost stack slice, after markobject.
    8: t                            TUPLE      (MARK at 5) Build a tuple out of the topmost stack slice, after markobject.
    9: t                        TUPLE      (MARK at 4) Build a tuple out of the topmost stack slice, after markobject.
   10: t                    TUPLE      (MARK at 3)     Build a tuple out of the topmost stack slice, after markobject.
   11: t                TUPLE      (MARK at 2)         Build a tuple out of the topmost stack slice, after markobject.
   12: t            TUPLE      (MARK at 1)             Build a tuple out of the topmost stack slice, after markobject.
   13: t        TUPLE      (MARK at 0)                 Build a tuple out of the topmost stack slice, after markobject.
   14: .    STOP                                       Stop the unpickling machine.
highest protocol among opcodes = 0
r   r   s    r   test_annotateDisTests.test_annotateT  s^    w !  	 	 	w !  	 	 	) ," # 	 	r   c                 p    U R                  SS5        U R                  SS5        U R                  SS5        g )Ns   S'abc'
.zQ    0: S    STRING     'abc'
    7: .    STOP
highest protocol among opcodes = 0
s   S"abc"
.s   S'õ'
.zV    0: S    STRING     '\xc3\xb5'
    6: .    STOP
highest protocol among opcodes = 0
r   r   s    r   test_stringDisTests.test_stringv  s@    | & 	
 	| & 	
 	( + 	r   c                     U R                  SSS5        U R                  SSS5        U R                  SSS5        U R                  SSS	5        U R                  S
SS5        U R                  SSS5        g )Ns   Sabc'
. zno string quotes around b"abc'"s   Sabc"
.zno string quotes around b'abc"'s   S'abc
.z3strinq quote b"'" not found at both ends of b"'abc"s   S"abc
.z3strinq quote b'"' not found at both ends of b'"abc's   S'abc"
.z6strinq quote b"'" not found at both ends of b'\\'abc"'s   S"abc'
.z6strinq quote b'"' not found at both ends of b'"abc\\''r   r   s    r   test_string_without_quotes#DisTests.test_string_without_quotes  s    ["?	A["?	A["V	X["W	Y]BZ	\]BZ	\r   c                 L    U R                  SS5        U R                  SS5        g )Ns	   T   abc.zQ    0: T    BINSTRING  'abc'
    8: .    STOP
highest protocol among opcodes = 1
s   T   õ.zV    0: T    BINSTRING  '\xc3\xb5'
    7: .    STOP
highest protocol among opcodes = 1
r   r   s    r   test_binstringDisTests.test_binstring  s,    / 2 	
 	4 7 	r   c                 L    U R                  SS5        U R                  SS5        g )Ns   Uabc.zV    0: U    SHORT_BINSTRING 'abc'
    5: .    STOP
highest protocol among opcodes = 1
s   Uõ.z[    0: U    SHORT_BINSTRING '\xc3\xb5'
    4: .    STOP
highest protocol among opcodes = 1
r   r   s    r   test_short_binstringDisTests.test_short_binstring  s+    | & 	
 	( + 	r   c                 L    U R                  SS5        U R                  SS5        g )Ns   cmodule
name
.zY    0: c    GLOBAL     'module name'
   13: .    STOP
highest protocol among opcodes = 0
s   cmödule
näme
.u[       0: c    GLOBAL     'mödule näme'
   15: .    STOP
highest protocol among opcodes = 0
r   r   s    r   test_globalDisTests.test_global  s,    * - 	
 	8 ; 	r   c                 (    U R                  SS5        g )Ns   (imodule
name
.zz    0: (    MARK
    1: i        INST       'module name' (MARK at 0)
   14: .    STOP
highest protocol among opcodes = 0
r   r   s    r   	test_instDisTests.test_inst  s    + . 	r   c                 (    U R                  SS5        g )Ns   Pabc
.zQ    0: P    PERSID     'abc'
    5: .    STOP
highest protocol among opcodes = 0
r   r   s    r   test_persidDisTests.test_persid  s    z $ 	r   r7   )!r8   r9   r:   r;   maxDiffr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r>   r7   r   r   r   r      s    G3
3			 	&,0
+	.	:,
/0
. D"\


r   r   c                       \ rS rSrS rSrg)MiscTestCasei  c                 @    1 Skn[         R                  " U [        US9  g )N>O   int4long1long4pyintpysetuint1uint2uint4uint8bytes1bytes4bytes8float8pyboolpydictpylistpylongpynonecode2opfloatnlopcodespybytespyfloatpytuplestring1string4pybufferpystringstringnl	anyobject	pyunicode	read_int4
OpcodeInfo
bytearray8
markobject
read_long1
read_long4
read_uint1
read_uint2
read_uint4
read_uint8
stacksliceStackObjectbytes_typespybytearraypyfrozensetread_bytes1read_bytes4read_bytes8read_float8read_floatnlread_string1read_string4UP_TO_NEWLINEread_stringnldecimalnl_longpybytes_or_strunicodestring1unicodestring4unicodestring8decimalnl_shortread_bytearray8unicodestringnlpyinteger_or_boolstringnl_noescapeArgumentDescriptorread_decimalnl_longread_unicodestring1read_unicodestring4read_unicodestring8TAKEN_FROM_ARGUMENT1TAKEN_FROM_ARGUMENT4read_decimalnl_shortread_unicodestringnlTAKEN_FROM_ARGUMENT4UTAKEN_FROM_ARGUMENT8Uread_stringnl_noescapestringnl_noescape_pairread_stringnl_noescape_pair)not_exported)r   check__all__r
   )r   rH  s     r   test__all__MiscTestCase.test__all__  s    
8 	T;\Jr   r7   N)r8   r9   r:   r;   rJ  r>   r7   r   r   r   r     s    Kr   r   c                 X    UR                  [        R                  " [        5      5        U$ r	   )addTestdoctestDocTestSuiter
   )loadertestspatterns      r   
load_testsrS    s    	MM'&&{34Lr   __main__)rp   r   r
   testr   test.pickletesterr   rN  unittestTestCaser   r@   rS   r   r   rS  r8   mainr7   r   r   <module>rZ     s    	    1  62.0A0A 62r &G(## GTgx   gT	K8$$ KB
 zMMO r   