3 \8H @sdZddlZddddddd d gZd;d dZdd,dZGd-d.d.eZGd/d d eZdZy0dd0lmZm Z m!Z!mZmZm"Z"e Z#e!Z$d1ZWn.e%k rfgZd2Z#iZ$d*a&d3d4Z"YnXeej'ese(e)gZ*e*j+e,xe*D]Z-e d5e-d6qWej.j/Z/e/d*krd7Z0ne/rd2Z0nd5Z0e e0e1d*d8e2ed9rd:Z3nd5Z3e e3e4d*d8[dS)?z&Python part of the warnings subsystem.Nwarn warn_explicit showwarning formatwarningfilterwarnings simplefilter resetwarningscatch_warningscCst||||||}t|dS)z7Hook to write a warning to a file; replace if you like.N)WarningMessage_showwarnmsg_impl)messagecategoryfilenamelinenofilelinemsgr /usr/lib64/python3.6/warnings.pyr scCst||||d|}t|S)z.Function to format a warning the standard way.N)r _formatwarnmsg_impl)r r rrrrrrrrsc CsP|j}|dkr tj}|dkr dSt|}y|j|Wntk rJYnXdS)N)rsysstderr_formatwarnmsgwriteOSError)rrtextrrrr sr cCsLd|j|j|jj|jf}|jdkr`yddl}|j|j|j}Wqftk r\d}d}YqfXn|j}|r~|j }|d|7}|j dk rHyddl }|j |j }Wntk rd}YnX|dk rH|d7}xx|D]p}|d|j|jf7}y$|dk r |j|j|j}nd}Wntk r*d}YnX|r|j }|d|7}qW|S)Nz%s:%s: %s: %s rz %s z.Object allocated at (most recent call first): z File "%s", lineno %s z %s ) rrr __name__r r linecachegetline Exceptionstripsource tracemallocget_object_traceback)rsrrr"tbframerrrr#sF          rcCsdyt}Wntk rYn= 0)append)r0r1r2r3r4r5) reAssertionError isinstancestrtype issubclassWarningint _add_filtercompileI)actionr r r4rr6r7rrrrws cCsH|d kstd|ft|tr(|dks0td t|d |d ||d d S) 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 r0r1r2r3r4r5zinvalid action: %rrzlineno must be an int >= 0N)r6)r0r1r2r3r4r5)r8r9r>r?)rBr rr6rrrrs c GsR|s6ytj|Wntk r&YnXtjd|n|tkrHtj|tdS)Nr)filtersremove ValueErrorinsertr6_filters_mutated)r6itemrrrr?s r?cCsgtdd<tdS)zAClear the list of warning filters, so that no filters are active.N)rCrGrrrrrs c@seZdZdZdS) _OptionErrorz,Exception used by option processing helpers.N)r __module__ __qualname____doc__rrrrrIsrIcCsRxL|D]D}y t|Wqtk rH}ztd|tjdWYdd}~XqXqWdS)NzInvalid -W option ignored:)r) _setoptionrIprintrr)argsargrrrr_processoptionss   rQcCsddl}|jd}t|dkr,td|fxt|dkrF|jdq.Wdd|D\}}}}}t|}|j|}t|}|j|}|r|d}|ryt|}|dkrt Wqt t fk rtd |fYqXnd}t |||||dS) Nr:ztoo many fields (max 5): %rr/cSsg|] }|jqSr)r ).0r$rrr sz_setoption..$zinvalid lineno %r) r7splitlenrIr6 _getactionescape _getcategoryr>rE OverflowErrorr)rPr7partsrBr r r4rrrrrMs.    rMcCsB|sdS|dkrdSxd D]}|j|r|SqWtd|fdS) Nr3allr2r1r4r5r0zinvalid action: %r)r3r2r1r4r5r0) startswithrI)rBarrrrYs  rYcCsddl}|stS|jd|rNy t|}Wqtk rJtd|fYqXn|jd}|d|}||dd}yt|dd|g}Wn"tk rtd|fYnXyt ||}Wn"t k rtd|fYnXt |tstd|f|S)Nrz^[a-zA-Z0-9_]+$zunknown warning category: %r.zinvalid module name: %rzinvalid warning category: %r) r7r=matchevalr'rIrfind __import__ ImportErrorgetattrAttributeErrorr<)r r7catir4klassmrrrr[s,     r[cCs|jj}d|kod|kS)zFSignal whether the frame is an internal CPython implementation detail. importlib _bootstrap)f_code co_filename)r&rrrr_is_internal_framesrrcCs&|j}x|dk r t|r |j}qW|S)z;Find the next frame that doesn't involve CPython internals.N)f_backrr)r&rrr_next_external_frames rtrbc Csvt|tr|j}|dkrt}t|to.t|tsDtdjt|jyZ|dks\t t j drht j |}n4t j d}x(t |dD]}t |}|dkrtqWWntk rt j}d}YnX|j}|j}d|kr|d}nd}|jd} | r| j} | jdrP| dd } n>|dkrFyt jd } Wntk rDd} YnX| sP|} |jd i} t||| ||| ||dS) z:Issue a warning, or maybe ignore it or raise an exception.Nz/category must be a Warning subclass, not '{:s}'rbrz__file__z.pyc__main__rZ__warningregistry__)r9r= __class__ UserWarningr;r<r*formatrrrr _getframerangertrE__dict__ f_globalsf_linenogetlowerendswithargvri setdefaultr) r r stacklevelr!r&xglobalsrr4rZfnlregistryrrrr sL           cCst|}|dkr8|pd}|ddjdkr8|dd}|dkrDi}|jddtkrd|jt|d<t|tr~t|}|j}n |}||}|||f} |j| rdSx^t D]R} | \} } } }}| dks| j |rt || r|dks|j |r|dks||krPqWt } | dkrd|| <dSddl }|j||| dkr:|| d krnd|| <||f}tj|rddSdt|<nf| d krznZ| d krd|| <||df}|j|rdSd||<n$| d krd|| <ntd | | ft|||||} t| dS)Nz z.pyversionrr1rbr0r5r2r4r3z1Unrecognized action (%r) in warnings.filters: %sr)r>rr_filters_versionclearr9r=r:rxrCrcr< defaultactionrgetlines onceregistry RuntimeErrorr r,)r r rrr4rmodule_globalsr!rkeyrHrBrrjmodlnrZoncekeyZaltkeyrrrrAsl                    c@s"eZdZd Zdd d Zd d ZdS)r r r rrrrr!Nc Cs:t}x|jD]} t|| || qW|r0|jnd|_dS)N)locals_WARNING_DETAILSsetattrr_category_name) selfr r rrrrr! local_valuesattrrrr__init__s zWarningMessage.__init__cCsd|j|j|j|j|jfS)NzD{message : %r, category : %r, filename : %r, lineno : %s, line : %r})r rrrr)rrrr__str__szWarningMessage.__str__)r r rrrrr!)NNN)rrJrKrrrrrrrr 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)recordr4cCs(||_|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)rrr4rrrrszcatch_warnings.__init__cCsPg}|jr|jd|jtjdk r4|jd|jt|j}d|dj|fS)Nz record=Truerz module=%rz%s(%s)z, )rr6rrrr;rjoin)rrOnamerrr__repr__s  zcatch_warnings.__repr__cCs~|jrtd|d|_|jj|_|jdd|j_|jj|jj|_|jj|_|j rvg}|j |j_|jj |j_|SdSdS)NzCannot enter %r twiceT) rrrrC_filtersrGr _showwarningr rr6r()rlogrrr __enter__s       zcatch_warnings.__enter__cGs>|jstd||j|j_|jj|j|j_|j|j_dS)Nz%Cannot exit %r without entering first) rrrrrCrGrrr )rexc_inforrr__exit__s     zcatch_warnings.__exit__)rrJrKrLrrrrrrrrr s   )rC_defaultaction _onceregistryrrrGTr3cCs td7adS)Nrb)rrrrrrGsrGr1)r r0)r r6gettotalrefcountr2)NN)N)NrbN)NNNN)5rLr__all__rrr rr(r,r-rr=rrr?rrrIrQrMrYr[rrrtrrobjectr r Z_warnings_defaults _warningsrCrrrGrrrgr warnoptions ImportWarningPendingDeprecationWarningZsilencer6DeprecationWarningclsflags bytes_warningZ bytes_action BytesWarninghasattrZresource_actionResourceWarningrrrrsv  0    5 FJ