Yf=@sdZddlZddddddd d gZddd dZdd dZd ed ddddZeddddZddZdd Z Gddde Z ddZ ddZ ddZddZddZd d!Zdd"d#dZdddd$dZGd%d&d&eZGd'd d eZdZyDdd(lmZmZmZmZmZmZeZeZd)ZWn6ek rgZd*ZiZd"a d+d,ZYnXe ej!ese"e#gZ$e$j%e&xe$D]Z'ed-d.e'qWej(j)Z)e)d"kr;d/Z*ne)rJd*Z*nd-Z*ee*d.e+d0d"e,ed1r~d2Z-nd-Z-ee-d.e.d0d"[dS)3z&Python part of the warnings subsystem.Nwarn warn_explicit showwarning formatwarningfilterwarnings simplefilter resetwarningscatch_warningsc Csa|dkr%tj}|dkr%dSy#|jt|||||Wntk r\YnXdS)z7Hook to write a warning to a file; replace if you like.N)sysstderrwriterOSError)messagecategoryfilenamelinenofileliner-/opt/alt/python35/lib64/python3.5/warnings.pyr s   # c Csd|||j|f}|dkrby"ddl}|j||}Wntk rad}YnX|r|j}|d|7}|S)z.Function to format a warning the standard way.z%s:%s: %s: %s Nrz %s )__name__ linecachegetline Exceptionstrip)rrrrrsrrrrrs     FcCsddl}|dks+td |ft|tsFtd t|tsatd t|ts|td t|tstd t|tr|dkstdt||j ||j ||j ||d|dS)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 rNerrorignorealwaysdefaultmoduleoncezinvalid action: %rzmessage must be a stringzcategory must be a classz#category must be a Warning subclasszmodule must be a stringzlineno must be an int >= 0append)rrrr r!r") reAssertionError isinstancestrtype issubclassWarningint _add_filtercompileI)actionrrr!rr#r$rrrr&s  cCsf|d kstd|ft|tr:|dksFtd 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 rrrr r!r"zinvalid action: %rrzlineno must be an int >= 0Nr#)rrrr r!r")r%r&r+r,)r/rrr#rrrr>s  c Gsc|s?ytj|Wntk r+YnXtjd|n|tkrXtj|tdS)Nr)filtersremove ValueErrorinsertr#_filters_mutated)r#itemrrrr,Ns   r,cCsgtddus z_setoption..$zinvalid lineno %r) r$splitlenr6r# _getactionescape _getcategoryr+r2 OverflowErrorr)r=r$partsr/rrr!rrrrr:ns.        r:cCsU|s dS|dkrdSx!d D]}|j|r!|Sq!Wtd|fdS) Nr allrrr!r"rzinvalid action: %r)r rrr!r"r) startswithr6)r/arrrrGs  rGcCs;ddl}|stS|jd|rcyt|}Wqtk r_td|fYqXn|jd}|d|}||dd}yt|dd|g}Wn%tk rtd|fYnXyt ||}Wn%t k rtd|fYnXt |ts7td|f|S)Nrz^[a-zA-Z0-9_]+$zunknown warning category: %r.zinvalid module name: %rzinvalid warning category: %r) r$r*matcheval NameErrorr6rfind __import__ ImportErrorgetattrAttributeErrorr))rr$catir!klassmrrrrIs,    rIcCs"|jj}d|ko!d|kS)zFSignal whether the frame is an internal CPython implementation detail. importlib _bootstrap)f_code co_filename)framerrrr_is_internal_frames rbcCs5|j}x%|dk r0t|r0|j}q W|S)z;Find the next frame that doesn't involve CPython internals.N)f_backrb)rarrr_next_external_frames  rdrPc Cst|tr|j}|dkr*t}t|toEt|tsftdjt|jy|dkst t j drt j |}nHt j d}x6t |dD]$}t |}|dkrtqWWn!tk rt j}d}YnX|j}|j}d|kr4|d}nd}|jd}|r}|j} | jdr|dd }nD|dkryt jd }Wntk rd}YnX|s|}|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}'rPrz__file__z.pyc__main__rZ__warningregistry__)r&r* __class__ UserWarningr(r) TypeErrorformatrrbr _getframerangerdr2__dict__ f_globalsf_linenogetlowerendswithargvrX setdefaultr) rr stacklevelraxglobalsrr!rZfnlregistryrrrrsL   !             cCst|}|dkrP|p!d}|ddjdkrP|dd}|dkrbi}|jddtkr|jt|dz.pyversionrrrPrr"rr!r z1Unrecognized action (%r) in warnings.filters: %sz:warnings.showwarning() must be set to a function or methodr|)r+rrrq_filters_versionclearr&r*r'rhr0rQr) defaultactionrgetlines onceregistry RuntimeErrorcallablerrj)rrrrr!rymodule_globalstextkeyr5r/r>rYmodlnrZoncekeyZaltkeyrrrrsn                          c@s:eZdZdZd Zddd d Zd d ZdS)WarningMessagez0Holds the result of a single showwarning() call.rrrrrrNc CsMt}x%|jD]}t||||qW|r@|jnd|_dS)N)locals_WARNING_DETAILSsetattrr_category_name) selfrrrrrr local_valuesattrrrr__init__@s zWarningMessage.__init__cCs&d|j|j|j|j|jfS)NzD{message : %r, category : %r, filename : %r, lineno : %s, line : %r})rrrrr)rrrr__str__Gs zWarningMessage.__str__)rrrrrr)rr7r8r9rrrrrrrr9s rc@sReZdZdZddddddZdd Zd 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. recordFr!NcCs8||_|dkr"tjdn||_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)_recordr modules_module_entered)rrr!rrrr^s "zcatch_warnings.__init__cCslg}|jr|jd|jtjdk rF|jd|jt|j}d|dj|fS)Nz record=Truerz module=%rz%s(%s)z, )rr#rr rr(rjoin)rr<namerrr__repr__js  zcatch_warnings.__repr__cs|jrtd|d|_|jj|_|jdd|j_|jj|jj|_|jrgfdd}||j_SdSdS)NzCannot enter %r twiceTcsjt||dS)N)r#r)r<kwargs)logrrr}sz-catch_warnings.__enter__..showwarning) rrrr0_filtersr4r _showwarningr)rrr)rr __enter__ss     zcatch_warnings.__enter__cGsH|jstd||j|j_|jj|j|j_dS)Nz%Cannot exit %r without entering first)rrrrr0r4rr)rexc_inforrr__exit__s   zcatch_warnings.__exit__)rr7r8r9rrrrrrrrr Ms  )r0_defaultaction _onceregistryrrr4Tr cCstd7adS)NrP)r}rrrrr4sr4rrrr#gettotalrefcountr)/r9r __all__rrr*rrr,rrr6r?r:rGrIrbrdrrobjectrr Z_warnings_defaults _warningsr0rrr4rrrVr} warnoptions ImportWarningPendingDeprecationWarningZsilencer#DeprecationWarningclsflags bytes_warningZ bytes_action BytesWarninghasattrZresource_actionResourceWarningrrrrsh             5HG.