403Webshell
Server IP : 121.121.20.254  /  Your IP : 216.73.216.202
Web Server : Microsoft-IIS/10.0
System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64
User : IUSR ( 0)
PHP Version : 8.3.28
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  C:/Python313/Lib/test/test_import/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : C:/Python313/Lib/test/test_import/__pycache__/__init__.cpython-313.pyc
�

��i����SSKrSSKrSSKrSSKrSSKrSSKJr SSKJ	r	J
r
JrJrJ
r
 SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr SSKrSSKJr SSKJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r, SSK-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5 SSK6J7r7J8r8J9r9J:r: SS	KJ;r; SS
KJ<r< SSK=J>r> SSK?J@r@ SS
KJArA SSKBrBSSKDrDSSKErESSKGrG\R�"\R�S5rJSrKSS.SjrLSS.SjrMSS.SjrNSS.SjrOSrPSS.SjrQSrRSrS\Bb\BS.SjrTSrUSrV"S S!\R�5rX\+"S"S#\R�\>55rZ\J"S$S%\R�55r["S&S'\R�5r\"S(S)\R�\>5r]"S*S+\R�\>5r^"S,S-\R�5r_"S.S/\R�5r`"S0S1\R�5ra\""S2S3\R�\>55rb\""S4S5\R�55rc"S6S7\R�5rd"S8S9\R�5re"S:S;\R�5rf"S<S=\X5rg\U"S>S?\R�\>55rh\iS@:Xa\R�"5 gg!\Ca SrBGN�f=f!\Ca SrDGN�f=f!\Fa SrEGNf=f!\Ca SrGGNf=f)A�N)�_get_sourcefile)�AppleFrameworkLoader�BuiltinImporter�ExtensionFileLoader�FrozenImporter�SourceFileLoader)�mock)�	os_helper)�
STDLIB_DIR�	swap_attr�	swap_item�cpython_only�is_apple_mobile�
is_emscripten�is_wasi�run_in_subinterp�run_in_subinterp_with_config�
Py_TRACE_REFS�requires_gil_enabled�Py_GIL_DISABLED�force_not_colorized_test_class�catch_unraisable_exception)�forget�make_legacy_pyc�unlink�unload�ready_to_import�
DirsOnSysPath�CleanImport�
import_module)�TESTFN�rmtree�
temp_umask�TESTFN_UNENCODABLE)�
script_helper)�threading_helper)�ExtraAssertions)�uncache)�
ModuleTypez*test meaningful only when writing bytecodec
��[U[5(a[U5n[S[S[
S[S[S0nUn[U[5(dU5eX4nURRn[U[5(d[U5nX5nXT:wa:SUSUR3nU(a[R"U5e[U5eU$)N�built-in�	extensionzframework extension�frozenzpure Pythonzexpected module to be z, got )�
isinstance�str�
__import__rrrrr�type�__spec__�loader�unittest�SkipTest�	Exception)�moduler3�skip�MODULE_KINDS�expected�actual�errs       �.C:\Python313\\Lib\test\test_import\__init__.py�_require_loaderr>Ps����&�#����F�#��	���[��3����-��L��H��h��%�%�/�x�/�%��%�H�
�_�_�
#�
#�F��f�d�#�#��f���
�
!�F�
��&�x�j��v���6G�H����#�#�C�(�(���n���M�F�r8c�|�[U[U5nURRS:XdUR5eg)Nr+)r>rr2�origin�r7r8s  r=�require_builtinrDls1��
�V�_�d�
;�F��?�?�!�!�Z�/�@����@�/r?c�`�[(a[U[U5 g[U[U5 g�N)rr>rrrCs  r=�require_extensionrGps#������ 4�d�;��� 3�T�:r?Tc�|�[U[U5nURRS:XdUR5eg)Nr-)r>rr2rBrCs  r=�require_frozenrIxs1��
�V�^�T�
:�F��?�?�!�!�X�-�>�v���>�-r?c�&�[U[U5 grF)r>rrCs  r=�require_pure_pythonrK|s���F�,�d�3r?c�D�[(a[X5$[X5$rF)rrr)�modname�filenames  r=�create_extension_loaderrOs����#�G�6�6�"�7�5�5r?��put_in_sys_modulesc���[X5n[RRX5n[RR	U5nURU5 U(aU[RU'U$rF)rO�	importlib�util�spec_from_loader�module_from_spec�exec_module�sys�modules)rMrNrQr3�specr7s      r=�import_extension_from_filer[�sX��
$�W�
7�F��>�>�*�*�7�;�D�
�^�^�
,�
,�T�
2�F�
���v���%����G���Mr?c�b�US-US-US-US-4Hn[U5 M [S5 g)N�.py�.pyc�.pywz	$py.class�__pycache__)rr")�name�fs  r=�remove_filesrc�s>���U�l��V�m��V�m��[� �"��	�q�	�	"�
�=�r?c�^�U4SjnU$)z�Skip rerunning for a particular test.

WARNING: Use this decorator with care; skipping rerunning makes it
impossible to find reference leaks. Provide a clear reason for skipping the
test using the 'reason' parameter.
c� >^^�SmUUU4SjnU$)NFc�J>�T(aURT5 T"U5 Smg)NT)�skipTest)�self�_has_run�func�reasons ���r=�wrapper�'no_rerun.<locals>.deco.<locals>.wrapper�s�����
�
�f�%���J��Hr?�)rjrlrirks` @�r=�deco�no_rerun.<locals>.deco�s�����	��r?rn)rkros` r=�no_rerunrq�s�����Kr?)�_origc���[RRSS5 UR5 URR
n[R"SU5 SSKng)N�_testsinglephaser)	rXrY�pop�_clear_globalsr2rB�_testinternalcapi�clear_extensionrt)rrrBrts   r=�restore__testsinglephasery�sF��	�����*�D�1�
�������&�&���)�)�*<�f�E�r?c��[U[5(dU4Sjn[U5nSn[U5"U5n[R
"[SLS5"U5$)zADecorator to skip if single-phase init modules are not supported.c�F�U"U5[5 $![5 f=frF)ry)rh�_meths  r=�meth�'requires_singlephase_init.<locals>.meth�s��
+��T�{�(�*��(�*�s�� zggh-117694: free-threaded build does not currently support single-phase init modules in sub-interpretersN�%test requires _testsinglephase module)r.r1rrr4�skipIfrt)r}�msgs  r=�requires_singlephase_initr��s^���d�D�!�!�!�	+�
���D�
s�C���$�T�*�D��?�?�+�t�3�B�D�DH�J�Jr?c�H�[R"[SLS5"U5$)z>Decorator to skip a test if subinterpreters are not supported.Nzsubinterpreters required)r4r��
_interpreters)r}s r=�requires_subinterpretersr��s%���?�?�=�D�0�5�7�7;�=�=r?c��\rSrSrSr\"SR
55r\S5r	\
R"S5r\
R"S5R5r\
R"S5R5r\
R"S5R5r\S	S
S	S
S.Sj5r\S
5r\SS	S.Sjj5r\S5rSrg	)�ModuleSnapshot��aA representation of a module for testing.

Fields:

* id - the module's object ID
* module - the actual module or an adequate substitute
   * __file__
   * __spec__
      * name
      * origin
* ns - a copy (dict) of the module's __dict__ (or None)
* ns_id - the object ID of the module's __dict__
* cached - the sys.modules[mod.__spec__.name] entry (or None)
* cached_id - the object ID of the sys.modules entry (or None)

In cases where the value is not available (e.g. due to serialization),
the value will be None.
z#id module ns ns_id cached cached_idc
��URRn[RR	U5nU"[U5U[R"S0URD6[UR5U[U5S9$)N)�idr7�ns�ns_id�cached�	cached_idrn)	r2rarXrY�getr��types�SimpleNamespace�__dict__)�cls�modrar�s    r=�from_module�ModuleSnapshot.from_module�se���|�|� � ��������&����#�w���$�$�4�s�|�|�4��S�\�\�"����j�

�	
r?z�
        {imports}

        name = {name!r}

        {prescript}

        mod = {name}

        {body}

        {postscript}
        z
        import sys
        a�
        # Capture the snapshot data.
        cached = sys.modules.get(name)
        snapshot = dict(
            id=id(mod),
            module=dict(
                __file__=mod.__file__,
                __spec__=dict(
                    name=mod.__spec__.name,
                    origin=mod.__spec__.origin,
                ),
            ),
            ns=None,
            ns_id=id(mod.__dict__),
            cached=None,
            cached_id=id(cached) if cached else None,
        )
        zL
        # Clean up the module.
        sys.modules.pop(name, None)
        NF)�	prescript�import_first�
postscript�postcleanupc���USLa
URnO\[U[5(aE[R"U5R5nUR[R-U-nOSnU(a$[R"U5R5OSnU(a$[R"U5R5OSnU(a#U(aU[RS--U-nOUnU(aU[R"SU35-
nURRURR5UUR5URR5US9$)NT��zq

                # Now import the module.
                assert name not in sys.modules
                import )�importsrar��bodyr�)�CLEANUP_SCRIPTr.r/�textwrap�dedent�strip�os�linesep�SCRIPT�format�IMPORTS�SCRIPT_BODY)r�rar�r�r�r�s      r=�build_script�ModuleSnapshot.build_scripts(���$���,�,�K�
��S�
)�
)�"�/�/�+�6�<�<�>�K��,�,�r�z�z�9�K�G�K��K�:C�H�O�O�I�.�4�4�6��	�<F�X�_�_�Z�0�6�6�8�B�
���'�"�*�*�q�.�8�;�F�
�(�
������.��v�	*!�"�
"�I��z�z� � ��K�K�%�%�'���o�o�'����&�&�(�!�!�
�	
r?c��[R"U5nUSn[R"S0USD6US'[R"S0UD6US'U"S0UD6$)Nr7r2rn)�json�loadsr�r�)r��text�rawr�s    r=�parse�ModuleSnapshot.parse<sW���j�j�����(�m���/�/�B�#�j�/�B��J���-�-�4��4��H�
��z�S�z�r?)�pipec�F�UbURXX45$[R"5nURXX45UupV[R"U5 [R"U5 $!UupV[R"U5 [R"U5 f=frF)�_from_subinterpr�r��close)r�ra�interpidr��script_kwds�r�ws       r=�from_subinterp�ModuleSnapshot.from_subinterpDsy�����&�&�t�t�I�I��w�w�y��	��&�&�t�t�I��D�A��H�H�Q�K��H�H�Q�K���D�A��H�H�Q�K��H�H�Q�K�s�A.�.2B c���UupV[R"SUS35nURS5nU(a([R"U5R5nXx-
nUR	5US'UR
"U40UD6n	Uc [
U	5n
U
S:wa[U
S35eO[R"X)5 [R"US5nURUR55$)Nzq
            # Send the result over the pipe.
            import json
            import os
            os.write(z., json.dumps(snapshot).encode())

            r�rz != 0��)r�r�r��lstripr�r�r�AssertionErrorr��
run_stringr��readr��decode)r�rar�r��
script_kwargsr�r�r��_postscript�script�retr�s            r=r��ModuleSnapshot._from_subinterpPs�������_�_�*��S�
�	&��
�$�'�'��5���"�/�/�+�6�=�=�?�K��%�J�&0�&6�&6�&8�
�l�#��!�!�$�8�-�8����"�6�*�C��a�x�$��u�E�]�3�3��
�$�$�X�6��w�w�q�$����y�y�����'�'r?rnrF)�__name__�
__module__�__qualname__�__firstlineno__�__doc__�tuple�split�_fields�classmethodr�r�r�r�r�r�r�r�r�r�r�r��__static_attributes__rnr?r=r�r��s	���$�9�?�?�A�B�G��

��

��_�_��
�F��o�o��
�
�U�W���/�/�#�
�"�U�W�#�$�_�_�&�
��U�W��
�#�"'� $�!&�	#
��#
�J�����	��	��	��(��(r?r�c��\rSrSrSrSrSrSrSrSr	\
S5rS	rS
r
SrSrS
rSrS4SjrSrSrSrSr\S5rSrSr\S5rSr\
S5rSrSrSr \
S5r!\"RF"5S5r$\%RL"\'RPS:HS 5S!5r)S"r*S#r+S$r,S%r-S&r.S'r/S(r0S)r1\%Rd"\'RPS:HS*5\%Rd"\'RPS+:HS,5\%Rd"\'RPRgS-5S.5S/555r4S0r5S1r6S2r7g3)5�ImportTestsipc�L�[[5 [R"5 grF)rcr!rS�invalidate_caches�rhs r=�setUp�ImportTests.setUpss���V���#�#�%r?c�"�[[5 grF)rr!r�s r=�tearDown�ImportTests.tearDownws	���v�r?c�j�UR[5 SSKnSSS5 g!,(df   g=f�Nr)�assertRaises�ModuleNotFoundError�(something_that_should_not_exist_anywhere�rhr�s  r=�&test_import_raises_ModuleNotFoundError�2ImportTests.test_import_raises_ModuleNotFoundErrorzs ��
�
�
�2�
3�;�4�
3�
3���$�
2c�n�UR[5 SSKJn SSS5 g!,(df   g=f)Nr)�blah)r�r�r�r�)rhr�s  r=�:test_from_import_missing_module_raises_ModuleNotFoundError�FImportTests.test_from_import_missing_module_raises_ModuleNotFoundError~s ��
�
�
�2�
3�E�4�
3�
3���&�
4c�n�UR[5 SSKJn SSS5 g!,(df   g=f)Nr)r�)r��ImportErrorrSr�r�s  r=�0test_from_import_missing_attr_raises_ImportError�<ImportTests.test_from_import_missing_attr_raises_ImportError�s��
�
�
�{�
+�J�,�
+�
+�r�c��[S5 SSKnUR[5nSSKJn SSS5 SSS5 URWRRS5 URURRWR5 UR[UR5S5 g!,(df   N�=f!,(df   N�=f)Nr�r��i_dont_existz7cannot import name 'i_dont_exist' from 'os' \(.*os.py\))rr�r�r�r��assertEqual�	exceptionra�path�__file__�assertRegexr/)rhr��cmr�s    r=�/test_from_import_missing_attr_has_name_and_path�;ImportTests.test_from_import_missing_attr_has_name_and_path�s���
��
���"�"�;�/�2�+�0��	
������*�*�D�1�������*�*�B�K�K�8�����R�\�\�*�,f�g�	0�/���
�s!�C
�B9�C
�9
C	�C
�

Cc��[S5nUR[5nSSKJn SSS5 URWRRS5 [US5(a`URURRURR5 UR[UR5S5 gUR[UR5S5 g!,(df   N�=f)N�	_testcapirr�r�zFcannot import name 'i_dont_exist' from '_testcapi' \(.*(\.(so|pyd))?\)zEcannot import name 'i_dont_exist' from '_testcapi' (unknown location))r r�r�r�r�r�r�ra�hasattrr�r2rBr�r/)rhr�r�r�s    r=�2test_from_import_missing_attr_has_name_and_so_path�>ImportTests.test_from_import_missing_attr_has_name_and_so_path�s���!�+�.�	�
�
�
�{�
+�r�.�,�������*�*�K�8��9�j�)�)�

���R�\�\�.�.�	�0B�0B�0I�0I�J�����B�L�L�!�Y�
�

����B�L�L�!�W�
�,�
+�s�C-�-
C;c��UR[5nSSKJn SSS5 UR	WR
RS5 URUR
R5 g!,(df   NZ=f)Nrr��_warning)	r�r�rr�r�r�ra�assertIsNoner��rhr�r�s   r=�&test_from_import_missing_attr_has_name�2ImportTests.test_from_import_missing_attr_has_name�sW��
�
�
�{�
+�r�-�,�	
������*�*�J�7����"�,�,�+�+�,�	,�
+�s�A1�1
A?c���UR[5nSSKJn SSS5 UR	WR
RSS15 URUR
5 g!,(df   NR=f)Nrr��	posixpath�ntpath)r�r��os.pathr��assertInr�ra�assertIsNotNoners   r=�/test_from_import_missing_attr_path_is_canonical�;ImportTests.test_from_import_missing_attr_path_is_canonical�sR��
�
�
�{�
+�r�,�,��
�
�b�l�l�'�'�+�x�)@�A����R�\�\�*�,�
+�s�A)�)
A7c��SSKn[5up#[USSS9nURS5 SSS5 0nUR	[
UR
U5S35 [SUS3U5 SSS5 URS	U5 SSS5 [5up#[USSS9nURS
5 SSS5 0nUR	[
UR
U5S35 [SUS3U5 SSS5 URS	U5 SSS5 g!,(df   N�=f!,(df   N�=f!,(df   N�=f!,(df   N�=f!,(df   Nm=f!,(df   g=f)Nrr��utf-8��encodingz__all__ = [b'invalid_type']z\.__all__ must be strzfrom z	 import *sinvalid_typez%globals()[b'invalid_type'] = object()z\.__dict__ must be str)	�rer�open�write�assertRaisesRegex�	TypeError�escape�exec�assertNotIn)rhrrar�rb�globalss      r=�"test_from_import_star_invalid_type�.ImportTests.test_from_import_star_invalid_type�sL���
�
�,�4��d�C�'�2�a����5�6�3��G��'�'��b�i�i��o�.�.D�E���u�T�F�)�,�g�6��
���_�g�6���
�,�4��d�C�'�2�a����?�@�3��G��'�'��b�i�i��o�.�.E�F���u�T�F�)�,�g�6��
���_�g�6��
�3�2�����	�
��3�2�����	�
�su�E�D$�2E�!D5�2E�E9�,E�>2E9�0E(�E9�$
D2	�.E�5
E	�?E�
E�
E%	�!E9�(
E6	�2E9�9
Fc�j�UR[5 SSKnSSS5 g!,(df   g=fr�)r�r��RAnDoM)rhrs  r=�test_case_sensitivity�!ImportTests.test_case_sensitivity�s!���
�
�{�
+��,�
+�
+�r�c�2�SSKJn [S5 SSKJn g)Nr)�double_constz"test.test_import.data.double_const)�test.test_import.datar!r)rhr!s  r=�test_double_const�ImportTests.test_double_const�s��	7��3�4�6r?c�8^�U4Sjn[RRS[R5 U"S5 [R
R
S5(aSHnU"U5 M
 [RS	g![RS	f=f)Nc�0>�[U-n[S-n[USSS9n[SUSUS9 [R"S5n[R"S5n[S	XCS9 [S
XSS9 SSS5 [[
R;a[
R[	[R"5 [[5nTRWRWS
U-5 TRURWS
U-5 [[5 [!U5 [!U5 g!,(df   N�=f![a#nTRSU<SU<35 SnAN�SnAff=f![[5 [!U5 [!U5 f=f)Nr^r�rrz)# This tests Python's ability to import azfile.��filer�za =zb =zimport from z	 failed: z'module loaded (%s) but contents invalid)r!r�print�random�	randrangerXrYrSr�r0r��failr��a�brr)	�ext�source�pycrbr-r.r�r<rhs	        �r=�test_with_extension�4ImportTests.test_import.<locals>.test_with_extension�sH����c�\�F��6�/�C��f�c�G�4���A��7��,��$�$�T�*���$�$�T�*���e�Q�'��e�Q�'�
5�����$��K�K��'��'�'�)�

�H�$�V�,�C�� � �����=��C�E�� � �����=��C�E��v���v���s��15�4��#�H��I�I�S�#�F�G�G��H���v���v���s��s=�A
D-�8D>�AE.�-
D;�>
E+�E&�!E.�&E+�+E.�.'Frr]�win)z.PYz.Pyz.pYr_z.PYWz.pYw)rXr��insertr��curdir�platform�
startswith)rhr2r/s`  r=�test_import�ImportTests.test_import�sn���	�>	������2�9�9�%�	���&��|�|�&�&�u�-�-�H�C�'��,�I������������s�=B�Bc�p�US-n[USSS9nURS5 [S5HnURS5 M URS5 SSS5 [R"U5 [U5 [RRS	5 [R"5 0n[U5 [S
U-SU5 [RS	[US-5 [US
-5 UR5 [RU	g!,(df   N�=f![U5 f=f![a gf=f![RS	[US-5 [US
-5 UR5 [RU	f![a ff=f=f)Nr]r�rrzd = [
i�z"",
�]r�zimport ����c�o)rr�range�
py_compile�compilerrXr��appendrSr�rr�clearrY�KeyError)rhr7rNrb�i�	namespaces      r=�test_module_with_large_stack�(ImportTests.test_module_with_large_stack�sl���E�>���(�C�'�
2�a�
�G�G�I���5�\������ �"�
�G�G�C�L�	3�	�
���x�(��8��	��������#�#�%��	�	��H�%���V�#�T�9�5�������8�c�>�"��8�c�>�"�
�O�O��
��K�K��'�?3�
2��
�8���*�
��
��������8�c�>�"��8�c�>�"�
�O�O��
��K�K��'���
��
�sZ�AD#� D4�8E�E�#
D1�4
E�
E�E�>F5�F%�$F5�%
F2�/F5�1F2�2F5c��[S-n[USSS9n[SUS9 SSS5 [RRS[R5 [R"5 [[R;a[R[	SHJnUR[[[5 UR[[RS	U-5 ML [RS	[[5 g!,(df   N�=f![RS	[[5 f=f)
Nr]r�rrza = 1/0r'r)�r��z'damaged module in sys.modules on %i try)r!rr)rXr�r5r�r6rSr�rYr��ZeroDivisionErrorr0rrc)rhr0rbrFs    r=�test_failing_import_sticks�&ImportTests.test_failing_import_sticks&s����%���
�&�#��
0�A��)�!�$�1�
	������2�9�9�%��#�#�%��S�[�[� ����F�#�	!����!�!�"3�Z��H�� � �����!J�Q�!N�P��
������� �!1�
0��������� �s�D
�AD�

D�"D=c���SSKnSSKnURXUR5 UR	UR
S5 SSKJn URX2R
UR5 g)Nrr�)�test�test.support�assertIsr��
assertHasAttr�support)rh�xrQ�ys    r=�test_import_name_binding�$ImportTests.test_import_name_binding:sI�����
�
�a�q�z�z�*����4�<�<��4�	!��
�
�a���q�z�z�2r?c��SnSSKJs Jn SnUS:aSSKJs Jn US-
nUS:aM[S5HnSSKJs Jn M g!SSKJs Jn f=f)N.r�
rKr�)�test.support.script_helperrUr%r@)rhrVrFs   r=�test_issue31286�ImportTests.test_issue31286EsX��	3��A�2�2�
���"�f�2�2�
��F�A��"�f�
�q��A�2�2���
3�2�s�A�Ac�V�[[R-S-n[USSS9nUR	S5 SSS5 [
RRS[R5 [[5nUR[[
R5 URURSS5 URURS	S5 [[5 [USSS9nUR	S
5 SSS5 UR!["[$R&U5 [
RR)[5nUR+US5 URURSS5 URURS	S5 [
RS	[[5 [-[5 g!,(df   GN�=f!,(df   N�=f![
RS	[[5 [-[5 f=f)
N�pyr�rrz
a = 1
b=2
rrKz!module has wrong attribute valuesr�za = 10
b=20//0
z$expected module to be in sys.modulesr[)r!r��extseprrrXr�r5r6r0r	rYr�r-r.rcr�rMrS�reloadr�r
r)rhr0rbr�s    r=�test_failing_reload�ImportTests.test_failing_reloadVs����"�)�)�#�d�*��
�&�#��
0�A�
�G�G�N�#�1�	������2�9�9�%�	��V�$�C��M�M�&�#�+�+�.����S�U�U�A�'J�K����S�U�U�A�'J�K�
�� ��f�c�G�4�����+�,�5�
���/��1A�1A�3�G��+�+�/�/�&�)�C�� � ��&L�M�
���S�U�U�B�(K�L����S�U�U�A�'J�K�������� ��6�N�C1�
0��"5�4��������� ��6�N�s1�G�/BG7�6G&�BG7�
G#�&
G4�0G7�71H(c��[S-n[USSS9nURS5 SSS5 [RRS[R5 [[5nURURS5 [R"U5 [R[	[U5 [R"5 [[5n[RR!UR5upEUR#US5 [RS	[%[5 [[R;a[R[	gg!,(df   GNO=f![RS	[%[5 [[R;a[R[	ff=f)Nr]r�rrztest = None
rr^)r!rrrXr�r5r�r6r0�assertEndsWithr��removerYrrSr��splitextr�rc)rhr0rbr��baser/s      r=�test_file_to_source�ImportTests.test_file_to_source|s3���%���
�&�#��
0�A�
�G�G�O�$�1�	������2�9�9�%�	(��V�$�C�������e�4��I�I�f�����F�#��F�#��'�'�)��V�$�C����(�(����6�I�D����S�&�)�������� �����$��K�K��'�%�#1�
0��������� �����$��K�K��'�%�s�E/�CF�/
E>�AGc�l�[RR[5n[R
"5nUR
U5 UR[5n[U5 SSS5 g![a# URSRU55 NVf=f!,(df   g=f)Nzpath is not encodable to {})
r�r��abspathr!rX�getfilesystemencoding�encode�UnicodeEncodeErrorrgr�r�r�r0)rhr�rr>s    r=�test_import_by_filename�#ImportTests.test_import_by_filename�s����w�w���v�&���,�,�.��	J��K�K��!��
�
�{�
+�q��t��,�
+��"�	J��M�M�7�>�>�x�H�I�	J��
+�
+�s�A5� B%�5*B"�!B"�%
B3c��[R"S[[R"S55n[R
"U5 g)Nr�z�            import sys
            class C:
               def __del__(self):
                  import importlib
            sys.argv.insert(0, C())
            )r%�make_scriptr!r�r��assert_python_ok)rh�testfns  r=�!test_import_in_del_does_not_crash�-ImportTests.test_import_in_del_does_not_crash�s7���*�*�2�v�x���H�8���	�&�&�v�.r?c�
�[RRS[R5 [
S-n[RRU5n[USSS9nSSS5 [R"US5 [#[
5 [R$"U5 [RS	['[
5 g!,(df   Nl=f![a URS5 Nt[a[nUR[[SS5[[S	S54;aeURS
R!U55 SnAN�SnAff=f![RS	['[
5 f=f)Nrr]r�rr)���rzz-cannot set modification time to large integer�	EOVERFLOW�EINVALz2cannot set modification time to large integer ({}))rXr�r5r�r6r!rSrT�cache_from_sourcer�utime�
OverflowErrorrg�OSError�errno�getattrr�r0�statrc)rhr0�compiledrb�es     r=�test_timestamp_overflow�#ImportTests.test_timestamp_overflow�s!��	������2�9�9�%�	!��e�^�F� �~�~�7�7��?�H��f�c�G�4���5�
^�����!;�<�
�v���G�G�H��������� �!5�4��!�
O��
�
�M�N��
^��7�7�7�5�+�t�#D�#*�5�(�D�#A�#C�C���
�
�R�Y�Y�Z[�\�]�]��	
^��������� �sZ�3E �#C�%E �.C�%E �
C�E �E�7E �9	E�AE�E �E�E � "Fc�^�[SS/S9 g![a URS5 gf=f)N�httpr�)�fromlistzfromlist must allow bogus names)r0r�r,r�s r=�test_bogus_fromlist�ImportTests.test_bogus_fromlist�s/��	9��v���1���	9��I�I�7�8�	9�s��,�,c�z�SS/n[R"U6nUR5up4URSU5 g)N�-cz&del __builtins__.__import__; import ossImportError)r%�spawn_python�communicater	)rh�args�popen�stdout�stderrs     r=�test_delete_builtins_import�'ImportTests.test_delete_builtins_import�s;���>�?���*�*�D�1���*�*�,����
�
�n�f�-r?c�p�UR[S5 SSKJn SSS5 g!,(df   g=f)Nz^No module named 'bogus'r)�foo)rr��bogusr�)rhr�s  r=�/test_from_import_message_for_nonexistent_module�;ImportTests.test_from_import_message_for_nonexistent_module�s#��
�
#�
#�K�1K�
L�!�M�
L�
L���'�
5c�p�UR[S5 SSKJn SSS5 g!,(df   g=f)Nz^cannot import name 'bogus'r)r�)rr�rr�)rhr�s  r=�,test_from_import_message_for_existing_module�8ImportTests.test_from_import_message_for_existing_module�s#��
�
#�
#�K�1N�
O� �P�
O�
O�r�c�,�"SS5nSnUR[U5 U"5[RU'UR	[
5nSSKJn SSS5 UR[WR5S5 g!,(df   N4=f)Nc��\rSrSrSrSrg)�IImportTests.test_from_import_AttributeError.<locals>.AlwaysAttributeErrori�c��[erF)�AttributeError)rh�_s  r=�__getattr__�UImportTests.test_from_import_AttributeError.<locals>.AlwaysAttributeError.__getattr__�s��$�$r?rnN)r�r�r�r�r�r�rnr?r=�AlwaysAttributeErrorr��s��
%r?r��test_from_import_AttributeErrorr��does_not_existzScannot import name 'does_not_exist' from '<unknown module name>' (unknown location))�
addCleanuprrXrYr�r�r�r�r�r/r�)rhr��module_namer�r�s     r=r��+ImportTests.test_from_import_AttributeError�sr��	%�	%�8�������,�#7�#9����K� �
�
�
�{�
+�r�F�,�	
����R�\�\�*�a�	c�,�
+�s�B�
Bc�B�[[SS5 UR[5 SSKJn SSS5 UR[
5 [R SSS5 SSS5 g!,(df   NE=f!,(df   N(=f!,(df   g=f)Nr�rr�)rr�r�r�r�r�)rhr�s  r=�test_issue31492�ImportTests.test_issue31492�se��
�r�:�t�
,��"�"�;�/�-�0��"�"�>�2��!�!�3�	-�
,�/�/��3�2��	-�
,�s9�B�A.�B�A?�B�.
A<	�8B�?
B
	�	B�
Bc�^^^�Sm[RRS[RR	[RR[5S55 SmUUU4Sjn[S5H�n[R"5m[S5Vs/sHn[R"US9PM nn[R"UTR5 [R"S5 SSS5 [R R#SS5 [R R#S	S5 TcM�Te [RS	gs snf!,(df   Nn=f![R R#SS5 [R R#S	S5 f=f![RS	f=f)
Nc�t�US:Xa2URRS:Xa[R"S5 ggg)N�call�has_deadlockg�������?)�f_code�co_name�time�sleep)�frame�event�args   r=�delay_has_deadlock�8ImportTests.test_concurrency.<locals>.delay_has_deadlock�s-�����5�<�<�#7�#7�>�#I��
�
�3��$J�r?r�datac�>�[R"T5 TR5 SSKn[R"S5 g![anUmSnAN(SnAff=fr�)rX�settrace�wait�package�
BaseException)r�r�r�r��excs  ���r=�run�)ImportTests.test_concurrency.<locals>.run�sF������/�0��
�
���"����T�"��%���C���s�A�
A�A�Ar[r�)�targetr�zpackage.submodule)rXr�r5r��join�dirnamer�r@�	threading�Event�Threadr&�
start_threads�setr�r�rYru)rhr�rFrV�threadsr�r�r�s     @@@r=�test_concurrency�ImportTests.test_concurrency�s1���	 �	������2�7�7�<�<�������(A�6�J�K�	��C�
#��2�Y��!���)��AF�q��J��A�9�+�+�3�7���J�?�)�7�7�����K��
�
�1�
�L��K�K�O�O�I�t�4��K�K�O�O�$7��>��?��I��������K�K�K���K�K�O�O�I�t�4��K�K�O�O�$7��>�������sV�':F8�!E�?F8�!E3�#E"�:E3�AF8�F8�F8�"
E0	�,E3�3AF5�5F8�8G�win32�Windows-specificc
��SSKJn U"[R5n[R
R
S5Rn[RR[RRU5SRSU;aSOS55n[R"5n[RRUS5n[R"U5 [RRU[RR![R"55n[$R&"[R"U5 [$R&"X%5 [(R("[RR[(R*"[R,5S55Hn[$R&"X�5 M [$R&"X65 Sn	[R.V
s0sH$o�R15[R.U
_M& n	n
US	-[2-U	S
'[4R6"USS	RSS
R[RRU55SS/5/[4R8U	[RRU5S9 [$R&"XF5 [4R6"USS/[4R8U	[RRU5S9 SSS5 gs sn
f!,(df   g=f)Nr)�GetModuleFileName�_sqlite3z
sqlite3{}.dll�_dr��DLLszvcruntime*.dll�;�
PYTHONPATHz-Scz	import oszp = os.add_dll_directory({!r})zimport _sqlite3zp.close)r��env�cwd)�_winapir�rX�	dllhandlerSrT�	find_specrBr�r�r�r�r�r
�temp_dir�mkdir�basename�
executable�shutil�copy�globr�prefix�environ�upperr�
subprocess�
check_call�STDOUT)rhr��dllname�pydname�depname�tmp�tmp2�pyexerbr��ks           r=�test_dll_dependency_import�&ImportTests.test_dll_dependency_imports/��-�#�C�M�M�2���.�.�*�*�:�6�=�=���'�'�,�,��G�G�O�O�G�$��"�"�4�7�?�4��C�E���
�
�
!�S��7�7�<�<��V�,�D��H�H�T�N��G�G�L�L��b�g�g�&6�&6�s�~�~�&F�G�E��K�K�����.��K�K��%��Y�Y�r�w�w�|�|�D�K�K��
�
�,C�EU�V�W�����A�#�X�
�K�K��&��C�57�Z�Z�@�Z��7�7�9�b�j�j��m�+�Z�C�@� $�s�
�Z� 7�C���
�!�!��u�c�h�h��4�;�;�������0�2�%��(��#�"�(�(���G�G�O�O�E�*�

,�
�K�K��&��!�!�5�%�1B�"C�+5�+<�+<�(+�(*������(>�
@�?"�
!��A�"�
!�s �/EL2�	+L-�4C0L2�-L2�2
Mc���UR[5n[R"SS5 SSS5 UR	S[WR55 g!,(df   N4=f)NrVs6'�Cuz"Frozen object named 'x' is invalid)r�r��_imp�get_frozen_objectr	r/r�)rhr�s  r=�test_issue105979�ImportTests.test_issue105979DsL��
�
�
�{�
+�r��"�"�3�(8�9�,��
�
�:��"�,�,�'�	)�,�
+�s�A�
A*c�v�UR[5nSSKJn SSS5 UR	S[R
S3[
WR55 UR[5nSSKJn SSS5 UR	S[
UR55 /SQnUHWnURUS9 Sn[R"S	U5nUR5upxUR	XW5 SSS5 MY g!,(df   N�=f!,(df   N�=f!,(df   M�=f)
Nr)�this_will_never_existz6cannot import name 'this_will_never_exist' from 'os' (�)zHcannot import name 'this_will_never_exist' from 'sys' (unknown location))zb
import os
os.__spec__.has_location = False
os.__file__ = []
from os import this_will_never_exist
za
import os
os.__spec__.has_location = False
del os.__file__
from os import this_will_never_exist
zY
import os
os.__spec__.origin = []
os.__file__ = []
from os import this_will_never_exist
�r�sGcannot import name 'this_will_never_exist' from 'os' (unknown location)r�)
r�r�r�r�r	r�r/r�rX�subTestr%r�r�)	rhr�r��scriptsr��expected_errorr�r�r�s	         r=�$test_frozen_module_from_import_error�0ImportTests.test_frozen_module_from_import_errorKs���
�
�
�{�
+�r�0�,��
�
�D�R�[�[�M�QR�S������	
��
�
�{�
+�r�1�,��
�
�V������	
�

��(�F����V��,�4��&�2�2�4��@��!&�!2�!2�!4����
�
�n�5�-�,��C,�
+��,�
+��8-�,�s#�D�1D�==D)�
D�
D&�)
D8	c��SnUS-US-/nUHXnURUS9 SnSSS5 [R"SU5nUR5upgUR	WU5 MZ g!,(df   NN=f)Nz�
import sys
class NotAModule: ...
nm = NotAModule()
nm.symbol = 123
sys.modules["not_a_module"] = nm
from not_a_module import symbol
z'from not_a_module import missing_symbolz8nm.__spec__ = []
from not_a_module import missing_symbolr�s`ImportError: cannot import name 'missing_symbol' from '<unknown module name>' (unknown location)r�)rr%r�r�r	)rhr�rr�rr�r�r�s        r=�!test_non_module_from_import_error�-ImportTests.test_non_module_from_import_errorws�����
�>�>��P�P�
���F����V��,�B��-�
"�.�.�t�V�<�E�"�.�.�0�N�F��M�M�.�&�1��,�,�s�A,�,
A:	c	��SS/nUGH�up#URUS9 [R"5n[[R
R
US5SSS9nURU5 SSS5 US-n[R"[R
R
US5US	9nUR5up�URX�5 [R"S
SUS	9nUR5up�URX�5 [R"SS
US	9nUR5up�URX�5 [R"SSUS	9nUR5up�URUS5 [R
R
US5n
[R"U
5 [R"[R
R
US5U
S	9nUR5up�URX�5 [R"S
SU
S	9nUR5up�URUS5 [R"SS
U
S	9nUR5up�URUS5 SSS5 SSS5 GM� g!,(df   GN,=f!,(df   N.=f!,(df   GM�=f)N�z#import fractions
fractions.Fraction�>AttributeError: module 'fractions' has no attribute 'Fraction'�zfrom fractions import Fractions;ImportError: cannot import name 'Fraction' from 'fractions'r��fractions.pyr�rr� \(consider renaming '.*fractions.py' since it has the same name as the standard library module named 'fractions' and prevents importing that standard library module\)�r��-m�	fractionsr�zimport fractions�-Pr?�child)rr
r�rr�r�r�rr%r�r�r�r�r�)rh�
script_errorsr��errorr�rbrr�r�r��	tmp_childs           r=�test_script_shadowing_stdlib�(ImportTests.test_script_shadowing_stdlib�sL��
�
�	
�
�+�M�F����V��,�i�.@�.@�.B�c��"�'�'�,�,�s�N�;�S�7�S�WX��G�G�F�O�T�"'�N�"��&�2�2�2�7�7�<�<��^�3T�Z]�^��!&�!2�!2�!4���� � ��8�%�2�2�4��#�N��!&�!2�!2�!4���� � ��8�%�2�2�4�9K�QT�U��!&�!2�!2�!4���� � ��8�&�2�2�4��S�Q��!&�!2�!2�!4���� � ���-��G�G�L�L��g�6�	�����#�&�2�2�2�7�7�<�<��^�3T�Zc�d��!&�!2�!2�!4���� � ��8�%�2�2�4��)�T��!&�!2�!2�!4���� � ���-�%�2�2�4�9K�QZ�[��!&�!2�!2�!4���� � ���-�S/C�,�,�+�S�S��/C�.B��,�,�s;�J6�*J%�J	�.HJ%�=J6�
J"
�J%�%
J3�/J6�6
K	c
�V�SS/nUGH�up#URUS9 [R"5n[R"[R
R
US55 [[R
R
USS5SSS9nURS	5 SSS5 [[R
R
US
5SSS9nURS5 URU5 SSS5 US-n[R"[R
R
US
5US
9nUR5up�URX�5 [R"SSUS
9nUR5up�URX�5 [R"SS
US
9nUR5up�URUS5 SSS5 SSS5 GM� g!,(df   GNG=f!,(df   GN=f!,(df   N@=f!,(df   GM!=f)N)zfractions.Fractionr
rr�r�__init__.pyr�rr�shadowing_module = True�main.pyz-import fractions; fractions.shadowing_module
s� \(consider renaming '.*[\\/]fractions[\\/]+__init__.py' since it has the same name as the standard library module named 'fractions' and prevents importing that standard library module\)rr�mainrs6module 'fractions' has no attribute 'shadowing_module')
rr
r�r�r�r�r�rrr%r�r�r��
rhrr�rr�rbrr�r�r�s
          r=�$test_package_shadowing_stdlib_module�0ImportTests.test_package_shadowing_stdlib_module�s���
�
�	
�
�+�M�F����V��,�i�.@�.@�.B�c���������c�;�7�8���G�G�L�L��k�=�A�3�QX����G�G�5�6���"�'�'�,�,�s�I�6��g�N�RS��G�G�L�M��G�G�F�O�O�"'�N�"��&�2�2�2�7�7�<�<��Y�3O�UX�Y��!&�!2�!2�!4���� � ��8�%�2�2�4��S�I��!&�!2�!2�!4���� � ��8�&�2�2�4���L��!&�!2�!2�!4���� � ��)b�c�7/C�,�,�+����O�N��
/C�.B��,�,�sT�H�AH�G#	�#1H�#G5	�7CH�
H�#
G2
�-H�5
H
�?H�
H�H�
H(	c	��SS/nUGHMup#URUS9 [R"5n[[R
R
US5SSS9nURU5 SSS5 US-n[R"[R
R
US55nUR5up�URX�5 [R"S	S
US9nUR5up�URX�5 [R"SS
US9nUR5up�URX�5 SSS5 SSS5 GMP g!,(df   N�=f!,(df   N-=f!,(df   GM�=f)N)zimport numpy
numpy.arrays7AttributeError: module 'numpy' has no attribute 'array')zfrom numpy import arrays4ImportError: cannot import name 'array' from 'numpy'r��numpy.pyr�rrsd \(consider renaming '.*numpy.py' if it has the same name as a library you intended to import\)\s+\Zr�numpyrr�zimport numpy�rr
r�rr�r�r�rr%r�r�r�rs
          r=�!test_script_shadowing_third_party�-ImportTests.test_script_shadowing_third_party�sD��
�
�	
�
�+�M�F����V��,�i�.@�.@�.B�c��"�'�'�,�,�s�J�7��w�O�ST��G�G�F�O�P�"'�M�"��
&�2�2�2�7�7�<�<��Z�3P�Q��!&�!2�!2�!4���� � ��8�%�2�2�4��c�J��!&�!2�!2�!4���� � ��8�%�2�2�4��S�Q��!&�!2�!2�!4���� � ��8�'/C�,�,�+�O�O��/C�.B��,�,�s;�E<�*E+�E	�.CE+�E<�
E(
�$E+�+
E9�5E<�<
F	c��[R"5n[[RRUS5SSS9nUR
S5 SSS5 Sn[R"SSUS	9nUR5upVURXS5 S
n[R"SSUS	9nUR5upVURXS5 SSS5 g!,(df   N�=f!,(df   g=f)Nr!r�rrz3this_script_does_not_attempt_to_import_numpy = Trues;AttributeError: module 'numpy' has no attribute 'attr'\s+\Zr�zimport numpy; numpy.attrrs?ImportError: cannot import name 'attr' from 'numpy' \(.*\)\s+\Zzfrom numpy import attr)r
r�rr�r�r�rr%r�r�r�)rhr�rbrr�r�r�s       r=�+test_script_maybe_not_shadowing_third_party�7ImportTests.test_script_maybe_not_shadowing_third_partys���
�
�
�
!�S��b�g�g�l�l�3�
�3�S�7�K�q����M�N�L�P�
�"�.�.�t�5O�UX�Y�E�"�.�.�0�N�F����V�4�T�
�"�.�.�t�5M�SV�W�E�"�.�.�0�N�F����V�4�!"�
!�K�K��"�
!�s$�*C*�C�A>C*�
C'	�#C*�*
C8c�	�[R"5n[[RRUS5SSS9nUR
S5 SSS5 [[RRUS5SSS9nUR
S5 SSS5 [R"SUS9nUR5upEURUR5S	5 [[RRUS5SSS9nUR
S
5 SSS5 [R"SUS9nUR5upEURUR5S	5 [[RRUS5SSS9nUR
S5 SSS5 [R"SUS9nUR5upEUR5nUR[U5S5 UHnURUS
5 M [[RRUS5SSS9nUR
S5 SSS5 [R"SUS9nUR5upEUR5nUR[U5S5 UHnURUS5 M [[RRUS5SSS9nUR
S5 SSS5 [R"SUS9nUR5upEUR5nUR[U5S5 UHnURUS
5 M [[RRUS5SSS9nUR
S5 SSS5 [R"SUS9nUR5upEUR5nUR[U5S5 UHnURUS5 M SSS5 g!,(df   GN�=f!,(df   GN�=f!,(df   GNC=f!,(df   GN�=f!,(df   GN-=f!,(df   GN�=f!,(df   N�=f!,(df   g=f)Nrr�rrrrz�
import fractions
fractions.shadowing_module
class substr(str):
    __hash__ = None
fractions.__name__ = substr('fractions')
try:
    fractions.Fraction
except TypeError as e:
    print(str(e))
rsunhashable type: 'substr'z�
import fractions
fractions.shadowing_module
class substr(str):
    __hash__ = None
fractions.__name__ = substr('fractions')
try:
    from fractions import Fraction
except TypeError as e:
    print(str(e))
ac
import fractions
fractions.shadowing_module

import sys
sys.stdlib_module_names = None
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))

del sys.stdlib_module_names
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))

sys.path = [0]
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))
rLs.module 'fractions' has no attribute 'Fraction'a~
import fractions
fractions.shadowing_module

import sys
sys.stdlib_module_names = None
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))

del sys.stdlib_module_names
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))

sys.path = [0]
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))
s5cannot import name 'Fraction' from 'fractions' \(.*\)z�
import fractions
fractions.shadowing_module
del fractions.__spec__.origin
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))

fractions.__spec__.origin = []
try:
    fractions.Fraction
except AttributeError as e:
    print(str(e))
r�a
import fractions
fractions.shadowing_module
del fractions.__spec__.origin
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))

fractions.__spec__.origin = []
try:
    from fractions import Fraction
except ImportError as e:
    print(str(e))
)r
r�rr�r�r�rr%r�r�r��rstrip�
splitlines�lenr�)rhr�rbr�r�r��lines�lines        r=�'test_script_shadowing_stdlib_edge_cases�3ImportTests.test_script_shadowing_stdlib_edge_cases"s���
�
�
�
!�S��b�g�g�l�l�3��7��w�O�ST����1�2�P��b�g�g�l�l�3�	�2�C�'�J�a����
�
�K�"�.�.�y�c�B�E�"�.�.�0�N�F����V�]�]�_�.J�K��b�g�g�l�l�3�	�2�C�'�J�a����
�
�K�"�.�.�y�c�B�E�"�.�.�0�N�F����V�]�]�_�.J�K��b�g�g�l�l�3�	�2�C�'�J�a������K�0"�.�.�y�c�B�E�"�.�.�0�N�F��%�%�'�E����S��Z��+���� � ��'X�Y���b�g�g�l�l�3�	�2�C�'�J�a������K�0"�.�.�y�c�B�E�"�.�.�0�N�F��%�%�'�E����S��Z��+���� � ��'`�a���b�g�g�l�l�3�	�2�C�'�J�a������K�""�.�.�y�c�B�E�"�.�.�0�N�F��%�%�'�E����S��Z��+���� � ��'X�Y���b�g�g�l�l�3�	�2�C�'�J�a������K� "�.�.�y�c�B�E�"�.�.�0�N�F��%�%�'�E����S��Z��+���� � ��'`�a��e"�
!�O�O��K�J�� K�J��$K�J��>K�J��@K�J��0K�J��}"�
!�s��*R4�P7�1R4�Q	�A8R4�
Q�A8R4�Q-�)BR4�Q?�BR4�7R�	BR4�'R#�9A5R4�7
Q	�R4�	
Q	�R4�
Q*	�%R4�-
Q<	�7R4�?
R	�	R4�
R 	�R4�#
R1	�-R4�4
SzCannot delete cwd on Windows�sunos5z$Cannot delete cwd on Solaris/Illumos�aixzCannot delete cwd on AIXc���[R"5n[RR	US5n[R
"U5 [
[RR	US5SSS9nURS5 SSS5 [R"SSUS	9nUR5upVS
nURXW5 SSS5 g!,(df   NR=f!,(df   g=f)N�subtmprr�rrzl
import sys
assert sys.path[0] == ''

import os
import shutil
shutil.rmtree(os.getcwd())

os.does_not_exist
r�zimport mainrs=AttributeError: module 'os' has no attribute 'does_not_exist')r
r�r�r�r�r�rrr%r�r�r�)rhr�r4rbr�r�r�rs        r=�(test_script_shadowing_stdlib_cwd_failure�4ImportTests.test_script_shadowing_stdlib_cwd_failure�s����
�
�
!�S��W�W�\�\�#�x�0�F��H�H�V���b�g�g�l�l�6�9�5�s�W�M�QR����	�	�N�"�.�.�t�]��O�E�"�.�.�0�N�F�^�N����V�4�%"�
!�N�M��"�
!�s%�A C%�6C�AC%�
C"	�C%�%
C3c	���SS/nUGHup#URUS9 [R"5n[[R
R
US5SSS9nURS5 SSS5 [[R
R
US	5SSS9nURS
5 URU5 SSS5 US-n[R"S	US9nUR5up�URX�5 SSS5 SSS5 GM g!,(df   N�=f!,(df   Nr=f!,(df   N>=f!,(df   GMY=f)
Nr	rr�rr�rrrrz=import sys; sys.path.insert(0, "this_folder_does_not_exist")
r
rr#rs
          r=�2test_script_shadowing_stdlib_sys_path_modification�>ImportTests.test_script_shadowing_stdlib_sys_path_modification�s��
�
�	
�
�+�M�F����V��,�i�.@�.@�.B�c��"�'�'�,�,�s�N�;�S�7�S�WX��G�G�5�6�T��"�'�'�,�,�s�I�6��g�N�RS��G�G�\�]��G�G�F�O�O�"'�N�"��&�2�2�9�#�F��!&�!2�!2�!4���� � ��8�/C�,�,�+�S�S��N�N��/C�.B��,�,�sS�E�*D?�D	�.1D?�#D.	�AD?�E�
D+
�'D?�.
D<
�8D?�?
E
�	E�
E 	c�X�UR[S5 "SS5n[R"U"55 SSS5 UR[S5 "SS5n[R"U"55 SSS5 g!,(df   NS=f!,(df   g=f)Nzembedded null characterc��\rSrSrSrSrSrg)�2ImportTests.test_create_dynamic_null.<locals>.Speci��ab�abcrnN�r�r�r�r�rarBr�rnr?r=�Specr<�s�����r?r@c��\rSrSrSrSrSrg)�3ImportTests.test_create_dynamic_null.<locals>.Spec2i�r>r=rnNr?rnr?r=�Spec2rB�s����!�r?rC)r�
ValueErrorr��create_dynamic)rhr@rCs   r=�test_create_dynamic_null�$ImportTests.test_create_dynamic_null�s���
�
#�
#�J�0I�
J�
�
�
�����'�	K��
#�
#�J�0I�
J�
"�
"�
�����(�	K�
J�
K�
J��K�
J�s�&B
�&B�

B�
B)rnN)�longlist)8r�r�r�r�r�r�r�r�r�r�rr�rrrrr#r9rHrNrXr]rc�skip_if_dont_write_bytecoderjrqrwr�r�r�r�r�r�r�r&�requires_working_threadingr�r4�
skipUnlessrXr7r�r�rrrrr$r'r/r�r8r5r8rFr�rnr?r=r�r�ps���&��<�F�K�h�����*-�+�7�*�7�'�R&�P!�(	3�3�"$�L!�(�!�(�.�	/�!�!�!�!�29��.��.�"�!�c� �	"��	"��0�0�2� �3� �D�������0�2D�E�*@�F�*@�X)�*6�X2�.5.�n'd�R9�B5�&Tb�l�_�_�S�\�\�W�,�.L�M�
�_�_�S�\�\�X�-�/U�V�
�_�_�S�\�\�,�,�U�3�5O�P�5�Q�W�N�5�*9�8)r?r�c�x�\rSrSr\R
"\RS:HS5\R"\	=(d \
S5S55r\R
"\RS:HS5\RS55r\R
"\RS:HS5\RS55rSrS	rg
)�FilePermissionTestsi��posix�%test meaningful only on posix systemsz$Emscripten's/WASI's umask is a stub.c��Sn[U5 [5up#[RR	U5n[U5n[RRU5(dURS5 [R"U5nSSS5 SSS5 UR[[R"WR55[SU)-55 g!,(df   N]=f!,(df   Nf=f)N��4__import__ did not result in creation of a .pyc filei�)r#rrSrTr}r0r�r��existsr,r�r��oct�S_IMODE�st_mode)rh�maskrar��cached_pathr7�	stat_infos       r=�test_creation_mode�&FilePermissionTests.test_creation_mode�s�����
��
��0�L�T�#�.�.�:�:�4�@�K���%�F��7�7�>�>�+�.�.��	�	�(�)�����,�I�
 1�
�	
����T�\�\�)�*;�*;�<�=��U�d�U�]�+�	-� 1�0��
�
�s#�C9�A8C(�C9�(
C6	�2C9�9
Dc�8�Sn[S5 [5up#[RR	U5n[
R"X15 [U5 [
RRU5(dURS5 [
R"U5nSSS5 SSS5 UR[[R"WR55[U55 g!,(df   NY=f!,(df   Nb=f)N�rQrR�r#rrSrTr}r��chmodr0r�rSr,r�r�rTrUrV)rh�moderar�rXrYs      r=�test_cached_mode_issue_2051�/FilePermissionTests.test_cached_mode_issue_2051s���
��
��
�� 1�\�d�#�.�.�:�:�4�@�K��H�H�T� ��t���7�7�>�>�+�.�.��	�	�(�)�����,�I�!2�
�	
����T�\�\�)�*;�*;�<�=�s�4�y�I�!2� 1��
�
�s#�D�BC:�'D�:
D	�D�
Dc�B�Sn[S5 [5up#[RR	U5n[
R"X15 [U5 [
RRU5(dURS5 [
R"U5nSSS5 SSS5 US-nUR[[R"WR55[U55 g!,(df   N^=f!,(df   Ng=f)N�rQrR�r^)rhr`rar�rXrYr:s       r=�test_cached_readonly�(FilePermissionTests.test_cached_readonly$s�����
��
�� 1�\�d�#�.�.�:�:�4�@�K��H�H�T� ��t���7�7�>�>�+�.�.��	�	�(�)�����,�I�!2�
��%�<������T�\�\�)�*;�*;�<�=�s�8�}�M�!2� 1��
�
�s#�D�BC?�'D�?
D
	�	D�
Dc��[5up[USSS9nURS5 SSS5 [R"U5n[R
"X$RURS-
45 [R"US5 [U5nURURS5 [R"US5 [USSS9nURS	5 SSS5 [U5 [R"5 [U5nURURS
5 [U5 [U5 [R"5 US-n[R "[R"R%U5U5 [U5nURURS
5 SSS5 g!,(df   GN�=f!,(df   N�=f!,(df   g=f)Nr�rrzx = 'original'
i�rd�originalr]zx = 'rewritten'
�	rewrittenr>)rrrr�r�r~�st_atime�st_mtimer_r0r�rVrrSr�r�renamerTr})rhrar�rb�s�m�
bytecode_onlys       r=�test_pyc_always_writable�,FilePermissionTests.test_pyc_always_writable5se���
�,�4��d�C�'�2�a����*�+�3�����
�A��H�H�T�J�J��
�
�9�(<�=�>��H�H�T�5�!��4� �A����Q�S�S�*�-��H�H�T�5�!��d�C�'�2�a����+�,�3��4�L��'�'�)��4� �A����Q�S�S�+�.��4�L��4�L��'�'�)� �3�J�M��I�I�i�n�n�6�6�t�<�m�L��4� �A����Q�S�S�+�.�3�
�2�2��3�2���
�s;�G0�G
�B-G0�G�*CG0�
G	�G0�
G-	�)G0�0
G>rnN)r�r�r�r�r4rKr�rar�rrrZr
�skip_unless_working_chmodrarfrqr�rnr?r=rMrM�s���������G�+�@�B�
�_�_�� ��.��
-�	�B�
-�������G�+�@�B��(�(�J�)�B�J�������G�+�@�B��(�(�N�)�B�N�/r?rMc�
�\rSrSrSrSr\RR\	5r
\RR\
\5\R-S-r
\RR!\
5rSrSrSrSrS	rS
rSrSrg
)�PycRewritingTestsiT�unlikely_module_namez�
import sys
code_filename = sys._getframe().f_code.co_filename
module_filename = __file__
constant = 1
def func():
    pass
func_filename = func.__code__.co_filename
r`c���[RSSUl[RR	UR
S5Ul[R"UR5 [URSSS9nURUR5 SSS5 [RRSUR5 [R "5 g!,(df   NN=f)Nr�rrr)rXr��sys_pathrYrur��orig_moduler�r��dir_namer�	file_namer�
module_sourcer5rSr�)rhrbs  r=r��PycRewritingTests.setUpgs���������
��;�;�?�?�4�+;�+;�T�B���
�������
�$�.�.�#��
8�A�
�G�G�D�&�&�'�9�������4�=�=�)��#�#�%�9�
8�s�=C!�!
C/c�P�UR[RSS&URb(UR[RUR
'O[
UR
5 [UR5 [UR5 [UR5 grF)rxrXr�ryrYr�rrr{�
compiled_namer"rzr�s r=r��PycRewritingTests.tearDownpsm���m�m���������'�,0�,<�,<�C�K�K��(�(�)��4�#�#�$��t�~�~���t�!�!�"��t�}�}�r?c�|�[5n[URX5 [RUR$rF)rr0r�rXrY)rhr�s  r=r �PycRewritingTests.import_modulezs.��
�Y���4�#�#�R�,��{�{�4�+�+�,�,r?c�B�UR5nURURUR5 URURUR5 URUR
UR5 [RUR	UR5nURURUR5 URURUR5 URUR
UR5 grF)	r r��module_filenamer{�
code_filename�
func_filenamerXrYr��rhr�s  r=�test_basics�PycRewritingTests.test_basicss���� � �"������,�,�d�n�n�=�����*�*�D�N�N�;�����*�*�D�N�N�;��K�K��(�(�)�� � �"������,�,�d�n�n�=�����*�*�D�N�N�;�����*�*�D�N�N�;r?c�F�[R"URSS9 UR5nUR	UR
UR5 UR	URUR5 UR	URUR5 g�Nzanother_module.py)�dfile)rArBr{r r�r�r�r�r�s  r=�test_incorrect_code_name�*PycRewritingTests.test_incorrect_code_name�ss�����4�>�>�1D�E�� � �"������,�,�d�n�n�=�����*�*�D�N�N�;�����*�*�D�N�N�;r?c��Sn[R"URUS9 [R"UR5 [UR5n[R"5 UR5nURURU5 URURU5 URURU5 gr�)
rArBr{r�rgrrSr�r r�r�r�r�)rhr��pyc_filer�s    r=�test_module_without_source�,PycRewritingTests.test_module_without_source�s���$�����4�>�>��8�
�	�	�$�.�.�!�"�4�>�>�2���#�#�%�� � �"������,�,�h�7�����*�*�F�3�����*�*�F�3r?c���[R"UR5 [URS5nURS5n[R"U5nSSS5 [WR5n[RRnURS5nXTU'UR[U5S9n[URS5nUR!W5 [R""X15 SSS5 UR5nUR%UR&R(UR(5 g!,(df   N�=f!,(df   N`=f)N�rb�rK)�	co_consts�wb)rArBr{rrr��marshal�load�listr�rSr �__code__�index�replacer�r�dumpr��constant�co_filename)rhrb�header�code�	constants�foreign_code�posr�s        r=�test_foreign_code�#PycRewritingTests.test_foreign_code�s�����4�>�>�*�
�$�$�$�d�
+�q��V�V�B�Z�F��<�<��?�D�,�����(�	� �.�.�7�7���o�o�a� ��%�#���|�|�e�I�&6�|�7��
�$�$�$�d�
+�q�
�G�G�F�O��L�L��!�,�� � �"��������1�1�<�3K�3K�L�,�
+��,�
+�s�(E
�(E�

E�
E))ryrxN)r�r�r�r�r�r|r�r�rmr!rzr�rar{rSrTr}rr�r�r r�r�r�r�r�rnr?r=ruruTs~��
)�K��M��w�w���v�&�H������X�{�3�b�i�i�?�$�F�I��N�N�4�4�Y�?�M�&��-�
	<�<�	4�Mr?ruc�z�\rSrSrSr\rSrSrSr	\
R"\RS:HS5S5rS	rg
)�
PathsTestsi�)rQutestäöüßutestéèu
test°³²c�t�[R"UR5 [RSSUlgrF)r�r�r�rX�syspathr�s r=r��PathsTests.setUp�s!��
��������x�x��{��r?c�h�[UR5 UR[RSS&grF)r"r�r�rXr�s r=r��PathsTests.tearDown�s���t�y�y���l�l�����r?c�|�[[RRURS5SSS9nUR	S5 SSS5 [
RR
URS-5 [S5nURURS5 [S5 g!,(df   Nm=f)Nztest_trailing_slash.pyr�rrz testdata = 'test_trailing_slash'�/�test_trailing_slash)rr�r�r�rrXrCr0r��testdatar)rhrbr�s   r=r��PathsTests.test_trailing_slash�s���
�"�'�'�,�,�t�y�y�*B�C���)�,-�
�G�G�6�7�)�	������	�	�#�
�&��.�/��������'<�=��$�%�
)�)�s�B-�-
B;r�r�c���[[RRURS5S5nUR	S5 SSS5 [
R"5 [RRUR5nSSKnUR5nUSnSU<SU<S3nXbSS-
n[R"U5 ["RR%SU5 ['S
5nUR-WR.S
5 UR1UR2U5 [5S
5 g!,(df   N�=f![aXnUR[R[R[R4;aUR!S	U<35 eSnAff=f![(a#nUR+SU<SU<35 SnAN�SnAff=f)
Nztest_unc_path.pyr�ztestdata = 'test_unc_path'rz\\�\�$r�z#cannot access administrative share �
test_unc_pathz&could not import 'test_unc_path' from z: )rr�r�r�rrSr�rm�socket�gethostname�listdirr�r��EPERM�EACCES�ENOENTrgrXr5r0r�r,r�r��assertStartsWithr�r)	rhrbr�r��hn�drive�uncr�r�s	         r=�
test_UNC_path�PathsTests.test_UNC_path�se��
�"�'�'�,�,�t�y�y�*<�=�s�
C�q�
�G�G�0�1�D��#�#�%��w�w���t�y�y�)���
�
�
�
!���Q�����'���A�B�x���	��J�J�s�O�	������3��	"��_�-�C�	
�������7����c�l�l�C�0����3D�
C���	��w�w�5�;�;����e�l�l�C�C��
�
��N�O���		���	"��I�I��a�!�
"�
"��	"�s<�D?�9E�0F5�?
E
�
F2�AF-�-F2�5
G"�?G�G")r�N)r�r�r�r��SAMPLESr!r�r�r�r�r4rKrXr7r�r�rnr?r=r�r��sI��)�G��D�#�#�
&��������0�2D�E� �F� r?r�c�N�\rSrSrSr\rSrSrSrSr	Sr
SrS	rS
r
Srg)
�RelativeImportTestsi�c��[S5 g)Nztest.relimport)rr�s r=r��RelativeImportTests.tearDown�s���� r?c�4�SSKJn URUS5 g)Nr�)�	relimportr�)r�r�rT)rhr�s  r=�test_relimport_star�'RelativeImportTests.test_relimport_star�s�� ����9�&;�<r?c�$^�U4Sjn[SSS9mU"5 [SSS9mU"5 [SSS9mUR[U5 [SSS9mUR[U5 [[5S9mUR[U5 g)Nc�>�[ST5 g)Nzfrom . import relimport)r)r�s�r=�check_relative�:RelativeImportTests.test_issue3221.<locals>.check_relative�s����*�B�/r?rQztest.notarealmodule)�__package__r�znotarealpkg.notarealmoduler�)r�)�dictr�r��objectr)rhr�r�s  @r=�test_issue3221�"RelativeImportTests.test_issue3221�s����	0��f�/D�
E�����f�/K�
L�����e�.C�
D�����-�~�>��e�.J�
K�����-�~�>��f�h�
'�����)�^�4r?c�6�[R"SSSS5 g)Nz-W�ignorer�zfoo = 1; from . import foo)r%�assert_python_failurer�s r=�)test_parentless_import_shadowed_by_global�=RelativeImportTests.test_parentless_import_shadowed_by_globals���+�+�D�(�D�(�	*r?c��UR[5 SSKJn UR	S5 SSS5 g!,(df   g=f)NrK)�sepz>explicit relative import triggered an implicit absolute import)r�r�r�r�r,)rhr�s  r=�#test_absolute_import_without_future�7RelativeImportTests.test_absolute_import_without_futures2���
�
�{�
+���I�I�1�
2�,�
+�
+�s	�7�
Ac��[RR[RR[5SS5n[SS5 [
U5 UR[5 SSK	nSSS5 URS[R5 URS[R5 SSS5 SSS5 g!,(df   N_=f!,(df   N(=f!,(df   g=f)Nr��package2�
submodule1�
submodule2r)
r�r�r�r�r�r(rr�r�r�rrXrY)rhr�r�s   r=�test_import_from_non_package�0RelativeImportTests.test_import_from_non_packages����w�w�|�|�B�G�G�O�O�H�5�v�z�J��
�\�<�
0�-��2E��"�"�;�/�!�0����\�3�;�;�7����\�3�;�;�7�	3F�
0�
0�/�/��3F�2E��
0�
0�s=�C1�C �1C�6AC �>C1�
C�C � 
C.	�*C1�1
C?c�N�[SSS5 [[RR	[RR[5S55 SSKnURR SSS5 SSS5 g!,(df   N=f!,(df   g=f)Nr�zpackage2.submodule1zpackage2.submodule2r�r)
r(rr�r�r�r�r��package2.submodule1r�r�)rhr�s  r=�!test_import_from_unloaded_package�5RelativeImportTests.test_import_from_unloaded_package!sf��
�Z�!6�8M�
N�
�2�7�7�<�<�������(A�6�J�
K�&����*�*�L�O�
N�
K�
K��O�
N�s$�AB�B�4B�
B	�B�
B$c���[RR[RR[5S5n[SS5 [
U5 SSKJn URURS5 SSKJn URURS5 SSS5 SSS5 [SS5 [
U5 SSKJn URURS5 SSKJn URURS5 SSS5 SSS5 g!,(df   N�=f!,(df   N�=f!,(df   N9=f!,(df   g=f)Nr��package3zpackage3.submoduler��	submodule�rebound)r�r�r�r�r�r(rr�r�r��attr�package3.submodule�rhr�r�s   r=�test_rebinding�"RelativeImportTests.test_rebinding's����w�w�|�|�B�G�G�O�O�H�5�v�>��
�Z�!5�
6�
�d�8K�*����Y�^�^�Y�7�2����Y�^�^�Y�7�	9L�
6�
�Z�!5�
6�
�d�8K�2����Y�^�^�Y�7�*����Y�^�^�Y�7�	9L�
6�
6�9L�8K��
6�
6��
9L�8K��
6�
6��J�D.�AD�D.�;E�AD?�E�
D+	�'D.�.
D<�?
E
	�	E�
Ec���[RR[RR[5S5n[SS5 [
U5 SSKJn URURS5 SSKJn URURS5 SSS5 SSS5 [SS5 [
U5 SSKJn URURS5 SSKJn URURS5 SSS5 SSS5 g!,(df   N�=f!,(df   N�=f!,(df   N9=f!,(df   g=f)Nr��package4zpackage4.submodulerr�r�rB)r�r�r�r�r�r(r�package4.submoduler�r�r�r�r�s   r=�test_rebinding2�#RelativeImportTests.test_rebinding26s����w�w�|�|�B�G�G�O�O�H�5�v�>��
�Z�!5�
6�
�d�8K�2����Y�^�^�[�9�*����Y�^�^�[�9�	9L�
6�
�Z�!5�
6�
�d�8K�*����Y�^�^�X�6�2����Y�^�^�[�9�	9L�
6�
6�9L�8K��
6�
6��
9L�8K��
6�
6�r�rnN)r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rnr?r=r�r��s4��!��E�=�
5�:*�
2�8�+�
8�:r?r�c��\rSrSrSrSrg)�OverridingImportBuiltinTestsiDc�T�SSKnSnURU"5U5 [[SS5 URU"5S5 SSS5 [	[5SS5 URU"5U5 SSS5 g!,(df   NE=f!,(df   g=f)Nrc��SSKnU$r��r�r�s r=r��?OverridingImportBuiltinTests.test_override_builtin.<locals>.fooIs
����Ir?r0c��g�N�rn�rVs r=�<lambda>�DOverridingImportBuiltinTests.test_override_builtin.<locals>.<lambda>Ns��!r?rc��grrnrs r=rrTs��1r?)r�r�r�builtinsr
r)rhr�r�s   r=�test_override_builtin�2OverridingImportBuiltinTests.test_override_builtinEs}���	�	
������#�
�x��|�
<����S�U�A�&�=��w�y�,��
=����S�U�B�'�>�
=�
=�
<��>�
=�s�B�'B�
B�
B'rnN)r�r�r�r�rr�rnr?r=r�r�Ds��(r?r�c�F�\rSrSrSrSrSr\S5r\	R"\RS:HS5\\
R\
R\	R "\S5S	55555r\S
5r\S5rSr\S
5r\S5rSrSrSrg)�PycacheTestsiXc�b�[[5 [S5 [UR5 g)Nr`)rr!r"rr0r�s r=�_clean�PycacheTests._clean[s���v���}���t�{�{�r?c�8�[S-UlUR5 [URSSS9n[	SUS9 SSS5 [
RRS[R5 [R"5 g!,(df   NR=f)Nr]r�rrz/# This is a test file written by test_import.pyr'r)r!r0rrr)rXr�r5r�r6rSr�)rh�fps  r=r��PycacheTests.setUp`sc���u�n������
�
�$�+�+�s�W�
5���C�"�M�6�������2�9�9�%��#�#�%�6�
5�s�B�
Bc��[RS[R:XdS5e[RS	UR	5 g)NrzUnexpected sys.path[0])rXr�r�r6rr�s r=r��PycacheTests.tearDownhs6���x�x��{�b�i�i�'�A�)A�A�'��H�H�Q�K����
r?c��UR[RRS55 [	[
5 UR
[RRS55 [RRUR5nUR
[RRU5SRU[
55 g)Nr`z*bytecode file {!r} for {!r} does not exist)�assertFalser�r�rSr0r!�
assertTruerSrTr}r0r��rh�pyc_paths  r=�test_import_pyc_path�!PycacheTests.test_import_pyc_pathms�����������
�6�7��6����������}�5�6��>�>�3�3�D�K�K�@����������x�0� � &��x�� 8�	:r?rNrOzumask is a stubc��[S5 [[5 SSS5 UR[R
R
S55 [RRUR5nUR[R
R
U5SRU[55 g!,(df   N�=f)N�r`z"bytecode file {!r} for {!r} exists)
r#r0r!rr�r�rSrSrTr}r0rr�rs  r=�test_unwritable_directory�&PycacheTests.test_unwritable_directoryws�����
��v�����������}�5�6��>�>�3�3�D�K�K�@�����������1�!�!'���&�!9�	;�	�
�s�B?�?
C
c��[[5 [RR	UR
5nUR
[RRU55 [R"UR
5 [[5 [R"5 UR[[[5 grF)r0r!rSrTr}r0rr�r�rSrgrr�r�r�)rhr�s  r=�test_missing_source� PycacheTests.test_missing_source�sr��	�6���>�>�3�3�D�K�K�@����������x�0�1�
�	�	�$�+�+���v���#�#�%����+�z�6�:r?c	�*�[[5 [UR5n[R
"UR5 [
[5 [R"5 [[5nURUR[RR[R"5[RRU555 [R
"U5 g![R
"U5 f=frF)r0r!rr0r�rgrrSr�r�r�r�r��getcwd�relpath�rhr�ros   r=�test_missing_source_legacy�'PycacheTests.test_missing_source_legacy�s���	�6��"�4�;�;�/��
�	�	�$�+�+���v���#�#�%��v���	 ����Q�Z�Z��W�W�\�\�"�)�)�+�r�w�w���x�7P�Q�
S�
�I�I�h���B�I�I�h��s
�9A*C:�:Dc��[[5n[RR	[S-5nURUR[RR[R"5U55 g)Nr])r0r!rSrTr}r��
__cached__r�r�r�r")rhror�s   r=�test___cached__�PycacheTests.test___cached__�sM���v����>�>�3�3�F�U�N�C��������r�w�w�|�|�B�I�I�K��'J�Kr?c	���[[5 [UR5n[R
"UR5 [
[5 [R"5 [[5nURUR[RR[R"5[RRU555 grF)r0r!rr0r�rgrrSr�r�r(r�r�r"r#r$s   r=�test___cached___legacy_pyc�'PycacheTests.test___cached___legacy_pyc�s���	�6��"�4�;�;�/��
�	�	�$�+�+���v���#�#�%��v��������������b�i�i�k�2�7�7�?�?�8�3L�M�	Or?c��Sn[R"S5 URU5 [[RRSS5S5 SSS5 [[RRSS5S5 SSS5 [R"5 [S5n[RR[RRSS55nURUR[RR[R"5U55 [RR[RRSS55nUR[RSR[RR[R"5U55 g!,(df   GN�=f!,(df   GNg=f)Nc�F�[S5 [S5 [S5 g�N�pep3147�pep3147.foo�r"rrnr?r=�cleanup�5PycacheTests.test_package___cached__.<locals>.cleanup�����9���=�!��9�r?r1rr��foo.pyr2)r�r�r�rr�r�rSr�r0rTr}r�r(r"rXrY�rhr4ro�init_pyc�foo_pycs     r=�test_package___cached__�$PycacheTests.test_package___cached__�s4��	�	��������� �
�"�'�'�,�,�y�-�8�$�
?��@�
�"�'�'�,�,�y�(�3�T�
:��;��#�#�%��}�%���>�>�3�3��G�G�L�L��M�2�4��������r�w�w�|�|�B�I�I�K��'J�K��.�.�2�2�2�7�7�<�<�	�8�3T�U��������]�3�>�>������b�i�i�k�7�;�	=�@�
?��
:�
:�s�G�	G+�
G(�+
G:c�f�Sn[R"S5 URU5 [[RRSS5S5 SSS5 [[RRSS5S5 SSS5 [R"5 [S5n[S5 [S5 [R"5 [S5n[RR[RRSS55nURUR[RR[R"5U55 [RR[RRSS55nUR[R SR[RR[R"5U55 g!,(df   GN�=f!,(df   GN�=f)Nc�F�[S5 [S5 [S5 gr0r3rnr?r=r4�>PycacheTests.test_package___cached___from_pyc.<locals>.cleanup�r6r?r1rr�r7r2)r�r�r�rr�r�rSr�r0rrTr}r�r(r"rXrYr8s     r=� test_package___cached___from_pyc�-PycacheTests.test_package___cached___from_pyc�sZ��	�	��������� �
�"�'�'�,�,�y�-�8�$�
?��@�
�"�'�'�,�,�y�(�3�T�
:��;��#�#�%��}�%���}���y���#�#�%��}�%���>�>�3�3��G�G�L�L��M�2�4��������r�w�w�|�|�B�I�I�K��'J�K��.�.�2�2�2�7�7�<�<�	�8�3T�U��������]�3�>�>������b�i�i�k�7�;�	=�@�
?��
:�
:�s�H�	H!�
H�!
H0c��[[5 [[5 [URSSS9n[SUS9 SSS5 [[5nUR
URS5 g!,(df   N:=f)Nr-rrzx = 5r'r)r0r!rrr0r)r�rV)rhrros   r=�test_recompute_pyc_same_second�+PycacheTests.test_recompute_pyc_same_second�s[��	�6���v��
�$�+�+�s�W�
5���'��#�6��v���������a� �6�
5�s�A3�3
B)r0N)r�r�r�r�rr�r�rIrr4rKr�rar
rs�skip_if_dac_overrider�rrrr%r)r,r;r@rCr�rnr?r=r
r
Xs����
&��
!�:�!�:�������G�+�@�B� ��(�(��#�#�
�_�_�]�$5�6�	;�7�$�)�!�B�	;�!�	;�!�	;�!� �!� �$L�!�
O�!�
O�!�=�!�=�,=�6!r?r
c���\rSrSrSr\S-rSrSr\R"\
"\S5(+=(d \R"5S:�S5\
RS	55rS
rg)�TestSymbolicallyLinkedPackagei��samplez-taggedc���[R"UR5 [R"UR5 [R
SSUl[R"UR5 UR[RUR5 [R
RURS5n[R"U5 [R
RU5(de[R"URURSS9 UR[RUR5 [R "5 UR#[R
R%UR5S5 [R
R'[R
RURS55(deg)NrT)�target_is_directory)r
r"�tagged�package_namerXr��
orig_sys_pathr�r�r�r��create_empty_filerS�symlinkrrSr�r��isdir�isfile)rh�	init_files  r=r��#TestSymbolicallyLinkedPackage.setUp�s4��������%�����*�*�+� �X�X�a�[���	����������	�(�(�$�+�+�6��G�G�L�L����m�<�	��#�#�I�.��w�w�~�~�i�(�(�(�(�	�
�
�4�;�;�� 1� 1�t�L����	�(�(�$�*;�*;�<��#�#�%���������t�'8�'8�9�4�@��w�w�~�~�b�g�g�l�l�4�+<�+<�m�L�M�M�M�Mr?c�>�UR[RSS&grF)rMrXr�r�s r=r��&TestSymbolicallyLinkedPackage.tearDowns���(�(�����r?�getwindowsversion)�rzWindows Vista or later requiredc�h�S/[RSS&[RRUR5(de[RR[RRURS55(de[R"UR5 g)N�.r)rXr�r�rSrLr�rSr r�s r=�test_symlinked_dir_importable�;TestSymbolicallyLinkedPackage.test_symlinked_dir_importablesv���e�������w�w�~�~�d�/�/�0�0�0�0��w�w�~�~�b�g�g�l�l�4�+<�+<�m�L�M�M�M�M�	���� 1� 1�2r?)rMN)r�r�r�r�rLrKr�r�r4rKr�rXrVr
�skip_unless_symlinkrZr�rnr?r=rGrG�sr���L�
�I�
%�F�N�.)�����C�,�-�-�	-�� � �"�f�,�)�+��"�"�3�#�	+�
3r?rGc�,�\rSrSrSrSrSrSrSrg)�ImportlibBootstrapTestsi(c�L�[RSnURU5 g)N�_frozen_importlib)rXrYrr�s  r=�test_frozen_importlib�-ImportlibBootstrapTests.test_frozen_importlib,s���k�k�-�.������r?c��SSKJn [RSnUR	X!5 URURS5 URURS5 URURS5 g)Nr)�
_bootstrapr`zimportlib._bootstraprSz
_bootstrap.py)
rSrdrXrYrSr�r�r�rfr�)rhrdr�s   r=�"test_frozen_importlib_is_bootstrap�:ImportlibBootstrapTests.test_frozen_importlib_is_bootstrap0s]��(��k�k�-�.���
�
�c�&�������'=�>�������+�6����C�L�L�/�:r?c��SSKJn [RSnUR	X!5 URURS5 URURS5 URURS5 g)Nr)�_bootstrap_external�_frozen_importlib_externalzimportlib._bootstrap_externalrSz_bootstrap_external.py)
rSrhrXrYrSr�r�r�rfr�)rhrhr�s   r=�4test_frozen_importlib_external_is_bootstrap_external�LImportlibBootstrapTests.test_frozen_importlib_external_is_bootstrap_external8s^��1��k�k�6�7���
�
�c�/�������'F�G�������+�6����C�L�L�*B�Cr?c��SSKJn [RSnUR	UR
UR
5 g)Nr)�	machineryr`)rSrmrXrYrS�
ModuleSpec)rhrmr�s   r=�test_there_can_be_only_one�2ImportlibBootstrapTests.test_there_can_be_only_one@s.��	(��k�k�-�.���
�
�i�*�*�C�N�N�;r?rnN)	r�r�r�r�rarerjror�rnr?r=r^r^(s���;�D�<r?r^c�*�\rSrSrSrSrSrSrSrg)�GetSourcefileTestsiIz�Test importlib._bootstrap_external._get_sourcefile() as used by the C API.

Because of the peculiarities of the need of this function, the tests are
knowingly whitebox tests.

c���[R"S5nSUl[S-n[S-nUR	[U5U5 SSS5 g!,(df   g=f)N�*importlib._bootstrap_external._path_isfileTr^r]�r	�patch�return_valuer!r�r)rh�_path_isfiler��expects    r=�test_get_sourcefile�&GetSourcefileTests.test_get_sourcefileSsO���Z�Z�D�
E��(,�L�%��F�?�D��e�^�F����_�T�2�F�;�	F�
E�
E�s�5A�
A#c��[R"S5nSUl[S-nUR	[U5U5 SSS5 g!,(df   g=f)NrtFr^ru)rhrxr�s   r=�test_get_sourcefile_no_source�0GetSourcefileTests.test_get_sourcefile_no_source\sF���Z�Z�D�
E��(-�L�%��F�?�D����_�T�2�D�9�F�
E�
E�s�,A�
Ac�L�[S-nUR[U5U5 g)Nz.bad_ext)r!r�r)rhr�s  r=�test_get_sourcefile_bad_ext�.GetSourcefileTests.test_get_sourcefile_bad_extds#���
�"�������.��5r?rnN)	r�r�r�r�r�rzr}r�r�rnr?r=rrrrIs���<�:�6r?rrc��\rSrSrSrSrSSjrSrSrSr	Sr
S	rS
rSr
SrS
rSrSr\S5r\R*"\S5S5rSrg)�ImportTracebackTestsikc��[R"[5 [RSSUl[RR
S[5 gr�)r�r�r!rXr��old_pathr5r�s r=r��ImportTracebackTests.setUpms/��
�����������
�������6�"r?c�\�UR[RSS&[[5 grF)r�rXr�r"r!r�s r=r��ImportTracebackTests.tearDownrs���m�m�������v�r?c��[RR[X-5n[	USSS9nURU5 SSS5 UR
[U5 [R"5 U$!,(df   N;=f)Nr�rr)
r�r�r�r!rrr�rrSr�)rhr��contentsr/�fnamerbs      r=�
create_module�"ImportTracebackTests.create_modulevs_�������V�S�Y�/��
�%��w�
/�1�
�G�G�H��0������$��#�#�%���	0�
/�s�A9�9
Bc�X�/nU(aWURRnURnU(aXSS:waURU5 URnU(aMWUR[
U5[
U5U5 [X25HupVURXe5 M g)Nr=)	�tb_framer�r�rC�tb_nextr�r,�zipr	)rh�tb�files�
deduped_filesr��fn�pats       r=�assert_traceback�%ImportTracebackTests.assert_traceback~s����
���;�;�%�%�D��!�!�B� �B��*;�$;��$�$�R�(����B��b�	
����]�+�S��Z��G��=�0�G�B��M�M�#�"�1r?c��SSKnURS5 UR	W[
/5 g![anURnSnAN3SnAff=f)Nr�#ImportError should have been raised)�nonexistent_xyzzyr,r��
__traceback__r�r�)rhr�r�r�s    r=�test_nonexistent_module�,ImportTracebackTests.test_nonexistent_module�sF��	=�$�
�I�I�;�<����b�8�*�-��	�	!����B��	!�s�/�
A�A
�
Ac���URSS5 SSKnURS5 URW[S/5 g![anURnSnAN4SnAff=f)Nr�zimport nonexistent_xyzzyrr�r7)r�r�r,r�r�r�r��rhr�r�r�s    r=�test_nonexistent_module_nested�3ImportTracebackTests.test_nonexistent_module_nested�sZ�����5�"<�=�	=��
�I�I�;�<����b�8�X�"6�7��	�	!����B��	!���A�
A"�A�A"c���URSS5 SSKnURS5 URW[S/5 g![anURnSnAN4SnAff=f)Nr��1/0r�)ZeroDivisionError should have been raisedr7�r�r�r,rMr�r�r�r�s    r=�test_exec_failure�&ImportTracebackTests.test_exec_failure�sZ�����5�%�(�	C��
�I�I�A�B����b�8�X�"6�7��	!�	!����B��	!�r�c���URSS5 URSS5 SSKnURS5 URW[SS/5 g![anURnSnAN5SnAff=f)	Nr�z
import bar�barr�rr�r7�bar.pyr�r�s    r=�test_exec_failure_nested�-ImportTracebackTests.test_exec_failure_nested�sl�����5�,�/����5�%�(�	C��
�I�I�A�B����b�8�X�x�"@�A��	!�	!����B��	!�s�A�
A5�A0�0A5c���URSS5 SSKnURS5 URW[/5 g![anURnSnAN3SnAff=f)Nr�zinvalid syntax is invalidrz#SyntaxError should have been raised)r�r�r,�SyntaxErrorr�r�r�r�s    r=�test_syntax_error�&ImportTracebackTests.test_syntax_error�sW�����5�"=�>�	=��
�I�I�;�<����b�8�*�-��	�	!����B��	!�s�A�
A!�A�A!c�.�SnUR[U5 [RR	[
U5n[R"U5 [RR	US5n[USSS9nURU5 SSS5 [RR	US5n[USSS9nURU5 SSS5 [R"5 XW4$!,(df   Nk=f!,(df   N7=f)N�_parent_foorr�rrr�)r�rr�r�r�r!r�rrrSr�)rh�parentr�pkg_name�pkg_path�	init_pathrb�bar_paths        r=�_setup_broken_package�*ImportTracebackTests._setup_broken_package�s��� �������)��7�7�<�<���1��
������G�G�L�L��=�9�	�
�)�S�7�
3�q�
�G�G�F�O�4��7�7�<�<��(�3��
�(�C�'�
2�a�
�G�G�E�N�3��#�#�%��"�"�
4�
3��3�
2�s�>C5�D�5
D�
Dc���URSS5upSSKnURS5 URW[U/5 g![anURnSnAN4SnAff=f)Nr�r�rr��r��_parent_foo.barr,rMr�r�r��rhr�r�r�r�r�s      r=�test_broken_submodule�*ImportTracebackTests.test_broken_submodule�s_��"�8�8��U�C��	�	C�"�
�I�I�A�B����b�8�X�"6�7��	!�	!����B��	!���A�
A$�A�A$c���URSS5upSSKJn URS5 UR
W[U/5 g![anUR
nSnAN4SnAff=f)Nr�r�r�r�r��r�r�r�r,rMr�r�r��rhr�r�r�r�r�s      r=�test_broken_from�%ImportTracebackTests.test_broken_from�s^��"�8�8��U�C��	�	=�'�
�I�I�;�<����b�8�X�"6�7��	!�	!����B��	!���A�
A&�A!�!A&c���URSS5upSSKnURS5 URW[U/5 g![anURnSnAN4SnAff=f)Nr�r�rr�r�r�s      r=�test_broken_parent�'ImportTracebackTests.test_broken_parent�s_��"�8�8���C��	�	C�"�
�I�I�A�B����b�8�Y�"7�8��	!�	!����B��	!�r�c���URSS5upSSKJn URS5 UR
W[U/5 g![anUR
nSnAN4SnAff=f)Nr�r�rr�r�r�r�s      r=�test_broken_parent_from�,ImportTracebackTests.test_broken_parent_from�s_��"�8�8���C��	�	C�'�
�I�I�A�B����b�8�Y�"7�8��	!�	!����B��	!�r�c��URSS5 [RSnS[UR5;aURR
nOSnSnX1RlSSKnURS5 URW[S[/5 Uc
UR?gX!Rlg![anURnSnANYSnAff=f!Uc
UR?fX!Rlf=f)	Nr�r�ri�load_modulec��SS- g)NrKrrn)r�s r=rW�9ImportTracebackTests.test_import_bug.<locals>.exec_modules	���!�r?rr�z<frozen importlib)r�rXrY�vars�SourceLoaderrWr�r,rMr�r�r�)rhrS�old_exec_modulerWr�r�r�s       r=�test_import_bug�$ImportTracebackTests.test_import_bug�s���	
���5�"�%��K�K� <�=�	��D��!7�!7�8�8�'�4�4�@�@�O�"�O�	E�
�1<�"�"�.�
G���	�	�E�F��!�!�"�x�1D�h�&O�P��&��*�*�6�5D�&�&�2��%�
%��_�_���
%���&��*�*�6�5D�&�&�2�s6�C#�-C�1.C#�
C �
C�C#�C � C#�#"Dzneed TESTFN_UNENCODABLEc��[R"S[S5nUR[U5 USSn[R
"SSU-SS9 g)Nr��pass���r�zmod = __import__(%a)F)�
__isolated)r%rtr$r�rru)rh�pynameras   r=�test_unencodable_filename�.ImportTracebackTests.test_unencodable_filenamesM���*�*�2�/A�6�J�������'��c�r�{���&�&�t�-C�d�-J�27�	9r?)r�N)r])r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r4rKr$r�r�rnr?r=r�r�ks���#�
��
#�.�8�8�	B�.�
#�8�8�9�9��E��E�4���+�-F�G�9�H�9r?r�c��\rSrSrSrSrSrSrSrSr	Sr
S	rS
rSr
SrS
r\\R$"\SLS5S55rSrSrg)�CircularImportTestsizMSee the docstrings of the modules being imported for the purpose of the
test.c��[[RR55H,nUR	S5(dM[RU	M. g)zKMake sure no modules pre-exist in sys.modules which are being used to
test.z&test.test_import.data.circular_importsN)r�rXrY�keysr8)rh�keys  r=r��CircularImportTests.tearDown s<������(�(�*�+�C��~�~�F�G�G��K�K��$�,r?c�P�SSKng![a URS5 gf=f)Nrz/circular import through relative imports failed)�,test.test_import.data.circular_imports.basicr�r,�rhrQs  r=�test_direct�CircularImportTests.test_direct's)��	I�?���	I��I�I�G�H�	I����%�%c�P�SSKng![a URS5 gf=f)Nrz@relative import in module contributing to circular import failed)�/test.test_import.data.circular_imports.indirectr�r,r�s  r=�
test_indirect�!CircularImportTests.test_indirect-s*��	'�B���	'��I�I�&�
'�	'�r�c�P�SSKng![a URS5 gf=f)Nrz-circular import involving a subpackage failed)�1test.test_import.data.circular_imports.subpackager�r,r�s  r=�test_subpackage�#CircularImportTests.test_subpackage4s)��	G�D���	G��I�I�E�F�	G�r�c��SSKJs Js Js Jn SSKJn URURWR5 g![
a UR
S5 NJf=f)Nrz9circular import with rebinding of module attribute failed)rT)
�0test.test_import.data.circular_imports.rebindingr9r��circular_imports�	rebindingr�r,�-test.test_import.data.circular_imports.subpkgrTrS)rhr�rTs   r=r��"CircularImportTests.test_rebinding:sJ��	S�P�P�	G��
�
�d�i�i����0���	S��I�I�Q�R�	S�s�>�A�Ac�P�SSKng![a URS5 gf=f)Nrz9circular import with binding a submodule to a name failed)�.test.test_import.data.circular_imports.bindingr�r,r�s  r=�test_binding� CircularImportTests.test_bindingBs)��	S�A���	S��I�I�Q�R�	S�r�c��SSKnSSKngr�)�*test.test_import.data.circular_imports.use�-test.test_import.data.circular_imports.sourcer�s  r=�test_crossreference1�(CircularImportTests.test_crossreference1Hs��9�<r?c�$�UR[5nSSKnSSS5 [WR5nURSU5 URSU5 URSU5 URSU5 g!,(df   Nl=f)Nrz-test.test_import.data.circular_imports.source�spamzpartially initialized modulezcircular import)r�r�rr/r�r	)rhr�rQ�errmsgs    r=�test_crossreference2�(CircularImportTests.test_crossreference2Lsl��
�
�
�~�
.�"�@�/��R�\�\�"���
�
�E�v�N��
�
�f�f�%��
�
�4�f�=��
�
�'��0�
/�
.�s�B�
Bc��UR[5nSSKnSSS5 URS[	WR
55 g!,(df   N4=f)Nrz�cannot import name 'b' from partially initialized module 'test.test_import.data.circular_imports.from_cycle1' (most likely due to a circular import))r�r��2test.test_import.data.circular_imports.from_cycle1r	r/r��rhr�rQs   r=�test_circular_from_import�-CircularImportTests.test_circular_from_importUsB��
�
�
�{�
+�r�E�,��
�
�
5�
�����		
�,�
+���A	�	
Ac�l�UR[S5 SSKnSSS5 g!,(df   g=f)Nz�partially initialized module 'test.test_import.data.circular_imports.import_cycle' from '.*' has no attribute 'some_attribute' \(most likely due to a circular import\)r)rr��3test.test_import.data.circular_imports.import_cycler�s  r=�test_circular_import�(CircularImportTests.test_circular_import_s/��
�
#�
#��
d�
�

G�
�
�
�s�%�
3c��UR[5nSSKnSSS5 URS[	WR
55 g!,(df   N4=f)Nrz�cannot access submodule 'parent' of module 'test.test_import.data.circular_imports.subpkg2' (most likely due to a circular import))r�r��5test.test_import.data.circular_imports.subpkg2.parentr	r/r�r
s   r=� test_absolute_circular_submodule�4CircularImportTests.test_absolute_circular_submodulegsB��
�
�
�~�
.�"�H�/��
�
�
5�
�����		
�/�
.�r
Nrc���SnSn[X5 [Rn[XSS9nUR	UR
U5 UR
U[R5 UR
U[R5 UR
U[R5 UR
U[R5 SSS5 URU[R5 URU[R5 URWR5U5 [R"SURR5 g!,(df   N�=f)aRegression test for gh-123950

Import a single-phase-init module that imports itself
from the PyInit_* function (before it's added to sys.modules).
Manages its own cache (which is `static`, and so incompatible
with multiple interpreters or interpreter reset).
�_testsinglephase_circularz2test.test_import.data.circular_imports.singlephaseFrPN)r(rtr�r[r��helper_mod_namer	rXrYrrS�clear_static_varrwrxr2rB)rhra�helper_namerNr�s     r=�test_singlephase_circular�-CircularImportTests.test_singlephase_circularqs��+��J��
�T�
'�'�0�0�H�-�T�@E�G�C�
���S�0�0�+�>��M�M�$����,��M�M�+�s�{�{�3��M�M�$����,��M�M�+�s�{�{�3�(�	
����s�{�{�+�����c�k�k�2��
�
�c�*�*�,�c�2��)�)�*E�*-�,�,�*=�*=�	?�!(�
'�s�B7E�
E)c���UR[S5 UR[S5 SSKJs Js Jn UR
[5 SSKJn SSS5 UR[U5[5 UR[W5[5 UR[5 SUlSSS5 g!,(df   Nr=f!,(df   g=f)Nz test.test_import.data.unwritablez"test.test_import.data.unwritable.xrr�*)r�r� test.test_import.data.unwritabler9r��
unwritable�assertWarns�
ImportWarningrV�assertNotEqualr1r)r�r�r�)rhr rVs   r=�test_unwritable_module�*CircularImportTests.test_unwritable_module�s������� B�C����� D�E�=�=�
�
�
�m�
,�:�-�	
���D��,�j�9�����a��*�-�
�
�
�~�
.��J�L�/�
.�-�
,��
/�
.�s�C�0C�
C�
C rn)r�r�r�r�r�r�r�r�r�r�r�rrrrrr�r4r�rtrr$r�rnr?r=r�r�sv��
�%�I�'�G�1�S�=�1�
�G�
��
�_�_�%��-�/V�W�?�X��?�:r?r�c��\rSrSr\"SSSSS9r\"SSS9r\R5VVVs0sHupX(+_M snnnrS\S'\	R"\"\S	5S
5S5r
S$S
jrS%SSSS.SjjrS%SSS.SjjrS%SS.SjjrSSS.SjrSS.Sjr\	R("\SLS5S5r\\	R("\SLS5S55r\S5r\	R("\SLS5S5r\	R("\SLS5S5r\	R("\SLS5S5r\	R("\SLS5S5r\S5r \	R("\SLS5S 5r!\"\S!55r#\"S"5r$S#r%gs snnnf)&�SubinterpImportTestsi�FT)�
allow_fork�
allow_exec�
allow_threads�allow_daemon_threadsr�)�use_main_obmalloc�gilrKr-r�zrequires os.pipe()c��[R"5upUR[RU5 UR[RU5 [	[S5(a[R
"US5 X4$)N�set_blockingF)r�r�r�r�r�r/)rhr�r�s   r=r��SubinterpImportTests.pipe�sU���w�w�y���������!�$�������!�$��2�~�&�&��O�O�A�u�%��v�
r?Nc���SnUbSUS3nU(a?[(aSnOSn[R"SUSUSUS	U<S
U<SU<SUS
35$[R"SUSUSUS
35$)Nr�zZ
                import _imp
                _imp._override_multi_interp_extensions_check(�)
                rrz
                from importlib.util import spec_from_loader, module_from_spec
                from importlib.machinery import z0
                import os, sys
                z
                loader = �(z, z*)
                spec = spec_from_loader(a4, loader)
                try:
                    module = module_from_spec(spec)
                    loader.exec_module(module)
                except ImportError as exc:
                    text = 'ImportError: ' + str(exc)
                else:
                    text = 'okay'
                os.write(z(, text.encode('utf-8'))
                z1
                try:
                    import z�
                except ImportError as exc:
                    text = 'ImportError: ' + str(exc)
                else:
                    text = 'okay'
                os.write()rr�r�)rhra�fdrN�check_override�
override_textr3s       r=�
import_script�"SubinterpImportTests.import_script�s����
��%�!>�>L�=M�N��M����/��.���?�?�(1�17��9��� � ���4�(�"�X�L�9)�)-��1����$��
�"�?�?�(��� � �6�"�
���
$�
�

r?)�check_singlephase_setting�check_singlephase_override�isolatedc�<�[U5 [S0URDU(aUROURDSU0D6nUR5upxUR
XUU5n	[U	40UD6n
URU
S5 [R"US5$)a#
Try importing the named module in a subinterpreter.

The subinterpreter will be in the current process.
The module will have already been imported in the main interpreter.
Thus, for extension/builtin modules, the module definition will
have been loaded already and cached globally.

"check_singlephase_setting" determines whether or not
the interpreter will be configured to check for modules
that are not compatible with use in multiple interpreters.

This should always return "okay" for all modules if the
setting is False (with no override).
�check_multi_interp_extensionsr�drn)r0r��
RUN_KWARGS�ISOLATED�NOT_ISOLATEDr�r7rr�r�r�)rhrarNr9r:r;�kwargsr�r�r�r�s           r=�run_here�SubinterpImportTests.run_here�s���(	�4���
��o�o�
� (�t�}�}�d�.?�.?�
�+D�
���y�y�{����#�#�D�X�$>�@��+�6�<�V�<������a� ��w�w�q�#��r?��strictr;c�J�URXUUS9nURUS5 g)N�r9r;�okay�rCr�)rhrarNrFr;�outs      r=�check_compatible_here�*SubinterpImportTests.check_compatible_here	s1���m�m�D�6<�%-����	
����g�&r?�r;c�p�URXSUS9nURURS5SUS35 g)NTrHr�ImportError: module �, does not support loading in subinterpreters)rCr�r�)rhrarNr;rKs     r=�check_incompatible_here�,SubinterpImportTests.check_incompatible_here	sH���m�m�D�6:�%-����	
����J�J�w��"�4�&�(T�U�	
r?c��[S0URDU(aUROURDSU0D6nUSnUS:XaSOUS:XaSO	US:XaSOUUS'[R
"S	[R"S
U<SU<SU<S
USURUS5<S355upgnURUS5 URUS5 g)Nr=r-r�defaultrK�sharedr��ownr�zP
            import _testinternalcapi, sys
            assert (
                z0 in sys.builtin_module_names or
                z( not in sys.modules
            ), repr(z2)
            config = type(sys.implementation)(**�T)
            ret = _testinternalcapi.run_in_subinterp_with_config(
                �sys.stdout.fileno()�U,
                config,
            )
            assert ret == 0, ret
            r?rIrn)
r�r?r@rAr%rur�r�r7r�)	rhrarFr;rBr-r�rKr<s	         r=�check_compatible_fresh�+SubinterpImportTests.check_compatible_fresh 	s���
�
��o�o�
� (�t�}�}�d�.?�.?�
�+1�
��
�U�m��%(�A�X�	��q��H�s�a�x�e�S�	�u�
�#�4�4�T�8�?�?�P��������H�1�17��9��#�#�D�*?�@�C�D
�L�<�����	
����c�"�����g�&r?c���[S0URDU(aUROURDSS0D6nUSnUS:XaSOUS:XaSO	US:XaS	OUUS'[R
"S
[R"SU<SU<S
USURUS5<S3	55upVnURUS5 URURS5SUS35 g)Nr=Tr-rrUrKrVr�rWr�z>
            import _testinternalcapi, sys
            assert z not in sys.modules, z1
            config = type(sys.implementation)(**rXrYrZr?rrPrQrn)r�r?r@rAr%rur�r�r7r�r�)rhrar;rBr-r�rKr<s        r=�check_incompatible_fresh�-SubinterpImportTests.check_incompatible_fresh=	s���
��o�o�
� (�t�}�}�d�.?�.?�
�+/�
��
�U�m��%(�A�X�	��q��H�s�a�x�e�S�	�u�
�#�4�4�T�8�?�?�P��8�0���91�17��9��#�#�D�*?�@�C�D
�	L�	<�	����	
����c�"�����J�J�w��"�4�&�(T�U�	
r?�requires _testinternalcapic�,�Sn[U5 [(d-URUS35 URUSS9 SSS5 URUS35 URUSS9 SSS5 g!,(df   N<=f!,(df   g=f)Nr��: not strictF�rF�: strict, not freshT)rDrrrL�rhr7s  r=�test_builtin_compat�(SubinterpImportTests.test_builtin_compatY	s����������������5�6��*�*�6�%�*�@�7�
�\�\�V�H�$7�8�
9��&�&�v�d�&�;�:�
9�7�6��
9�
9�s�A4�B�4
B�
Bc��Sn[USS9 [U5RRS:wa[R
"US35e[(d-URUS35 URUSS9 SSS5 URUS	35 URUSS9 SSS5 g!,(df   N<=f!,(df   g=f)
Nr`Tr@r-z is unexpectedly not frozenrbFrcrd)	rIr0r2rBr4r5rrrLres  r=�test_frozen_compat�'SubinterpImportTests.test_frozen_compate	s���%���v�D�)��f��&�&�-�-��9��#�#�v�h�.I�$J�K�K���������5�6��*�*�6�%�*�@�7�
�\�\�V�H�$7�8�
9��&�&�v�d�&�;�:�
9�7�6��
9�
9�s�(B/�C�/
B=�
Cc��Sn[U5 URUS35 URUSS9 SSS5 URUS35 URU5 SSS5 URUS35 UR	U5 SSS5 URUS35 UR	USS	9 SSS5 g!,(df   N�=f!,(df   N{=f!,(df   N^=f!,(df   g=f)
NrtrbFrcrd�: strict, freshz: isolated, freshTrN)rGrrLrRr^res  r=�!test_single_init_extension_compat�6SubinterpImportTests.test_single_init_extension_compatr	s���#���&�!�
�\�\�V�H�L�1�
2��&�&�v�e�&�<�3�
�\�\�V�H�$7�8�
9��(�(��0�:�
�\�\�V�H�O�4�
5��)�)�&�1�6�
�\�\�V�H�$5�6�
7��)�)�&�4�)�@�8�
7�
3�
2��
9�
9��
5�
5��
7�
7�s/�C�C�=C'�+C8�
C�
C$�'
C5�8
Dz$test requires _testmultiphase modulec��Sn[U5 [(d-URUS35 URUSS9 SSS5 URUS35 URUSS9 SSS5 URUS35 UR	USS9 SSS5 g!,(df   Ni=f!,(df   NM=f!,(df   g=f)N�_testmultiphaserbFrcrdTrl)rGrrrLr[res  r=� test_multi_init_extension_compat�5SubinterpImportTests.test_multi_init_extension_compat	s���#���&�!���������5�6��*�*�6�%�*�@�7�
�\�\�V�H�$7�8�
9��&�&�v�d�&�;�:�
�\�\�V�H�O�4�
5��'�'��t�'�<�6�
5�	7�6��
9�
9��
5�
5��#�B!�B2�C�!
B/�2
C�
Cc���Sn[Rn[X5n[U5 UR	US35 URXSS9 SSS5 UR	US35 URXSS9 SSS5 [(d.UR	US35 URXSS9 SSS5 gg!,(df   Nu=f!,(df   NY=f!,(df   g=f)	N�_test_non_isolatedz
: isolatedTrNz: not isolatedFrbrc)rpr�r[rGrrRrrL�rhrMrNr7s    r=�-test_multi_init_extension_non_isolated_compat�BSubinterpImportTests.test_multi_init_extension_non_isolated_compat�	s���'��"�+�+��+�G�>���&�!�
�\�\�W�I�Z�0�
1��(�(��T�(�J�2�
�\�\�W�I�^�4�
5��(�(��U�(�K�6�������	��6�7��*�*�7�U�*�K�8�7��	2�
1��
5�
5��8�7�s#�B=�*C�"C�=
C�
C�
C-c
�F�SH�nURUS9 [Rn[X5n[	U5 URUS35 URXSS9 SSS5 URUS35 UR
XSSS9 SSS5 [(d.URUS	35 UR
XSSS9 SSS5 SSS5 M� g!,(df   N�=f!,(df   Ne=f!,(df   N==f!,(df   GM=f)
N)�_test_shared_gil_only�"_test_no_multiple_interpreter_slot)rMz: isolated, strictTrNz: not isolated, strictFrEz: not isolated, not strict)rrpr�r[rGrRrLrrvs    r=�4test_multi_init_extension_per_interpreter_gil_compat�ISubinterpImportTests.test_multi_init_extension_per_interpreter_gil_compat�	s��>�G����g��.�*�3�3��3�G�F��!�&�)��\�\�W�I�-?�"@�A��0�0��:>�1�@�B��\�\�W�I�-C�"D�E��.�.�w�6:�U�/�L�F�'������	�1K�&L�M��2�2�#�e�e�3�M�N�/�.�>�B�A��F�E��N�M��/�.�sS�;D�C�!D�=C.�'D�6C?�D�
C+�'D�.
C<�8D�?
D
�	D�
D 	c��Sn[U5 [(d-URUS35 URUSS9 SSS5 URUS35 URUSS9 SSS5 URUS35 UR	USS9 SSS5 g!,(df   Ni=f!,(df   NM=f!,(df   g=f)Nr�rbFrcrdTrl)rKrrrLr[res  r=�test_python_compat�'SubinterpImportTests.test_python_compat�	s������F�#���������5�6��*�*�6�%�*�@�7�
�\�\�V�H�$7�8�
9��&�&�v�d�&�;�:�
�\�\�V�H�O�4�
5��'�'��t�'�<�6�
5�	7�6��
9�
9��
5�
5�rsc�^^�Sm[T5 UU4SjnUU4SjnTRS5 U"SS5 SSS5 TRS5 U"SS5 SSS5 TRS	5 U"SS
5 SSS5 TRS5 U"SS5 SSS5 TRS
5 U"SS5 SSS5 TRS5 U"SS
5 SSS5 g!,(df   N�=f!,(df   N�=f!,(df   N�=f!,(df   N�=f!,(df   Nv=f!,(df   g=f)Nrtc�L>�TRTUUS9nTRUS5 g�N)r9r:rIrJ��setting�overriderKr7rhs   ��r=�check_compatible�_SubinterpImportTests.test_singlephase_check_with_setting_and_override.<locals>.check_compatible�	s1����-�-��*1�+3� ��C�

���S�'�*r?c�L>�TRTUUS9nTRUS5 gr�)rCr#r�s   ��r=�check_incompatible�aSubinterpImportTests.test_singlephase_check_with_setting_and_override.<locals>.check_incompatible�	s1����-�-��*1�+3� ��C�

����W�-r?z(config: check enabled; override: enabledTrKz+config: check enabled; override: use configrz)config: check enabled; override: disabledr=z)config: check disabled; override: enabledFz,config: check disabled; override: use configz*config: check disabled; override: disabled)rGr)rhr�r�r7s`  @r=�0test_singlephase_check_with_setting_and_override�ESubinterpImportTests.test_singlephase_check_with_setting_and_override�	s����#���&�!�	+�	.��\�\�D�
E��t�Q�'�F�
�\�\�G�
H��t�Q�'�I�
�\�\�E�
F��T�2�&�G��\�\�E�
F��u�a�(�G�
�\�\�H�
I��U�A�&�J�
�\�\�F�
G��U�B�'�H�
G�F�
E��
H�
H��
F�
F��G�
F��
I�
I��
G�
G�sG�
C1�
D�5
D�
D$�;
D5�
E�1
C?�
D�
D!�$
D2�5
E�
Ec��Sn[U5 URUS35 URUSSS9 SSS5 URUS35 URUSSS9 SSS5 g!,(df   N==f!,(df   g=f)Nr�rdTrErl)rKrrLr[res  r=�test_isolated_config�)SubinterpImportTests.test_isolated_config�	s}�����F�#�
�\�\�V�H�$7�8�
9��&�&�v�d�T�&�J�:�
�\�\�V�H�O�4�
5��'�'��t�d�'�K�6�
5�:�
9��
5�
5�s�A+�A<�+
A9�<
B
c�*^�[R"S5n[R"5mUR	U4Sj5 [R
"TU5nUR
US5 [R
"TU5nUR
US5 g)NzU
            import _testsinglephase
            print(_testsinglephase)
            c�0>�[R"T5$rF)r��destroy�r�s�r=r�?SubinterpImportTests.test_disallowed_reimport.<locals>.<lambda>�	s���
� 5� 5�h� ?r?)r�r�r��creater�r��assertIsNot)rhr��excsnapr�s   @r=�test_disallowed_reimport�-SubinterpImportTests.test_disallowed_reimport�	sy������"���!�'�'�)�����?�@��*�*�8�V�<������$�'��*�*�8�V�<������$�'r?c��SSKnURnSU<S3n[R"5n[	5n[R
"XC5nURnSSS5 [R"U5 URW5 URURRS5 URURS5 URW5 URUR[5 UR[!UR"5S5 g!,(df   N�=f![R"U5 f=f)Nrz�if True:
        from test.test_import import import_extension_from_file

        import_extension_from_file('_testsinglephase_raise_exception', r�r�z5failed to import from subinterpreter due to exception�evil)rtr�r�r�rr��
unraisabler�r
r1r�r�rS�exc_type�RuntimeErrorr�r/�	exc_value)rhrtrNr��interpr�r�r�s        r=�%test_pyinit_function_raises_exception�:SubinterpImportTests.test_pyinit_function_raises_exception
s��	 �#�,�,��H�IQ�|�ST�X��
�%�%�'��	*�+�-��)�4�4�V�D�	��]�]�
�.�
�!�!�&�)����Y�'����Y�^�^�4�4�m�D����Y�]�]�,c�d����Z�(��
�
�j�)�)�<�8�����Z�1�1�2�F�;�.�-��
�!�!�&�)�s"�
D4�#D#�D4�#
D1�-D4�4Ern)NNrF)&r�r�r�r�r�r?r@�itemsrAr4rKr�r�r�r7rCrLrRr[r^r�rwrfrrir�rmrprqrwr|rr�r�r�r�r�r�)�.0r��vs000r=r'r'�sJ������"�	�J���
��H�*2���)9�:�)9���A�u�H�)9�:�L��L���
�����V�,�.B�C��D��*�X"�+0�,0��"�H
'�%*�',�
'�
�u�
�6;�U�'�::?�
�8�_�_�&�$�.�0L�M�	<�N�	<��
�_�_�&�$�.�0L�M�	<�N��	<��
A��
A��_�_�_��,�.T�U�=�V�=��_�_�_��,�.T�U�L�V�L� �_�_�_��,�.T�U�M�V�M�6�_�_�&�$�.�0L�M�	=�N�	=�� (�� (�D�_�_�&�$�.�0L�M�L�N�L���
(���
(��<��<��s
;s�Fr'c�^�\rSrSrSr\U4Sj5r\R\	R"S5R5-r\U4Sj5rSr
U=r$)�TestSinglePhaseSnapshoti
a�A representation of a single-phase init module for testing.

Fields from ModuleSnapshot:

* id - id(mod)
* module - mod or a SimpleNamespace with __file__ & __spec__
* ns - a shallow copy of mod.__dict__
* ns_id - id(mod.__dict__)
* cached - sys.modules[name] (or None if not there or not snapshotable)
* cached_id - id(sys.modules[name]) (or None if not there)

Extra fields:

* summed - the result of calling "mod.sum(1, 2)"
* lookedup - the result of calling "mod.look_up_self()"
* lookedup_id - the object ID of self.lookedup
* state_initialized - the result of calling "mod.state_initialized()"
* init_count - (optional) the result of calling "mod.initialized_count()"

Overridden methods from ModuleSnapshot:

* from_module()
* parse()

Other methods from ModuleSnapshot:

* build_script()
* from_subinterp()

----

There are 5 modules in Modules/_testsinglephase.c:

* _testsinglephase
   * has global state
   * extra loads skip the init function, copy def.m_base.m_copy
   * counts calls to init function
* _testsinglephase_basic_wrapper
   * _testsinglephase by another name (and separate init function symbol)
* _testsinglephase_basic_copy
   * same as _testsinglephase but with own def (and init func)
* _testsinglephase_with_reinit
   * has no global or module state
   * mod.state_initialized returns None
   * an extra load in the main interpreter calls the cached init func
   * an extra load in legacy subinterpreters does a full load
* _testsinglephase_with_state
   * has module state
   * an extra load in the main interpreter calls the cached init func
   * an extra load in legacy subinterpreters does a full load

(See Modules/_testsinglephase.c for more info.)

For all those modules, the snapshot after the initial load (not in
the global extensions cache) would look like the following:

* initial load
   * id: ID of nww module object
   * ns: exactly what the module init put there
   * ns_id: ID of new module's __dict__
   * cached_id: same as self.id
   * summed: 3  (never changes)
   * lookedup_id: same as self.id
   * state_initialized: a timestamp between the time of the load
     and the time of the snapshot
   * init_count: 1  (None for _testsinglephase_with_reinit)

For the other scenarios it varies.

For the _testsinglephase, _testsinglephase_basic_wrapper, and
_testsinglephase_basic_copy modules, the snapshot should look
like the following:

* reloaded
   * id: no change
   * ns: matches what the module init function put there,
     including the IDs of all contained objects,
     plus any extra attributes added before the reload
   * ns_id: no change
   * cached_id: no change
   * lookedup_id: no change
   * state_initialized: no change
   * init_count: no change
* already loaded
   * (same as initial load except for ns and state_initialized)
   * ns: matches the initial load, incl. IDs of contained objects
   * state_initialized: no change from initial load

For _testsinglephase_with_reinit:

* reloaded: same as initial load (old module & ns is discarded)
* already loaded: same as initial load (old module & ns is discarded)

For _testsinglephase_with_state:

* reloaded
   * (same as initial load (old module & ns is discarded),
     except init_count)
   * init_count: increase by 1
* already loaded: same as reloaded
c�(>�[TU]U5nURSS5UlUR	5Ul[
UR
5UlUR5Ul[US5(aUR5UlU$)NrKr��initialized_count)�superr��sum�summed�look_up_self�lookedupr��lookedup_id�state_initializedr�r��
init_count)r�r�rh�	__class__s   �r=r��#TestSinglePhaseSnapshot.from_module�
sx����w�"�3�'���g�g�a��m����(�(�*��
��d�m�m�,���!$�!6�!6�!8����3�+�,�,�!�3�3�5�D�O��r?a�
        snapshot['module'].update(dict(
            int_const=mod.int_const,
            str_const=mod.str_const,
            _module_initialized=mod._module_initialized,
        ))
        snapshot.update(dict(
            summed=mod.sum(1, 2),
            lookedup_id=id(mod.look_up_self()),
            state_initialized=mod.state_initialized(),
            init_count=mod.initialized_count(),
            has_spam=hasattr(mod, 'spam'),
            spam=getattr(mod, 'spam', None),
        ))
        c�P>�[TU]U5nUR(dU?U?U$rF)r�r��has_spamr)r�r�rhr�s   �r=r��TestSinglePhaseSnapshot.parse�
s'����w�}�T�"���}�}��	��M��r?)r�r�r�r�r�)r�r�r�r�r�r�r�r�r�r�r�r*r�r��
__classcell__)r�s@r=r�r�
s^���d�L����!�,�,�x���@�0
��V�X��K� ���r?r�c�B�\rSrSrSr\S5rSr\S5rSr	Sr
SrS	rS
r
S$SSS
.SjjrSrSrSrSrSrSrSrSrSrSrSrSr\R8"\SLS5S5r\"SS9\ S55r!\"S S9\ S!55r"\ S"5r#S#r$g)%�SinglephaseInitTestsi�
rtc��[RRUR5n[	UR
5Ul[(a�UR[LdeURUl
[URS-S5n[RR[RR[ R"5UR%5R'55UlSSS5 O7UR[*LdeURUl
URUlUR-5 g!,(df   N=f)Nz.originr�)rSrTr��NAMEr1r3�LOADERrrrB�ORIGINrr�r�r�r�rXr�r�r��FILEr�clean_up)r�rZrbs   r=�
setUpClass�SinglephaseInitTests.setUpClass�
s����~�~�'�'����1���$�+�+�&��
�
�?��:�:�!5�5�5�5����C�J��d�k�k�I�-�s�3�q��7�7�<�<��G�G�O�O�C�N�N�3��F�F�H�N�N�$����4�3��:�:�!4�4�4�4����C�J��{�{�C�H�	����4�3�s
�A-E�
Ec�$�UR5 grF)r�r�s r=r��SinglephaseInitTests.tearDown�
s���
�
�r?c���URnU[R;a�[[RUS5(a}[RURUR
:Xd1[RURSUR
35e[RUR
5 [RU	[R"XR5 g)Nrvz != )
r�rXrYr�r�r�rvrwrxr�)r�ras  r=r��SinglephaseInitTests.clean_up�
s����x�x���3�;�;���s�{�{�4�(�*:�;�;��{�{�4�(�1�1�S�X�X�=�B��{�{�4�(�1�1�2�$�s�x�x�j�A�B�=����D�!�0�0�2����D�!��)�)�$�
�
�;r?c�8^^�UU4SjnTRU5 g)Nc�H>�[R"TTR5 grF)rwrxr�)rarhs��r=r��9SinglephaseInitTests.add_module_cleanup.<locals>.clean_up�
s����-�-�d�D�K�K�@r?)r�)rhrar�s`` r=�add_module_cleanup�'SinglephaseInitTests.add_module_cleanup�
s���	A�	
����!r?c�|�SSKJn URX5n[RRXUS9nU"U5$)z
Load an extension module.
r)�_load)r3)�importlib._bootstrapr�r�rSrT�spec_from_file_location)rhrar�r�r3rZs      r=�
_load_dynamic�"SinglephaseInitTests._load_dynamic�
s@��
	/����T�(���~�~�5�5�d�=C�6�E���T�{�r?c�(�URnX;deURXR5nUR	X2R55 X2U'[R"UU[RU5S9$![a 0=o lN�f=f�N�rar7�snapshot)
�already_loadedr�r�r�r�valuesr�r�r�r�)rhrar�r�s    r=r��SinglephaseInitTests.load�
s���	6�!�0�0�N��)�)�)�� � ��{�{�3������3�3�5�6�"�t���$�$���,�8�8��=�
�	
��
�	6�35�5�N�0�	6�s�A<�<B�Bc���[RUULdeURUR:XdeURXR5n[
R"UU[RU5S9$r�)	rXrYr�r�r�r�r�r�r�)rhrar��reloadeds    r=�re_load�SinglephaseInitTests.re_load�
sj���{�{�4� �C�'�'�'��|�|�s�|�|�+�+�+��%�%�d�K�K�8���$�$���,�8�8��B�
�	
r?c��^^�[R"S5mU4SjnTRU5 [R"T[R
"S55 UU4SjnTRU5 T$)N�legacyc�h>�[R"T5 g![Ra gf=frF)r�r��InterpreterNotFoundErrorr�s�r=�ensure_destroyed�ASinglephaseInitTests.add_subinterpreter.<locals>.ensure_destroyed
s.���
��%�%�h�/�� �9�9�
��
�s��1�1zI
            import sys
            import _testinternalcapi
            c
��>�[R"T[R"STR<STR
<S355 [R"T5 g)Nz
                name = z�
                if name in sys.modules:
                    sys.modules.pop(name)._clear_globals()
                _testinternalcapi.clear_extension(name, r2)r�rr�r�r�r�r�)r�rhs��r=r��9SinglephaseInitTests.add_subinterpreter.<locals>.clean_upsW������x����>��	�	�}�%9�:>����H�	:�*�
�
�!�!�(�+r?)r�r�r�rr�r�)rhr�r�r�s`  @r=�add_subinterpreter�'SinglephaseInitTests.add_subinterpreters_��� �'�'��1��	�
	
���(�)����8�X�_�_�6�&�	�	,�	
����!��r?NF�r�r�c	��URnU(aUcSOSnSUSUR<S3nURn[RUUUSUUS9n	[R"USU	S9$![ab [R
"5=upx=o`lUR
[RU5 UR
[RU5 N�f=f)	Nzimport _testinternalcapir�z
                z^
                mod._clear_globals()
                _testinternalcapi.clear_extension(name, r2T)r�r�r�r�r�)r�r��_piper�r�r�r�r�r�r�r�r�)
rhr�r�r�ra�import_r�r�r�r�s
          r=�import_in_subinterp�(SinglephaseInitTests.import_in_subinterp"s����y�y���4<�4D�0�"�G���	�9�9=����H��K�	)��:�:�D�+�9�9�����!�#�
:�
���$�$����
�	
���	)�')�w�w�y�0�D�A�0�4�*��O�O�B�H�H�a�(��O�O�B�H�H�a�(�	)�s�A*�*A)C�Cc��SnURnU(dSnURRnURURRUR5 URUR
UR5 URURRUR5 U(d URUR[5 URURS5 URURS5 URUR[ 5 UR#URS5 URnURUR$S5 UR&b<URUR&[ 5 UR#UR&S5 U(awURUR(UR*5 URUR,UR*5 UR/[05 UR2 SSS5 gUR5UR6U5 UR5UR8U5 g!,(df   g=f)NFTi�zsomething differentrrL)r7r�r�r2rar�r�rBr��assertIsSubclassrr6�	int_const�	str_const�assertIsInstance�_module_initialized�float�
assertGreaterr�r�r�r�r�r�r�rrSr�r�)rh�loadedr;r��snaps     r=�check_common�!SinglephaseInitTests.check_commonHs������m�m����H��/�/�(�(�C�������*�*�F�K�K�8�������t�y�y�1�������,�,�d�k�k�:���!�!�#�)�)�Y�7��������-�������(=�>����c�5�5�u�=����3�2�2�A�6�����������a�(��!�!�-��!�!�$�"8�"8�%�@����t�5�5�q�9��
���T�-�-�t�w�w�7����T�^�^�T�W�W�5��"�"�>�2��	�	�3�2�
�M�M�$�-�-��-��M�M�$�+�+�s�+�	3�2�s�(
I7�7
Jc���URURRUR5 UR	UR
RUR5 grF)r�r7r�rarSr�r��rhr�s  r=�check_direct�!SinglephaseInitTests.check_directks<��������/�/����=��
�
�f�o�o�.�.��
�
�>r?c��X!RLdeURUR:wdeURURRUR5 UR	UR
RUR5 grF)r7r�rar#rSr�r�)rhr��origs   r=�check_indirect�#SinglephaseInitTests.check_indirectpsb���=�=�(�(�(��}�}����+�+�+����F�M�M�2�2�F�K�K�@��
�
�f�o�o�.�.��
�
�>r?c��URnURURS5 URUR[
5 UR
URS5 URURU5 gr�)r�r�r�r�r��intr�r�)rhr��expected_init_countr�s    r=�check_basic� SinglephaseInitTests.check_basicws`����������/�/��6����d�o�o�s�3����4�?�?�A�.�������*=�>r?c��grFrnr�s  r=�check_with_reinit�&SinglephaseInitTests.check_with_reinit�s��	
r?c��URnURURS5 URURRUR
5 g)zE
The module had not been loaded before (at least since fully reset).
rKN)r�r�r�r7r�r�)rhr�r�s   r=�check_fresh� SinglephaseInitTests.check_fresh�sH������
	
������!�,�	
������8�8��/�/�	1r?c�b�URnURURURR5 URURURR5 URURURRS-5 URUR
RUR5 URURURR5 URURURR5 g)zX
The module had been loaded before and then reset
(but the module global state wasn't).
rKN�r�r#r�r�r�r7r�r�)rhr�ri�prevr�s     r=�check_semi_fresh�%SinglephaseInitTests.check_semi_fresh�s���
����
	
���D�G�G�T�]�]�%5�%5�6����D�G�G�T�]�]�%5�%5�6�������$�-�-�*B�*B�Q�*F�G�	
������8�8��/�/�	1����D�2�2� �M�M�;�;�	=����D�2�2� �M�M�;�;�	=r?c��URnURURURR5 URURURR5 URUR
RUR5 URURURR5 g)z4
The module had been loaded before and never reset.
Nr
)rhr�rir�s    r=�check_copied�!SinglephaseInitTests.check_copied�s�������
	
���D�G�G�T�]�]�%5�%5�6�������$�-�-�*B�*B�C�	
������8�8��/�/�	1�����/�/����8�8�	:r?c�F�URUR5nURnUR"5nUR"5 UR"5nUR
"5nUR
US5 URUS5 URUS5 g)Nrr=)r�r�r7r�rvr�r�r�)rhr�rt�init_before�
init_afterr�s      r=�test_cleared_globals�)SinglephaseInitTests.test_cleared_globals�s������4�9�9�%��!�=�=��&�8�8�:���'�'�)�%�7�7�9�
�%�7�7�9�
����;��*�����Q�'�����R�(r?c���SUlURnSnURU5 URU5nUR	U5 URU5 UR
X25 SSS5 WRnURS3nURU5 US-
nURU5 URU5nUR	U5 URX45 UR
X25 URUR5UR5 URUR5U5 SSS5 URnURS3nURU5 US-
nURU5 URU5nUR	U5 URU5 UR
X25 URUR5U5 URUR5U5 SSS5 URS3nURU5 URU5 URU5nUR	U5 URURRS5 URU5 UR!U5 URUR5U5 URUR5U5 SSS5 URS3nURU5 URU5 URU5nUR#URR$5 UR	U5 UR'URRS5 URU5 UR!U5 URUR5U5 URUR5U5 SSS5 g!,(df   GN�=f!,(df   GN�=f!,(df   GN!=f!,(df   GNO=f!,(df   g=f)NrK�_basic_wrapper�_basic_copy�_with_reinit�_with_state)�maxDiffr�rr�r�r�rr7r�r�rSr�r�r�r�r�rr��_clear_module_stater�)rhrarr��basic�basic_lookedups      r=�
test_variants�"SinglephaseInitTests.test_variants�sw������y�y����
�\�\�$�
��Y�Y�t�_�F����f�%����f�%����V�9� ��
�
���)�)��N�+������%��q� ��
�\�\�$�
��Y�Y�t�_�F����f�%�����.����V�9�
�M�M�%�,�,�.��
�
�>����U�4�4�6�8K�L� � �����)�)��K�(������%��q� ��
�\�\�$�
��Y�Y�t�_�F����f�%����f�%����V�9�
�M�M�%�,�,�.��?����U�4�4�6�8K�L� ��)�)��L�)������%�
�\�\�$�
��Y�Y�t�_�F����f�%��M�M�&�/�/�;�;�T�B����f�%��"�"�6�*�
�M�M�%�,�,�.��?����U�4�4�6�8K�L� ��)�)��K�(������%�
�\�\�$�
��Y�Y�t�_�F��O�O�F�M�M�=�=�>����f�%����V�_�_�>�>��E����f�%��"�"�6�*�
�M�M�%�,�,�.��?����U�4�4�6�8K�L� �
� �
�� �
��& �
�� �
��  �
�s@�AP
�6BP�BP.�
B+Q�1CQ�

P�
P+�.
P=�
Q�
Q c��SUlURURS3URS34GH�nURU5 URU5 UR	U5nURXR5nURU5 URU5 UR[URR5URR5 URURRRURR5 URURRRUR5 URURR URRR 5 UR#URUR5 UR#URRURR5 UR#URR$URR$5 URURR&URR&5 URURR(URR(5 UR#URR*UR5 SSS5 GM� g!,(df   GM�=f)Nrr)rr�r�rr�r�r7r�r�r�r�r�r�r�r2rar�rSr�r�r�r�)rhrar�r�s    r=�test_basic_reloaded�(SinglephaseInitTests.test_basic_reloaded!s+�����
�I�I��y�y�k��(��y�y�k��%�
�D�

�#�#�D�)����d�#����4����<�<��m�m�<���!�!�&�)��!�!�(�+�� � ��F�M�M�$:�$:�!;�!'���!6�!6�8�� � ����!3�!3�!<�!<�!'���!7�!7�9�� � ����!9�!9�!>�!>��
�
�N�� � ����!9�!9�!)�!2�!2�!5�!5�!>�!>�@��
�
�h�o�o�v�}�}�=��
�
�h�o�o�6�6��
�
�8N�8N�O��
�
�h�/�/�8�8�$�o�o�6�6�8�� � ��!2�!2�!D�!D�!'���!B�!B�D�� � ��!2�!2�!=�!=�!'���!;�!;�=��
�
�h�/�/�6�6����H�;$�#�

�$�#�s
�JK7�7
L	c���SUlURUR5nURS3S4URS3S44GHup#URU5 UR	X#S9 URU5nU(a%URURR5 URX$R5nU(a%URURR5 URU5 URU5 UR[URR5URR5 URURRRURR5 URURR R"UR"5 URURR$URRR$5 UR'URUR5 UR)URRURR5 UR+URR,UR5 URR.c'UR+URR.S5 O:UR1URR.URR.5 UR+URR2UR5 SSS5 GM g!,(df   GM(=f)NrFrT)ra�	has_state)rr�r�r�rr�r7rr�r�r�r�r�r�r�r�r2rar�r�r#rSr�r�r�r�)rhr rar(r�r�s      r=�test_with_reinit_reloaded�.SinglephaseInitTests.test_with_reinit_reloadedKst������	�	�$�)�)�$���	�	�{�,�
'��/��	�	�{�+�
&��-� 
�O�D�
�#�#�D�)����4��=����4�����O�O�F�M�M�$E�$E�F��<�<��m�m�<����O�O�H�O�O�$G�$G�H��!�!�&�)��!�!�(�+�� � ��F�M�M�$:�$:�!;�!'���!6�!6�8�� � ����!3�!3�!<�!<�!'���!7�!7�9�� � ����!9�!9�!>�!>��
�
�N�� � ����!9�!9�!)�!2�!2�!5�!5�!>�!>�@�� � ����&�-�-�@��#�#�H�O�O�$<�$<�$*�M�M�$:�$:�<��
�
�h�/�/�8�8�(�/�/�J��?�?�4�4�<��M�M�(�"3�"3�"E�"E�t�L��&�&�x�'8�'8�'J�'J�'-���'H�'H�J��
�
�h�/�/�6�6����H�A>�=� 
�
>�=�s
�+K$M�
M-	r`c�~�SH�nURUS3nURU5 URX R5nUR	UR
U5 [RRUS5 [R"X R5 SSS5 M� g!,(df   M�=f)N)r�rr�_check_cache_first)r�rr�r�r�r�rXrYrurwrx)rh�variantrar�s    r=�test_check_state_first�+SinglephaseInitTests.test_check_state_firstys���:�G��i�i�[��	�);�<�D����d�#��(�(��{�{�;��� � ����t�4�������d�+�!�1�1�$���D�	$�#�;�#�#�s�A8B-�-
B<	z+module state is not cleared (see gh-140657))rkc��URUR5nURnSUlUR	U5 URU5 UR
5nUR
5nUR5nUR	U5 URXQ5 URU5nUR	U5 URXQ5 URU5nUR	U5 URXQ5 g)Nz&spam, spam, spam, spam, eggs, and spam)	r�r�r7rr�r
r�r�r)rh�main_loadedrt�	interpid1�	interpid2r�s      r=�.test_basic_multiple_interpreters_main_no_reset�CSinglephaseInitTests.test_basic_multiple_interpreters_main_no_reset�s����i�i��	�	�*��&�-�-�� H������+�&�����%��+�+�-�	��+�+�-�	��)�)�+�����&�!����&�.��)�)�)�4�����&�!����&�.��)�)�)�4�����&�!����&�.r?zArerun not possible; module state is never cleared (see gh-102251)c�t�[(a[R"S5eUR5nUR5nUR	UR
5nURR5 [R"UR
UR5 URSS9nURU5 URU5 URU5nURU5 URXT5 URU5nURU5 URXe5 g)Nzcrashes on Py_TRACE_REFS buildsz�
                # Attrs set after loading are not in m_copy.
                mod.spam = 'spam, spam, mash, spam, eggs, and spam'
                )r�)rr4r5r�r�r�r7rvrwrxr�r�r�r
r)rhr2r3�loaded_mainri�loaded_interp1�loaded_interp2s       r=�1test_basic_multiple_interpreters_deleted_no_reset�FSinglephaseInitTests.test_basic_multiple_interpreters_deleted_no_reset�s��
�=��#�#�$E�F�F��+�+�-�	��+�+�-�	��i�i��	�	�*�����)�)�+��)�)�$�)�)�T�[�[�A��'�'��(���
	
���$��������1�1�)�<�����.�)����.�/��1�1�)�<�����.�)����.�9r?c�p�UR5nUR5nURSSS9nURU5 URU5 URUSS9nURU5 URU5 URUSS9nURU5 URU5 g)Nz�
            # Attrs set after loading are not in m_copy.
            mod.spam = 'spam, spam, mash, spam, eggs, and spam'
            Tr�)r�)r�r�r�r
)rhr2r3r�s    r=�+test_basic_multiple_interpreters_reset_each�@SinglephaseInitTests.test_basic_multiple_interpreters_reset_each
s����+�+�-�	��+�+�-�	��)�)���*�
��	
���&�!����� ��)�)�)��)�F�����&�!����� ��)�)�)��)�F�����&�!����� r?)r�r�rrF)%r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrr
rrrr"r%r)r4r�rwr.rqr�r4r:r=r�rnr?r=r�r��
s)���D�����2��
<��
<�"��

�
��."
�'+�(-�"
�L!,�F?�
?�?�
�

1�=�,:�,)�RM�h(I�T,I�\�_�_�&�$�.�0L�M�E�N�E��B�C��:/��D�:/�F�X�Y��A:��Z�A:�T�0!��0!r?r��__main__)krr�r�r��importlib.utilrS�importlib._bootstrap_externalr�importlib.machineryrrrrrr�r�rAr*r�r�r�rXr�r�r�r�r4r	r�rRr
rrr
rrrrrrrrrrr�test.support.import_helperrrrrrrrr �test.support.os_helperr!r"r#r$r%r&�test.support.testcaser'�test.test_importlib.utilr(r)rtr�rpr�r�rwr��dont_write_bytecoderIr>rDrGrIrKrOr[rcrqryr�r�r�r��TestCaser�rMrur�r�r�r
rGr^rrr�r�r'r�r�r�rrnr?r=�<module>rIs:�������9����	��
�
���
��������"����� /�/�/�4�4�&�)�1�,����������
'�o�o����4�6��
�8%*�A�',�;�$(�?�).�4�6�IM����&��*:� �J�=�`(�U�*�*�`(�F �F)�(�#�#�_�F)� �F)�R�V/�(�+�+�V/��V/�rVM��)�)�VM�r3 ��"�"�O�3 �l^:�(�+�+�_�^:�B(�8�#4�#4�(�(_!�8�$�$�_!�D+3�H�$5�$5�+3�\�<�h�/�/��<��<�@�6��*�*�6��6�Bm9�8�,�,�m9�`@�(�+�+�@�F}<�8�,�,�}<�@H�n�H�V�a
!�8�,�,�o�a
!��a
!�V�z���M�M�O���uh���������O������M��������sH�J8�K�K�K%�8K�K�K�K�K"�!K"�%K1�0K1

Youez - 2016 - github.com/yon3zu
LinuXploit