U e5dÜšã@sÂdZdadd„Zdd„ZiZiZGdd„deƒZGdd „d ƒZGd d „d ƒZ Gd d „d ƒZ dd„Z dd„Z dd„Z ddœdd„Zdd„Zdd„Zdd„Zdd„ZGd d!„d!ƒZddd"œd#d$„Zd^d%d&„Zd'd(œd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Zd3d4„Zd5d6„ZGd7d8„d8ƒZGd9d:„d:ƒZGd;d<„d<ƒZd=d>„Z d?d@„Z!d_dAdB„Z"dCdD„Z#dEZ$e$dFZ%dGdH„Z&e'ƒZ(dIdJ„Z)d`dLdM„Z*d'dNœdOdP„Z+dQdR„Z,dadTdU„Z-dVdW„Z.dXdY„Z/dZd[„Z0d\d]„Z1dS)baSCore implementation of import. This module is NOT meant to be directly imported! It has been designed such that it can be bootstrapped into Python as the implementation of import. As such it requires the injection of specific modules and attributes in order to work. One should use importlib as the public-facing version of this module. NcCs8dD] }t||ƒrt||t||ƒƒq|j |j¡dS)z/Simple substitute for functools.update_wrapper.)Ú __module__Ú__name__Ú __qualname__Ú__doc__N)ÚhasattrÚsetattrÚgetattrÚ__dict__Úupdate)ÚnewÚoldÚreplace©r ú,/usr/lib64/python3.8/importlib/_bootstrap.pyÚ_wraps rcCs ttƒ|ƒS©N)ÚtypeÚsys©Únamer r rÚ _new_module#src@s eZdZdS)Ú_DeadlockErrorN)rrrr r r rr0src@s8eZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd S) Ú _ModuleLockz©A recursive lock implementation which is able to detect deadlocks (e.g. thread 1 trying to take locks A then B, and thread 2 trying to take locks B then A). cCs0t ¡|_t ¡|_||_d|_d|_d|_dS©Né)Ú_threadÚ allocate_lockÚlockÚwakeuprÚownerÚcountÚwaiters©Úselfrr r rÚ__init__:s   z_ModuleLock.__init__cCs<t ¡}|j}t |¡}|dkr$dS|j}||krdSqdS)NFT)rÚ get_identrÚ _blocking_onÚget)r"ÚmeÚtidrr r rÚ has_deadlockBs z_ModuleLock.has_deadlockc Cs²t ¡}|t|<z”|j�n|jdks.|j|krT||_|jd7_W5QR£W¢VdS| ¡rhtd|ƒ‚|j  d¡r‚|j d7_ W5QRX|j  ¡|j  ¡qW5t|=XdS)z¹ Acquire the module lock. If a potential deadlock is detected, a _DeadlockError is raised. Otherwise, the lock is always acquired and True is returned. réTzdeadlock detected by %rFN) rr$r%rrrr)rrÚacquirer Úrelease©r"r(r r rr+Ns   z_ModuleLock.acquirec Cslt ¡}|j�T|j|kr"tdƒ‚|jd8_|jdkr^d|_|jr^|jd8_|j ¡W5QRXdS)Núcannot release un-acquired lockr*r) rr$rrÚ RuntimeErrorrr rr,r-r r rr,gs  z_ModuleLock.releasecCsd |jt|ƒ¡S)Nz_ModuleLock({!r}) at {}©ÚformatrÚid©r"r r rÚ__repr__tsz_ModuleLock.__repr__N) rrrrr#r)r+r,r4r r r rr4s   rc@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú_DummyModuleLockzVA simple _ModuleLock equivalent for Python builds without multi-threading support.cCs||_d|_dSr)rrr!r r rr#|sz_DummyModuleLock.__init__cCs|jd7_dS)Nr*T)rr3r r rr+€sz_DummyModuleLock.acquirecCs$|jdkrtdƒ‚|jd8_dS)Nrr.r*)rr/r3r r rr,„s z_DummyModuleLock.releasecCsd |jt|ƒ¡S)Nz_DummyModuleLock({!r}) at {}r0r3r r rr4‰sz_DummyModuleLock.__repr__N)rrrrr#r+r,r4r r r rr5xs r5c@s$eZdZdd„Zdd„Zdd„ZdS)Ú_ModuleLockManagercCs||_d|_dSr)Ú_nameÚ_lockr!r r rr#�sz_ModuleLockManager.__init__cCst|jƒ|_|j ¡dSr)Ú_get_module_lockr7r8r+r3r r rÚ __enter__“s z_ModuleLockManager.__enter__cOs|j ¡dSr)r8r,)r"ÚargsÚkwargsr r rÚ__exit__—sz_ModuleLockManager.__exit__N)rrrr#r:r=r r r rr6�sr6cCs‚t ¡zjzt|ƒ}Wntk r0d}YnX|dkrptdkrLt|ƒ}nt|ƒ}|fdd„}t  ||¡t|<W5t ¡X|S)z‹Get or create the module lock for a given module name. Acquire/release internally the global import lock to protect _module_locks.NcSs0t ¡zt |¡|krt|=W5t ¡XdSr)Ú_impÚ acquire_lockÚ release_lockÚ _module_locksr&)Úrefrr r rÚcb°s  z_get_module_lock..cb) r>r?r@rAÚKeyErrorrr5rÚ_weakrefrB)rrrCr r rr9�s    r9cCs6t|ƒ}z | ¡Wntk r(Yn X| ¡dS)z½Acquires then releases the module lock for a given module name. This is used to ensure a module is completely initialized, in the event it is being imported by another thread. N)r9r+rr,)rrr r rÚ_lock_unlock_moduleÂs  rFcOs |||ŽS)a.remove_importlib_frames in import.c will always remove sequences of importlib frames that end with a call to this function Use it instead of a normal call in places where including the importlib frames introduces unwanted noise into the traceback (e.g. when executing module code) r )Úfr;Úkwdsr r rÚ_call_with_frames_removedÓsrIr*)Ú verbositycGs6tjj|kr2| d¡sd|}t|j|Žtjd�dS)z=Print the message to stderr if -v/PYTHONVERBOSE is turned on.)ú#zimport z# )ÚfileN)rÚflagsÚverboseÚ startswithÚprintr1Ústderr)ÚmessagerJr;r r rÚ_verbose_messageÞs  rScs‡fdd„}t|ˆƒ|S)z1Decorator to verify the named module is built-in.cs&|tjkrtd |¡|d�‚ˆ||ƒS)Nú{!r} is not a built-in moduler)rÚbuiltin_module_namesÚ ImportErrorr1©r"Úfullname©Úfxnr rÚ_requires_builtin_wrapperès   ÿz4_requires_builtin.._requires_builtin_wrapper©r)rZr[r rYrÚ_requires_builtinæs  r]cs‡fdd„}t|ˆƒ|S)z/Decorator to verify the named module is frozen.cs&t |¡std |¡|d�‚ˆ||ƒS©Nz{!r} is not a frozen moduler)r>Ú is_frozenrVr1rWrYr rÚ_requires_frozen_wrapperós   ÿz2_requires_frozen.._requires_frozen_wrapperr\)rZr`r rYrÚ_requires_frozenñs  racCs>t||ƒ}|tjkr2tj|}t||ƒtj|St|ƒSdS)z€Load the specified module into sys.modules and return it. This method is deprecated. Use loader.exec_module instead. N)Úspec_from_loaderrÚmodulesÚ_execÚ_load)r"rXÚspecÚmoduler r rÚ_load_module_shimýs      rhcCsât|ddƒ}t|dƒr8z | |¡WStk r6YnXz |j}Wntk rVYnX|dk rht|ƒSz |j}Wntk rŠd}YnXz |j}Wn:tk rÐ|dkr¼d  |¡YSd  ||¡YSYnXd  ||¡SdS)NÚ __loader__Ú module_reprú?ú úú) rrrjÚ ExceptionÚ__spec__ÚAttributeErrorÚ_module_repr_from_specrÚ__file__r1)rgÚloaderrfrÚfilenamer r rÚ _module_repr s.       rvc@sreZdZdZddddœdd„Zdd„Zdd „Zed d „ƒZej d d „ƒZed d„ƒZ edd„ƒZ e j dd„ƒZ dS)Ú ModuleSpecaÐThe specification for a module, used for loading. A module's spec is the source for information about the module. For data associated with the module, including source, use the spec's loader. `name` is the absolute name of the module. `loader` is the loader to use when loading the module. `parent` is the name of the package the module is in. The parent is derived from the name. `is_package` determines if the module is considered a package or not. On modules this is reflected by the `__path__` attribute. `origin` is the specific location used by the loader from which to load the module, if that information is available. When filename is set, origin will match. `has_location` indicates that a spec's "origin" reflects a location. When this is True, `__file__` attribute of the module is set. `cached` is the location of the cached bytecode file, if any. It corresponds to the `__cached__` attribute. `submodule_search_locations` is the sequence of path entries to search when importing submodules. If set, is_package should be True--and False otherwise. Packages are simply modules that (may) have submodules. If a spec has a non-None value in `submodule_search_locations`, the import system will consider modules loaded from the spec as packages. Only finders (see importlib.abc.MetaPathFinder and importlib.abc.PathEntryFinder) should modify ModuleSpec instances. N)ÚoriginÚ loader_stateÚ is_packagecCs6||_||_||_||_|r gnd|_d|_d|_dS©NF)rrtrxryÚsubmodule_search_locationsÚ _set_fileattrÚ_cached)r"rrtrxryrzr r rr#VszModuleSpec.__init__cCsfd |j¡d |j¡g}|jdk r4| d |j¡¡|jdk rP| d |j¡¡d |jjd |¡¡S)Nz name={!r}z loader={!r}z origin={!r}zsubmodule_search_locations={}z{}({})z, ) r1rrtrxÚappendr|Ú __class__rÚjoin)r"r;r r rr4bs  ÿ  ÿzModuleSpec.__repr__cCsj|j}zH|j|jkoL|j|jkoL|j|jkoL||jkoL|j|jkoL|j|jkWStk rdYdSXdSr{)r|rrtrxÚcachedÚ has_locationrq)r"ÚotherÚsmslr r rÚ__eq__ls  ÿ þý ü ûzModuleSpec.__eq__cCs:|jdkr4|jdk r4|jr4tdkr&t‚t |j¡|_|jSr)r~rxr}Ú_bootstrap_externalÚNotImplementedErrorÚ _get_cachedr3r r rr‚xs  zModuleSpec.cachedcCs ||_dSr)r~)r"r‚r r rr‚�scCs$|jdkr|j d¡dS|jSdS)z The name of the module's parent.NÚ.r)r|rÚ rpartitionr3r r rÚparent…s zModuleSpec.parentcCs|jSr)r}r3r r rrƒ�szModuleSpec.has_locationcCst|ƒ|_dSr)Úboolr})r"Úvaluer r rrƒ‘s) rrrrr#r4r†Úpropertyr‚ÚsetterrŒrƒr r r rrw1s $ÿ       rw©rxrzcCsšt|dƒrJtdkrt‚tj}|dkr0|||d�S|r8gnd}||||d�S|dkrŠt|dƒr†z| |¡}WqŠtk r‚d}YqŠXnd}t||||d�S)z5Return a module spec based on various loader methods.Ú get_filenameN)rt)rtr|rzFr‘)rr‡rˆÚspec_from_file_locationrzrVrw)rrtrxrzr“Úsearchr r rrb–s$   ÿ  rbcCs8z |j}Wntk rYnX|dk r,|S|j}|dkrZz |j}Wntk rXYnXz |j}Wntk r|d}YnX|dkr¸|dkr´z |j}Wq¸tk r°d}Yq¸Xn|}z |j}Wntk rÚd}YnXzt|jƒ}Wntk �rd}YnXt |||d�}|dk�r"dnd|_ ||_ ||_ |S)N©rxFT) rprqrrirsÚ_ORIGINÚ __cached__ÚlistÚ__path__rwr}r‚r|)rgrtrxrfrÚlocationr‚r|r r rÚ_spec_from_module°sH         r›F©ÚoverridecCsâ|st|ddƒdkr6z |j|_Wntk r4YnX|sJt|ddƒdkr²|j}|dkr’|jdk r’tdkrnt‚tj}|  |¡}|j|_ ||_d|_ z ||_ Wntk r°YnX|sÆt|ddƒdkrèz |j |_Wntk ræYnXz ||_Wntk �rYnX|�s"t|ddƒdk�rR|jdk �rRz |j|_Wntk �rPYnX|j�rÞ|�srt|ddƒdk�r–z |j|_ Wntk �r”YnX|�s®t|ddƒdk�rÞ|jdk �rÞz |j|_Wntk �rÜYnX|S)NrriÚ __package__r™rsr—)rrrrqrtr|r‡rˆÚ_NamespaceLoaderÚ__new__Ú_pathrsrirŒržrpr™rƒrxr‚r—)rfrgr�rtrŸr r rÚ_init_module_attrsÝs`            r¢cCsRd}t|jdƒr|j |¡}nt|jdƒr2tdƒ‚|dkrDt|jƒ}t||ƒ|S)z+Create a module based on the provided spec.NÚ create_moduleÚ exec_modulezBloaders that define exec_module() must also define create_module())rrtr£rVrrr¢©rfrgr r rÚmodule_from_spec%s    r¦cCsj|jdkrdn|j}|jdkrB|jdkr2d |¡Sd ||j¡Sn$|jrVd ||j¡Sd |j|j¡SdS)z&Return the repr to use for the module.Nrkrlrmrnú)rrxrtr1rƒ)rfrr r rrr6s   rrc CsÌ|j}t|ƒ�´tj |¡|k r6d |¡}t||d�‚zj|jdkrj|j dkrZtd|jd�‚t ||dd�n4t ||dd�t |jdƒs’|j  |¡n |j  |¡W5tj |j¡}|tj|j<XW5QRX|S)zFExecute the spec's specified module in an existing module's namespace.zmodule {!r} not in sys.modulesrNúmissing loaderTrœr¤)rr6rrcr&r1rVÚpoprtr|r¢rÚ load_moduler¤)rfrgrÚmsgr r rrdGs"      rdcCsz|j |j¡Wn4|jtjkr@tj |j¡}|tj|j<‚YnXtj |j¡}|tj|j<t|ddƒdkr”z |j|_Wntk r’YnXt|ddƒdkrâz(|j |_ t |dƒsÊ|j  d¡d|_ Wntk ràYnXt|ddƒdk�rz ||_ Wntk �rYnX|S)Nriržr™rŠrrp)rtrªrrrcr©rrirqrržrr‹rpr¥r r rÚ_load_backward_compatiblees6      r¬c CsÜ|jdk rt|jdƒst|ƒSt|ƒ}d|_z¢|tj|j<z4|jdkr`|jdkrlt d|jd�‚n |j  |¡Wn2ztj|j=Wnt k r˜YnX‚YnXtj  |j¡}|tj|j<t d|j|jƒW5d|_X|S)Nr¤TFr¨rzimport {!r} # {!r})rtrr¬r¦Ú _initializingrrcrr|rVr¤rDr©rSr¥r r rÚ_load_unlockedŠs.      r®c Cs*t|jƒ�t|ƒW5QR£SQRXdS)z¿Return a new module object, loaded by the spec's loader. The module is not added to its parent. If a module is already in sys.modules, that existing module gets clobbered. N)r6rr®)rfr r rre´s rec@sˆeZdZdZedd„ƒZeddd„ƒZeddd„ƒZed d „ƒZ ed d „ƒZ ee d d„ƒƒZ ee dd„ƒƒZ ee dd„ƒƒZeeƒZdS)ÚBuiltinImporterz�Meta path import for built-in modules. All methods are either class or static methods to avoid the need to instantiate the class. cCs d |j¡S)úsReturn repr for the module. The method is deprecated. The import machinery does the job itself. z)r1r)rgr r rrjÌszBuiltinImporter.module_reprNcCs,|dk r dSt |¡r$t||dd�SdSdS)Nzbuilt-inr•)r>Ú is_builtinrb©ÚclsrXÚpathÚtargetr r rÚ find_specÕs  zBuiltinImporter.find_speccCs| ||¡}|dk r|jSdS)z¯Find the built-in module. If 'path' is ever specified then the search is considered a failure. This method is deprecated. Use find_spec() instead. N)r¶rt)r³rXr´rfr r rÚ find_moduleÞs zBuiltinImporter.find_modulecCs.|jtjkr"td |j¡|jd�‚ttj|ƒS)zCreate a built-in modulerTr)rrrUrVr1rIr>Úcreate_builtin)r"rfr r rr£ês   ÿzBuiltinImporter.create_modulecCsttj|ƒdS)zExec a built-in moduleN)rIr>Ú exec_builtin)r"rgr r rr¤òszBuiltinImporter.exec_modulecCsdS)z9Return None as built-in modules do not have code objects.Nr ©r³rXr r rÚget_code÷szBuiltinImporter.get_codecCsdS)z8Return None as built-in modules do not have source code.Nr rºr r rÚ get_sourceýszBuiltinImporter.get_sourcecCsdS)z4Return False as built-in modules are never packages.Fr rºr r rrzszBuiltinImporter.is_package)NN)N)rrrrÚ staticmethodrjÚ classmethodr¶r·r£r¤r]r»r¼rzrhrªr r r rr¯Ãs*        r¯c@s�eZdZdZdZedd„ƒZeddd„ƒZeddd „ƒZ ed d „ƒZ ed d „ƒZ edd„ƒZ ee dd„ƒƒZee dd„ƒƒZee dd„ƒƒZdS)ÚFrozenImporterzŽMeta path import for frozen modules. All methods are either class or static methods to avoid the need to instantiate the class. ÚfrozencCsd |jtj¡S)r°r§)r1rr¿r–)Úmr r rrjszFrozenImporter.module_reprNcCs"t |¡rt|||jd�SdSdS)Nr•)r>r_rbr–r²r r rr¶ s zFrozenImporter.find_speccCst |¡r|SdS)z]Find a frozen module. This method is deprecated. Use find_spec() instead. N)r>r_)r³rXr´r r rr·'szFrozenImporter.find_modulecCsdS)z*Use default semantics for module creation.Nr )r³rfr r rr£0szFrozenImporter.create_modulecCs@|jj}t |¡s$td |¡|d�‚ttj|ƒ}t||j ƒdSr^) rprr>r_rVr1rIÚget_frozen_objectÚexecr)rgrÚcoder r rr¤4s  ÿ zFrozenImporter.exec_modulecCs t||ƒS)z_Load a frozen module. This method is deprecated. Use exec_module() instead. )rhrºr r rrª=szFrozenImporter.load_modulecCs t |¡S)z-Return the code object for the frozen module.)r>rÂrºr r rr»FszFrozenImporter.get_codecCsdS)z6Return None as frozen modules do not have source code.Nr rºr r rr¼LszFrozenImporter.get_sourcecCs t |¡S)z.Return True if the frozen module is a package.)r>Úis_frozen_packagerºr r rrzRszFrozenImporter.is_package)NN)N)rrrrr–r½rjr¾r¶r·r£r¤rªrar»r¼rzr r r rr¿ s.        r¿c@s eZdZdZdd„Zdd„ZdS)Ú_ImportLockContextz$Context manager for the import lock.cCs t ¡dS)zAcquire the import lock.N)r>r?r3r r rr:_sz_ImportLockContext.__enter__cCs t ¡dS)zr@)r"Úexc_typeÚ exc_valueÚ exc_tracebackr r rr=csz_ImportLockContext.__exit__N)rrrrr:r=r r r rrÆ[srÆcCs@| d|d¡}t|ƒ|kr$tdƒ‚|d}|r= 0z__package__ not set to a stringz6attempted relative import with no known parent packagezEmpty module nameN)Ú isinstanceÚstrÚ TypeErrorr1rrÍrV©rrÎrÏr r rÚ _sanity_check©s    rßzNo module named z{!r}cCsÜd}| d¡d}|r†|tjkr*t||ƒ|tjkr>tj|Stj|}z |j}Wn2tk r„td ||¡}t||d�d‚YnXt ||ƒ}|dkr¬tt |¡|d�‚nt |ƒ}|rØtj|}t || d¡d|ƒ|S)NrŠrz; {!r} is not a packageré) r‹rrcrIr™rqÚ_ERR_MSGr1ÚModuleNotFoundErrorrÚr®r)rÚimport_r´rŒÚ parent_moduler«rfrgr r rÚ_find_and_load_unlocked¼s*        råc Csjt|ƒ�2tj |t¡}|tkr6t||ƒW5QR£SW5QRX|dkr^d |¡}t||d�‚t|ƒ|S)zFind and load the module.Nz(import of {} halted; None in sys.modulesr) r6rrcr&Ú_NEEDS_LOADINGrår1rârF)rrãrgrRr r rÚ_find_and_loadÚs  ÿ rçrcCs*t|||ƒ|dkr t|||ƒ}t|tƒS)a2Import and return the module based on its name, the package the call is being made from, and the level adjustment. This function represents the greatest common denominator of functionality between import_module and __import__. This includes setting __package__ if the loader did not. r)rßrÒrçÚ _gcd_importrÞr r rrèês  rè©Ú recursivec Csâ|D]Ø}t|tƒsB|r"|jd}nd}td|›dt|ƒj›�ƒ‚q|dkrl|sÜt|dƒrÜt||j|dd�qt||ƒsd  |j|¡}zt ||ƒWqt k rÚ}z*|j |krÈt j  |t¡d k rÈWY¢q‚W5d }~XYqXq|S) zîFigure out what __import__ should return. The import_ parameter is a callable which takes the name of module to import. It is required to decouple the function from assuming importlib's import implementation is desired. z.__all__z ``from list''zItem in z must be str, not Ú*Ú__all__TrérÊN)rÛrÜrrÝrrÚ_handle_fromlistrìr1rIrârrrcr&ræ)rgÚfromlistrãrêÚxÚwhereÚ from_nameÚexcr r rríùs,    ÿ  ÿrícCs’| d¡}| d¡}|dk rR|dk rN||jkrNtjd|›d|j›d�tdd�|S|dk r`|jStjd tdd�|d }d |krŽ| d ¡d }|S)z§Calculate what __package__ should be. __package__ is not guaranteed to be defined or could be set to None to represent that its proper value is unknown. ržrpNz __package__ != __spec__.parent (z != ú)é)Ú stacklevelzYcan't resolve package from __spec__ or __package__, falling back on __name__ and __path__rr™rŠr)r&rŒrÖr×rØr‹)ÚglobalsrÎrfr r rÚ_calc___package__s&  þþr÷r c Cs´|dkrt|ƒ}n$|dk r|ni}t|ƒ}t|||ƒ}|s–|dkrTt| d¡dƒS|s\|St|ƒt| d¡dƒ}tj|jdt|jƒ|…Snt|dƒr¬t||tƒS|SdS)a×Import a module. The 'globals' argument is used to infer where the import is occurring from to handle relative imports. The 'locals' argument is ignored. The 'fromlist' argument specifies what should exist as attributes on the module being imported (e.g. ``from module import ``). The 'level' argument represents the package location to import from in a relative import (e.g. ``from ..pkg import mod`` would have a 'level' of 2). rNrŠr™) rèr÷Ú partitionrÌrrcrrrí) rröÚlocalsrîrÏrgÚglobals_rÎÚcut_offr r rÚ __import__9s      rücCs&t |¡}|dkrtd|ƒ‚t|ƒS)Nzno built-in module named )r¯r¶rVr®)rrfr r rÚ_builtin_from_name^s  rýc Cs¦|a|attƒ}tj ¡D]H\}}t||ƒr|tjkrrrrcÚitemsrÛrUr¯r_r¿r›r¢rrýr) Ú sys_moduleÚ _imp_moduleÚ module_typerrgrtrfÚ self_moduleÚ builtin_nameÚbuiltin_moduler r rÚ_setupes$          rcCs&t||ƒtj t¡tj t¡dS)z0Install importers for builtin and frozen modulesN)rrrÕrr¯r¿)rÿrr r rÚ_installˆs  rcCs ddl}|a| tjt¡dS)z9Install importers that require external filesystem accessrN)Ú_frozen_importlib_externalr‡rrrcr)rr r rÚ_install_external_importers�sr)NN)N)Nr)NNr r)2rr‡rrrAr%r/rrr5r6r9rFrIrSr]rarhrvrwrbr›r¢r¦rrrdr¬r®rer¯r¿rÆrÒrÔrÚrßÚ_ERR_MSG_PREFIXráråÚobjectrærçrèrír÷rürýrrrr r r rÚs^D%   $e -H%*IO   / % %#