+
    BiFD                     L   ^ RI t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	 ^ RI
Ht ^ RI
Ht ^ RIHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ R	IHt ]! R
4      t]! ]R4      '       d   R]P6                  9   tM]P:                  R8H  tR t]P>                  ! ]! ]R4      R4       ! R R]P@                  4      4       t! ! R R]P@                  4      t"]P>                  ! ]	PF                  R4       ! R R]P@                  4      4       t$]%R8X  d   ]PL                  ! 4        R# R# )    N)support)threading_helper)verbose)import_module)unlinktemp_dirTESTFN)run_pty)assert_python_ok)requires_working_threadingreadline_READLINE_LIBRARY_VERSIONzEditLine wrappereditlinec                  L   \         '       d   \        \        R 4      '       d;   \        R\        P                  R 24       \        R\        P
                  R 24       \        \        R4      '       d   \        R\        P                  : 24       \        R\         24       R# R# )_READLINE_VERSIONzreadline version: z#xzreadline runtime version: r   zreadline library version: zuse libedit emulation? N)r   hasattrr   printr   _READLINE_RUNTIME_VERSIONr   is_editline     )/usr/lib/python3.14/test/test_readline.pysetUpModuler      s    w 8011&x'A'A"&EFG.x/Q/QRT.UVW8899.x/Q/Q.TUV'}56 r   clear_historyzXThe history update test cannot be run because the clear_history method is not available.c                   r   a  ] tR t^*t o R t]P                  ! ]! ]R4      R4      R 4       t	R t
R tRtV tR# )	TestHistoryManipulationc                   \         P                  4        \         P                  R 4       \         P                  R4       V P                  \         P	                  ^ 4      R4       V P                  \         P	                  ^4      R 4       V P                  \         P	                  ^4      R4       \         P                  ^ R4       V P                  \         P	                  ^ 4      R4       V P                  \         P	                  ^4      R4       V P                  \         P	                  ^4      R4       V P                  \         P                  4       ^4       \         P                  ^ 4       V P                  \         P	                  ^ 4      R4       V P                  \         P	                  ^4      R4       V P                  \         P                  4       ^4       R# )
first linesecond lineNzreplaced line)r   r   add_historyassertEqualget_history_itemreplace_history_itemget_current_history_lengthremove_history_itemselfs   &r   testHistoryUpdates*TestHistoryManipulation.testHistoryUpdates4   sR    \*]+2215t<2215|D2215}E%%a92215t<2215G2215}E<<>B$$Q'2215t<2215}E<<>Br   append_history_filezappend_history not availablec                h   \         P                  ! R R7      pVP                  4        VP                  pV P	                  \
        V4       \        P                  4        \        P                  R4       \        P                  R4       \        P                  V4       \        P                  4        V P                  \        P                  4       ^ 4       \        P                  V4       V P                  \        P                  4       ^4       V P                  \        P                  ^4      R4       V P                  \        P                  ^4      R4       \        P                  ^V4       \        P                  4        \        P                  V4       V P                  \        P                  4       ^4       V P                  \        P                  ^4      R4       V P                  \        P                  ^4      R4       V P                  \        P                  ^4      R4       \        P
                  ! V4        \        P                  ^V4       \        P
                  ! V4       \        P                  V4       V P#                  \$        4      ;_uu_ 4        \        P                  RV4       RRR4       V P#                  \$        4      ;_uu_ 4        \        P                  RV4       RRR4       R#   \          d     Li ; i  + '       g   i     L_; i  + '       g   i     R# ; i)F)deleter   r   Nii   )tempfileNamedTemporaryFileclosename
addCleanupr   r   r   r    write_history_filer!   r$   read_history_filer"   r*   osFileNotFoundErrorassertRaises
ValueError)r'   hfile	hfilenames   &  r   test_write_read_append.TestHistoryManipulation.test_write_read_appendK   sA    ++59JJ		* 	 \*]+##I. <<>B""9-<<>B2215|D2215}E 	$$Q	2 ""9-<<>B2215|D2215}E2215}E 			)	!((I6 IIi  	##I. z**((i8 + z**((i@ +*! ! 		 +* +**s*   K< LL <L
	L
L	 L1	c                   \         P                  4         \         P                  R 4       \         P                  R4       \         P                  ^R4       \         P                  \        4       V P                  \        P                  \        4       \         P                  4        \         P                  \        4       \        '       d   \         P                  R4       V P                  \         P                  ^4      R 4       V P                  \         P                  ^4      R4       R#   \         d-   pT P	                  R\        T4      ,           4        Rp?EL4Rp?ii ; i)u	   entrée 1 Locale cannot encode test data: Nu	   entrée 2u
   entrée 22dummy)r   r   r    UnicodeEncodeErrorskipTestformatr#   r2   r	   r1   r4   remover3   r   r!   r"   )r'   errs   & r   test_nonascii_history-TestHistoryManipulation.test_nonascii_history   s     	L  - 	[)%%a6##F+		6* ""6*;   )2215{C2215|D " 	LMM<vc{JKK	Ls   D- -E$8!EE$c                   \         P                  4       pV P                  \         P                  V4       \         P	                  4        \         P                  R 4       \         P                  R4       \         P                  R4       \         P                  ^4       V P                  \         P                  4       ^4       \         P                  \        4       V P                  \        P                  \        4       \         P	                  4        V P                  \         P                  4       ^ 4       V P                  \         P                  4       ^4       \         P                  \        4       V P                  \         P                  ^4      R4       V P                  \         P                  ^4      R4       V P                  \         P                  ^4      R4       V P                  \         P                  4       R4       R# )r   r   
third lineN)      )r   get_history_lengthr1   set_history_lengthr   r    r!   r2   r	   r4   rB   r$   r3   r"   assertInr'   previous_lengths   & r   test_write_read_limited_history7TestHistoryManipulation.test_write_read_limited_history   sW   "55733_E \*]+\*##A&446:##F+		6* <<>B446:""6*2215}E2215|D2215t< 	h99;VDr   r   N)__name__
__module____qualname____firstlineno__r(   unittest
skipUnlessr   r   r:   rD   rO   __static_attributes____classdictcell____classdict__s   @r   r   r   *   sL     C. +@A792A92AhE&E Er   r   c                   D  a  ] tR t^t o ]P
                  ! ]P                  R8  ;'       d    ]'       * R4      R 4       t	R t
RtR tR tR tR	 t]P
                  ! ]P                  R
8  R4      ]P
                  ! ]R4      R 4       4       t]! 4       R 4       tR tRtV tR# )TestReadlinei  z%not supported in this library versionc                L    \        R RRR7      w  rpV P                  VR4       R# )z-czimport readlinezxterm-256color)TERMr   N)r   r!   )r'   rcstdoutstderrs   &   r   	test_initTestReadline.test_init   s,     .d4E3CEF%r   c                F    V P                  \        P                  R4       R# )r   N)r   r   )rL   r   backendr&   s   &r   test_backendTestReadline.test_backend   s    h&&(@Ar   zvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
c                r    \        V P                  P                  R 4      4      pV P                  RV4       R# )Ts   History length: 1Nr
   auto_history_scriptrA   rL   r'   outputs   & r   test_auto_history_enabled&TestReadline.test_auto_history_enabled   s.    1188>? 	*F3r   c                r    \        V P                  P                  R 4      4      pV P                  RV4       R# )Fs   History length: 0Nri   rk   s   & r   test_auto_history_disabled'TestReadline.test_auto_history_disabled   s.    1188?@ 	*F3r   c                p    \         P                  ! R 4      p\        VRR7      pV P                  RV4       R# )a  
            import readline
            def complete(text, state):
                if state == 0 and text == "$":
                    return "$complete"
                return None
            if readline.backend == "editline":
                readline.parse_and_bind(r'bind "\t" rl_complete')
            else:
                readline.parse_and_bind(r'"\t": complete')
            readline.set_completer_delims(" \t\n")
            readline.set_completer(complete)
            print(input())
        s   $	
inputs	   $completeNtextwrapdedentr
   rL   r'   scriptrl   s   &  r   test_set_complete_delims%TestReadline.test_set_complete_delims   s1     "  x0lF+r   c                @   \         P                  ! \         P                  R 4      pVR9   d   V P                  RV: 24       \        P
                  P                  '       dR   \         P                  ! 4       p\        P                  ! V4      P                  pVR8w  d   V P                  RV: 24        \        P                  R4       RpRpVR\        R	4      ,          ,          pVR
,          pVR,          pVR,          p\!        WE4      pV P#                  RV4       V P#                  RV4       \        P$                  R8X  g   \&        '       g   V P#                  RV4       \&        '       g;   \)        \        R4      '       d%   V P#                  RV4       V P#                  RV4       RpV P#                  RV,           R,           V4       V P#                  RV,           V4       R #   \         d-   pT P                  R\        T4      ,           4        R p?ELOR p?ii ; i)Nzthe LC_CTYPE locale is zutf-8zthe LC_CTYPE encoding is u   ëïr=   a  import readline

is_editline = readline.backend == "editline"
inserted = "[\xEFnserted]"
macro = "|t\xEB[after]"
set_pre_input_hook = getattr(readline, "set_pre_input_hook", None)
if is_editline or not set_pre_input_hook:
    # The insert_line() call via pre_input_hook() does nothing with Editline,
    # so include the extra text that would have been inserted here
    macro = inserted + macro

if is_editline:
    readline.parse_and_bind(r'bind ^B ed-prev-char')
    readline.parse_and_bind(r'bind "\t" rl_complete')
    readline.parse_and_bind(r'bind -s ^A "{}"'.format(macro))
else:
    readline.parse_and_bind(r'Control-b: backward-char')
    readline.parse_and_bind(r'"\t": complete')
    readline.parse_and_bind(r'set disable-completion off')
    readline.parse_and_bind(r'set show-all-if-ambiguous off')
    readline.parse_and_bind(r'set show-all-if-unmodified off')
    readline.parse_and_bind(r'Control-a: "{}"'.format(macro))

def pre_input_hook():
    readline.insert_text(inserted)
    readline.redisplay()
if set_pre_input_hook:
    set_pre_input_hook(pre_input_hook)

def completer(text, state):
    if text == "t\xEB":
        if state == 0:
            print("text", ascii(text))
            print("line", ascii(readline.get_line_buffer()))
            print("indexes", readline.get_begidx(), readline.get_endidx())
            return "t\xEBnt"
        if state == 1:
            return "t\xEBxt"
    if text == "t\xEBx" and state == 0:
        return "t\xEBxt"
    return None
readline.set_completer(completer)

def display(substitution, matches, longest_match_length):
    print("substitution", ascii(substitution))
    print("matches", ascii(matches))
readline.set_completion_display_matches_hook(display)

print("result", ascii(input()))
print("history", ascii(readline.get_history_item(1)))
      z[after]s   		s   x	   s   text 't\xeb'
s#   line '[\xefnserted]|t\xeb[after]'
darwins   indexes 11 13
set_pre_input_hooks   substitution 't\xeb'
s    matches ['t\xebnt', 't\xebxt']
s   '[\xefnserted]|t\xebxt[after]'s   result s   
s   history )CPOSIX)locale	setlocaleLC_CTYPEr@   sysflags	utf8_modegetencodingcodecslookupr0   r   r    r?   rA   lenr
   rL   platformr   r   )r'   locencodingrC   ry   rt   rl   expecteds   &       r   test_nonasciiTestReadline.test_nonascii   s   v5.  MM3C7;<99))+H}}X.33H7"  9(FG	L  ,2h 3y>))'*F3@&I<<8#;;MM.7 {wx1EFFMM6?MMA6J5j8+g5v> 	kH,f5c " 	LMM<vc{JKK	Ls   4G& &H1!HHi   z3this readline version does not support history-sizez-editline history size configuration is brokenc                   ^
p\        4       ;_uu_ 4       p\        P                  P                  VR4      p\	        VR4      ;_uu_ 4       pVP                  RV,          4       RRR4       \        P                  P                  VR4      p\	        VR4      ;_uu_ 4       pRP                  R \        V^,          4       4       4      pVP                  V4       RRR4       Rp\        \        P                  4      pW8R	&   WXR
&   \        VRVR7       \	        VR4      ;_uu_ 4       pVP                  4       p	RRR4       V P                  \        X	4      V4       V P                  V	R,          P                  4       R4       RRR4       R#   + '       g   i     EL1; i  + '       g   i     L; i  + '       g   i     L; i  + '       g   i     R# ; i)
   inputrcwbs   set history-size %d
Nhistoryr   c              3   4   "   T F  pR V,          x  K  	  R# 5i)s   item %d
Nr   ).0is   & r   	<genexpr>1TestReadline.test_history_size.<locals>.<genexpr>[  s        B)@A !-q 0 0)@s   z
import os
import readline

history_file = os.environ["HISTORY_FILE"]
readline.read_history_file(history_file)
input()
readline.write_history_file(history_file)
INPUTRCHISTORY_FILEs   last input)rt   envrbs
   last input)r   r4   pathjoinopenwriterangedictenvironr
   	readlinesr!   r   strip)
r'   history_sizetest_dirr   fhistory_filedatary   r   liness
   &         r   test_history_sizeTestReadline.test_history_sizeM  sV   
 ZZ8ggll8Y7Ggt$$0<?@ % 77<<)<LlD))Qxx  B).|a/?)@ B B	 *F rzz"C$	N".F/s;lD))Q *SZ6U2Y__.>? Z$$$ *), *)9 ZZsU   5G
F	#<G:F	AG&F2	7A
GF	GF/*G2G=GG	c                p    \         P                  ! R 4      p\        VRR7      pV P                  RV4       R# )a  
            import threading
            from test.support.threading_helper import join_thread

            def func():
                input()

            thread1 = threading.Thread(target=func)
            thread2 = threading.Thread(target=func)
            thread1.start()
            thread2.start()
            join_thread(thread1)
            join_thread(thread2)
            print("done")
        s   input1input2rs   s   doneNru   rx   s   &  r   test_gh123321_threadsafe%TestReadline.test_gh123321_threadsafet  s4      "   ':;gv&r   c                
   \         P                  4       pV P                  \         P                  V4       \         P	                  R 4       \         P	                  R4       \         P	                  R4       \         P                  ^4       V P                  \         P                  4       ^4       \         P                  \        4       V P                  \        P                  \        4       \         P                  \        4       R# )r   r   rG   N)r   rJ   r1   rK   r    r!   r2   r	   r4   rB   r3   rM   s   & r   rO   ,TestReadline.test_write_read_limited_history  s    "55733_E\*]+\*##A&446:##F+		6*""6*r   r   N)rQ   rR   rS   rT   rU   skipIfr   r   r   rb   rf   rj   rm   rp   rz   r   r   r   r   rO   rW   rX   rY   s   @r   r\   r\      s     __X//&8LL_<>&>&B44,&b6R __X//%7JL__[DF!?FL!?F  !' "'.+ +r   r\   z4these tests can only possibly fail with GIL disabledc                   l   a  ] tR tRt o ]P
                  ]P                  ! 4       R 4       4       tRtV t	R# )FreeThreadingTesti  c                   R  p^(p\         P                  ! V4      p\        V4       Uu. uF  p\         P                  ! W3R7      NK  	  pp\        P
                  ! V4      ;_uu_ 4         RRR4       R# u upi   + '       g   i     R# ; i)c                     V P                  4        \        ^d4       FU  p\        P                  4        \        P	                  R4       \        P	                  R4       \        P                  4        KW  	  R# )d   z 	
`@#%^&*()=+[{]}\|;:'",<>?N)waitr   r   get_completer_delimsset_completer_delims)b_s   & r   completer_delims?FreeThreadingTest.test_free_threading.<locals>.completer_delims  sO    FFH3Z--/--.PQ--.PQ--/	  r   )targetargsN)	threadingBarrierr   Threadr   start_threads)r'   r   countbarrierr   threadss   &     r   test_free_threading%FreeThreadingTest.test_free_threading  su    	0 ##E*W\]bWcdWcRS9##+;*MWcd++G44 54 e444s   !A6*A;;B	r   N)
rQ   rR   rS   rT   r   reap_threadsr   r   rW   rX   rY   s   @r   r   r     s.     ""002 3 #r   r   __main__)'r   r   r4   r   r-   rv   r   rU   testr   test.supportr   r   test.support.import_helperr   test.support.os_helperr   r   r	   test.support.pty_helperr
   test.support.script_helperr   test.support.threading_helperr   r   r   r   r   re   r   rV   TestCaser   r\   Py_GIL_DISABLEDr   rQ   mainr   r   r   <module>r      s     	 
      )   4 ; ; + 7 D $
8011%)K)KKK""j0K	7 
WX7>?Ex00 E?EDj+8$$ j+d 
W,,.de))  f( zMMO r   