o ?Og@sdZddZdZdZdZdaddZddZiZiZ Gdd d e Z Gd d d Z Gd d d Z GdddZddZddZddZddddZddZddZddZd d!ZGd"d#d#Zddd$d%d&Zd`d'd(Zd)d*d+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Z Gd9d:d:Z!Gd;d<d<Z"Gd=d>d>Z#d?d@Z$dAdBZ%dadCdDZ&dEdFZ'dGZ(e(dHZ)dIdJZ*e+Z,dKdLZ-dbdNdOZ.d)dPdQdRZ/dSdTZ0dcdVdWZ1dXdYZ2dZd[Z3d\d]Z4d^d_Z5dS)daSCore 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. cCs&z|jWStyt|jYSwN) __qualname__AttributeErrortype)objr;/opt/alt/python310/lib64/python3.10/importlib/_bootstrap.py _object_names  rNcCs8dD]}t||rt||t||q|j|jdS)z/Simple substitute for functools.update_wrapper.) __module____name__r__doc__N)hasattrsetattrgetattr__dict__update)newoldreplacerrr_wrap(s  rcCs tt|Sr)rsysnamerrr _new_module0s rc@s eZdZdS)_DeadlockErrorN)r r rrrrrr=src@s8eZdZdZddZddZddZdd Zd d Zd S) _ModuleLockzA 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|_dSN)_thread allocate_locklockwakeuprownercountwaitersselfrrrr__init__Gs   z_ModuleLock.__init__cCsVt}|j}t} t|}|durdS|j}||krdS||vr%dS||q )NTF)r get_identr!set _blocking_ongetadd)r%metidseenrrrr has_deadlockOs  z_ModuleLock.has_deadlockcCst}|t|<zW |j@|jdks|j|kr/||_|jd7_ WdWt|=dS|r9td||j drF|j d7_ Wdn1sPwY|j |j q t|=w)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. TrNzdeadlock detected by %rF) rr'r)rr"r!r/rr acquirer#releaser%r-rrrr1ds*    z_ModuleLock.acquirecCst}|jG|j|krtd|jdksJ|jd8_|jdkr>d|_|jrF|jd8_|jWddSWddSWddS1sQwYdS)Ncannot release un-acquired lockrr0) rr'rr! RuntimeErrorr"r#r r2r3rrrr2}s    "z_ModuleLock.releasecCd|jt|S)Nz_ModuleLock({!r}) at {}formatridr%rrr__repr__z_ModuleLock.__repr__N) r r rr r&r/r1r2r;rrrrrAs rc@s0eZdZdZddZddZddZdd Zd S) _DummyModuleLockzVA simple _ModuleLock equivalent for Python builds without multi-threading support.cCs||_d|_dSr)rr"r$rrrr& z_DummyModuleLock.__init__cCs|jd7_dS)Nr0T)r"r:rrrr1sz_DummyModuleLock.acquirecCs$|jdkr td|jd8_dS)Nrr4r0)r"r5r:rrrr2s z_DummyModuleLock.releasecCr6)Nz_DummyModuleLock({!r}) at {}r7r:rrrr;r<z_DummyModuleLock.__repr__N)r r rr r&r1r2r;rrrrr=s  r=c@s$eZdZddZddZddZdS)_ModuleLockManagercCs||_d|_dSr)_name_lockr$rrrr&r>z_ModuleLockManager.__init__cCst|j|_|jdSr)_get_module_lockr@rAr1r:rrr __enter__s z_ModuleLockManager.__enter__cOs|jdSr)rAr2)r%argskwargsrrr__exit__sz_ModuleLockManager.__exit__N)r r rr&rCrFrrrrr?s r?cCstz@zt|}Wn tyd}Ynw|dur>tdur%t|}nt|}|fdd}t||t|<Wt |SWt |St w)zGet or create the module lock for a given module name. Acquire/release internally the global import lock to protect _module_locks.NcSsDtzt||urt|=WtdSWtdStwr)_imp acquire_lock _module_locksr* release_lock)refrrrrcbs z_get_module_lock..cb) rGrHrIKeyErrorrr=r_weakrefrKrJ)rrrLrrrrBs&     rBcCs6t|}z|Wn tyYdSw|dS)zAcquires 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)rBr1rr2)rrrrr_lock_unlock_modules   rOcOs||i|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)frDkwdsrrr_call_with_frames_removedsrRr0) verbositycGs:tjj|kr|dsd|}t|j|tjddSdS)z=Print the message to stderr if -v/PYTHONVERBOSE is turned on.)#zimport z# )fileN)rflagsverbose startswithprintr8stderr)messagerSrDrrr_verbose_messages  r\cfdd}t||S)z1Decorator to verify the named module is built-in.cs&|tjvrtd||d||S)N{!r} is not a built-in moduler)rbuiltin_module_names ImportErrorr8r%fullnamefxnrr_requires_builtin_wrapper   z4_requires_builtin.._requires_builtin_wrapperr)rdrerrcr_requires_builtin  rhcr])z/Decorator to verify the named module is frozen.cs&t|std||d||SNz{!r} is not a frozen moduler)rG is_frozenr`r8rarcrr_requires_frozen_wrapper rfz2_requires_frozen.._requires_frozen_wrapperrg)rdrlrrcr_requires_frozenrirmcCsJd}t|tt||}|tjvr!tj|}t||tj|St|S)zLoad the specified module into sys.modules and return it. This method is deprecated. Use loader.exec_module() instead. zgthe load_module() method is deprecated and slated for removal in Python 3.12; use exec_module() instead) _warningswarnDeprecationWarningspec_from_loaderrmodules_exec_load)r%rbmsgspecmodulerrr_load_module_shims      rxcCst|dd}t|dd}rt|St|dr'z||WSty&Ynwz|j}Wn ty7d}Ynwz|j}WntyW|durOd|YSd||YSwd||S) z,The implementation of ModuleType.__repr__(). __loader__N__spec__ module_repr? ) r_module_repr_from_specr r{ Exceptionr r__file__r8)rwloaderrvrfilenamerrr _module_repr&s,         rc@sreZdZdZddddddZddZdd Zed d Zej d d Zed dZ eddZ e j ddZ dS) ModuleSpecaThe 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||_||_||_||_|rgnd|_d|_d|_dS)NF)rrrrsubmodule_search_locations _set_fileattr_cached)r%rrrrrrrrr&es zModuleSpec.__init__cCsfd|jd|jg}|jdur|d|j|jdur(|d|jd|jjd|S)Nz name={!r}z loader={!r}z origin={!r}zsubmodule_search_locations={}z{}({})z, ) r8rrrappendr __class__r join)r%rDrrrr;qs    zModuleSpec.__repr__cCsf|j}z$|j|jko&|j|jko&|j|jko&||jko&|j|jko&|j|jkWSty2tYSwr)rrrrcached has_locationrNotImplemented)r%othersmslrrr__eq__{s       zModuleSpec.__eq__cCs:|jdur|jdur|jrtdurtt|j|_|jSr)rrr_bootstrap_externalNotImplementedError _get_cachedr:rrrrs zModuleSpec.cachedcCs ||_dSr)r)r%rrrrrs cCs |jdur |jddS|jS)z The name of the module's parent.N.r)rr rpartitionr:rrrparents zModuleSpec.parentcCs|jSr)rr:rrrrszModuleSpec.has_locationcCst||_dSr)boolr)r%valuerrrrs) r r rr r&r;rpropertyrsetterrrrrrrr@s"$       rrrcCst|dr%tdur ttj}|dur|||dS|rgnd}||||dS|durCt|drAz||}Wn ty@d}Ynwd}t||||dS)z5Return a module spec based on various loader methods. get_filenameN)r)rrrFr)r rrspec_from_file_locationrr`r)rrrrrsearchrrrrqs&     rqcCs&z|j}Wn tyYnw|dur|S|j}|dur+z|j}Wn ty*Ynwz|j}Wn ty;d}Ynw|durW|durUz|j}Wn tyTd}Ynw|}z|j}Wn tygd}Ynwzt|j}Wn tyzd}Ynwt |||d}|durdnd|_ ||_ ||_ |S)NrFT) rzrr ryr_ORIGIN __cached__list__path__rrrr)rwrrrvrlocationrrrrr_spec_from_modulesT           rFoverridecCs|s t|dddurz|j|_Wn tyYnw|s$t|dddurW|j}|durH|jdurHtdur6ttj}| |}|j|_ ||_d|_ z||_ Wn tyVYnw|sat|dddurqz|j |_Wn typYnwz||_Wn tyYnw|st|dddur|jdurz|j|_Wn tyYnw|jr|st|dddurz|j|_ Wn tyYnw|st|dddur|jdurz|j|_W|StyY|Sw|S)Nr ry __package__rrr)rrr rrrrr_NamespaceLoader__new___pathrryrrrzrrrrr)rvrwrrrrrr_init_module_attrssr                   rcCsRd}t|jdr|j|}n t|jdrtd|dur"t|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())r rrr`rrrrvrwrrrmodule_from_spec4s    rcCsd|jdurdn|j}|jdur |jdurd|Sd||jS|jr*d||jSd|j|jS)z&Return the repr to use for the module.Nr|r}r~r)rrrr8r)rvrrrrrEs   rc Cs|j}t|{tj||urd|}t||dzP|jdur5|jdur-td|jdt ||ddn(t ||ddt |jdsWt |jd}t |t|j|n|j|Wtj|j}|tj|j<ntj|j}|tj|j<wWd|S1swY|S) zFExecute the spec's specified module in an existing module's namespace.zmodule {!r} not in sys.modulesrNmissing loaderTrr7.exec_module() not found; falling back to load_module())rr?rrrr*r8r`rrrr rrnro ImportWarning load_modulerpop)rvrwrrurrrrsVs2         rscCsz |j|jWn|jtjvr tj|j}|tj|j<tj|j}|tj|j<t|dddurFz|j|_Wn tyEYnwt|dddurlz|j |_ t |dsa|j dd|_ Wn tykYnwt|dddurz||_ W|StyY|Sw|S)Nryrrrrrz)rrrrrrrrryrr rr rrzrrrr_load_backward_compatibletsB        rc Cs|jdurt|jdst|jd}t|tt|St|}d|_zP|t j |j <z|jdur>|j dur=t d|j dn|j|Wnzt j |j =WtyYYwt j |j }|t j |j <td|j |jWd|_|Sd|_w)NrrTrrzimport {!r} # {!r}F)rr rrnrorrr _initializingrrrrrr`rrMrr\)rvrurwrrr_load_unlockeds<          rcCs6t|j t|WdS1swYdS)zReturn 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)r?rrrvrrrrts $rtc@seZdZdZdZeddZedddZeddd Z ed d Z ed d Z ee ddZ ee ddZee ddZeeZdS)BuiltinImporterzMeta path import for built-in modules. All methods are either class or static methods to avoid the need to instantiate the class. zbuilt-incCs"tdtd|jdtjdS)sReturn repr for the module. The method is deprecated. The import machinery does the job itself. zQBuiltinImporter.module_repr() is deprecated and slated for removal in Python 3.12z)rnrorpr rrrwrrrr{szBuiltinImporter.module_reprNcCs*|durdSt|rt|||jdSdSNr)rG is_builtinrqrclsrbpathtargetrrr find_specs  zBuiltinImporter.find_speccCs*tdt|||}|dur|jSdS)zFind the built-in module. If 'path' is ever specified then the search is considered a failure. This method is deprecated. Use find_spec() instead. zjBuiltinImporter.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadN)rnrorprr)rrbrrvrrr find_modules   zBuiltinImporter.find_modulecCs.|jtjvrtd|j|jdttj|S)zCreate a built-in moduler^r)rrr_r`r8rRrGcreate_builtinrrrrrs   zBuiltinImporter.create_modulecCsttj|dS)zExec a built-in moduleN)rRrG exec_builtinrrrrr szBuiltinImporter.exec_modulecCdS)z9Return None as built-in modules do not have code objects.Nrrrbrrrget_codezBuiltinImporter.get_codecCr)z8Return None as built-in modules do not have source code.Nrrrrr get_sourcerzBuiltinImporter.get_sourcecCr)z4Return False as built-in modules are never packages.FrrrrrrrzBuiltinImporter.is_packageNNr)r r rr r staticmethodr{ classmethodrrrrrhrrrrxrrrrrrs.         rc@seZdZdZdZeddZedddZeddd Z ed d Z ed d Z eddZ ee ddZee ddZee ddZdS)FrozenImporterzMeta path import for frozen modules. All methods are either class or static methods to avoid the need to instantiate the class. frozencCstdtd|jtjS)rzPFrozenImporter.module_repr() is deprecated and slated for removal in Python 3.12r)rnrorpr8r rr)mrrrr{/szFrozenImporter.module_reprNcCst|r t|||jdSdSr)rGrkrqrrrrrr:s zFrozenImporter.find_speccCstdtt|r |SdS)z]Find a frozen module. This method is deprecated. Use find_spec() instead. ziFrozenImporter.find_module() is deprecated and slated for removal in Python 3.12; use find_spec() insteadN)rnrorprGrk)rrbrrrrrAszFrozenImporter.find_modulecCr)z*Use default semantics for module creation.NrrrrrrMszFrozenImporter.create_modulecCs@|jj}t|std||dttj|}t||j dSrj) rzrrGrkr`r8rRget_frozen_objectexecr)rwrcoderrrrQs   zFrozenImporter.exec_modulecCs t||S)z_Load a frozen module. This method is deprecated. Use exec_module() instead. )rxrrrrrZs zFrozenImporter.load_modulecC t|S)z-Return the code object for the frozen module.)rGrrrrrrd zFrozenImporter.get_codecCr)z6Return None as frozen modules do not have source code.NrrrrrrjrzFrozenImporter.get_sourcecCr)z.Return True if the frozen module is a package.)rGis_frozen_packagerrrrrprzFrozenImporter.is_packagerr)r r rr rrr{rrrrrrrmrrrrrrrr$s0         rc@s eZdZdZddZddZdS)_ImportLockContextz$Context manager for the import lock.cC tdS)zAcquire the import lock.N)rGrHr:rrrrC} z_ImportLockContext.__enter__cCr)zYWdqYnw||||}Wdn1sQwY|dur|s|tjvrtj|}z|j } Wn t yx|YSw| dur|S| S|SqdS)zFind a module's spec.Nz5sys.meta_path is None, Python is likely shutting downzsys.meta_path is empty) r meta_pathr`rnrorrrrrrrrz) rrrr is_reloadrrrvrwrzrrr _find_specsD           rcCsnt|tstdt||dkrtd|dkr)t|ts#td|s)td|s3|dkr5tddSdS)zVerify arguments are "sane".zmodule name must be str, not {}rzlevel must be >= 0z__package__ not set to a stringz6attempted relative import with no known parent packagezEmpty module nameN) isinstancestr TypeErrorr8r ValueErrorr`rrrrrr _sanity_checks   rzNo module named z{!r}c Csd}|dd}|r@|tjvrt|||tjvrtj|Stj|}z|j}Wnty?td||}t||ddwt ||}|durRtt||dt |}|rtj|}|dd}z t |||W|Styd|d|}t |tY|Sw|S)Nrrz; {!r} is not a packagerzCannot set an attribute on z for child module )rrrrrRrr_ERR_MSGr8ModuleNotFoundErrorrrr rnror) rimport_rr parent_modulerurvrwchildrrr_find_and_load_unlockeds<          rcCst|tj|t}|turt||WdSWdn1s&wY|dur:d|}t||dt||S)zFind and load the module.Nz(import of {} halted; None in sys.modulesr) r?rrrr*_NEEDS_LOADINGrr8rrO)rrrwr[rrr_find_and_loads  rrcCs*t||||dkrt|||}t|tS)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)rrr _gcd_importrrrrrs   r recursivec Cs|D]h}t|ts |r|jd}nd}td|dt|j|dkr5|s4t|dr4t||j|ddqt||sjd |j|}zt ||Wqt yi}z|j |krdt j |td urdWYd }~qd }~wwq|S) zFigure 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__TrrN)rrr rrr _handle_fromlistrr8rRrrrrrr*r)rwfromlistrrxwhere from_nameexcrrrrs6        rcCs|d}|d}|dur)|dur'||jkr'tjd|d|jdtdd|S|dur0|jStjd tdd|d }d |vrG|d d }|S)zCalculate 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. rrzNz __package__ != __spec__.parent (z != )) stacklevelzYcan't resolve package from __spec__ or __package__, falling back on __name__ and __path__r rrr)r*rrnrorr)globalsrrvrrr_calc___package__Bs*  rrc Cs|dkr t|}n|dur|ni}t|}t|||}|sJ|dkr*t|ddS|s.|St|t|dd}tj|jdt|j|St|drUt||tS|S)aImport 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). rNrr) rr partitionrrrrr r r) rrlocalsrrrwglobals_rcut_offrrr __import__]s    rcCs&t|}|durtd|t|S)Nzno built-in module named )rrr`r)rrvrrr_builtin_from_names  rc Cs|a|att}tjD]$\}}t||r1|tjvrt}n t|r&t }nq t ||}t ||q tjt }dD]}|tjvrEt |} ntj|} t||| q9dS)zSetup importlib by importing needed built-in modules and injecting them into the global namespace. As sys is needed for sys.modules access and _imp is needed to load built-in modules, those two modules must be explicitly passed in. )rrnrNN)rGrrrritemsrr_rrkrrrr rr ) sys_module _imp_module module_typerrwrrv self_module builtin_namebuiltin_modulerrr_setups(          rcCs&t||tjttjtdS)z0Install importers for builtin and frozen modulesN)rrrrrr)rrrrr_installs  rcCs ddl}|a|tjtdS)z9Install importers that require external filesystem accessrN)_frozen_importlib_externalrrrrrr )rrrr_install_external_importerssr rrr)NNrr)6r rrrnrNrrrrIr)r5rrr=r?rBrOrRr\rhrmrxrrrqrrrrrsrrrtrrrrrrr_ERR_MSG_PREFIXrrobjectrrrrrrrrrr rrrrsh M%   e -H$-PU  /  % %#