a |_L@sdZddlZgdZd=ddZd>ddZdd Zd d ZeZd d ZeZ ddZ de dddfddZ e ddfddZ ddZddZGdddeZddZddZd d!Zd"d#Zd$d%Zd&d'Zd?d)d*Zd@d+d,ZGd-d.d.eZGd/d0d0eZd1d2Zz0dd3lmZm Z m!Z!mZmZm"Z"e Z#e!Z$d4Z%Wn0e&y`gZd5Z#iZ$d(a'd6d7Z"dZ%Yn0eej(e%se)ed8se d5e*d9d(d:e d;e*d(d<e d;e+d(d<e d;e,d(d<e d;e-d(d<[%dS)Az&Python part of the warnings subsystem.N)warn warn_explicit showwarning formatwarningfilterwarnings simplefilter resetwarningscatch_warningscCst||||||}t|dS)7Hook to write a warning to a file; replace if you like.N)WarningMessage_showwarnmsg_impl)messagecategoryfilenamelinenofilelinemsgr$/usr/local/lib/python3.9/warnings.pyr srcCst||||d|}t|S).Function to format a warning the standard way.N)r _formatwarnmsg_impl)r rrrrrrrrrsrcCsN|j}|dur tj}|dur dSt|}z||WntyHYn0dSN)rsysstderr_formatwarnmsgwriteOSError)rrtextrrrr s r c Cs|jj}|jd|jd|d|jd}|jdurnzddl}||j|j}Wqttyjd}d}Yqt0n|j}|r| }|d|7}|j durz ddl }Wntyd}d}Yn20| }z| |j }Wntyd}Yn0|dur||d7}|D]r}|d|j|jf7}z$|dur<||j|j}nd}WntyZd}Yn0|r| }|d |7}qn|s||d 7}|S) N:z:  rz %s Tz-Object allocated at (most recent call last): z File "%s", lineno %s z %s z<: Enable tracemalloc to get the object allocation traceback )r__name__rrr r linecachegetline Exceptionstripsource tracemallocZ is_tracingZget_object_traceback) rrsr"rr'Ztracingtbframerrrr#sT"              rcCsbzt}WntyYn<0|turVt|s4td||j|j|j|j|j |j dSt |dS)r z:warnings.showwarning() must be set to a function or methodN) r NameError_showwarning_origcallable TypeErrorr rrrrrr )rZswrrr _showwarnmsg`s r/cCsFzt}WntyYn$0|tur>||j|j|j|j|jSt|S)r) rr+_formatwarning_origr rrrrr)rZfwrrrrus   rFcCs|dvsJd|ft|ts(Jdt|ts:Jdt|tsLJdt|ts^Jdt|trp|dksxJd|s|rdd l}|r|||j}nd }|r||}nd }t ||||||d d S) aInsert an entry into the list of warnings filters (at the front). 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'message' -- a regex that the warning message must match 'category' -- a class that the warning must be a subclass of 'module' -- a regex that the module name must match 'lineno' -- an integer line number, 0 matches all warnings 'append' -- if true, append to the list of filters errorignorealwaysdefaultmoduleonceinvalid action: %rzmessage must be a stringzcategory must be a classz#category must be a Warning subclasszmodule must be a stringrlineno must be an int >= 0Nappend) isinstancestrtype issubclassWarningintrecompileI _add_filter)actionr rr7rr<rCrrrrs&  rcCsH|dvsJd|ft|tr(|dks0Jdt|d|d||ddS)aInsert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'category' -- a class that the warning must be a subclass of 'lineno' -- an integer line number, 0 matches all warnings 'append' -- if true, append to the list of filters r2r9rr:Nr;)r=rBrF)rGrrr<rrrrs rcGsP|s4zt|Wnty$Yn0td|n|tvrFt|tdS)Nr)filtersremove ValueErrorinsertr<_filters_mutated)r<itemrrrrFs  rFcCsgtdd<tdS)zAClear the list of warning filters, so that no filters are active.N)rHrLrrrrrs rc@seZdZdZdS) _OptionErrorz,Exception used by option processing helpers.N)r! __module__ __qualname____doc__rrrrrNsrNc CsP|D]F}z t|WqtyH}ztd|tjdWYd}~qd}~00qdS)NzInvalid -W option ignored:)r) _setoptionrNprintrr)argsargrrrr_processoptionss  rVc Cs|d}t|dkr$td|ft|dkr<|dq$dd|D\}}}}}t|}t|}|sl|rtddl}|r||}|r||d}|rzt|}|dkrt Wqt t fytd |fdYq0nd}t |||||dS) Nrztoo many fields (max 5): %rr1cSsg|] }|qSr)r%).0r(rrr sz_setoption..rz\Zzinvalid lineno %r) splitlenrNr< _getaction _getcategoryrCZescaperBrJ OverflowErrorr)rUZpartsrGr rr7rrCrrrrRs2     rRcCsB|sdS|dkrdSdD]}||r|Sqtd|fdS)Nr6allr5)r6r5r4r7r8r3r9) startswithrN)rGarrrr\s   r\cCs|stSd|vrddl}|}nH|d\}}}zt|dd|g}Wn"tydtd|fdYn0zt||}Wn"tytd|fdYn0t|tstd|f|S)N.rzinvalid module name: %rzunknown warning category: %rzinvalid warning category: %r) rAbuiltins rpartition __import__ ImportErrorrNgetattrAttributeErrorr@)rmZklassr7_catrrrr]s"   r]cCs|jj}d|vod|vS)zFSignal whether the frame is an internal CPython implementation detail. importlib _bootstrap)f_code co_filename)r*rrrr_is_internal_framesrpcCs"|j}|durt|r|j}q|S)z;Find the next frame that doesn't involve CPython internals.N)f_backrp)r*rrr_next_external_framesrrc Cs t|tr|j}|durt}t|tr0t|tsDtdt|jzV|dks\t t drht |}n0t d}t |dD]}t |}|dur~tq~Wn tyt j}d}d}Yn0|j}|jj}|j}d|vr|d} nd} |di} t||||| | ||dS)z:Issue a warning, or maybe ignore it or raise an exception.Nz/category must be a Warning subclass, not '{:s}'rsrr!zZ__warningregistry__)r=rA __class__ UserWarningr?r@r.formatr!rpr _getframerangerrrJ__dict__ f_globalsrnrof_lineno setdefaultr) r r stacklevelr&r*xglobalsrrr7registryrrrrs<        rcCst|}|dur8|pd}|dddkr8|dd}|durDi}|ddtkrd|t|d<t|tr~t|}|j}n |}||}|||f} || rdSt D]V} | \} } } }}| dus| |rt || r|dus| |r|dks||krqqt } | dkrdSddl }|||| dkr2|| dkrfd || <||f}t|r\dSd t|<nf| d krrnZ| d krd || <||df}||rdSd ||<n$| d krd || <ntd | | ft|||||} t| dS)Nz z.pyversionrr4r3r8rsr5r7r6z1Unrecognized action (%r) in warnings.filters: %s)rBlowerget_filters_versionclearr=rAr>rtrHZmatchr@ defaultactionr"Zgetlines onceregistry RuntimeErrorr r/)r rrrr7rZmodule_globalsr&rkeyrMrGrrkmodZlnr"ZoncekeyZaltkeyrrrrGs|                 rc@s"eZdZdZdddZddZdS)r )r rrrrrr&NcCs>||_||_||_||_||_||_||_|r4|jnd|_dSr) r rrrrrr&r!_category_name)selfr rrrrrr&rrr__init__szWarningMessage.__init__cCsd|j|j|j|j|jfS)NzD{message : %r, category : %r, filename : %r, lineno : %s, line : %r})r rrrr)rrrr__str__s  zWarningMessage.__str__)NNN)r!rOrPZ_WARNING_DETAILSrrrrrrr s  r c@s8eZdZdZdddddZddZd d Zd d ZdS) r aA context manager that copies and restores the warnings filter upon exiting the context. The 'record' argument specifies whether warnings should be captured by a custom implementation of warnings.showwarning() and be appended to a list returned by the context manager. Otherwise None is returned by the context manager. The objects appended to the list are arguments whose attributes mirror the arguments to showwarning(). The 'module' argument is to specify an alternative module to the module named 'warnings' and imported under that name. This argument is only useful when testing the warnings module itself. FN)recordr7cCs(||_|durtjdn||_d|_dS)zSpecify whether to record warnings and if an alternative module should be used other than sys.modules['warnings']. For compatibility with Python 3.0, please consider all arguments to be keyword-only. NwarningsF)_recordrmodules_module_entered)rrr7rrrrszcatch_warnings.__init__cCsPg}|jr|d|jtjdur4|d|jt|j}d|d|fS)Nz record=Truerz module=%rz%s(%s)z, )rr<rrrr?r!join)rrTnamerrr__repr__s  zcatch_warnings.__repr__cCs~|jrtd|d|_|jj|_|jdd|j_|j|jj|_|jj|_|j rvg}|j |j_|jj |j_|SdSdS)NzCannot enter %r twiceT) rrrrH_filtersrLr _showwarningr rr<r,)rZlogrrr __enter__s       zcatch_warnings.__enter__cGs>|jstd||j|j_|j|j|j_|j|j_dS)Nz%Cannot exit %r without entering first) rrrrrHrLrrr )rexc_inforrr__exit__s     zcatch_warnings.__exit__)r!rOrPrQrrrrrrrrr s   r cszdjdg}jdurVddlddl}fdd}|d||t|7}d|d}t |t d d dS) Nz coroutine 'z' was never awaited rc3s4tjD]$\}}}||}||||fVq dSr)reversed cr_originr#)rrfuncnamercoror"rrextracts z*_warn_unawaited_coroutine..extractz-Coroutine created at (most recent call last) r1r )rr}r&) rPrr" tracebackr<Z format_listlistrrstriprRuntimeWarning)rZ msg_linesrrrrrr_warn_unawaited_coroutines   r)rH_defaultaction _onceregistryrrrLTr6cCs td7adS)Nrs)rrrrrrLsrLZgettotalrefcount__main__)rr7r<r4)rr<)NN)N)NrsN)NNNN).rQr__all__rrr rr,r/r0rrArrrFrr$rNrVrRr\r]rprrrrobjectr r r _warningsrHrrrLrrZ_warnings_defaultsrfr warnoptionshasattrDeprecationWarningPendingDeprecationWarning ImportWarningResourceWarningrrrrsj  ;  #  ) GC