Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / module-warnings.html
CommitLineData
86530b38
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-imp.html" />
13<link rel="prev" href="module-marshal.html" />
14<link rel="parent" href="python.html" />
15<link rel="next" href="warning-categories.html" />
16<meta name='aesop' content='information' />
17<title>3.20 warnings -- Warning control</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="3.19 marshal "
25 href="module-marshal.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
28 href="python.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="3.20.1 Warning Categories"
31 href="warning-categories.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-marshal.html">3.19 marshal </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="warning-categories.html">3.20.1 Warning Categories</A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0052000000000000000000">
563.20 <tt class="module">warnings</tt> --
57 Warning control</A>
58</H1>
59
60<P>
61<A NAME="module-warnings"></A>
62<a id='l2h-688' xml:id='l2h-688'></a>
63
64<P>
65
66<span class="versionnote">New in version 2.1.</span>
67
68<P>
69Warning messages are typically issued in situations where it is useful
70to alert the user of some condition in a program, where that condition
71(normally) doesn't warrant raising an exception and terminating the
72program. For example, one might want to issue a warning when a
73program uses an obsolete module.
74
75<P>
76Python programmers issue warnings by calling the <tt class="function">warn()</tt>
77function defined in this module. (C programmers use
78<tt class="cfunction">PyErr_Warn()</tt>; see the
79<em class="citetitle"><a
80 href="../api/exceptionHandling.html"
81 title="Python/C API Reference
82Manual"
83 >Python/C API Reference
84Manual</a></em> for details).
85
86<P>
87Warning messages are normally written to <code>sys.stderr</code>, but their
88disposition can be changed flexibly, from ignoring all warnings to
89turning them into exceptions. The disposition of warnings can vary
90based on the warning category (see below), the text of the warning
91message, and the source location where it is issued. Repetitions of a
92particular warning for the same source location are typically
93suppressed.
94
95<P>
96There are two stages in warning control: first, each time a warning is
97issued, a determination is made whether a message should be issued or
98not; next, if a message is to be issued, it is formatted and printed
99using a user-settable hook.
100
101<P>
102The determination whether to issue a warning message is controlled by
103the warning filter, which is a sequence of matching rules and actions.
104Rules can be added to the filter by calling
105<tt class="function">filterwarnings()</tt> and reset to its default state by calling
106<tt class="function">resetwarnings()</tt>.
107
108<P>
109The printing of warning messages is done by calling
110<tt class="function">showwarning()</tt>, which may be overridden; the default
111implementation of this function formats the message by calling
112<tt class="function">formatwarning()</tt>, which is also available for use by custom
113implementations.
114
115<P>
116
117<p><br /></p><hr class='online-navigation' />
118<div class='online-navigation'>
119<!--Table of Child-Links-->
120<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
121
122<UL CLASS="ChildLinks">
123<LI><A href="warning-categories.html">3.20.1 Warning Categories</a>
124<LI><A href="warning-filter.html">3.20.2 The Warnings Filter</a>
125<LI><A href="warning-functions.html">3.20.3 Available Functions</a>
126</ul>
127<!--End of Table of Child-Links-->
128</div>
129
130<DIV CLASS="navigation">
131<div class='online-navigation'>
132<p></p><hr />
133<table align="center" width="100%" cellpadding="0" cellspacing="2">
134<tr>
135<td class='online-navigation'><a rel="prev" title="3.19 marshal "
136 href="module-marshal.html"><img src='../icons/previous.png'
137 border='0' height='32' alt='Previous Page' width='32' /></A></td>
138<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
139 href="python.html"><img src='../icons/up.png'
140 border='0' height='32' alt='Up One Level' width='32' /></A></td>
141<td class='online-navigation'><a rel="next" title="3.20.1 Warning Categories"
142 href="warning-categories.html"><img src='../icons/next.png'
143 border='0' height='32' alt='Next Page' width='32' /></A></td>
144<td align="center" width="100%">Python Library Reference</td>
145<td class='online-navigation'><a rel="contents" title="Table of Contents"
146 href="contents.html"><img src='../icons/contents.png'
147 border='0' height='32' alt='Contents' width='32' /></A></td>
148<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
149 border='0' height='32' alt='Module Index' width='32' /></a></td>
150<td class='online-navigation'><a rel="index" title="Index"
151 href="genindex.html"><img src='../icons/index.png'
152 border='0' height='32' alt='Index' width='32' /></A></td>
153</tr></table>
154<div class='online-navigation'>
155<b class="navlabel">Previous:</b>
156<a class="sectref" rel="prev" href="module-marshal.html">3.19 marshal </A>
157<b class="navlabel">Up:</b>
158<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
159<b class="navlabel">Next:</b>
160<a class="sectref" rel="next" href="warning-categories.html">3.20.1 Warning Categories</A>
161</div>
162</div>
163<hr />
164<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
165</DIV>
166<!--End of Navigation Panel-->
167<ADDRESS>
168See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
169</ADDRESS>
170</BODY>
171</HTML>