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 Cszt ¡}|j�b|j|kr"tdƒ‚|jdks0t‚|jd8_|jdkrld|_|jrl|jd8_|j  ¡W5QRXdS)Núcannot release un-acquired lockrr*) rr$rrÚ RuntimeErrorrÚAssertionErrorr 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,r5r 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)rr4r r rr+€sz_DummyModuleLock.acquirecCs$|jdkrtdƒ‚|jd8_dS)Nrr.r*)rr/r4r r rr,„s z_DummyModuleLock.releasecCsd |jt|ƒ¡S)Nz_DummyModuleLock({!r}) at {}r1r4r r rr5‰sz_DummyModuleLock.__repr__N)rrrrr#r+r,r5r r r rr6xs r6c@s$eZdZdd„Zdd„Zdd„ZdS)Ú_ModuleLockManagercCs||_d|_dSr)Ú_nameÚ_lockr!r r rr#�sz_ModuleLockManager.__init__cCst|jƒ|_|j ¡dSr)Ú_get_module_lockr8r9r+r4r r rÚ __enter__“s z_ModuleLockManager.__enter__cOs|j ¡dSr)r9r,)r"ÚargsÚkwargsr r rÚ__exit__—sz_ModuleLockManager.__exit__N)rrrr#r;r>r r r rr7�sr7cCs‚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@rArBÚKeyErrorrr6rÚ_weakrefrC)rrrDr r rr:�s    r:cCs6t|ƒ}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)r:r+rr,)rrr r rÚ_lock_unlock_moduleÂs  rGcOs |||Ž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ÓsrJr*)Ú 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Úprintr2Ústderr)ÚmessagerKr<r r rÚ_verbose_messageÞs  rTcs‡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Ú ImportErrorr2©r"Úfullname©Úfxnr rÚ_requires_builtin_wrapperès   ÿz4_requires_builtin.._requires_builtin_wrapper©r)r[r\r rZrÚ_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_frozenrWr2rXrZr rÚ_requires_frozen_wrapperós   ÿz2_requires_frozen.._requires_frozen_wrapperr])r[rar rZrÚ_requires_frozenñs  rbcCs>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"rYÚspecÚmoduler r rÚ_load_module_shimýs      ricCsâ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ú?ú úú) rrrkÚ ExceptionÚ__spec__ÚAttributeErrorÚ_module_repr_from_specrÚ__file__r2)rhÚloaderrgrÚfilenamer r rÚ _module_repr s.       rwc@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)rruryrzÚsubmodule_search_locationsÚ _set_fileattrÚ_cached)r"rruryrzr{r 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, ) r2rruryÚappendr}Ú __class__rÚjoin)r"r<r r rr5bs  ÿ  ÿzModuleSpec.__repr__cCsj|j}zH|j|jkoL|j|jkoL|j|jkoL||jkoL|j|jkoL|j|jkWStk rdYdSXdSr|)r}rruryÚcachedÚ has_locationrr)r"ÚotherÚsmslr r rÚ__eq__ls  ÿ þý ü ûzModuleSpec.__eq__cCs:|jdkr4|jdk r4|jr4tdkr&t‚t |j¡|_|jSr)rryr~Ú_bootstrap_externalÚNotImplementedErrorÚ _get_cachedr4r 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Ú rpartitionr4r r rÚparent…s zModuleSpec.parentcCs|jSr)r~r4r r rr„�szModuleSpec.has_locationcCst|ƒ|_dSr)Úboolr~)r"Úvaluer r rr„‘s) rrrrr#r5r‡ÚpropertyrƒÚsetterr�r„r r r rrx1s $ÿ       rx©ryr{cCsš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)ru)rur}r{Fr’)rrˆr‰Úspec_from_file_locationr{rWrx)rruryr{r”Úsearchr r rrc–s$   ÿ  rccCs8z |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©ryFT) rqrrrrjrtÚ_ORIGINÚ __cached__ÚlistÚ__path__rxr~rƒr})rhruryrgrÚ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)NrrjÚ __package__ršrtr˜)rrrrrrur}rˆr‰Ú_NamespaceLoaderÚ__new__Ú_pathrtrjr�rŸrqršr„ryrƒr˜)rgrhržrur 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())rrur¤rWrrr£©rgrhr 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.Nrlrmrnroú)rryrur2r„)rgrr r rrs6s   rsc 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¥)rr7rrdr&r2rWÚpoprur}r£rÚ load_moduler¥)rgrhrÚmsgr r rreGs"      recCsz|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)NrjrŸršr‹rrq)rur«rrrdrªrrjrrrrŸrrŒrqr¦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})rurr­r§Ú _initializingrrdrr}rWr¥rErªrTr¦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)r7rr¯)rgr r rrf´s rfc@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)r2r)rhr r rrkÌszBuiltinImporter.module_reprNcCs,|dk r dSt |¡r$t||dd�SdSdS)Nzbuilt-inr–)r?Ú is_builtinrc©ÚclsrYÚ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·ru)r´rYrµrgr r rÚ find_moduleÞs zBuiltinImporter.find_modulecCs.|jtjkr"td |j¡|jd�‚ttj|ƒS)zCreate a built-in modulerUr)rrrVrWr2rJr?Úcreate_builtin)r"rgr r rr¤ês   ÿzBuiltinImporter.create_modulecCsttj|ƒdS)zExec a built-in moduleN)rJr?Ú exec_builtin)r"rhr r rr¥òszBuiltinImporter.exec_modulecCsdS)z9Return None as built-in modules do not have code objects.Nr ©r´rYr 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 rr{szBuiltinImporter.is_package)NN)N)rrrrÚ staticmethodrkÚ classmethodr·r¸r¤r¥r^r¼r½r{rir«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¨)r2rrÀr—)Úmr r rrkszFrozenImporter.module_reprNcCs"t |¡rt|||jd�SdSdS)Nr–)r?r`rcr—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´rYrµr r rr¸'szFrozenImporter.find_modulecCsdS)z*Use default semantics for module creation.Nr )r´rgr r rr¤0szFrozenImporter.create_modulecCs@|jj}t |¡s$td |¡|d�‚ttj|ƒ}t||j ƒdSr_) rqrr?r`rWr2rJÚget_frozen_objectÚexecr)rhrÚcoder r rr¥4s  ÿ zFrozenImporter.exec_modulecCs t||ƒS)z_Load a frozen module. This method is deprecated. Use exec_module() instead. )rir»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 rr{RszFrozenImporter.is_package)NN)N)rrrrr—r¾rkr¿r·r¸r¤r¥r«rbr¼r½r{r 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@r4r r rr;_sz_ImportLockContext.__enter__cCs t ¡dS)zcsz_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Ú TypeErrorr2rrÎrW©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ŒrrdrJršrrÚ_ERR_MSGr2ÚModuleNotFoundErrorrÛr¯r)rÚimport_rµr�Ú parent_moduler¬rgrhr 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) r7rrdr&Ú_NEEDS_LOADINGrær2rãrG)rrärhrSr 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ír2rJrãrrrdr&rç)rhÚ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ŸrqNz __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Ïrgr 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Írrdrrrî) rr÷ÚlocalsrïrÐrhÚglobals_rÏÚcut_offr r rÚ __import__9s      rýcCs&t |¡}|dkrtd|ƒ‚t|ƒS)Nzno built-in module named )r°r·rWr¯)rrgr r rÚ_builtin_from_name^s  rþc Cs¦|a|attƒ}tj ¡D]H\}}t||ƒr|tjkrs^D%   $e -H%*IO   / % %#