%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.12/test/support/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.12/test/support/__pycache__/os_helper.cpython-312.pyc

�

���f�^���ddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
dZdjeej ��ZedzZej$dk(rddlZej(de�ZdZej,dk(reej.�j$d	k\rwed
zZ	ej1ej2��ede�dej2��d
��dZn0ej$dvr"	dj9ej2��	dZdD].Z	ej@ejBe��ek7re"�	eZnejF�Z$dZ%dD]#Z	ej9ej2���%ereezZ'ndZ'e'xseZ(d�Z)da*d�Z+d�Z,da-d�Z.d�Z/da0d�Z1d�Z2da3d�Z4d�Z5d�Z6d�Z7ej$jqd �rd?d!�Z9d"�Z:d#�Z;d$�Z<d%�Z=nejnZ:ej|Z;d&�Z<d'�Z=d(�Z>d)�Z?ej�d@d*��ZAej�d?d+��ZBej�dAd,��ZCd-�ZDej�d.��ZEd/�ZFGd0�d1�ZGd2�ZHeIed3�rej�d4��ZJnej�d5��ZJGd6�d7ej�j��ZM	e
j�r!ddlOZOeOj�d8d9�:�ZQd	ZRd	ZSd;ZTd<ZUneV�	ej�d=��ZWy#e$rY���wxYw#e$r(edj9ej2�d�zZY�� wxYw#e"$rY��(wxYw#e$rY	ej9ej2�ejL��n
#e$rYY��&wxYwejBe�ezZ%Y��wxYw#eXeVf$rd>�ZWYywxYw)B�N)�supportz@testz	{}_{}_tmpu-àòɘŁğ�darwin�NFD�nt�u-共Ł♡ͣ�zWARNING: The filename z, CAN be encoded by the filesystem encoding (z.). Unicode filename tests may not be effective>�wasir�
emscripten��s-��surrogateescape�)�æuİuŁuφuКuאu،uتuก� u€)s�w�r
s���s�s��c���ttd�}	|j�|j�t	t�S#|j�t	t�wxYw)z`
    Create an invalid file descriptor by opening and closing a file and return
    its fd.
    �wb)�open�TESTFN�fileno�close�unlink��files �-/usr/lib/python3.12/test/support/os_helper.py�make_bad_fdr�sB��
����D���{�{�}��
�
���v���	
�
�
���v��s�A�!A"c��t�tStjjt�}|dz}	tj
||�d}tj|�|a|S#tttf$rd}Y|a|SwxYw)N�can_symlinkTF)
�_can_symlink�os�path�abspathr�symlink�remove�OSError�NotImplementedError�AttributeError)�src�symlink_path�cans   rrr�s�������
�'�'�/�/�&�
!�C���&�L� �
�
�
�3��%���	�	�	�,���L��J��
�(�.�9�����L��J��s�A'�'B�Bc�X�t�}d}|r|Stj|�|�S)z8Skip decorator for tests that require functional symlinkz*Requires functional symlink implementation)r�unittest�skip��test�ok�msgs   r�skip_unless_symlinkr/�s,��	��B�
6�C��4�3�-�8�=�=��-�d�3�3�c���ddl}t�tSttd�sd}|a|Sddl}|j�}|j
|��\}}	ttd�5}	tj|dd�tj|dd	�tj|j�dd�|j�}tjd
|�}|duxst|jd��dk\}ddd�t#t�t#|�t%|�a|S#t $rd}Y�>wxYw#1swY�CxYw#t#t�t#|�t%|�wxYw)
Nr�setxattrF��dirrs	user.testr0strusted.foos42z
2.6.(\d{1,2})��')�tempfile�
_can_xattr�hasattrr�platform�mkdtemp�mkstemprrr2r�release�re�match�int�groupr"r�rmdir)	r7r'r:�tmp_dir�tmp_fp�tmp_name�fp�kernel_version�ms	         r�	can_xattrrI�sI��������2�z�"���.�J��J�-	��"�"�$��#�+�+��+�8����	��f�d�#�
 �r� ��K�K���c�:��K�K��.�%�@��K�K��	�	��\�3�?�%-�%5�%5�%7�N����!1�>�B�A��t�)�<�s�1�7�7�1�:��"�'<�C�
 �
�6�N��8���'�N��J��J��� ��C� ��
 �
 ��
�6�N��8���'�N�sC�E
�!E�#BD0�?E
�0D>�;E�=D>�>E�E
�E
�
'E4c�X�t�}d}|r|Stj|�|�S)zDSkip decorator for tests that require functional extended attributesz(no non-broken extended attribute support)rIr)r*r+s   r�skip_unless_xattrrK�s,��	��B�
4�C��4�3�-�8�=�=��-�d�3�3r0c�`�t�tSttd�sdatS	ttd�5}	tj
td�tjt�j}tj
td�tjt�j}t
j|�t
j|�k7}ddd�tt�a|S#t$r}d}Yd}~�+d}~wwxYw#1swY�4xYw#tt�wxYw)N�chmodFrimi�)�
_can_chmodr9rrrrM�stat�st_mode�S_IMODEr"r)�f�mode1�mode2r'�es     r�	can_chmodrV�s��������2�w���
����
�&�$�
�		A�1�
A������'������/�/�������'������/�/���l�l�5�)�T�\�\�%�-@�@��		A�	�v���J��J���
����
��
		A�		A��	�v��sL�D�D�A:C8�2+D�D�8	D
�D�D�D
�
D�D�D�D-c�X�t�}d}|r|Stj|�|�S)z`Skip tests that require working os.chmod()

    WASI SDK 15.0 cannot change file mode bits.
    zrequires working os.chmod())rVr)r*r+s   r�skip_unless_working_chmodrXs.��

��B�
'�C��4�3�-�8�=�=��-�d�3�3r0c�"�t�sdat�tS	ttd�5}t	j
td�	ttd�5	ddd�daddd�	t	j
td�tt�tS#1swY�CxYw#t$rdaY�QwxYw#1swY�VxYw#t$rY�IwxYw#	t	j
td�n#t$rYnwxYwtt�wxYw)NFr�Ti�)rV�_can_dac_overriderrrrMr"r)rRs r�can_dac_overrider\s����;�!���$� � ��
�&�$�
�	)�1��H�H�V�U�#�
)��&�$�'����
%)�!�	)�	��H�H�V�U�#�	�v��������
*�$)�!�
*��	)�	)���	��	��	��H�H�V�U�#���	��	���v��s��C�B7�B&�B�B&� B7�"C�+C�B#	�B&�&B4�1B7�3B4�4B7�7C�<C�	C�C�D�C/�.D�/	C;�8D�:C;�;Dc�Z�t�}d}|r|Stj|�|�S)Nz"incompatible with CAP_DAC_OVERRIDE�r\r)r*r+s   r�skip_if_dac_overrider_:s0��
�
�	�B�
.�C��4�3�-�8�=�=��-�d�3�3r0c�X�t�}d}|r|Stj|�|�S)Nzrequires CAP_DAC_OVERRIDEr^r+s   r�skip_unless_dac_overridera@s-��	�	�B�
%�C��4�3�-�8�=�=��-�d�3�3r0c�F�	t|�y#ttf$rYywxYw�N)�_unlink�FileNotFoundError�NotADirectoryError��filenames rrrFs'��
������1�2�
��
�s�� � �winc�8�||�|r|}n(tjj|�\}}|xsd}d}|dkr?tj|�}|r|sy|vsyt	j
|�|dz}|dkr�?t
jd|ztd��y)N�.g����MbP?g�?rz)tests may fail, delete still pending for ���
stacklevel)	rr�split�listdir�time�sleep�warnings�warn�RuntimeWarning)�func�pathname�waitall�dirname�name�timeout�Ls       r�_waitforr}Ns����X����G��G�G�M�M�(�3�M�G�T��n��G�����m��
�
�7�#�A� �A��'+�a�i���J�J�w���q�L�G���m�	�
�
�A�H�L�$��	4r0c�8�ttj|�yrc)r}rrrgs rrdrdos������H�%r0c�8�ttj|�yrc)r}rrB�rys r�_rmdirr�rs������7�#r0c�Z���ddlm���fd��t�|d��t�fd�|�y)Nr��
_force_runc�����|tj|�D]�}tjj||�}	tj|�j
}tj|�r't�|d���|tj|���|tj|���y#t$r-}td|�d|��tj��d}Yd}~��d}~wwxYw)Nzsupport.rmtree(): os.lstat(z) failed with rrT�rx)rrpr�join�lstatrPr"�print�sys�
__stderr__rO�S_ISDIRr}rBr)rrz�fullname�mode�excr��
_rmtree_inners     ��rr�z_rmtree.<locals>._rmtree_innerxs����"�4����T�:�

>���7�7�<�<��d�3����8�8�H�-�5�5�D��<�<��%��]�H�d�C��x����8�<��x����H�=�

>�����%�s�,�"�~�~�/��D��	�s�B4�4	C*�=#C%�%C*Tr�c�4���|tj|�Src)rrB)�pr�s �r�<lambda>z_rmtree.<locals>.<lambda>�s���:�a����1�5�r0)�test.supportr�r})rr�r�s @@r�_rmtreer�us$���+�	>�	���d�3��5�t�<r0c���	ddl}|jt|�dz�}|jjj||t|��}|r|d|S|S#t$rY|SwxYw)Nrr)�ctypes�create_unicode_buffer�len�windll�kernel32�GetLongPathNameW�ImportError)rr��buffer�lengths    r�	_longpathr��s{��
	'��
2�V�1�1�#�d�)�a�-�@�F��]�]�+�+�<�<�T�6�=@��[�J�F���g�v��&�����	����	�s�A�	A*�)A*c���ddl}	|j|�y#t$rYnwxYw�fd���|�tj|�y)Nrc���ddlm}||tj|�D]�}tjj||�}	tj|�j}tj|�r!�|�||tj|��y||tj|���y#t$rd}Y�^wxYw)Nrr�)
r�r�rrprr�r�rPr"rOr�rBr)rr�rzr�r�r�s     �rr�z_rmtree.<locals>._rmtree_inner�s����/�"�4����T�:�

:���7�7�<�<��d�3����8�8�H�-�5�5�D��<�<��%�!�(�+��t�R�X�X�x�8��t�R�Y�Y��9�

:�����D��s�B4�4C�C)�shutil�rmtreer"rrB)rr�r�s  @rr�r��sF����	��M�M�$�����	��	��	:�	�d��
����s��	%�%c��|Src��rs rr�r������r0c�:�	t|�y#t$rYywxYwrc)r�rer�s rrBrB�s ��
��w����
��
����	�c�:�	t|�y#t$rYywxYwrc)r�rer�s rr�r��s ��
���
���
��
�r�c#�K�ddl}d}|�2|j�}d}tjj	|�}n	tj
|�d}|rtj�}	|��|r$tj�k(rt|�yyy#t$r/}|s�tjd|�d|��td��Yd}~�ud}~wwxYw#|r$tj�k(rt|�wwwxYw�w)	a�Return a context manager that creates a temporary directory.

    Arguments:

      path: the directory to create temporarily.  If omitted or None,
        defaults to creating a temporary directory using tempfile.mkdtemp.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, if the path is specified and cannot be
        created, only a warning is issued.

    rNFTz5tests may fail, unable to create temporary directory �: �rm)r7r;rr�realpath�mkdirr"rsrtru�getpidr�)r�quietr7�dir_createdr��pids      r�temp_dirr��s�������K��|����!�����w�w����%��	8��H�H�T�N��K���i�i�k����
��3�"�)�)�+�-��4�L�.�;���	8����M�M�1�15���3�%�A�(�Q�
8�
8��	8���3�"�)�)�+�-��4�L�.�;�sF�;C=�B�C=�,C�0'C=�	C� %C
�C=�
C�C=�(C:�:C=c#�K�tj�}	tjtjj	|��	tj���tj|�y#t
$r/}|s�t
jd|�d|��td��Yd}~�`d}~wwxYw#tj|�wxYw�w)agReturn a context manager that changes the current working directory.

    Arguments:

      path: the directory to use as the temporary current working directory.

      quiet: if False (the default), the context manager raises an exception
        on error.  Otherwise, it issues only a warning and keeps the current
        working directory the same.

    zBtests may fail, unable to change the current working directory to r�r�rmN)	r�getcwd�chdirrr�r"rsrtru)rr��	saved_dirr�s    r�
change_cwdr��s������	�	��I�4�
������!�!�$�'�(���i�i�k��
�������4����
�
�&�&*�X�R��u�6�$��	4�	4��4��	�����s@�C�2A7�B2�!C�7	B/�%B*�%C�*B/�/C�2C	�	Cc#�K�t||��5}t||��5}|��ddd�ddd�y#1swY�xYw#1swYyxYw�w)a�
    Context manager that temporarily creates and changes the CWD.

    The function temporarily changes the current working directory
    after creating a temporary directory in the current directory with
    name *name*.  If *name* is None, the temporary directory is
    created using tempfile.mkdtemp.

    If *quiet* is False (default) and it is not possible to
    create or change the CWD, an error is raised.  If *quiet* is True,
    only a warning is raised and the original CWD is used.

    )rr�)r�N)r�r�)rzr��	temp_path�cwd_dirs    r�temp_cwdr�
sS����
�t�5�	)��Y�
�	��
/�	�7��M�	���	�	����s-�A�A�4�A�	A�=	�A�A	�Ac��tj|tjtjztjz�}tj
|�y)z>Create an empty file. If the file already exists, truncate it.N)rr�O_WRONLY�O_CREAT�O_TRUNCr)rh�fds  r�create_empty_filer�s3��	����2�;�;����3�b�j�j�@�	A�B��H�H�R�Lr0c#�HK�tjj|�sJ�tj}t	td�r|tj
z}tj||�}	|��tj|�y#tj|�wxYw�w)z&Open a file descriptor to a directory.�O_DIRECTORYN)rr�isdir�O_RDONLYr9r�rr)r�flags�dir_fds   r�open_dir_fdr�$sq�����7�7�=�=������K�K�E��r�=�!�
������
�W�W�T�5�
!�F����
�����������s�A+B"�.B�2B"�B�B"c�,�ddl}|j|��5}|j}|j�}||k(r|j	�}	t
jj||�cddd�S#t$rYddd�ywxYw#1swYyxYw)zODetects if the file system for the specified directory
    is case-insensitive.rNr3F)	r7�NamedTemporaryFilerz�upper�lowerrr�samefilere)�	directoryr7�base�	base_path�	case_paths     r�fs_is_case_insensitiver�2s����	�	$�	$��	$�	3��t��I�I�	��O�O�%�	��	�!�!���)�I�	��7�7�#�#�I�y�9�
���!�	����	����s)�2B
�
A3�3	B�<B
�B�B
�
Bc�"�eZdZdZd�Zd�Zd�Zy)�FakePathz0Simple implementation of the path protocol.
    c��||_yrcr�)�selfrs  r�__init__zFakePath.__init__Ds	����	r0c�"�d|j�d�S)Nz
<FakePath �>r��r�s r�__repr__zFakePath.__repr__Gs���D�I�I�=��*�*r0c���t|jt�s4t|jt�r&t	|jt�r|j�|jSrc)�
isinstancer�
BaseException�type�
issubclassr�s r�
__fspath__zFakePath.__fspath__Js?���t�y�y�-�0��t�y�y�$�'��4�9�9�m�4��)�)�O��9�9�r0N)�__name__�
__module__�__qualname__�__doc__r�r�r�r�r0rr�r�As����+�r0r�c�D�tjjd�rd}ntjdk(rd}nd}|�$	tj|�}t|�dz
Sd}ttd�r	tjd	�}d}tjd
k(rQ	ddl
}|ji}|j|j|jfD]}|j|d�||<�		d}t#|�D]2}	tj$|�}tj&|�|dz
}�4	|�=j|j|jfD]}|j|||��|S#t$rY��wxYw#t$rY��wxYw#tt f$rY��wxYw#t$r(}	|	j(t(j*k7r�Yd}	~	��d}	~	wwxYw#|�>j|j|jfD]}|j|||��wwxYw)z/Count the number of open file descriptors.
    )�linux�freebsdr	z
/proc/self/fdrz/dev/fdNr5rZ�sysconf�SC_OPEN_MAX�win32r)r�r:�
startswithrrpr�rer9r�r"�msvcrt�CrtSetReportMode�CRT_WARN�	CRT_ERROR�
CRT_ASSERTr$r��range�dupr�errno�EBADF)
�fd_path�names�MAXFD�	old_modesr��report_type�countr��fd2rUs
          r�fd_countrSsH���|�|���A�B�!��	����	!�������	��J�J�w�'�E��u�:��>�!�
�E��r�9��	��J�J�}�-�E��I�
�|�|�w��	D���#�#�
�I� &��� &� 0� 0� &� 1� 1� 3�
D��*0�)@�)@��AB�*D�	�+�&�
D�M�����,�
	�B�	
��f�f�R�j��
����
���
��
	�� � &��� &� 0� 0� &� 1� 1� 3�
M���'�'��Y�{�5K�L�
M�
�L��a!�	��	���	��	����,�	��	��$�
��7�7�e�k�k�)��*��
��� � &��� &� 0� 0� &� 1� 1� 3�
M���'�'��Y�{�5K�L�
M�!�sl�"E4�4F�F�0G�F)�G�4	F�F�	F�F�F&�%F&�)	G�2G�G�G�G�AH�umaskc#�K�tj|�}	d��tj|�y#tj|�wxYw�w)z8Context manager that temporarily sets the process umask.N)rr)r�oldmasks  r�
temp_umaskr�s5�����(�(�5�/��	���H�H�W���B�H�H�W��s�A
�3�A
�A
�
A
c#�K�d��y�w)z"no-op on platforms without umask()Nr�)rs rrr�s����	�s�c�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�EnvironmentVarGuardz_Class to help protect the environment variable properly.  Can be used as
    a context manager.c�<�tj|_i|_yrc)r�environ�_environ�_changedr�s rr�zEnvironmentVarGuard.__init__�s���
�
��
���
r0c� �|j|Src)r
�r��envvars  r�__getitem__zEnvironmentVarGuard.__getitem__�s���}�}�V�$�$r0c��||jvr(|jj|�|j|<||j|<yrc�rr
�get�r�r�values   r�__setitem__zEnvironmentVarGuard.__setitem__�s9������&�$(�M�M�$5�$5�f�$=�D�M�M�&�!� %��
�
�f�r0c��||jvr(|jj|�|j|<||jvr|j|=yyrcrr
s  r�__delitem__zEnvironmentVarGuard.__delitem__�sH������&�$(�M�M�$5�$5�f�$=�D�M�M�&�!��T�]�]�"��
�
�f�%�#r0c�6�|jj�Src)r
�keysr�s rrzEnvironmentVarGuard.keys�s���}�}�!�!�#�#r0c�,�t|j�Src)�iterr
r�s r�__iter__zEnvironmentVarGuard.__iter__�s���D�M�M�"�"r0c�,�t|j�Src)r�r
r�s r�__len__zEnvironmentVarGuard.__len__�s���4�=�=�!�!r0c��|||<yrcr�rs   r�setzEnvironmentVarGuard.set�s����V�r0c�
�||=yrcr�r
s  r�unsetzEnvironmentVarGuard.unset�s	����Lr0c��t|�Src)�dictr�s r�copyzEnvironmentVarGuard.copy�s���D�z�r0c��|Srcr�r�s r�	__enter__zEnvironmentVarGuard.__enter__�r�r0c���|jj�D]3\}}|�||jvs�|j|=�%||j|<�5|jt_yrc)r�itemsr
rr	)r��
ignore_exc�k�vs    r�__exit__zEnvironmentVarGuard.__exit__�sZ���m�m�)�)�+�	%�F�Q���y���
�
�%��
�
�a�(�#$��
�
�a� �	%��]�]��
r0N)r�r�r�r�r�rrrrrrr r"r%r'r-r�r0rrr�sC����%�&�&�$�#�"�����#r0rr�T)�use_last_errorrl�c#�K�ttj�D]<}|�d�}tj	|dd�r� tj�tk(s�<ntjd��tjt||�s'tjtj���	|��tjttz||�s'tjtj���y#tjttz||�s'tjtj���wxYw�w)z6Temporarily yield a substitute drive for a given path.�:Nrzno available logical drive)�reversed�string�ascii_uppercaser��QueryDosDeviceWr��get_last_error�ERROR_FILE_NOT_FOUNDr)�SkipTest�DefineDosDeviceW�DDD_NO_BROADCAST_SYSTEM�WinError�DDD_REMOVE_DEFINITION�DDD_EXACT_MATCH_ON_REMOVE)r�c�drives   r�subst_driver@�s�����&�0�0�1�	B�A��c��G�E��,�,�U�D�!�<��)�)�+�/C�C��		B��#�#�$@�A�A��(�(�'���6��/�/�&�"7�"7�"9�:�:�	?��K��,�,�)�,E�E��4�!��o�o�f�&;�&;�&=�>�>�!��8�,�,�)�,E�E��4�!��o�o�f�&;�&;�&=�>�>�!�s+�9E�E�AE�3D�7A
E�AE�Ec�,�tjd��)Nz#ctypes or kernel32 is not available)r)r8r�s rr@r@�s����� E�F�Fr0)F)NF)�tempcwdF)Y�collections.abc�collections�
contextlibr�rr>rOr3r�rqr)rsr,r�TESTFN_ASCII�formatr��TESTFN_UNICODEr:�unicodedata�	normalize�TESTFN_UNENCODABLErz�getwindowsversion�encode�getfilesystemencodingr��UnicodeEncodeError�decode�UnicodeDecodeError�FS_NONASCII�	character�fsdecode�fsencode�UnicodeErrorr��SAVEDCWD�TESTFN_UNDECODABLE�getfilesystemencodeerrors�TESTFN_NONASCIIrrrrr/r8rIrKrNrVrXr[r\r_rarr�r}rdr�r�r�rBr��contextmanagerr�r�r�r�r�r�r�rr9r�abc�MutableMappingr�
MS_WINDOWSr��WinDLLr�r7r<r=r:r$r@r�r�r0r�<module>r`s������	�	��
�
��������!�!�,�	��	�	��<��� =�=���<�<�8���*�[�*�*�5�.�A�N�
���7�7�d�?��s����'�'�1�,�*�,M�M��	&��%�%�&?�c�&?�&?�&A�B�
�'�)B��)B�)B�)D�F�
G�"&���\�\�9�9�

����0�s�0�0�2�3�	
��� �+�I�B
��2�;�;�{�r�{�{�9�-�.�)�;���<�
 ��
�W+�\�2�9�9�;����
��D�"	����-�C�-�-�/�0�%�8�"�[�0�O��O�	�	(�L��
����(4��
��B4��
��04����84�4�
��<�<���5�!�4�B&�$�=�*��i�i�G�
�X�X�F��0�
�
����%��%�P������6������&����
��
����$@�F�2�w��������������
6#�+�/�/�8�8�6#�r"?����� �6�=�=��D�A�� �� !��$%�!�"#����	 ����?��?��G"�	��	���N�)��o�o�7�c�7�7�9�;L�M�N��N��f�
��
��F��	��K�K�1��1�1�3�5��5�5�7�
9��!�	��	��(�R�[�[��6��=��
���x	�^�$�G�G�G�s~�6 L� L�/'M�5 M�/N8�L�L�)M�M�M�M�N5�0N�
N5�N�N5�N�N5�4N5�8
O�O

Zerion Mini Shell 1.0