Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(16025)

Side by Side Diff: Doc/library/exceptions.rst

Issue 11682: PEP 380 reference implementation for 3.3
Patch Set: Created 7 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 .. _bltin-exceptions: 1 .. _bltin-exceptions:
2 2
3 Built-in Exceptions 3 Built-in Exceptions
4 =================== 4 ===================
5 5
6 .. index:: 6 .. index::
7 statement: try 7 statement: try
8 statement: except 8 statement: except
9 9
10 In Python, all exceptions must be instances of a class that derives from 10 In Python, all exceptions must be instances of a class that derives from
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 243
244 Raised when an error is detected that doesn't fall in any of the other 244 Raised when an error is detected that doesn't fall in any of the other
245 categories. The associated value is a string indicating what precisely went 245 categories. The associated value is a string indicating what precisely went
246 wrong. (This exception is mostly a relic from a previous version of the 246 wrong. (This exception is mostly a relic from a previous version of the
247 interpreter; it is not used very much any more.) 247 interpreter; it is not used very much any more.)
248 248
249 249
250 .. exception:: StopIteration 250 .. exception:: StopIteration
251 251
252 Raised by built-in function :func:`next` and an :term:`iterator`\'s 252 Raised by built-in function :func:`next` and an :term:`iterator`\'s
253 :meth:`__next__` method to signal that there are no further values. 253 :meth:`__next__` method to signal that there are no further items to be
254 produced by the iterator.
255
256 The exception object has a single attribute :attr:`value`, which is
257 given as an argument when constructing the exception, and defaults
258 to :const:`None`.
259
260 When a generator function returns, a new :exc:`StopIteration` instance is
261 raised, and the value returned by the function is used as the
262 :attr:`value` parameter to the constructor of the exception.
254 263
255 264
256 .. exception:: SyntaxError 265 .. exception:: SyntaxError
257 266
258 Raised when the parser encounters a syntax error. This may occur in an 267 Raised when the parser encounters a syntax error. This may occur in an
259 :keyword:`import` statement, in a call to the built-in functions :func:`exec` 268 :keyword:`import` statement, in a call to the built-in functions :func:`exec`
260 or :func:`eval`, or when reading the initial script or standard input 269 or :func:`eval`, or when reading the initial script or standard input
261 (also interactively). 270 (also interactively).
262 271
263 Instances of this class have attributes :attr:`filename`, :attr:`lineno`, 272 Instances of this class have attributes :attr:`filename`, :attr:`lineno`,
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 .. versionadded:: 3.2 567 .. versionadded:: 3.2
559 568
560 569
561 570
562 Exception hierarchy 571 Exception hierarchy
563 ------------------- 572 -------------------
564 573
565 The class hierarchy for built-in exceptions is: 574 The class hierarchy for built-in exceptions is:
566 575
567 .. literalinclude:: ../../Lib/test/exception_hierarchy.txt 576 .. literalinclude:: ../../Lib/test/exception_hierarchy.txt
OLDNEW
« no previous file with comments | « Doc/library/dis.rst ('k') | Doc/reference/expressions.rst » ('j') | Modules/parsermodule.c » ('J')

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+