403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux web0264.sh.tyo1 4.18.0-553.79.1.lve.el7h.x86_64 #1 SMP Wed Oct 15 16:34:46 UTC 2025 x86_64
User : c9415830 ( 11735)
PHP Version : 8.4.17
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python36/lib64/python3.6/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python36/lib64/python3.6/test/__pycache__/test_readline.cpython-36.opt-2.pyc
3

�
�^1�@s�ddlmZddlmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZm
Z
mZmZddlmZed�Zejo�dejkZe
jeed�d	�Gd
d�de
j��ZGdd
�d
e
j�Zddd�Zedkr�e
j�dS)�)�	ExitStack)�EION)�
import_module�unlink�temp_dir�TESTFN)�assert_python_ok�readline�libedit�
clear_historyzXThe history update test cannot be run because the clear_history method is not available.c@s6eZdZdd�Zejeed�d�dd��Zdd�Z	d	S)
�TestHistoryManipulationcCs�tj�tjd�tjd�|jtjd�d�|jtjd�d�|jtjd�d�tjdd�|jtjd�d�|jtjd�d�|jtjd�d�|jtj�d�tjd�|jtjd�d�|jtjd�d�|jtj�d�dS)Nz
first linezsecond liner��z
replaced line)r	r�add_history�assertEqual�get_history_item�replace_history_item�get_current_history_lengthZremove_history_item)�self�r�2/opt/alt/python36/lib64/python3.6/test_readline.py�testHistoryUpdatess


z*TestHistoryManipulation.testHistoryUpdates�append_history_filezappend_history not availablec
Cs@tjdd�}|j�|j}|jt|�tj�tjd�tjd�tj	|�tj�|j
tj�d�tj|�|j
tj�d�|j
tj
d�d�|j
tj
d�d�tjd|�tj�tj|�|j
tj�d�|j
tj
d�d�|j
tj
d�d�|j
tj
d�d�tj|�|jt��tjd|�WdQRXtj	|�dS)	NF)�deletez
first linezsecond linerrr
�)�tempfileZNamedTemporaryFile�close�name�
addCleanuprr	rr�write_history_filerr�read_history_filerr�osZassertRaises�FileNotFoundError)rZhfileZ	hfilenamerrr�test_write_read_append6s2





z.TestHistoryManipulation.test_write_read_appendcCs�tj�ytjd�Wn4tk
rJ}z|jdt|��WYdd}~XnXtjd�tjdd�tjt�|j	t
jt�tj�tjt�t
r�tjd�|jtjd�d�|jtjd�d�dS)Nu	entrée 1z Locale cannot encode test data: u	entrée 2r
u
entrée 22Zdummyr)r	rr�UnicodeEncodeError�skipTest�formatrrrrr!�remover �is_editlinerr)r�errrrr�test_nonascii_history]s$



z-TestHistoryManipulation.test_nonascii_historyN)
�__name__�
__module__�__qualname__r�unittest�
skipUnless�hasattrr	r#r*rrrrrs
&rc@sneZdZejejdkoed�dd��ZdZ	dd�Z
dd	�Zd
d�Zejejdkd
�ejed�dd���Z
dS)�TestReadlineiz%not supported in this library versioncCs$tdddd�\}}}|j|d�dS)Nz-czimport readlinezxterm-256color)ZTERM�)rr)rZrc�stdout�stderrrrr�	test_initsszTestReadline.test_initzvimport readline
readline.set_auto_history({})
input()
print("History length:", readline.get_current_history_length())
cCs t|jjd��}|jd|�dS)NTsHistory length: 1
)�run_pty�auto_history_scriptr&�assertIn)r�outputrrr�test_auto_history_enabled�sz&TestReadline.test_auto_history_enabledcCs t|jjd��}|jd|�dS)NFsHistory length: 0
)r6r7r&r8)rr9rrr�test_auto_history_disabled�sz'TestReadline.test_auto_history_disabledcCs tjtjd�}|dkr&|jd|���ytjd�Wn4tk
rh}z|jdt|��WYdd}~XnXd}d}|dtd	�7}|d
7}|d7}|d7}t	||�}|j
d
|�|j
d|�|j
d|�tr�ttd�r�|j
d|�|j
d|�d}|j
d|d|�|j
d|d|�dS)N�C�POSIXzthe LC_CTYPE locale is uëïz Locale cannot encode test data: a*import readline

is_editline = readline.__doc__ and "libedit" in readline.__doc__
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		sx	�
stext 't\xeb'
s#line '[\xefnserted]|t\xeb[after]'
sindexes 11 13
Zset_pre_input_hookssubstitution 't\xeb'
s matches ['t\xebnt', 't\xebxt']
s'[\xefnserted]|t\xebxt[after]'sresult s
shistory )r<r=)
�locale�	setlocale�LC_CTYPEr%r	rr$r&�lenr6r8r(r0)r�locr)�script�inputr9Zexpectedrrr�
test_nonascii�s.$4
zTestReadline.test_nonasciiiz3this readline version does not support history-sizez-editline history size configuration is brokenc
Csd}t���}tjj|d�}t|d��}|jd|�WdQRXtjj|d�}t|d��,}djdd�t|d	�D��}|j|�WdQRXd
}ttj�}||d<||d<t	|d
|d�t|d��}|j
�}	WdQRX|jt|	�|�|j|	dj
�d�WdQRXdS)N�
�inputrc�wbsset history-size %d
�historyr2css|]}d|VqdS)sitem %d
Nr)�.0�irrr�	<genexpr>�sz1TestReadline.test_history_size.<locals>.<genexpr>rz�
import os
import readline

history_file = os.environ["HISTORY_FILE"]
readline.read_history_file(history_file)
input()
readline.write_history_file(history_file)
ZINPUTRCZHISTORY_FILEslast input
)rG�env�rbr
s
last input���)rr!�path�join�open�write�range�dict�environr6�	readlinesrrD�strip)
rZhistory_sizeZtest_dirrJ�fZhistory_file�datarFrP�linesrrr�test_history_size�s&


zTestReadline.test_history_sizeN)r+r,r-r.ZskipIfr	Z_READLINE_VERSIONr(r5r7r:r;rHr_rrrrr1qsVr1�dummy input
c'Cs�td�}t�}|j�\}}tjd|f}tj|||||d�}tj|�t	���N}	|	j
|�dd�}
|	j|
|�|	jtj|�|	j
tj
��}|j|tjtjB�tj|d�x�x�|j�D]�\}}
|
tj@�r"ytj|d�}Wn4tk
�r}z|jtkr��d}WYdd}~XnX|�s|S|j|�|
tj@r�y|tj||�d�}Wn6tk
�rz}z|jtk�rf�d}WYdd}~XnX|s�|j|tj�q�Wq�WWdQRXdS)	N�ptyz-c)�stdinr3r4rPcSs&y|j�Wntk
r YnXdS)N)�	terminate�ProcessLookupError)�procrrrrcszrun_pty.<locals>.terminateFir2)r�	bytearray�openpty�sys�
executable�
subprocess�Popenr!rr�
enter_context�callback�	selectorsZSelectSelector�registerZ
EVENT_READZEVENT_WRITE�set_blockingZselect�read�OSError�errnor�extendrVZmodify)rFrGrPrar9ZmasterZslave�argsreZcleanuprcZsel�_Zevents�chunkr)rrrr6
sF





r6�__main__)r`N)�
contextlibrrsrrAr!rnrjrhrr.Ztest.supportrrrrZtest.support.script_helperrr	�__doc__r(r/r0ZTestCaserr1r6r+�mainrrrr�<module>s(
Y
2

Youez - 2016 - github.com/yon3zu
LinuXploit