U e5dL@sdZddlZddddddd d gZdd+dZd?d,dZGd-d.d.eZGd/d d eZd0d1Zz0dd2lmZm Z m!Z!mZmZm"Z"e Z#e!Z$d3Z%Wn2e&k rngZd4Z#iZ$d*a'd5d6Z"dZ%YnXeej(e%se)ed7se d4e*d8d*d9e d:e*d*d;e d:e+d*d;e d:e,d*d;e d:e-d*d;[%dS)@z&Python part of the warnings subsystem.Nwarn 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/lib64/python3.8/warnings.pyr scCst||||d|}t|S).Function to format a warning the standard way.N)r _formatwarnmsg_impl)r rrrrrrrrrscCsP|j}|dkr tj}|dkr dSt|}z||Wntk rJYnXdSN)rsysstderr_formatwarnmsgwriteOSError)rrtextrrrr sr c Cs|jj}|jd|jd|d|jd}|jdkrpzddl}||j|j}Wqvtk rld}d}YqvXn|j}|r| }|d|7}|j dk rz ddl }Wntk rd}d}Yn4X| }z| |j }Wntk rd}YnX|dk r|d7}|D]t}|d|j|jf7}z$|dk rB||j|j}nd}Wntk rbd}YnX|r | }|d |7}q n|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 tracemalloc is_tracingget_object_traceback) rrsr"rr'tracingtbframerrrr#sT"           rcCsdzt}Wntk rYn= 0Nappend) AssertionError isinstancestrtype issubclassWarningintrecompileI _add_filter)actionr rr<rrArIrrrrs&  cCsH|dkstd|ft|tr(|dks0tdt|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 r7r>rr?Nr@)rBrCrHrL)rMrrrArrrrs cGsR|s6zt|Wntk r&YnXtd|n|tkrHt|tdS)Nr)filtersremove ValueErrorinsertrA_filters_mutated)rAitemrrrrLs rLcCsgtdd<tdS)zAClear the list of warning filters, so that no filters are active.N)rNrRrrrrrs c@seZdZdZdS) _OptionErrorz,Exception used by option processing helpers.N)r! __module__ __qualname____doc__rrrrrTsrTc CsN|D]D}z t|Wqtk rF}ztd|tjdW5d}~XYqXqdS)NzInvalid -W option ignored:)r) _setoptionrTprintrr)argsargrrrr_processoptionss  r\c Cs|d}t|dkr$td|ft|dkr<|dq$dd|D\}}}}}t|}t|}|sl|rtddl}|r||}|r||d}|rzt|}|dkrt Wqt t fk rtd |fdYqXnd}t |||||dS) Nrztoo many fields (max 5): %rr6cSsg|] }|qSr)r%).0r*rrr sz_setoption..rz\Zzinvalid lineno %r) splitlenrTrA _getaction _getcategoryrIescaperHrP OverflowErrorr)r[partsrMr rr<rrIrrrrXs2     rXcCsB|sdS|dkrdSdD]}||r|Sqtd|fdS)Nr;allr:)r;r:r9r<r=r8r>) startswithrT)rMarrrrbs  rbcCs|stSd|krddl}|}nJ|d\}}}zt|dd|g}Wn$tk rftd|fdYnXzt||}Wn$tk rtd|fdYnXt|tstd|f|S)N.rzinvalid module name: %rzunknown warning category: %rzinvalid warning category: %r) rGbuiltins rpartition __import__ ImportErrorrTgetattrAttributeErrorrF)rmklassr<_catrrrrcs" rccCs|jj}d|kod|kS)zFSignal whether the frame is an internal CPython implementation detail. importlib _bootstrap)f_code co_filename)r-rrrr_is_internal_framesrycCs"|j}|dk rt|r|j}q|S)z;Find the next frame that doesn't involve CPython internals.N)f_backry)r-rrr_next_external_framesr{c Cst|tr|j}|dkrt}t|tr0t|tsDtdt|jzV|dks\t t drht |}n0t d}t |dD]}t |}|dkr~tq~Wn"tk rt j}d}d}YnX|j}|jj}|j}d|kr|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}'r|rr!zZ__warningregistry__)rCrG __class__ UserWarningrErFr1formatr!ryr _getframeranger{rP__dict__ f_globalsrwrxf_lineno setdefaultr) r r stacklevelr&r-xglobalsrrr<registryrrrrs>       cCst|}|dkr8|pd}|dddkr8|dd}|dkrDi}|ddtkrd|t|d<t|tr~t|}|j}n |}||}|||f} || rdSt D]V} | \} } } }}| dks| |rt || r|dks| |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.pyversionrr9r8r=r|r:r<r;z1Unrecognized action (%r) in warnings.filters: %s)rHlowerget_filters_versionclearrCrGrDr}rNmatchrF defaultactionr"getlines onceregistry RuntimeErrorr r3)r rrrr<rmodule_globalsr&rkeyrSrMrrtmodZlnr"ZoncekeyZaltkeyrrrrGs|                 c@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__szWarningMessage.__str__)NNN)r!rUrV_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)recordr<cCs(||_|dkrtjdn||_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)rrr<rrrrszcatch_warnings.__init__cCsPg}|jr|d|jtjdk r4|d|jt|j}d|d|fS)Nz record=Truerz module=%rz%s(%s)z, )rrArrrrEr!join)rrZnamerrr__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) rrrrN_filtersrRr _showwarningr rrAr/)rlogrrr __enter__s       zcatch_warnings.__enter__cGs>|jstd||j|j_|j|j|j_|j|j_dS)Nz%Cannot exit %r without entering first) rrrrrNrRrrr )rexc_inforrr__exit__s     zcatch_warnings.__exit__)r!rUrVrWrrrrrrrrr s   cszdjdg}jdk rVddlddl}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) r6r )rrr&) rVrr" tracebackrA format_listlistrrstriprRuntimeWarning)r msg_linesrrrrrr_warn_unawaited_coroutines   r)rN_defaultaction _onceregistryrrrRTr;cCs td7adS)Nr|)rrrrrrRsrRZgettotalrefcount__main__)rr<rAr9)rrA)NN)N)Nr|N)NNNN).rWr__all__rrr rr/r3r4rrGrrrLrr$rTr\rXrbrcryr{rrobjectr r r _warningsrNrrrRrrZ_warnings_defaultsrnr warnoptionshasattrDeprecationWarningPendingDeprecationWarning ImportWarningResourceWarningrrrrs|  ;  #  ) GC