Jz`flcs"SrSSKrSSKrSSKrSSKrSSKJr SSKJr SSK J r J r /SQr "SS\R5r"S S \R5r"S S \5r"S S\5r"SS5r"SS\\\5r"SS\\\5rSrSr"SS\5r"SS\5r"SS\5r"SS\5r"SS \5r"S!S"\5r"S#S$5r"S%S&\\5r"S'S(\\5r "S)S*\\5r!"S+S,\5r"g)-z4Utilities for with-statement contexts. See PEP 343.iN)dequewraps) MethodType GenericAlias)asynccontextmanagercontextmanagerclosing nullcontextAbstractContextManagerAbstractAsyncContextManagerAsyncExitStackContextDecorator ExitStackredirect_stdoutredirect_stderrsuppressaclosingchdircf\rSrSrSr\"\5rSrSr \ RS5r \S5r Srg)r iz,An abstract base class for context managers.cU$z0Return `self` upon entering the runtime context.rself #/usr/lib64/python3.13/contextlib.py __enter__Z AbstractContextManager.__enter__s csgz9Raise any exception triggered within the runtime context.Nrrexc_typeZ exc_value traceback r__exit__ZAbstractContextManager.__exit__srcPU[La[R"USS5$[$)Nrr")r _collections_abc_check_methodsNotImplementedclsZC r__subclasshook__Z'AbstractContextManager.__subclasshook__"s& ( (#221k:N NrN)__name__ __module__ __qualname____firstlineno____doc__ classmethodr__class_getitem__ __slots__rabcabstractmethodr"r*__static_attributes__rrrr r sH6#L1I rr cr)r i)z9An abstract base class for asynchronous context managers.rc# U$7frrrrr __aenter__Z&AbstractAsyncContextManager.__aenter__1s  cs # g7frrrr!r __aexit__Z%AbstractAsyncContextManager.__aexit__5s cr#)Nr7r9)r r$r%r&r'r)rr*Z,AbstractAsyncContextManager.__subclasshook__:s- - -#221l3>@ @rN)r+r,r-r.r/r0rr1r2r7r3r4r9r*r5rrrr r )sHC#L1I rr c$\rSrSrSrSrSrSrg)r iBzJA base class or mixin that enables context managers to work as decorators.cr)aReturn a recreated instance of self. Allows an otherwise one-shot context manager like _GeneratorContextManager to support use as a decorator via implicit recreation. This is a private interface just for _GeneratorContextManager. See issue #11647 for details. rrrr _recreate_cmZContextDecorator._recreate_cmEs  rc4^^[T5UU4Sj5nU$)Ncsj>TR5 T"U0UD6sSSS5 $!,(df  g=fNr<argskwdsfuncr rinnerZ(ContextDecorator.__call__..innerRs1""$ +T*T* + + +s$ 2rrrCrE`` r__call__ZContextDecorator.__call__Qs t +  + rrNr+r,r-r.r/r<rHr5rrrr r BsP rr cr;)AsyncContextDecoratoriYzPA base class or mixin that enables async context managers to work as decorators.cr)z-Return a recreated instance of self. rrrrr<Z"AsyncContextDecorator._recreate_cm\s  rcr=)Ncs># TR5IShvN T"U0UD6IShvN sSSS5IShvN $N%NN !,IShvN (df  g=f7fr>r?r@rDrrEZ-AsyncContextDecorator.__call__..innerbsR((* 1 1!40400 1 1 10 1 1 1 1sPA>A AAA AAAAAA A AArrFrGrrHZAsyncContextDecorator.__call__as t 1  1 rrNrIrrrrJrJYsV rrJcr;)_GeneratorContextManagerBaseiizBShared functionality for @contextmanager and @asynccontextmanager.csU"U0UD6UlXUsUlUlUl[ USS5nUc[ U5R nX@lg)Nr/)genrCrArBgetattrtyper/)rrCrArBZdoc r__init__Z%_GeneratorContextManagerBase.__init__lsN&&*.d' 49didIt, ;t*$$C rcsdURURURUR5$r>)Z __class__rCrArBrrrr<Z)_GeneratorContextManagerBase._recreate_cmzs#~~diiDII>>r)rLrCrArBr/N)r+r,r-r.r/rPr<r5rrrrKrKisL?rrKcr;)_GeneratorContextManageriz%Helper for @contextmanager decorator.csnU?U?U?[UR5$![ a [ S5Sef=fNzgenerator didn't yield)rArBrCnextrL StopIteration RuntimeErrorrrrrZ"_GeneratorContextManager.__enter__sD Ity$) C> ! C78d B Cs4csRUc"[UR5 [S5eUcU"5nURR U5 [S5e!URR5 f=f![a gf=f![a nXBLsSnA$SnAf[aDnXBLa X4lSnAg[U[5(aURULa X2lSnAgeSnAf[anXBLaeX4lSnAgSnAff=f!URR5 f=f)Ngenerator didn't stopFz#generator didn't stop after throw()) rSrLrUcloserTZthrow __traceback__ isinstance __cause__ BaseExceptionrZtypZvaluer excrOrr"Z!_GeneratorContextManager.__exit__s  ; %TXX%&'>??}# u%F !"#HIIWHHNN$ !  ! ('' <(1% um44 .*3'  #$-!  siA7 AB D A47 BB DBD D& C%5*C%$C%% D2 DD D&rArCrLrBN)r+r,r-r.r/rr"r5rrrrQrQs 0C7!rrQcr;)_AsyncGeneratorContextManageriz*Helper for @asynccontextmanager decorator.cs# U?U?U?[UR5IShvN $N![ a [ S5Sef=f7frR)rArBrCanextrLStopAsyncIterationrUrrrr7Z(_AsyncGeneratorContextManager.__aenter__sL Ity$) Ctxx( ((! C78d B Cs%A)')A)AAcs# Uc*[UR5IShvN [S5eUcU"5nURR U5IShvN [S5eNJ!URR5IShvN f=f![a gf=fNJ![a nXBLsSnA$SnAf[aJnXBLa X4lSnAg[U[[45(aURULa X2lSnAgeSnAf[anXBLaeX4lSnAgSnAff=f!URR5IShvN f=f7f)NrVFz$generator didn't stop after athrow()) r`rLrUacloseraZathrowrXrYrTrZr[r\rOrr9Z'_AsyncGeneratorContextManager.__aexit__s6 ; ,DHHo%%,&'>??}# hhooe,,,F ("#IJJe&((//+++ &  -% ('' <(1% u}6H&IJJ .*3'  #$-! hhoo'''sEBA*B A, EB&B$B& D/*B,B B  BE B!E B!!E$B&& D,0B82D,3E8 D, D E0D E D  D, D'"E'D,,E/E EEEr^N)r+r,r-r.r/r7r9r5rrrr_r_s 5C7(rr_c0^[T5U4Sj5nU$)a@contextmanager decorator. Typical usage: @contextmanager def some_generator(): try: yield finally: This makes this: with some_generator() as : equivalent to this: try: = finally: c>[TX5$r>)rQrArBrC rhelperZcontextmanager..helper/s'd99rrrCrg` rrrs 6 4[:: Mrcrc)a@asynccontextmanager decorator. Typical usage: @asynccontextmanager async def some_async_generator(): try: yield finally: This makes this: async with some_async_generator() as : equivalent to this: try: = finally: crdr>)r_rerfrrgZ#asynccontextmanager..helperPs,T4>>rrrhrirrr5s 6 4[?? Mrc*\rSrSrSrSrSrSrSrg)riVa Context to automatically close something at the end of a block. Code like this: with closing(.open()) as f: is equivalent to this: f = .open() try: finally: f.close() cXlgr>thingrrmr)rrPZclosing.__init__g rcUR$r>rlrrrrZclosing.__enter__is zzrcs8URR5 gr>)rmrWrZexc_infor)rr"Zclosing.__exit__ks rrlN r+r,r-r.r/rPrr"r5rrrrrVs rrcrj)rioarAsync context manager for safely finalizing an asynchronously cleaned-up resource such as an async generator, calling its ``aclose()`` method. Code like this: async with aclosing(.fetch()) as agen: is equivalent to this: agen = .fetch() try: finally: await agen.aclose() crkr>rlrnr)rrPZaclosing.__init__rorc"# UR$7fr>rlrrrr7Zaclosing.__aenter__szz csT# URR5IShvN gN7fr>)rmrbrqr)rr9Zaclosing.__aexit__sjj!!!s (&(rlN) r+r,r-r.r/rPr7r9r5rrrrros""rrcs*\rSrSrSrSrSrSrSrg)_RedirectStreamiNcXl/Ulgr>) _new_target _old_targets)rZ new_targetr)rrPZ_RedirectStream.__init__s%rcsURR[[UR55 [ [URUR 5 UR $r>)rxappendrMsys_streamsetattrrwrrrrZ_RedirectStream.__enter__sC   dll!;<T\\4#3#34rcsj[[URURR 55 gr>)r|rzr{rxpop)rexctypeexcinstexctbr!rr"Z_RedirectStream.__exit__s!T\\4#4#4#8#8#:;r)rxr{rw) r+r,r-r.r{rPrr"r5rrrrurusG   _exceptions)rZ exceptionsr)rrPZsuppress.__init__s%rcgr>rrrrrZsuppress.__enter__ rcsUcg[XR5(ag[U[5(a#URUR5upEUcgUeg)NTF)Z issubclassrZBaseExceptionGroupZsplit)rr~rrZmatchZrest rr"Zsuppress.__exit__sT ?  g// 0 0 g1 2 2!--(8(89KE|JrrNrrrrrrrs& rrcsf\rSrSrSr\S5r\S5rSrSr Sr Sr S r S r SS jrS rg )_BaseExitStackiz.A base class for ExitStack and AsyncExitStack.c[X5$r>rcmcm_exitr)r_create_exit_wrapperZ#_BaseExitStack._create_exit_wrapper '&&rc^^^UUU4SjnU$)Ncs>T"T0TD6 gr>rrr]ZtbrAcallbackrB r _exit_wrapperZ8_BaseExitStack._create_cb_wrapper.._exit_wrappers d #d #rrrrArBr``` r_create_cb_wrapperZ!_BaseExitStack._create_cb_wrappers $rcs"[5Ulgr>)r_exit_callbacksrrrrPZ_BaseExitStack.__init__s $wrcsf[U5"5nURUl[5UlU$)z@Preserve the context stack by transferring it to a new instance.)rNrr)rZ new_stackr)rpop_allZ_BaseExitStack.pop_alls+JL $($8$8 !$wrcs[U5nURnURX5 U$![a UR U5 U$f=f)zRegisters a callback with the standard __exit__ method signature. Can suppress exceptions the same way __exit__ method can. Also accepts any object with an __exit__ method (registering a call to the method instead of the object itself). )rNr" _push_cm_exitAttributeError_push_exit_callbackrZexitZ_cb_typeZ exit_methodr!rpushZ_BaseExitStack.pushsX: 2"++K   t 1  +  $ $T *  +s ,A  A cs[U5nURnURnU"U5nURX5 U$![a( [ SUR SUR S35Sef=f)zEnters the supplied context manager. If successful, also pushes its __exit__ method as a callback and returns the result of the __enter__ method. '.z6' object does not support the context manager protocolN)rNrr"r TypeErrorr,r-rrrr(Z_enterZ_exitZresultrr enter_contextZ_BaseExitStack.enter_contexts2h S]]FLLE 2%  Sa/q1A1A0BCGHINR S Ss A2A2cs`UR"U/UQ70UD6nXlURU5 U$)zLRegisters an arbitrary callback and arguments. Cannot suppress exceptions. )r __wrapped__rrrrArBrrOrrZ_BaseExitStack.callbacks9 //H4H4H %-!   /rcJURX5nURUS5 g)z;Helper to correctly register callbacks to __exit__ methods.TN)rrrrrrr!rrZ_BaseExitStack._push_cm_exit#s"11">    5rcs<URRX!45 gr>)rry)rris_syncs rrZ"_BaseExitStack._push_exit_callback(s ##W$78r)rrN)T)r+r,r-r.r/ staticmethodrrrPrrrrrrr5rrrrrsN8'' '(& 6 9rrcrj)r i-aoContext manager for dynamic management of a stack of exit callbacks. For example: with ExitStack() as stack: files = [stack.enter_context(open(fname)) for fname in filenames] # All opened files will automatically be closed at the end of # the with statement, even if attempts to open files later # in the list raise an exception. crr>rrrrrZExitStack.__enter__8s rcs^ USnUSLn[R"5m U 4SjnSnSnUR(afURR5upxU(deUcSnO[ U5X"R 4nU"U6(aSnSnSnUR(aMfU(aURn UeU=(a U$![ an U"X5 SnU nSn A NOSn A ff=f![ a W Ulef=f)NcP>URnUbX!LagUTLaOUnMXlgr> __context__new_excZold_excZ exc_context frame_exc r_fix_exception_contextZ2ExitStack.__exit__.._fix_exception_contextB<%11 &+*@)+%#* rFNNNTrzZ exceptionrr}rNrXr[r) r exc_detailsr] received_excrsuppressed_exc pending_raisercbr fixed_ctxrs @rr"ZExitStack.__exit__;s!n$ MMO  *  ""..224KGN7 ;"2K"&s)S2C2C"CK{#%)N$)MC"""$   OO  ..! &w4 $   ! "+ s$!-C)C% C" CC"%C8cs*URSSS5 gz%Immediately unwind the context stack.N)r"rrrrWZExitStack.closeqs dD$'r)rN) r+r,r-r.r/rr"rWr5rrrr r -s4/l(rr csb\rSrSrSr\S5r\S5rSrSr Sr Sr S r S r S rS rg )r iwaAsync context manager for dynamic management of a stack of exit callbacks. For example: async with AsyncExitStack() as stack: connections = [await stack.enter_async_context(get_connection()) for i in range(5)] # All opened connections will automatically be released at the # end of the async with statement, even if attempts to open a # connection later in the list raise an exception. crr>rrr)r_create_async_exit_wrapperZ)AsyncExitStack._create_async_exit_wrapperrrcr)Ncs2># T"T0TD6IShvN gN7fr>rrrrrZ>AsyncExitStack._create_async_cb_wrapper.._exit_wrappersD)D) ) )s rrrr_create_async_cb_wrapperZ'AsyncExitStack._create_async_cb_wrappers *rcs# [U5nURnURnU"U5IShvN nURX5 U$![a( [ SUR SUR S35Sef=fNL7f)zEnters the supplied async context manager. If successful, also pushes its __aexit__ method as a callback and returns the result of the __aenter__ method. rrzC' object does not support the asynchronous context manager protocolN)rNr7r9rrr,r-_push_async_cm_exitrrrenter_async_contextZ"AsyncExitStack.enter_async_contexts 2h '^^FMME bz!   +  'a/q1A1A0BCTU"& ' '"s% BA BA?B 2A<<Bcs[U5nURnURX5 U$![a UR US5 U$f=f)zRegisters a coroutine function with the standard __aexit__ method signature. Can suppress exceptions the same way __aexit__ method can. Also accepts any object with an __aexit__ method (registering a call to the method instead of the object itself). F)rNr9rrrrr!rpush_async_exitZAsyncExitStack.push_async_exitsZ: 8",,K  $ $T 7  2  $ $T5 1  2s ,A  A csbUR"U/UQ70UD6nXlURUS5 U$)zVRegisters an arbitrary coroutine function and arguments. Cannot suppress exceptions. F)rrrrrOrpush_async_callbackZ"AsyncExitStack.push_async_callbacks; 55hNNN %-!   6rcsF# URSSS5IShvN gN7fr)r9rrrrbZAsyncExitStack.aclosesnnT4...s !!cr)zDHelper to correctly register coroutine function to __aexit__ method.FN)rrrr!rrZ"AsyncExitStack._push_async_cm_exits$77D    6rcr6r>rrrrr7ZAsyncExitStack.__aenter__s  r8cs^ # USnUSLn[R"5m U 4SjnSnSnUR(atURR5upxUcSnO[ U5X"R 4nU(aU"U6n O U"U6IShvN n U (aSnSnSnUR(aMtU(aURn UeU=(a U$NE![ an U"X5 SnU nSn A NQSn A ff=f![ a W Ulef=f7f)Nrcrr>rrrrrZ8AsyncExitStack.__aexit__.._fix_exception_contextrrFrTr) rrr]rrrrrrZ cb_suppressrrrs @rr9ZAsyncExitStack.__aexit__s!n$ MMO  *  ""..224KG ;"2K"&s)S2C2C"CK"$k"2K(*K(8"8K%)N$)MC""",   OO  ..+#9 ! &w4 $   ! "+ s`AD 2C C CD 1D 9C7 D C C4 C/*D /C44D 7D  D )rrN)r+r,r-r.r/rrrrrrrbrr7r9r5rrrr r wsR '' $$ /7 8/rr cs:\rSrSrSrS SjrSrSrSrSr S r g) ria7Context manager that does no additional processing. Used as a stand-in for a normal context manager, when a particular block of code is only sometimes used with a normal context manager: cm = optional_cm if condition else nullcontext() with cm: # Perform operation, using optional_cm if condition is True Ncrkr> enter_result)rrr)rrPZnullcontext.__init__s(rcrpr>rrrrrZnullcontext.__enter__s   rcrr>rrZexcinfor)rr"Znullcontext.__exit__rrcrsr>rrrrr7Znullcontext.__aenter__s   rtcs # g7fr>rrr)rr9Znullcontext.__aexit__s r:rr>) r+r,r-r.r/rPrr"r7r9r5rrrrrs )! ! rrcrj)ri"zHNon thread-safe context manager to change the current working directory.crvr>path_old_cwd)rrr)rrPZchdir.__init__%s  rcsURR[R"55 [R"UR 5 gr>)rryosZgetcwdrrrrrrZchdir.__enter__)s* RYY[) rcs`[R"URR55 gr>)rrrr}rr)rr"Zchdir.__exit__-s ""$%rrNrrrrrrr"sR&rr)#r/r3rrzr$Z collectionsrZ functoolsrZtypesrrZ__all__ZABCr r Zobjectr rJrKrQr_rrrrrurrrrr r rrrrrrs9: * SWW0#''2v. F  ??0G! G!RG( G(TBB$2"*"4<,<$ o  o $%$NQ9Q9jF( 6F(TM/^%@M/` (*E 6 & " &r