HEX
Server: Apache
System: Linux bd12.noc223.com 4.18.0-553.121.1.lve.el8.x86_64 #1 SMP Thu Apr 30 16:40:41 UTC 2026 x86_64
User: handcraf (1693)
PHP: 8.1.28
Disabled: NONE
Upload Files
File: //opt/alt/python312/lib64/python3.12/test/__pycache__/test_symtable.cpython-312.opt-1.pyc
�

h�e5,��z�dZddlZddlZdZd�ZGd�dej
�Zedk(rej�yy)z&
Test the API of the symtable module.
�Na�
import sys

glob = 42
some_var = 12
some_non_assigned_global_var = 11
some_assigned_global_var = 11

class Mine:
    instance_var = 24
    def a_method(p1, p2):
        pass

def spam(a, b, *var, **kw):
    global bar
    global some_assigned_global_var
    some_assigned_global_var = 12
    bar = 47
    some_var = 10
    x = 23
    glob
    def internal():
        return x
    def other_internal():
        nonlocal some_var
        some_var = 3
        return some_var
    return internal

def foo():
    pass

def namespace_test(): pass
def namespace_test(): pass

type Alias = int
type GenericAlias[T] = list[T]

def generic_spam[T](a):
    pass

class GenericMine[T: int]:
    pass
c�\�|j�D]}|j�|k(s�|cSy�N)�get_children�get_name)�block�name�chs   �9/opt/alt/python312/lib64/python3.12/test/test_symtable.py�
find_blockr7s-��� � �"���
�;�;�=�D� ��I��c���eZdZejedd�Zeed�Zeed�Zeed�Z	ee	d�Z
ee	d�Zeed�Zeed	�Z
eed
�Zeed
�Zeed�Zeed�Zeed�Zeed�Zeed
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d �Z'd!�Z(d"�Z)d#�Z*d$�Z+d%�Z,d&�Z-d'�Z.d(�Z/y))*�SymtableTest�?�exec�Mine�a_method�spam�internal�other_internal�foo�Alias�GenericAlias�generic_spam�GenericMine�Tc��|j|jj�d�|j|jj�d�|j|jj�d�|j|j
j�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�y)N�module�class�functionz
type aliasztype parameterz
TypeVar bound)�assertEqual�top�get_typerrrrrrr�GenericAlias_innerr�generic_spam_innerr�GenericMine_innerr��selfs r
�	test_typezSymtableTest.test_typePs���������*�*�,�h�7�������+�+�-�w�7�������/�/�1�:�>�������+�+�-�z�:�������/�/�1�:�>�������*�*�,�j�9�������,�,�.��=�����*�*�3�3�5�7G�H�����0�0�9�9�;�\�J�����*�*�3�3�5�7G�H�����0�0�9�9�;�Z�H�����)�)�2�2�4�6F�G�����/�/�8�8�:�G�D���������*�O�<rc�L�|j|jj�d�|j|jj�d�|j|jj�d�|j|j
j�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�|j|jj�d�y)Nr)�
assertGreaterr!�get_idrrrrrrrrrr&s r
�test_idzSymtableTest.test_id`s&�����4�8�8�?�?�,�a�0����4�9�9�+�+�-�q�1����4�=�=�/�/�1�1�5����4�9�9�+�+�-�q�1����4�=�=�/�/�1�1�5����4�8�8�?�?�,�a�0����4�:�:�,�,�.��2����4�,�,�3�3�5�q�9����4�,�,�3�3�5�q�9����4�+�+�2�2�4�a�8rc��|j|jj��|j|jj��yr)�assertFalser!�is_optimized�
assertTruerr&s r
�test_optimizedzSymtableTest.test_optimizedls6��������.�.�0�1�����	�	�.�.�0�1rc�L�|j|jj��|j|jj��|j|jj��|j|jj��yr)r.r!�	is_nestedrrr0rr&s r
�test_nestedzSymtableTest.test_nestedqsl��������+�+�-�.�������,�,�.�/�������,�,�.�/�����
�
�/�/�1�2rc��|j|jj��|j|jj��|j	|j
j��yr)r0r!�has_childrenrr.rr&s r
�
test_childrenzSymtableTest.test_childrenwsO��������-�-�/�0�����	�	�.�.�0�1�������.�.�0�1rc��|j|jj�d�|j|jj�d�y)Nr�)r r!�
get_linenorr&s r
�test_linenozSymtableTest.test_lineno|s<��������,�,�.��2�������-�-�/��4rc�v�|j}|jt|j��gd��gd�}|jt|j	��|�|jt|j��gd��|j|jj�d�y)N)�a�b�kw�var)r=r>rr?r�some_varr@�x)�bar�glob�some_assigned_global_var)rB)rr �sorted�get_parameters�
get_locals�get_globalsr�	get_frees)r'�func�expecteds   r
�test_function_infozSymtableTest.test_function_info�s����y�y������� 3� 3� 5�6�8O�P�Y��������� 1�2�H�=������ 0� 0� 2�3�5`�a�������0�0�2�F�;rc���|j|jjd�j��|j	|jjd�j��|j|jjd�j��|j|jjd�j��|j	|jjd�j��|j	|jjd�j��|j|jjd�j��|j|jjd�j��|j|jjd�j��y)NrDrCrB�instance_var�some_non_assigned_global_varrE)	r0r�lookup�	is_globalr.�is_declared_globalrrr!r&s r
�test_globalszSymtableTest.test_globals�sJ������	�	�(�(��0�:�:�<�=�������)�)�&�1�D�D�F�G�����	�	�(�(��/�9�9�;�<�����	�	�(�(��/�B�B�D�E�������-�-�c�2�<�<�>�?�������)�)�.�9�C�C�E�F�����	�	�(�(��/�9�9�;�<���������(F�G�Q�Q�S�T���������(B�C�M�M�O�Prc�<�|j|jjd�j��|j	|j
jd�j��d}|j
|j
j�|�y)NrA)rA)r.rrQ�is_nonlocalr0rr �
get_nonlocals�r'rLs  r
�
test_nonlocalzSymtableTest.test_nonlocal�sr��������)�)�*�5�A�A�C�D�����+�+�2�2�:�>�J�J�L�M� ������,�,�:�:�<�h�Grc���|j|jjd�j��|j	|jjd�j��|j|j
jd�j��|j|j
jd�j��y)NrBrCrPrE)r0rrQ�is_localr.r!r&s r
�
test_localzSymtableTest.test_local�s�������	�	�(�(��-�6�6�8�9�������)�)�%�0�9�9�;�<���������(F�G�P�P�R�S���������(B�C�L�L�N�Orc�t�|j|jjd�j��y)NrB)r0rrQ�is_freer&s r
�	test_freezSymtableTest.test_free�s&������
�
�,�,�S�1�9�9�;�<rc�T�|j|jjd�j��|j|jjd�j��|j|jjd�j��y)NrBr)r0rrQ�
is_referencedrr.r&s r
�test_referencedzSymtableTest.test_referenced�sp������
�
�,�,�S�1�?�?�A�B�����	�	�(�(��4�B�B�D�E�������)�)�#�.�<�<�>�?rc���dD]:}|j|jj|�j���<|j	|jjd�j��y)N)r=r@r?rB)r0rrQ�is_parameterr.)r'�syms  r
�test_parameterszSymtableTest.test_parameters�s]��%�	B�C��O�O�D�I�I�,�,�S�1�>�>�@�A�	B�������)�)�#�.�;�;�=�>rc��|jt|jj��t|jj	���|jt|jjd�y)N�not_here)r �lenr!�get_identifiers�get_symbols�assertRaises�KeyErrorrQr&s r
�test_symbol_lookupzSymtableTest.test_symbol_lookup�sU������T�X�X�5�5�7�8��T�X�X�1�1�3�4�	6�	
���(�D�H�H�O�O�Z�@rc��|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|j
jd�j��|j|jjd�j��|j
|j
jd�j��|j|jjd�j�|j
u�|jjd�}|jt|j��d�|jt|j�|jjd�}|jt|j��d	�|jt|j�y)
Nrrrr�namespace_testrB�rDr)
r0r!rQ�is_namespacerrr.�
get_namespacer ri�get_namespacesrl�
ValueError)r'�ns_test�	ns_test_2s   r
�test_namespaceszSymtableTest.test_namespaces�s������������/�<�<�>�?�����	�	�(�(��4�A�A�C�D����������/�<�<�>�?�����	�	�(�(��4�A�A�C�D���������(8�9�F�F�H�I�������)�)�#�.�;�;�=�>����������/�=�=�?�4�9�9�L�M��(�(�/�/�"2�3������W�3�3�5�6��:����*�g�&;�&;�<��H�H�O�O�F�+�	�����Y�5�5�7�8�!�<����*�i�&=�&=�>rc�4�|j|jjd�j��|j|jjd�j��|j|jjd�j��|j|j
jd�j��|j
|jjd�j��y)NrBrCrr)r0rrQ�is_assignedr!rr.rr&s r
�
test_assignedzSymtableTest.test_assigned�s�������	�	�(�(��-�9�9�;�<�����	�	�(�(��/�;�;�=�>����������/�;�;�=�>�����	�	�(�(��4�@�@�B�C�������-�-�c�2�>�>�@�Arc�0�tjddd�}|j�d}|j|jd�j	��|j|jd�j��|j
|jd�j��tjddd�}|j�d}|j|jd�j	��|j
|jd�j��tjddd�}|j|jd�j��tjddd�}y)	Nzdef f():
    x: int
�testrrrBzdef f():
    x = 1
zglobal x
x: intz=def g():
    x = 2
    def f():
        nonlocal x
    x: int)�symtablerr0rQr[�is_annotatedr.rR)r'�st1�st2�st3�st4�st5�st6s       r
�test_annotatedzSymtableTest.test_annotated�s9����� 8�&�&�I����� ��#������
�
�3��0�0�2�3�����
�
�3��4�4�6�7�������C��2�2�4�5���� 7���H����� ��#������
�
�3��0�0�2�3�������C��5�5�7�8���� 2�F�F�C������
�
�3��1�1�3�4����!-�
!'��0�rc�t�|j|jjd�j��y)N�sys)r0r!rQ�is_importedr&s r
�
test_importedzSymtableTest.test_imported�s$�����������.�:�:�<�=rc�r�|j|jj�d�|j|jj�d�|j|jj	d�j�d�|j|j
j�d�y)Nr!rrBr)r r!rrrQrr&s r
�	test_namezSymtableTest.test_name�s���������*�*�,�e�4�������+�+�-�v�6�������)�)�#�.�7�7�9�3�?�������+�+�-�v�6rc�X�|j|jj�d�y)N)r)r r�get_methodsr&s r
�test_class_infozSymtableTest.test_class_info�s��������.�.�0�-�@rc����fd�}|dd�|dd�tjddd��jt�5tjdtd�d�ddd��jt�5tjdt	d�d�ddd��jt�5tjdtd�d�ddd�y#1swY��xYw#1swY�TxYw#1swYyxYw)	Nc�2��	tj|dd��jd|���y#t$r^}�j|jd��j|j
d��j|j|�Yd}~yd}~wwxYw)Nrrzno SyntaxError for �)r~�fail�SyntaxErrorr �filename�lineno�offset)�
brokencoder��er's   �r
�
checkfilenamez9SymtableTest.test_filename_correct.<locals>.checkfilename�s}���
C��!�!�*�f�f�=��	�	�Z�A�B���
3�� � ����V�4�� � ����1�-�� � ����6�2�2��
3�s�/�	B�AB�Bzdef f(x): foo)(r9zdef f(x): global x��passsspamr)r~rl�	TypeError�	bytearray�
memoryview�list)r'r�s` r
�test_filename_correctz"SymtableTest.test_filename_correct�s����	C�	�'��,��*�B�/����&�'�6�2�
�
�
�y�
)�	B����f�i��&8�&�A�	B�
�
�
�y�
)�	C����f�j��&9�6�B�	C�
�
�
�y�
)�	=����f�d�7�m�V�<�	=�	=�		B�	B��	C�	C��	=�	=�s$�!C+�!C7�!D�+C4�7D�Dc�2�tjddd�}y)N�42r�eval�r~�r'�symbolss  r
�	test_evalzSymtableTest.test_evals���#�#�D�#�v�6�rc�2�tjddd�}y)Nr�r�singler�r�s  r
�test_singlezSymtableTest.test_single
s���#�#�D�#�x�8�rc�2�tjddd�}y)Nzdef f(x): return xrrr�r�s  r
�	test_execzSymtableTest.test_exec
s���#�#�$8�#�v�F�rc��tjtjd�dd�}|jt	|d��d}tj|dd�}|jt	|d��y)N�utf8rrrs+# -*- coding: iso8859-15 -*-
class �: pass
uŽ)r~�	TEST_CODE�encode�assertIsNotNoner)r'r!�codes   r
�
test_byteszSymtableTest.test_bytessd�����	� 0� 0�� 8�#�v�F�����Z��V�4�5�B������c�6�2�����Z��X�6�7rc��|jt|j�d�|jt|j�d�y)Nz<SymbolTable for module ?>z$<Function SymbolTable for spam in ?>)r �strr!rr&s r
�test_symtable_reprzSymtableTest.test_symtable_reprs4������T�X�X��(D�E�����T�Y�Y��)O�Prc���d|jj��d|jj��d�}|jt	|jj
�|�y)Nz<symtable entry top(z), line �>)r!r+r:r �repr�_tablerXs  r
�test_symtable_entry_reprz%SymtableTest.test_symtable_entry_reprsN��)�$�(�(�/�/�*;�)<�H�T�X�X�EX�EX�EZ�D[�[\�]������d�h�h�o�o�.��9rN)0�__name__�
__module__�__qualname__r~r�r!rrrrrrrrrr#rr$rr%rr(r,r1r4r7r;rMrTrYr\r_rbrfrnrxr{r�r�r�r�r�r�r�r�r�r�r��rr
rr=sT��
�(�
�
�I�s�F�
3�C��c�6�"�D��$�
�+�H��c�6�"�D��$�
�+�H���&6�7�N�
�S�%�
 �C��s�G�$�E��c�>�2�L�#�L�.�A���c�>�2�L�#�L�.�A���S�-�0�K�"�;�
�>���;��$�A�=� 
9�2�
3�2�
5�<�
Q�H�P�=�@�
?�
A�?�"B�0�2>�7�A�=�,7�9�G�8�Q�:rr�__main__)	�__doc__r~�unittestr�r�TestCaserr��mainr�rr
�<module>r�sN�����+
�	�\�b:�8�$�$�b:�J�z���H�M�M�O�r