Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/warnings.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@sSdZddlZddlZddlZddddddgZdd	d
�Zddd�ZeZdd�Z	d
e
d
ddd�Ze
ddd�Zd�Z
defd��YZd�Zd�Zd�Zd�Zdd	d�Zdddd�Zdefd��YZdefd��YZeZy>ddlmZmZmZmZmZeZeZ e!ZWn#e"k
r�gZdZiZ nXeej#�esLe$e%gZ&ej'r�ej(j)r�e&j*e+�nxe&D]Z,edd e,�q�ej(j-Z-e-d	krd!Z.ne-r-dZ.ndZ.ee.d e/d"d	�n[dS(#s&Python part of the warnings subsystem.i�Ntwarntshowwarningt
formatwarningtfilterwarningst
resetwarningstcatch_warningsicCs9tjr5|dkrt}nt|||d�ndS(s�Issue a deprecation warning for Python 3.x related changes.

    Warnings are omitted unless Python is started with the -3 option.
    iN(tsystpy3kwarningtNonetDeprecationWarningR(tmessagetcategoryt
stacklevel((s/sys/lib/python2.7/warnings.pytwarnpy3ks		cCsS|dkrtj}ny#|jt|||||��Wntk
rNnXdS(s7Hook to write a warning to a file; replace if you like.N(RRtstderrtwriteRtIOError(R
Rtfilenametlinenotfiletline((s/sys/lib/python2.7/warnings.pyt
_show_warnings#
cCsdd|||j|f}|dkr7tj||�n|}|r`|j�}|d|7}n|S(s.Function to format a warning the standard way.s%s:%s: %s: %s
s  %s
N(t__name__Rt	linecachetgetlinetstrip(R
RRRRts((s/sys/lib/python2.7/warnings.pyR$s$ticCscddl}||j||j�||j|�|f}|rOtj|�ntjd|�dS(s�Insert 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
    i�Ni(tretcompiletItfilterstappendtinsert(tactionR
RtmoduleRR Rtitem((s/sys/lib/python2.7/warnings.pyR-s
cCs?|d|d|f}|r+tj|�ntjd|�dS(s�Insert 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
    iN(RRR R!(R"RRR R$((s/sys/lib/python2.7/warnings.pytsimplefilterJscCsgt(dS(sAClear the list of warning filters, so that no filters are active.N(R(((s/sys/lib/python2.7/warnings.pyR^st_OptionErrorcBseZdZRS(s,Exception used by option processing helpers.(Rt
__module__t__doc__(((s/sys/lib/python2.7/warnings.pyR&bscCsLxE|D]=}yt|�Wqtk
rC}tjdI|IJqXqWdS(NsInvalid -W option ignored:(t
_setoptionR&RR(targstargtmsg((s/sys/lib/python2.7/warnings.pyt_processoptionsgs

c	Cs[ddl}|jd�}t|�dkrCtd|f��nx#t|�dkrh|jd�qFWg|D]}|j�^qp\}}}}}t|�}|j|�}t|�}|j|�}|r�d}n|r;y%t	|�}|dkr
t
�nWqAt
tfk
r7td|f��qAXnd}t|||||�dS(	Ni�t:istoo many fields (max 5): %rRt$isinvalid lineno %r(
RtsplittlenR&R Rt
_getactiontescapet_getcategorytintt
ValueErrort
OverflowErrorR(	R+RtpartsRR"R
RR#R((s/sys/lib/python2.7/warnings.pyR)os.+

cCsU|s
dS|dkrdSx!d	D]}|j|�r!|Sq!Wtd|f��dS(
NtdefaulttalltalwaystignoreR#tonceterrorsinvalid action: %r(sdefaultsalwayssignoresmodulesonceserror(t
startswithR&(R"ta((s/sys/lib/python2.7/warnings.pyR2�s
cCs/ddl}|stS|jd|�rbyt|�}Wqtk
r^td|f��qXn�|jd�}|| }||d}yt|dd|g�}Wn$t	k
r�td|f��nXyt
||�}Wn$tk
rtd|f��nXt|t�s+td|f��n|S(Ni�s^[a-zA-Z0-9_]+$sunknown warning category: %rt.isinvalid module name: %rsinvalid warning category: %r(
RtWarningtmatchtevalt	NameErrorR&trfindt
__import__RtImportErrortgetattrtAttributeErrort
issubclass(RRtcattiR#tklasstm((s/sys/lib/python2.7/warnings.pyR4�s,



c
CsRt|t�r|j}n|dkr0t}nytj|�}Wn tk
retj}d}nX|j	}|j
}d|kr�|d}nd}|jd�}|r�|j�}|j
d�r |d }q nI|dkrytjd	}Wqtk
r
d}qXn|s |}n|jd
i�}	t||||||	|�dS(
s:Issue a warning, or maybe ignore it or raise an exception.iRs<string>t__file__s.pycs.pyoi�t__main__it__warningregistry__N(s.pycs.pyo(t
isinstanceRBt	__class__RtUserWarningRt	_getframeR6t__dict__t	f_globalstf_linenotgettlowertendswithtargvRJt
setdefaultt
warn_explicit(
R
RRtcallertglobalsRR#Rtfnltregistry((s/sys/lib/python2.7/warnings.pyR�s:	
	
		


	cCsbt|�}|dkrJ|p!d}|dj�dkrJ|d }qJn|dkr_i}nt|t�r�t|�}|j}n|}||�}|||f}|j|�r�dSx�tD]|}	|	\}
}}}
}|dks�j	|�r�t
||�r�|
dks!|
j	|�r�|dks9||kr�Pq�q�Wt}
|
dkrad||<dStj
||�|
dkr�|�n|
dkr�d||<||f}tj|�r�dSdt|<n�|
d	kr�nt|
d
krd||<||df}|j|�rdSd||<n/|
dkr5d||<ntd|
|	f��t||||�dS(
Ns	<unknown>i�s.pyiR<iR>R=R;R#R9s1Unrecognized action (%r) in warnings.filters:
 %s(R5RR[RSRBtstrRTRZRRCRKt
defaultactionRtgetlinestonceregistrytRuntimeErrorR(R
RRRR#Rctmodule_globalsttexttkeyR$R"R,RLtmodtlntoncekeytaltkey((s/sys/lib/python2.7/warnings.pyR_�sb	

	




tWarningMessagecBs,eZdZd	Zd
d
d�Zd�ZRS(s0Holds the result of a single showwarning() call.R
RRRRRc	CsMt�}x%|jD]}t||||�qW|r@|jnd|_dS(N(tlocalst_WARNING_DETAILStsetattrRRt_category_name(	tselfR
RRRRRtlocal_valuestattr((s/sys/lib/python2.7/warnings.pyt__init__ s	cCs&d|j|j|j|j|jfS(NsD{message : %r, category : %r, filename : %r, lineno : %s, line : %r}(R
RtRRR(Ru((s/sys/lib/python2.7/warnings.pyt__str__'s(smessagescategorysfilenameslinenosfileslineN(RR'R(RrRRxRy(((s/sys/lib/python2.7/warnings.pyRpscBs8eZdZedd�Zd�Zd�Zd�ZRS(s�A 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.

    cCs8||_|dkr"tjdn||_t|_dS(s�Specify 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.

        twarningsN(t_recordRRtmodulest_moduletFalset_entered(RutrecordR#((s/sys/lib/python2.7/warnings.pyRx>s	"cCsrg}|jr|jd�n|jtjdk	rL|jd|j�nt|�j}d|dj|�fS(Nsrecord=TrueRzs	module=%rs%s(%s)s, (R{R R}RR|ttypeRtjoin(RuR*tname((s/sys/lib/python2.7/warnings.pyt__repr__Js	cs�|jrtd|��nt|_|jj|_|j|j_|jj|_|jr�g��fd�}||j_�SdSdS(NsCannot enter %r twicecs�jt||��dS(N(R Rp(R*tkwargs(tlog(s/sys/lib/python2.7/warnings.pyR\s(
RRhtTrueR}Rt_filtersRt_showwarningR{R(RuR((R�s/sys/lib/python2.7/warnings.pyt	__enter__Ss			cGs>|jstd|��n|j|j_|j|j_dS(Ns%Cannot exit %r without entering first(RRhR�R}RR�R(Rutexc_info((s/sys/lib/python2.7/warnings.pyt__exit__cs	N(	RR'R(R~RRxR�R�R�(((s/sys/lib/python2.7/warnings.pyR-s
			(Rtdefault_actiont
once_registryRR_R9R<RR>R (0R(RRttypest__all__RR
RRRRBRR%Rt	ExceptionR&R-R)R2R4RR_tobjectRpRR~t_warnings_defaultst	_warningsRR�R�ReRgR�RHtwarnoptionst
ImportWarningtPendingDeprecationWarningtsilenceRtflagstdivision_warningR R	tclst
bytes_warningtbytes_actiontBytesWarning(((s/sys/lib/python2.7/warnings.pyt<module>s^

					
	)AE(




		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].