shell bypass 403
o
abI � @ s� d Z ddlZddlZddlZddlZddlZddlZdd� ZdZ dZ
dZdZd Z
d
ZdZdZd
ZdZdZdZdZG dd� dej�ZG dd� de�ZG dd� de�ZG dd� de�Zedkrce�� dS dS )z>Tests for the unparse.py script in the Tools/parser directory.� Nc C s6 t �| ��}|�� W d � S 1 sw Y dS )znRead and return the contents of a Python source file (as a
string), taking into account the file encoding.N)�tokenize�open�read)�filename�stream� r �:/usr/local/python-3.10/lib/python3.10/test/test_unparse.py�read_pyfile s $�r zQdef f():
for x in range(10):
break
else:
y = 2
z = 3
zIdef g():
while True:
break
else:
y = 2
z = 3
zQfrom . import fred
from .. import barney
from .australia import shrimp as prawns
zzdef f():
x = 1
def g():
nonlocal x
x = 2
y = 7
def h():
nonlocal x, y
zOtry:
1 / 0
except ZeroDivisionError as e:
raise ArithmeticError from e
z@f1(arg)
@f2
class Foo: pass
z=if cond1:
suite1
elif cond2:
suite2
else:
suite3
z,if cond1:
suite1
elif cond2:
suite2
zctry:
suite1
except ex1:
suite2
except ex2:
suite3
else:
suite4
finally:
suite5
zwith f():
suite1
zwith f() as x:
suite1
z$with f() as x, g() as y:
suite1
)� zclass foo:
zdef foo():
zasync def foo():
c @ sF e Zd Zdd� Zdd� Zefdd�Zddd �Zdd
d�Zddd
�Z dS )�ASTTestCasec C s | � t�|�t�|�� d S �N)�assertEqual�ast�dump)�self�ast1�ast2r r r �assertASTEqualw s zASTTestCase.assertASTEqualc K sn | j ||d��& tj|fi |��}t�|�}tj|fi |��}| �||� W d � d S 1 s0w Y d S )N)�code1Zast_parse_kwargs)�subTestr �parse�unparser )r r �kwargsr �code2r r r r �check_ast_roundtripz s
"�zASTTestCase.check_ast_roundtripc C sB | j |d�� | �|tj|� W d � d S 1 sw Y d S )N)�node)r ZassertRaisesr r )r r Zraisesr r r �
check_invalid� s "�zASTTestCase.check_invalidNc C s |p|}t �t �|��}||fS r )r r r �r r r r r r �
get_source� s zASTTestCase.get_sourcec C �P | � ||�\}}| j||d�� | �||� W d � d S 1 s!w Y d S �N)r r )r r r
r r r r �check_src_roundtrip� � "�zASTTestCase.check_src_roundtripc C r r )r r ZassertNotEqualr r r r �check_src_dont_roundtrip� r"