Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4338920

Browse files
committed
Added doc strings to the exception classes.
Contributed by Blake Winton, but considerably edited.
1 parent 40233ea commit 4338920

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

Lib/exceptions.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"""
6161

6262
class Exception:
63+
"""Proposed base class for all exceptions."""
6364
def __init__(self, *args):
6465
self.args = args
6566

@@ -75,9 +76,11 @@ def __getitem__(self, i):
7576
return self.args[i]
7677

7778
class StandardError(Exception):
79+
"""Base class for all standard Python exceptions."""
7880
pass
7981

8082
class SyntaxError(StandardError):
83+
"""Invalid syntax."""
8184
filename = lineno = offset = text = None
8285
msg = ""
8386
def __init__(self, *args):
@@ -94,8 +97,7 @@ def __str__(self):
9497
return str(self.msg)
9598

9699
class EnvironmentError(StandardError):
97-
"""Base class for exceptions that occur outside the Python system.
98-
Primarily used as a base class for OSError and IOError."""
100+
"""Base class for I/O related errors."""
99101
def __init__(self, *args):
100102
self.args = args
101103
self.errno = None
@@ -126,70 +128,94 @@ def __str__(self):
126128
return StandardError.__str__(self)
127129

128130
class IOError(EnvironmentError):
131+
"""I/O operation failed."""
129132
pass
130133

131134
class OSError(EnvironmentError):
132-
"""Used by the posix module."""
135+
"""OS system call failed."""
133136
pass
134137

135138
class RuntimeError(StandardError):
139+
"""Unspecified run-time error."""
136140
pass
137141

138142
class NotImplementedError(RuntimeError):
143+
"""Method or function hasn't been implemented yet."""
139144
pass
140145

141146
class SystemError(StandardError):
147+
"""Internal error in the Python interpreter.
148+
149+
Please report this to the Python maintainer, along with the traceback,
150+
the Python version, and the hardware/OS platform and version."""
142151
pass
143152

144153
class EOFError(StandardError):
154+
"""Read beyond end of file."""
145155
pass
146156

147157
class ImportError(StandardError):
158+
"""Import can't find module, or can't find name in module."""
148159
pass
149160

150161
class TypeError(StandardError):
162+
"""Inappropriate argument type."""
151163
pass
152164

153165
class ValueError(StandardError):
166+
"""Inappropriate argument value (of correct type)."""
154167
pass
155168

156169
class KeyboardInterrupt(StandardError):
170+
"""Program interrupted by user."""
157171
pass
158172

159173
class AssertionError(StandardError):
174+
"""Assertion failed."""
160175
pass
161176

162177
class ArithmeticError(StandardError):
178+
"""Base class for arithmetic errors."""
163179
pass
164180

165181
class OverflowError(ArithmeticError):
182+
"""Result too large to be represented."""
166183
pass
167184

168185
class FloatingPointError(ArithmeticError):
186+
"""Floating point operation failed."""
169187
pass
170188

171189
class ZeroDivisionError(ArithmeticError):
190+
"""Second argument to a division or modulo operation was zero."""
172191
pass
173192

174193
class LookupError(StandardError):
194+
"""Base class for lookup errors."""
175195
pass
176196

177197
class IndexError(LookupError):
198+
"""Sequence index out of range."""
178199
pass
179200

180201
class KeyError(LookupError):
202+
"""Mapping key not found."""
181203
pass
182204

183205
class AttributeError(StandardError):
206+
"""Attribute not found."""
184207
pass
185208

186209
class NameError(StandardError):
210+
"""Name not found locally or globally."""
187211
pass
188212

189213
class MemoryError(StandardError):
214+
"""Out of memory."""
190215
pass
191216

192217
class SystemExit(Exception):
218+
"""Request to exit from the interpreter."""
193219
def __init__(self, *args):
194220
self.args = args
195221
if len(args) == 0:

0 commit comments

Comments
 (0)