+
    Bi!-                        ^ RI t ^ RIt^ RIt^ RIHt ^ RIHtHtHt ]P                  ! R4      t
]P                  ! R4      t]P                  ! R4      tRt^t]! ]R4      ;_uu_ 4       t]! ]4      P'                  4       tRRR4       ]P+                  4       R,           t ! R	 R
]P.                  4      t]R8X  d   ]P4                  ! 4        R# R#   + '       g   i     LX; i)    N)support)import_helper	os_helperwarnings_helper	_testcapi_testlimitedcapi_iorb
c                   V   a  ] tR t^t o R tR tR tR tR tR t	R t
R tR	 tR
tV tR# )CAPIFileTestc                   \         P                  p\        p\        VR 4      ;_uu_ 4       pVP	                  4       pVP                  ^ 4       V! WBR ^ \        \        \        ^ 4      p V P                  V\        P                  4       V P                  VP                  4       \        P                  4       4       VP                  4        VP                  ^ 4       V! WBR R\        \        \        ^ 4      p V P                  V\        P                  4       V P                  VP                  4       \        P                  4       4       VP                  4        VP                  ^ 4       V! WBR^RR\        ^ 4      p V P                  V\        P                   4       V P                  VP"                  R4       V P                  VP$                  R4       V P                  VP                  4       \&        4       VP                  4         RRR4       R#   TP                  4        i ; i  TP                  4        i ; i  TP                  4        i ; i  + '       g   i     R# ; i)r
   i   rutf-8replaceN)r   pyfile_fromfd__file__openfilenoseekNULLassertIsInstancer	   FileIOassertEqualreadline
FIRST_LINEencodecloseBufferedReaderTextIOWrapperencodingerrorsFIRST_LINE_NORM)selfr   filenamefpfdobjs   &     //usr/lib/python3.14/test/test_capi/test_file.pytest_pyfile_fromfdCAPIFileTest.test_pyfile_fromfd   s   (66(D!!RB GGAJdAtT4KC%%c3::6  1B1B1DE		 GGAJdD$dANC%%c3+=+=>  1B1B1DE		 GGAJc1 'D!=C%%c3+<+<=  w7  Y7  A		? "! 		 		 		? "!!sV   <I(AH:;I6AH(3I<A<H=8IH%%I(H::I=III#	c                   \         P                  p\        \        R 4      ;_uu_ 4       pVP	                  ^ 4       V P                  V! VR4      \        P                  R4      4       VP	                  ^ 4       V P                  V! V^ 4      \        4       VP	                  ^ 4       V P                  V! V^4      \        R,          4       RRR4       \        \        R4      ;_uu_ 4       pVP	                  ^ 4       V P                  V! VR4      \        P                  R4      P                  4       4       VP	                  ^ 4       V P                  V! V^ 4      \        P                  4       4       VP	                  ^ 4       V P                  V! V^4      \        P                  4       R,          4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r   r   :N   NNr
   )
r   pyfile_getliner   r   r   r   r#   rstripr   r   )r$   r/   r&   s   &  r)   test_pyfile_getline CAPIFileTest.test_pyfile_getline9   sl    *88 (C  BGGAJ^B3,33D9;GGAJ^B2,.GGAJ^B2,R02 ! (D!!RGGAJ^B3'..t4;;=?GGAJ^B2'..02GGAJ^B2'..046 "! !  "!!s   B!F?*CG?G	G#	c           
        \         P                  p\        P                  ! 4       ;_uu_ 4       pV P	                  V! R P                  4       V4      ^ 4       V P                  \        4      ;_uu_ 4        V! RV4       RRR4       V P                  \        4      ;_uu_ 4        V! RP                  RR4      V4       RRR4       VP                  4       pV P	                  VR 4       RRR4       V P                  \        4      ;_uu_ 4        V! R\        4       RRR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     Lk; i  + '       g   i     R# ; i)u
   aé€􏿿   Nu   r   surrogatepasss   abc)r   pyfile_writestringioStringIOr   r   assertRaisesUnicodeDecodeErrorgetvalueSystemErrorr   )r$   writestrr&   texts   &   r)   test_pyfile_writestring$CAPIFileTest.test_pyfile_writestringV   s    #66[[]]bX&=&D&D&FKQO""#566"% 7""#566/BBG 7 ;;=DT#:;  {++VT" ,+ 7666	 ] ,++sH   AE	3
D#	=%E	"D6	<*E	E#D3.E	6EE		E	E-	c           
     &   \         P                  p^p\        P                  ! 4       ;_uu_ 4       pV P	                  V! RW24      ^ 4       V! \
        W24       V P	                  V! RV^ 4      ^ 4       V! \
        V^ 4       VP                  4       pV P	                  VR4       RRR4       ^{R\        4       3 FU  pV P                  VR7      ;_uu_ 4        V P                  \        4      ;_uu_ 4        V! RWR4       RRR4       RRR4       KW  	  V P                  \        4      ;_uu_ 4        V! R\
        ^ 4       RRR4       R#   + '       g   i     L; i  + '       g   i     Le; i  + '       g   i     K  ; i  + '       g   i     R# ; i)   rawreprzraw<NULL>'repr'<NULL>Nabc)file)r   pyfile_writeobjectr7   r8   r   r   r;   objectsubTestr9   AttributeError	TypeError)r$   writeobjectPy_PRINT_RAWr&   r>   invalid_files   &     r)   test_pyfile_writeobject$CAPIFileTest.test_pyfile_writeobjectg   s(    '99[[]]b[A1Eb/ [Q7;b!$;;=DT#:;  !%2L<00&&~66|B 7 10 3
 y))tQ' *)% ] 76 100 *))s<   A1EE+1
E;E+,E?E	E(#E++E<?F	c           
        \         P                  pV P                  V! ^{4      ^{4       V P                  V! ^ 4      ^ 4       \        \        R4      ;_uu_ 4       pV P                  V! V4      VP                  4       4       RRR4       Rp\        P                  ! V\        34      ;_uu_ 4        V P                  V! R4      ^4       RRR4        ! R R4      pV P                  \        4      ;_uu_ 4        V! R4       RRR4       V P                  \        4      ;_uu_ 4        V! V! R4      4       RRR4       V P                  \        4      ;_uu_ 4        V! V! R4      4       RRR4       RR	.\        4       3 FT  pV P                  VR
7      ;_uu_ 4        V P                  \        4      ;_uu_ 4        V! V4       RRR4       RRR4       KV  	  R#   + '       g   i     EL`; i  + '       g   i     EL-; i  + '       g   i     EL	; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     K  ; i){   r
   Nz!bool is used as a file descriptorTc                   ,   a  ] tR t^t o R tR tRtV tR# )=CAPIFileTest.test_pyobject_asfiledescriptor.<locals>.FakeFilec                    Wn         R # Nr'   )r$   r'   s   &&r)   __init__FCAPIFileTest.test_pyobject_asfiledescriptor.<locals>.FakeFile.__init__   s        c                    V P                   # rV   rW   )r$   s   &r)   r   DCAPIFileTest.test_pyobject_asfiledescriptor.<locals>.FakeFile.fileno   s    wwrZ   rW   N)__name__
__module____qualname____firstlineno__rX   r   __static_attributes____classdictcell____classdict__s   @r)   FakeFilerT      s      rZ   re   r>   stringlist)r(   r.   )r   pyobject_asfiledescriptorr   r   r   r   r   check_warningsRuntimeWarningr9   
ValueErrorrK   rH   rI   )r$   asfdr&   msgre   r(   s   &     r)   test_pyobject_asfiledescriptor+CAPIFileTest.test_pyobject_asfiledescriptor   s   
  99cC(a!$(D!!RT"Xryy{3 " 3++S.,ABBT$Z+ C	 	 z**H +z**" + y))&!" * vh1C#&&&&y11I 2 '& 23 "!!
 CBB +**** *) 21 '&&s`   'G.G+6	G?$HH&I8	H9IG(	+G<	?H	H#	&H6	9I	IIc                   \         P                  pV! \        4      pV P                  VP                  R 4       V P                  VP                  4       V P                  VP                  R4       V P                  VP                  4       \        4       V P                  VP                  4       \        P                  ! \        4      4       V P                  VP                  4       4       V P                  VP                  4       4       V P                  VP                  R 4       \        P                  ! V \        V4      4       R# )FwN)r   pyfile_newstdprinter	STDOUT_FDr   closedassertIsNoner!   moder   isattyosflushr   r   check_disallow_instantiationtype)r$   rr   rF   s   &  r)   test_pyfile_newstdprinter&CAPIFileTest.test_pyfile_newstdprinter   s    (==#I.e,$--(C(	2		)(<= 	$**,' 	$**,'e,,,T4:>rZ   c                   \         P                  p\        P                  pV P	                  \        P
                  V4        \        P                  ! \        4      p \        VR4      ;_uu_ 4       pVP                  4       p\        P                  ! V\        4       V! \        4      pV P                  VP                  R4      ^4       V P                  VP                  R4      ^4       RRR4       \        P                  ! X\        4       \        P                   ! V4       \        VR4      ;_uu_ 4       pV P                  VP#                  4       R4       RRR4       R#   \         d!   pT P                  R T: 24        Rp?EL-Rp?ii ; i  + '       g   i     L; i  \        P                  ! X\        4       \        P                   ! T4       i ; i  + '       g   i     R# ; i)zos.dup() failed with Nwbr>   u   []r   ztext[\udc80])r   rr   r   TESTFN
addCleanupunlinkrx   duprs   OSErrorskipTestr   r   dup2r   writer   read)r$   rr   r%   
old_stdoutexcr&   r'   rF   s   &       r)   test_pyfile_newstdprinter_write,CAPIFileTest.test_pyfile_newstdprinter_write   sT   (==##	(((3	;	*J
	!h%% YY[I&+I6  F!3Q7   J!7; & GGJ	*HHZ (C  BRWWY8 ! )  	;MM1#9::	;
 &% GGJ	*HHZ    sI   E# F$ 1A:F+F$ 8!G#F.F		FF!	F$ $3GG+	c           
     6
   \         P                  p\        \        R 4      ;_uu_ 4       pVP	                  4       pRRR4       \        \
        P                  ! \        4      3 F}  pV P                  VR7      ;_uu_ 4        V! VR 4      pV P                  VXR,          4       V! \        P                  ! V4      R 4      pV P                  WSR,          4       RRR4       K  	  \        P                  \
        P                  ! \        P                  4      .p\        P                  eS   VP                  \        P                  4       VP                  \
        P                  ! \        P                  4      4       \        P                  e    VP                  \        P                  4       V F  pV P                  VR7      ;_uu_ 4         \        VR4      ;_uu_ 4       pVP!                  X4       RRR4        T! TR 4      pT P                  TXR,          4       \        P$                  ! T4        RRR4       K  	  V P'                  \(        4      ;_uu_ 4        V! RR 4       RRR4       V P'                  \(        4      ;_uu_ 4        V! RR 4       RRR4       V P'                  \"        4      ;_uu_ 4        V! \        R4       RRR4       V P'                  \"        4      ;_uu_ 4        V! \        R4       RRR4       V P'                  \*        \"        34      ;_uu_ 4        V! \        R	4       RRR4       ^{\-        4       3 FU  pV P                  VR7      ;_uu_ 4        V P'                  \.        4      ;_uu_ 4        V! VR 4       RRR4       RRR4       KW  	  \0        P2                  '       d6   V P'                  \"        4      ;_uu_ 4        V! \        R
4       RRR4       R# R#   + '       g   i     EL; i  + '       g   i     EK  ; i  + '       g   i     EL/; i  \"         d    Rp RRR4       EK  i ; i  \        P$                  ! T4       i ; i  + '       g   i     EK  ; i  + '       g   i     EL; i  + '       g   i     EL ; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     EL; i  + '       g   i     ELX; i  + '       g   i     EK  ; i  + '       g   i     R# ; i)r
   N)r%   :N   Nr   za bs   a bs   s   s   zrt+, ccs=UTF-8)r   py_fopenr   r   r   rx   fsencoderI   r   r   FakePathr   TESTFN_UNDECODABLEappendfsdecodeTESTFN_UNENCODABLEr   r   r   r9   rk   r:   rH   rK   r   
MS_WINDOWS)r$   r   r&   sourcer%   data	filenamesinvalid_types   &       r)   test_py_fopenCAPIFileTest.test_py_fopen   s   %%(D!!RWWYF " "2;;x#89Hx00$/  vd|4	 2 28 <dC  d|4 10 : KK	(()
	 ''3Y99:R[[)E)EFG''3Y99:!Hx00h--( ./#Hd3D$$T6$<8$$X. 10 "" z**Xt$ +z**Y% + w''X{+ (w'' X23 (
  2G<==X{+ > !&(OL|44&&y11\40 2 54 ,
 ""7++#34 ,+ w "!! 100& .--   $H 10 $$X. 100  +***** ('''''
 >== 211 544
 ,++s   O0?APQ%P-!P3P-<"Q
Q%
Q:
R<R"/R6(S
'S2
SS2T0P	PP*$P-(Q%*P--Q	:Q%Q	Q%
Q"	"Q%%Q7:R	R	"R3	6S	
S	S/)	S22TT	c                   \         P                  p\        P                  pV P	                  \        P
                  V4       \        VR 4      ;_uu_ 4       pVP                  R4       RRR4       V! VR4      pV P                  VR4       \        VR 4      ;_uu_ 4       pVP                  R4       RRR4       V! VR4      pV P                  VR4       \        VR 4      ;_uu_ 4       pVP                  R4       RRR4       V! VR4      pV P                  VR4       R#   + '       g   i     L; i  + '       g   i     L; i  + '       g   i     LS; i)	r   s   line1
line2Ni  s   line1
s   line2
line3s   line2
s   line3line4s   line3
)	r   py_universalnewlinefgetsr   r   r   r   r   r   r   )r$   r   r%   r&   lines   &    r)   test_py_universalnewlinefgets*CAPIFileTest.test_py_universalnewlinefgets)  s   #,#E#E ##	(((3(D!!RHH_% " ($7z*(D!!RHH&' " ($7z*(D!!RHH_% " ($7z*! "! "! "!s$   DD1'ED.	1E	E	 N)r]   r^   r_   r`   r*   r1   r?   rO   rn   r|   r   r   r   ra   rb   rc   s   @r)   r   r      s<     #J6:#"(8&T?*9@B5N+ +rZ   r   __main__)r7   rx   unittesttestr   test.supportr   r   r   import_moduler   r   r	   r   rs   r   r   r&   nextdecoder   r0   r#   TestCaser   r]   mainr   rZ   r)   <module>r      s    	 	   B B ''4	 ../AB !!%(		(DRb"J ##%,k+8$$ k+b	 zMMO m	 s   (CC	