chunk_id
large_stringlengths
36
36
doc_type
large_stringclasses
2 values
category
large_stringclasses
17 values
document
large_stringclasses
50 values
version_raw
large_stringclasses
590 values
chunk_index
int64
0
262
text
large_stringlengths
11
5.69k
file_path
large_stringclasses
882 values
4662a856-bc25-5944-836b-7d368e820d91
docs
python
python_exceptions
313
47
as are the values of its [`message`](#BaseExceptionGroup.message "BaseExceptionGroup.message"), [`__traceback__`](#BaseException.__traceback__ "BaseException.__traceback__"), [`__cause__`](#BaseException.__cause__ "BaseException.__cause__"), [`__context__`](#BaseException.__context__ "BaseExcept...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
7b585607-d2b2-59ee-95dc-65bf30f78d32
docs
python
python_exceptions
313
48
: Like [`subgroup()`](#BaseExceptionGroup.subgroup "BaseExceptionGroup.subgroup"), but returns the pair `(match, rest)` where `match` is `subgroup(condition)` and `rest` is the remaining non-matching part. derive(*excs*)[¶](#BaseExceptionGroup.derive "Link to this definition") : Returns...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
06977834-a33a-525c-aff6-1f6390ec8222
docs
python
python_exceptions
313
49
than [`ExceptionGroup`](#ExceptionGroup "ExceptionGroup"). [`subgroup()`](#BaseExceptionGroup.subgroup "BaseExceptionGroup.subgroup") and [`split()`](#BaseExceptionGroup.split "BaseExceptionGroup.split") copy the [`__traceback__`](#BaseException.__traceback__ "BaseException.__traceback__"), ...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
01bc53e7-eaaf-5e6d-ad4b-97ed593f0b7a
docs
python
python_exceptions
313
50
>>> e = MyGroup("eg", [ValueError(1), TypeError(2)]) >>> e.add_note("a note") >>> e.__context__ = Exception("context") >>> e.__cause__ = Exception("cause") >>> try: ... raise e ... except Exception as e: ... exc = e ... >>> match, res...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
f5c85aca-6762-51fe-8253-f132e1aa0844
docs
python
python_exceptions
313
51
Note that [`BaseExceptionGroup`](#BaseExceptionGroup "BaseExceptionGroup") defines [`__new__()`](../reference/datamodel.html#object.__new__ "object.__new__"), so subclasses that need a different constructor signature need to override that rather than [`__init__()`](../reference/datamodel.html#object.__init_...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
0fc77c51-6fa4-5062-b74f-1731cf541201
docs
python
python_exceptions
313
52
is also a subclass of [`Exception`](#Exception "Exception") can only wrap instances of [`Exception`](#Exception "Exception"). Added in version 3.11. ## Exception hierarchy[¶](#exception-hierarchy "Link to this heading") The class hierarchy for built-in exceptions is: ```None BaseException ├── BaseExcep...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
449286f2-10f7-5f4b-be25-ea357f5f3512
docs
python
python_exceptions
313
53
│ │ ├── ConnectionAbortedError │ │ ├── ConnectionRefusedError │ │ └── ConnectionResetError │ ├── FileExistsError │ ├── FileNotFoundError │ ├── InterruptedError │ ├── IsADirectoryError │ ├── NotADirectoryError │ ├── PermissionError...
large_dataset/raw/docs/python/exceptions/exceptions_313.md
71e6ed53-4495-5437-9995-44d3c8c64bc7
docs
python
python_exceptions
313
54
├── ImportWarning ├── PendingDeprecationWarning ├── ResourceWarning ├── RuntimeWarning ├── SyntaxWarning ├── UnicodeWarning └── UserWarning ```
large_dataset/raw/docs/python/exceptions/exceptions_313.md
2a60a204-a17e-58aa-b9d1-d735a1a4466d
docs
python
python_exceptions
314
0
# Built-in Exceptions¶ Source: https://docs.python.org/3.14/library/exceptions.html Version: 3.14 In Python, all exceptions must be instances of a class that derives from [`BaseException`](#BaseException "BaseException"). In a [`try`](../reference/compound_stmts.html#try) statement with an [`except`](../reference/com...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
a539fd77-a6ee-5c9e-b1a1-cd640e1198dd
docs
python
python_exceptions
314
1
class’s constructor. User code can raise built-in exceptions. This can be used to test an exception handler or to report an error condition “just like” the situation in which the interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error. The built...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
82337b8d-9a8a-5e64-8914-7b1ccbb2168a
docs
python
python_exceptions
314
2
BaseException.\_\_cause\_\_[¶](#BaseException.__cause__ "Link to this definition") BaseException.\_\_suppress\_context\_\_[¶](#BaseException.__suppress_context__ "Link to this definition") : When raising a new exception while another exception is already being handled, the new exception’s `__context__` attri...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
3737cb4d-68fb-5d31-9dab-0385ff091064
docs
python
python_exceptions
314
3
`__cause__` also implicitly sets the `__suppress_context__` attribute to `True`, so that using `raise new_exc from None` effectively replaces the old exception with the new one for display purposes (e.g. converting [`KeyError`](#KeyError "KeyError") to [`AttributeError`](#AttributeError "AttributeError"...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
6c272b98-5f3f-5193-ae9a-bb9fff6c4832
docs
python
python_exceptions
314
4
## Inheriting from built-in exceptions[¶](#inheriting-from-built-in-exceptions "Link to this heading") User code can create subclasses that inherit from an exception type. It’s recommended to only subclass one exception type at a time to avoid any possible conflicts between how the bases handle the `args` attribute, a...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
9dae7fe7-8eb3-5d82-b8ec-0c7ff268c666
docs
python
python_exceptions
314
5
## Base classes[¶](#base-classes "Link to this heading") The following exceptions are used mostly as base classes for other exceptions. *exception* BaseException[¶](#BaseException "Link to this definition") : The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined cl...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
64267816-3b5d-5268-8289-5f45bc7c8ca5
docs
python
python_exceptions
314
6
with\_traceback(*tb*)[¶](#BaseException.with_traceback "Link to this definition") : This method sets *tb* as the new traceback for the exception and returns the exception object. It was more commonly used before the exception chaining features of [**PEP 3134**](https://peps.python.org/pep-3134...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
c1171272-606a-54ae-80a6-3edb816944ee
docs
python
python_exceptions
314
7
: A writable field that holds the [traceback object](../reference/datamodel.html#traceback-objects) associated with this exception. See also: [The raise statement](../reference/simple_stmts.html#raise). add\_note(*note*)[¶](#BaseException.add_note "Link to this definition") : Add the st...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
a1bc9640-c554-556c-8c13-95e724cc4c5f
docs
python
python_exceptions
314
8
: All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class. *exception* ArithmeticError[¶](#ArithmeticError "Link to this definition") : The base class for those built-in exceptions that are raised for various arithmetic err...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
fbfa723e-625d-5a2d-ba74-1f0de612fc9a
docs
python
python_exceptions
314
9
can be raised directly by [`codecs.lookup()`](codecs.html#codecs.lookup "codecs.lookup"). ## Concrete exceptions[¶](#concrete-exceptions "Link to this heading") The following exceptions are the exceptions that are usually raised. *exception* AssertionError[¶](#AssertionError "Link to this definition") : Raised...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
18122a16-e62a-59f7-8ec3-944b2a4d009a
docs
python
python_exceptions
314
10
obj[¶](#AttributeError.obj "Link to this definition") : The object that was accessed for the named attribute. Changed in version 3.10: Added the [`name`](#AttributeError.name "AttributeError.name") and [`obj`](#AttributeError.obj "AttributeError.obj") attributes. *exception* EOFError[¶](#EOFError "Link ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
518c4d25-756c-52dd-a7dd-b0f53e0d7d78
docs
python
python_exceptions
314
11
see [`generator.close()`](../reference/expressions.html#generator.close "generator.close") and [`coroutine.close()`](../reference/datamodel.html#coroutine.close "coroutine.close"). It directly inherits from [`BaseException`](#BaseException "BaseException") instead of [`Exception`](#Exception "Exception") since ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
a9ad4f15-338a-59ee-8b9f-e42f97b2001b
docs
python
python_exceptions
314
12
Changed in version 3.3: Added the [`name`](#ImportError.name "ImportError.name") and [`path`](#ImportError.path "ImportError.path") attributes. *exception* ModuleNotFoundError[¶](#ModuleNotFoundError "Link to this definition") : A subclass of [`ImportError`](#ImportError "ImportError") which is raised by [`impor...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
a89140d1-2247-5cb7-9b0c-c8c9e9c1df2a
docs
python
python_exceptions
314
13
*exception* KeyboardInterrupt[¶](#KeyboardInterrupt "Link to this definition") : Raised when the user hits the interrupt key (normally `Control`-`C` or `Delete`). During execution, a check for interrupts is made regularly. The exception inherits from [`BaseException`](#BaseException "BaseException") so as to ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
3061db34-ad7a-5045-a693-c72606d3971b
docs
python
python_exceptions
314
14
*exception* MemoryError[¶](#MemoryError "Link to this definition") : Raised when an operation runs out of memory but the situation may still be rescued (by deleting some objects). The associated value is a string indicating what kind of (internal) operation ran out of memory. Note that because of the unde...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
41241723-1996-5c1d-a297-99fa536fdf54
docs
python
python_exceptions
314
15
: The name of the variable that was attempted to be accessed. Changed in version 3.10: Added the [`name`](#NameError.name "NameError.name") attribute. *exception* NotImplementedError[¶](#NotImplementedError "Link to this definition") : This exception is derived from [`RuntimeError`](#RuntimeError "Runtime...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
c956c388-4fa2-552b-9194-881f2e534645
docs
python
python_exceptions
314
16
above; see [`NotImplemented`](constants.html#NotImplemented "NotImplemented") for details on correct usage of the built-in constant. *exception* OSError([*arg*])[¶](#OSError "Link to this definition") *exception* OSError(*errno*, *strerror*[, *filename*[, *winerror*[, *filename2*]]]) : This exception is rai...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
c0809283-5694-5a54-a350-1dee449f001d
docs
python
python_exceptions
314
17
described in [OS exceptions](#os-exceptions) below. The particular subclass depends on the final [`errno`](#OSError.errno "OSError.errno") value. This behaviour only occurs when constructing [`OSError`](#OSError "OSError") directly or via an alias, and is not inherited when subclassing. errno[¶](#O...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
c6832678-c4aa-5e9d-bc9b-ac313bc53f83
docs
python
python_exceptions
314
18
*winerror* argument is ignored, and the [`winerror`](#OSError.winerror "OSError.winerror") attribute does not exist. strerror[¶](#OSError.strerror "Link to this definition") : The corresponding error message, as provided by the operating system. It is formatted by the C functi...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
4cfc9117-e839-51ec-a830-bb435d422eed
docs
python
python_exceptions
314
19
Changed in version 3.3: [`EnvironmentError`](#EnvironmentError "EnvironmentError"), [`IOError`](#IOError "IOError"), [`WindowsError`](#WindowsError "WindowsError"), [`socket.error`](socket.html#socket.error "socket.error"), [`select.error`](select.html#select.error "select.error") and `mmap.error` have been...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
5860491f-96fe-55c7-b082-ab78c944a9b1
docs
python
python_exceptions
314
20
[`MemoryError`](#MemoryError "MemoryError") than give up). However, for historical reasons, OverflowError is sometimes raised for integers that are outside a required range. Because of the lack of standardization of floating-point exception handling in C, most floating-point operations are not checked. ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
18a32496-a53e-53a3-a961-07abef746e75
docs
python
python_exceptions
314
21
See also the [`sys.is_finalizing()`](sys.html#sys.is_finalizing "sys.is_finalizing") function. Added in version 3.13: Previously, a plain [`RuntimeError`](#RuntimeError "RuntimeError") was raised. Changed in version 3.14: [`threading.Thread.join()`](threading.html#threading.Thread.join "threading.Thread.j...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
6cfd1b37-b72a-5f99-9e98-ce8c241a3d61
docs
python
python_exceptions
314
22
[`weakref.proxy()`](weakref.html#weakref.proxy "weakref.proxy") function, is used to access an attribute of the referent after it has been garbage collected. For more information on weak references, see the [`weakref`](weakref.html#module-weakref "weakref: Support for weak references and weak dictionaries."...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
1fd2a909-bb8f-546a-abca-78aadf78e27f
docs
python
python_exceptions
314
23
: The exception object has a single attribute `value`, which is given as an argument when constructing the exception, and defaults to [`None`](constants.html#None "None"). When a [generator](../glossary.html#term-generator) or [coroutine](../glossary.html#term-coroutine) function returns,...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
5d19ba60-d1f7-56bf-a5e3-807e9b36a433
docs
python
python_exceptions
314
24
Changed in version 3.5: Introduced the RuntimeError transformation via `from __future__ import generator_stop`, see [**PEP 479**](https://peps.python.org/pep-0479/). Changed in version 3.7: Enable [**PEP 479**](https://peps.python.org/pep-0479/) for all code by default: a [`StopIteration`](#StopIteration "...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
4f2c234c-9146-54f1-9a7a-09f09321de38
docs
python
python_exceptions
314
25
[`import`](../reference/simple_stmts.html#import) statement, in a call to the built-in functions [`compile()`](functions.html#compile "compile"), [`exec()`](functions.html#exec "exec"), or [`eval()`](functions.html#eval "eval"), or when reading the initial script or standard input (also interactively). ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
d88c8da1-5518-56c0-8390-1ba5d84c4b4c
docs
python
python_exceptions
314
26
text[¶](#SyntaxError.text "Link to this definition") : The source code text involved in the error. end\_lineno[¶](#SyntaxError.end_lineno "Link to this definition") : Which line number in the file the error occurred ends in. This is 1-indexed: the first line in the file has a `lineno` of 1...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
e58debca-a703-59b0-b7cb-44c6c8f6507a
docs
python
python_exceptions
314
27
*exception* IndentationError[¶](#IndentationError "Link to this definition") : Base class for syntax errors related to incorrect indentation. This is a subclass of [`SyntaxError`](#SyntaxError "SyntaxError"). *exception* TabError[¶](#TabError "Link to this definition") : Raised when indentation contains an inc...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
7b62bf7b-89c9-51a9-84d7-a26585f25180
docs
python
python_exceptions
314
28
a package you’re using, you should report this to the author or maintainer of your Python interpreter. Be sure to report the version of the Python interpreter (`sys.version`; it is also printed at the start of an interactive Python session), the exact error message (the exception’s associated value)...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
9fe7f3f3-5283-5180-a724-a16468a2559d
docs
python
python_exceptions
314
29
constructor accepts the same optional argument passed to [`sys.exit()`](sys.html#sys.exit "sys.exit"). If the value is an integer, it specifies the system exit status (passed to C’s `exit()` function); if it is `None`, the exit status is zero; if it has another type (such as a string), the object’s valu...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
7f311eac-0d4b-5d68-8b15-f9894af4474e
docs
python
python_exceptions
314
30
: The exit status or error message that is passed to the constructor. (Defaults to `None`.) *exception* TypeError[¶](#TypeError "Link to this definition") : Raised when an operation or function is applied to an object of inappropriate type. The associated value is a string giving details about the ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
4cf01d30-70a2-5320-8a02-64b257f2f2d4
docs
python
python_exceptions
314
31
should result in a [`ValueError`](#ValueError "ValueError"). *exception* UnboundLocalError[¶](#UnboundLocalError "Link to this definition") : Raised when a reference is made to a local variable in a function or method, but no value has been bound to that variable. This is a subclass of [`NameError`](#Nam...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
dec7eb95-2900-5a62-91a4-ba99b38903c2
docs
python
python_exceptions
314
32
object[¶](#UnicodeError.object "Link to this definition") : The object the codec was attempting to encode or decode. start[¶](#UnicodeError.start "Link to this definition") : The first index of invalid data in [`object`](functions.html#object "object"). This value should not be negative as...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
bbfeac5a-c68f-501e-8537-9d8a153913f2
docs
python
python_exceptions
314
33
: Raised when a Unicode-related error occurs during decoding. It is a subclass of [`UnicodeError`](#UnicodeError "UnicodeError"). *exception* UnicodeTranslateError[¶](#UnicodeTranslateError "Link to this definition") : Raised when a Unicode-related error occurs during translating. It is a subclass of [`Uni...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
a1c97d50-4c2c-53a2-a3bd-32d9ae308f65
docs
python
python_exceptions
314
34
starting from Python 3.3, they are aliases of [`OSError`](#OSError "OSError"). *exception* EnvironmentError[¶](#EnvironmentError "Link to this definition") *exception* IOError[¶](#IOError "Link to this definition") *exception* WindowsError[¶](#WindowsError "Link to this definition") : Only available on Windows. #...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
75273f1c-2cfd-5a07-bf0f-577a08d9cf17
docs
python
python_exceptions
314
35
In addition to those of [`OSError`](#OSError "OSError"), [`BlockingIOError`](#BlockingIOError "BlockingIOError") can have one more attribute: characters\_written[¶](#BlockingIOError.characters_written "Link to this definition") : An integer containing the number of **bytes** written to the stream ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
9141d896-dd94-502b-888c-221a7755bb27
docs
python
python_exceptions
314
36
[`ConnectionRefusedError`](#ConnectionRefusedError "ConnectionRefusedError") and [`ConnectionResetError`](#ConnectionResetError "ConnectionResetError"). *exception* BrokenPipeError[¶](#BrokenPipeError "Link to this definition") : A subclass of [`ConnectionError`](#ConnectionError "ConnectionError"), raised when ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
560cc1ee-4663-5c61-9c8e-7e94120a023d
docs
python
python_exceptions
314
37
: A subclass of [`ConnectionError`](#ConnectionError "ConnectionError"), raised when a connection attempt is refused by the peer. Corresponds to `errno` [`ECONNREFUSED`](errno.html#errno.ECONNREFUSED "errno.ECONNREFUSED"). *exception* ConnectionResetError[¶](#ConnectionResetError "Link to this definition") :...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
521e6cd0-cfd4-592e-a983-1d1b625b69c9
docs
python
python_exceptions
314
38
*exception* InterruptedError[¶](#InterruptedError "Link to this definition") : Raised when a system call is interrupted by an incoming signal. Corresponds to `errno` [`EINTR`](errno.html#errno.EINTR "errno.EINTR"). Changed in version 3.5: Python now retries system calls when a syscall is interrupted by a ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
1f594bda-1133-52bb-a2c7-efc46e23e3ad
docs
python
python_exceptions
314
39
something which is not a directory. On most POSIX platforms, it may also be raised if an operation attempts to open or traverse a non-directory file as if it were a directory. Corresponds to `errno` [`ENOTDIR`](errno.html#errno.ENOTDIR "errno.ENOTDIR"). *exception* PermissionError[¶](#PermissionError "...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
a81a1d22-d734-5a44-9727-588a4d52ef6d
docs
python
python_exceptions
314
40
Corresponds to `errno` [`ESRCH`](errno.html#errno.ESRCH "errno.ESRCH"). *exception* TimeoutError[¶](#TimeoutError "Link to this definition") : Raised when a system function timed out at the system level. Corresponds to `errno` [`ETIMEDOUT`](errno.html#errno.ETIMEDOUT "errno.ETIMEDOUT"). Added in version 3.3...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
1b95b48a-7fd0-5905-b92f-e52be4cc0d21
docs
python
python_exceptions
314
41
: Base class for warnings about deprecated features when those warnings are intended for other Python developers. Ignored by the default warning filters, except in the `__main__` module ([**PEP 565**](https://peps.python.org/pep-0565/)). Enabling the [Python Development Mode](devmode.html#devmode) shows ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
f9b9d953-1311-508b-a8f2-09fde0b4eb16
docs
python
python_exceptions
314
42
Development Mode](devmode.html#devmode) shows this warning. The deprecation policy is described in [**PEP 387**](https://peps.python.org/pep-0387/). *exception* SyntaxWarning[¶](#SyntaxWarning "Link to this definition") : Base class for warnings about dubious syntax. This warning is typically emitted w...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
6d59c587-295b-580a-afbc-1988e8311af5
docs
python
python_exceptions
314
43
Development Mode](devmode.html#devmode) shows this warning. *exception* UnicodeWarning[¶](#UnicodeWarning "Link to this definition") : Base class for warnings related to Unicode. *exception* EncodingWarning[¶](#EncodingWarning "Link to this definition") : Base class for warnings related to encodings. See...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
4d1fa8f0-07fe-5d5b-a995-a0755e22970e
docs
python
python_exceptions
314
44
## Exception groups[¶](#exception-groups "Link to this heading") The following are used when it is necessary to raise multiple unrelated exceptions. They are part of the exception hierarchy so they can be handled with [`except`](../reference/compound_stmts.html#except) like all other exceptions. In addition, they are ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
eec649ea-6c89-5513-ae96-f6f50445e4ea
docs
python
python_exceptions
314
45
it can wrap any exception, while [`ExceptionGroup`](#ExceptionGroup "ExceptionGroup") extends [`Exception`](#Exception "Exception") and it can only wrap subclasses of [`Exception`](#Exception "Exception"). This design is so that `except Exception` catches an [`ExceptionGroup`](#ExceptionGroup "ExceptionGrou...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
165bb848-9428-5f9f-9956-84fc62bcff7f
docs
python
python_exceptions
314
46
message[¶](#BaseExceptionGroup.message "Link to this definition") : The `msg` argument to the constructor. This is a read-only attribute. exceptions[¶](#BaseExceptionGroup.exceptions "Link to this definition") : A tuple of the exceptions in the `excs` sequence given to the constructor. This...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
5c775d0d-739c-5524-aa25-690c53a5ffbb
docs
python
python_exceptions
314
47
The nesting structure of the current exception is preserved in the result, as are the values of its [`message`](#BaseExceptionGroup.message "BaseExceptionGroup.message"), [`__traceback__`](#BaseException.__traceback__ "BaseException.__traceback__"), [`__cause__`](#BaseException.__cause__ "BaseEx...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
d799a596-7aa6-5f73-aab2-378737e891f9
docs
python
python_exceptions
314
48
: Like [`subgroup()`](#BaseExceptionGroup.subgroup "BaseExceptionGroup.subgroup"), but returns the pair `(match, rest)` where `match` is `subgroup(condition)` and `rest` is the remaining non-matching part. derive(*excs*)[¶](#BaseExceptionGroup.derive "Link to this definition") : Returns...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
5e30a10a-6080-5da1-8197-7201c97b7526
docs
python
python_exceptions
314
49
than [`ExceptionGroup`](#ExceptionGroup "ExceptionGroup"). [`subgroup()`](#BaseExceptionGroup.subgroup "BaseExceptionGroup.subgroup") and [`split()`](#BaseExceptionGroup.split "BaseExceptionGroup.split") copy the [`__traceback__`](#BaseException.__traceback__ "BaseException.__traceback__"), ...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
5b2c8cbb-4696-59ab-a7bb-d4d64e7bd8b0
docs
python
python_exceptions
314
50
>>> e = MyGroup("eg", [ValueError(1), TypeError(2)]) >>> e.add_note("a note") >>> e.__context__ = Exception("context") >>> e.__cause__ = Exception("cause") >>> try: ... raise e ... except Exception as e: ... exc = e ... >>> match, res...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
1aee8796-6f79-50d2-9f23-cfa28b0b127e
docs
python
python_exceptions
314
51
Note that [`BaseExceptionGroup`](#BaseExceptionGroup "BaseExceptionGroup") defines [`__new__()`](../reference/datamodel.html#object.__new__ "object.__new__"), so subclasses that need a different constructor signature need to override that rather than [`__init__()`](../reference/datamodel.html#object.__init_...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
94e9587e-ca1a-594c-abd5-40914c4bf14d
docs
python
python_exceptions
314
52
is also a subclass of [`Exception`](#Exception "Exception") can only wrap instances of [`Exception`](#Exception "Exception"). Added in version 3.11. ## Exception hierarchy[¶](#exception-hierarchy "Link to this heading") The class hierarchy for built-in exceptions is: ```None BaseException ├── BaseExcep...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
074f6e47-b196-58a9-9ddc-605211d74299
docs
python
python_exceptions
314
53
│ │ ├── ConnectionAbortedError │ │ ├── ConnectionRefusedError │ │ └── ConnectionResetError │ ├── FileExistsError │ ├── FileNotFoundError │ ├── InterruptedError │ ├── IsADirectoryError │ ├── NotADirectoryError │ ├── PermissionError...
large_dataset/raw/docs/python/exceptions/exceptions_314.md
e39404ae-6f24-5ece-a153-75100d31ef15
docs
python
python_exceptions
314
54
├── ImportWarning ├── PendingDeprecationWarning ├── ResourceWarning ├── RuntimeWarning ├── SyntaxWarning ├── UnicodeWarning └── UserWarning ```
large_dataset/raw/docs/python/exceptions/exceptions_314.md
d9bdfd98-327a-56c7-8973-22d8cfae0b43
docs
python
python_exceptions
315
0
# Built-in Exceptions¶ Source: https://docs.python.org/3.15/library/exceptions.html Version: 3.15 In Python, all exceptions must be instances of a class that derives from [`BaseException`](#BaseException "BaseException"). In a [`try`](../reference/compound_stmts.html#try) statement with an [`except`](../reference/com...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
68a0c0e1-e280-5e7d-95e1-1e33e85dcc06
docs
python
python_exceptions
315
1
class’s constructor. User code can raise built-in exceptions. This can be used to test an exception handler or to report an error condition “just like” the situation in which the interpreter raises the same exception; but beware that there is nothing to prevent user code from raising an inappropriate error. The built...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
2b11bf46-3bc3-515c-9c90-9b52efefd692
docs
python
python_exceptions
315
2
BaseException.\_\_cause\_\_[¶](#BaseException.__cause__ "Link to this definition") BaseException.\_\_suppress\_context\_\_[¶](#BaseException.__suppress_context__ "Link to this definition") : When raising a new exception while another exception is already being handled, the new exception’s `__context__` attri...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
2adaa05c-eeb2-56c6-b1b4-db8ceebdd50a
docs
python
python_exceptions
315
3
`__cause__` also implicitly sets the `__suppress_context__` attribute to `True`, so that using `raise new_exc from None` effectively replaces the old exception with the new one for display purposes (e.g. converting [`KeyError`](#KeyError "KeyError") to [`AttributeError`](#AttributeError "AttributeError"...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
df17d773-eebc-5916-bc71-80e1f0f105e1
docs
python
python_exceptions
315
4
## Inheriting from built-in exceptions[¶](#inheriting-from-built-in-exceptions "Link to this heading") User code can create subclasses that inherit from an exception type. It’s recommended to only subclass one exception type at a time to avoid any possible conflicts between how the bases handle the `args` attribute, a...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
f47df378-8436-569f-ba4a-6a29585f8c33
docs
python
python_exceptions
315
5
## Base classes[¶](#base-classes "Link to this heading") The following exceptions are used mostly as base classes for other exceptions. *exception* BaseException[¶](#BaseException "Link to this definition") : The base class for all built-in exceptions. It is not meant to be directly inherited by user-defined cl...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
fca01444-9852-50c0-9218-28f9f6f2fc5e
docs
python
python_exceptions
315
6
with\_traceback(*tb*)[¶](#BaseException.with_traceback "Link to this definition") : This method sets *tb* as the new traceback for the exception and returns the exception object. It was more commonly used before the exception chaining features of [**PEP 3134**](https://peps.python.org/pep-3134...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
a7b6a804-eb69-5291-a143-c62b95e35814
docs
python
python_exceptions
315
7
: A writable field that holds the [traceback object](../reference/datamodel.html#traceback-objects) associated with this exception. See also: [The raise statement](../reference/simple_stmts.html#raise). add\_note(*note*)[¶](#BaseException.add_note "Link to this definition") : Add the st...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
d74e5bcc-380a-5a12-b865-3e19aa347507
docs
python
python_exceptions
315
8
: All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class. *exception* ArithmeticError[¶](#ArithmeticError "Link to this definition") : The base class for those built-in exceptions that are raised for various arithmetic err...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
b212199b-9d7e-5465-bd7b-81e4855fe0bf
docs
python
python_exceptions
315
9
can be raised directly by [`codecs.lookup()`](codecs.html#codecs.lookup "codecs.lookup"). ## Concrete exceptions[¶](#concrete-exceptions "Link to this heading") The following exceptions are the exceptions that are usually raised. *exception* AssertionError[¶](#AssertionError "Link to this definition") : Raised...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
9f5e0213-f773-5391-9272-d494822dce96
docs
python
python_exceptions
315
10
obj[¶](#AttributeError.obj "Link to this definition") : The object that was accessed for the named attribute. Changed in version 3.10: Added the [`name`](#AttributeError.name "AttributeError.name") and [`obj`](#AttributeError.obj "AttributeError.obj") attributes. *exception* EOFError[¶](#EOFError "Link ...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
941a288d-095b-528f-b4c2-9525061dad9a
docs
python
python_exceptions
315
11
see [`generator.close()`](../reference/expressions.html#generator.close "generator.close") and [`coroutine.close()`](../reference/datamodel.html#coroutine.close "coroutine.close"). It directly inherits from [`BaseException`](#BaseException "BaseException") instead of [`Exception`](#Exception "Exception") since ...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
0e942521-b1e7-55d9-a722-bbd03fb0ff32
docs
python
python_exceptions
315
12
Changed in version 3.3: Added the [`name`](#ImportError.name "ImportError.name") and [`path`](#ImportError.path "ImportError.path") attributes. *exception* ModuleNotFoundError[¶](#ModuleNotFoundError "Link to this definition") : A subclass of [`ImportError`](#ImportError "ImportError") which is raised by [`impor...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
95d453d7-2f55-5da2-a59e-adf22825161c
docs
python
python_exceptions
315
13
*exception* KeyboardInterrupt[¶](#KeyboardInterrupt "Link to this definition") : Raised when the user hits the interrupt key (normally `Control`-`C` or `Delete`). During execution, a check for interrupts is made regularly. The exception inherits from [`BaseException`](#BaseException "BaseException") so as to ...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
55c26ea9-6530-5cb0-a92d-d42cd6d7783c
docs
python
python_exceptions
315
14
*exception* MemoryError[¶](#MemoryError "Link to this definition") : Raised when an operation runs out of memory but the situation may still be rescued (by deleting some objects). The associated value is a string indicating what kind of (internal) operation ran out of memory. Note that because of the unde...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
d850393e-6c45-5e6a-ac0d-7a17e222e85f
docs
python
python_exceptions
315
15
: The name of the variable that was attempted to be accessed. Changed in version 3.10: Added the [`name`](#NameError.name "NameError.name") attribute. *exception* NotImplementedError[¶](#NotImplementedError "Link to this definition") : This exception is derived from [`RuntimeError`](#RuntimeError "Runtime...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
d024eace-130d-5aae-af22-375b17139723
docs
python
python_exceptions
315
16
above; see [`NotImplemented`](constants.html#NotImplemented "NotImplemented") for details on correct usage of the built-in constant. *exception* OSError([*arg*])[¶](#OSError "Link to this definition") *exception* OSError(*errno*, *strerror*[, *filename*[, *winerror*[, *filename2*]]]) : This exception is rai...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
c4a61fa8-f262-57bd-bc61-9d24a6c4f829
docs
python
python_exceptions
315
17
described in [OS exceptions](#os-exceptions) below. The particular subclass depends on the final [`errno`](#OSError.errno "OSError.errno") value. This behaviour only occurs when constructing [`OSError`](#OSError "OSError") directly or via an alias, and is not inherited when subclassing. errno[¶](#O...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
9954701a-e31e-5fd0-b0c6-bcd1f2d902e9
docs
python
python_exceptions
315
18
*winerror* argument is ignored, and the [`winerror`](#OSError.winerror "OSError.winerror") attribute does not exist. strerror[¶](#OSError.strerror "Link to this definition") : The corresponding error message, as provided by the operating system. It is formatted by the C functi...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
6875304b-96a3-5dc3-a350-d850f474bb16
docs
python
python_exceptions
315
19
Changed in version 3.3: [`EnvironmentError`](#EnvironmentError "EnvironmentError"), [`IOError`](#IOError "IOError"), [`WindowsError`](#WindowsError "WindowsError"), [`socket.error`](socket.html#socket.error "socket.error"), [`select.error`](select.html#select.error "select.error") and `mmap.error` have been...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
e94dbc6c-3bc7-553c-a06a-bcf8c8e93730
docs
python
python_exceptions
315
20
[`MemoryError`](#MemoryError "MemoryError") than give up). However, for historical reasons, OverflowError is sometimes raised for integers that are outside a required range. Because of the lack of standardization of floating-point exception handling in C, most floating-point operations are not checked. ...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
63c40964-20f9-5e88-8067-2be8ce7044f5
docs
python
python_exceptions
315
21
* acquiring a lock such as [`threading.Lock`](threading.html#threading.Lock "threading.Lock"), when it is known that the operation would otherwise deadlock. See also the [`sys.is_finalizing()`](sys.html#sys.is_finalizing "sys.is_finalizing") function. Added in version 3.13: Previously, a plain [`Run...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
107384dc-1f55-55a4-883e-3d59412c679e
docs
python
python_exceptions
315
22
[`sys.getrecursionlimit()`](sys.html#sys.getrecursionlimit "sys.getrecursionlimit")) is exceeded. Added in version 3.5: Previously, a plain [`RuntimeError`](#RuntimeError "RuntimeError") was raised. *exception* ReferenceError[¶](#ReferenceError "Link to this definition") : This exception is raised when a we...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
15f13e18-149d-5f4a-ba18-a140ef1cf533
docs
python
python_exceptions
315
23
: Raised by built-in function [`next()`](functions.html#next "next") and an [iterator](../glossary.html#term-iterator)'s [`__next__()`](stdtypes.html#iterator.__next__ "iterator.__next__") method to signal that there are no further items produced by the iterator. value[¶](#StopIteration.value "Link to th...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
e2cb3956-e812-5933-be0b-a750e30b5481
docs
python
python_exceptions
315
24
it is converted into a [`RuntimeError`](#RuntimeError "RuntimeError") (retaining the [`StopIteration`](#StopIteration "StopIteration") as the new exception’s cause). Changed in version 3.3: Added `value` attribute and the ability for generator functions to use it to return a value. Changed in vers...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
2502dfe7-be3f-5403-b8b2-5b643cd999e0
docs
python
python_exceptions
315
25
[asynchronous iterator](../glossary.html#term-asynchronous-iterator) object to stop the iteration. Added in version 3.5. *exception* SyntaxError(*message*, *details*)[¶](#SyntaxError "Link to this definition") : Raised when the parser encounters a syntax error. This may occur in an [`import`](../referen...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
eac597c5-d4b3-54e7-8eee-384a66ba4486
docs
python
python_exceptions
315
26
: Which line number in the file the error occurred in. This is 1-indexed: the first line in the file has a `lineno` of 1. offset[¶](#SyntaxError.offset "Link to this definition") : The column in the line where the error occurred. This is 1-indexed: the first character in the line has an...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
5d3690ab-0577-5bf2-92ee-06a2f8a428ee
docs
python
python_exceptions
315
27
and the offsets are offsets in a text constructed from the replacement expression. For example, compiling f’Bad {a b} field’ results in this args attribute: (‘f-string: …’, (‘’, 1, 2, ‘(a b)n’, 1, 5)). Changed in version 3.10: Added the [`end_lineno`](#SyntaxError.end_lineno "SyntaxError.end_lineno") a...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
0f23f5a6-cfb2-5e6e-863c-42b0b37c2850
docs
python
python_exceptions
315
28
look so serious to cause it to abandon all hope. The associated value is a string indicating what went wrong (in low-level terms). In [CPython](../glossary.html#term-CPython), this could be raised by incorrectly using Python’s C API, such as returning a `NULL` value without an exception set. If you...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
3a4d88b9-e505-528d-b3df-c1f7ee2828d1
docs
python
python_exceptions
315
29
[`BaseException`](#BaseException "BaseException") instead of [`Exception`](#Exception "Exception") so that it is not accidentally caught by code that catches [`Exception`](#Exception "Exception"). This allows the exception to properly propagate up and cause the interpreter to exit. When it is not handle...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
d851cf7b-eaaa-5ff1-84ea-8957a3d0599a
docs
python
python_exceptions
315
30
executed, and so that a debugger can execute a script without running the risk of losing control. The [`os._exit()`](os.html#os._exit "os._exit") function can be used if it is absolutely positively necessary to exit immediately (for example, in the child process after a call to [`os.fork()`](os.html#os....
large_dataset/raw/docs/python/exceptions/exceptions_315.md
e0dfa86c-4359-5767-936e-09c0185e1874
docs
python
python_exceptions
315
31
implementation, [`NotImplementedError`](#NotImplementedError "NotImplementedError") is the proper exception to raise. Passing arguments of the wrong type (e.g. passing a [`list`](stdtypes.html#list "list") when an [`int`](functions.html#int "int") is expected) should result in a [`TypeError`](#TypeError "T...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
55b568f9-978a-595f-93a4-2301b1716449
docs
python
python_exceptions
315
32
[`UnicodeError`](#UnicodeError "UnicodeError") has attributes that describe the encoding or decoding error. For example, `err.object[err.start:err.end]` gives the particular invalid input that the codec failed on. encoding[¶](#UnicodeError.encoding "Link to this definition") : The name of the enc...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
39904267-3c8f-5bb3-8f3b-9f8a1055c5a2
docs
python
python_exceptions
315
33
: The index after the last invalid data in [`object`](functions.html#object "object"). This value should not be negative as it is interpreted as an absolute offset but this constraint is not enforced at runtime. *exception* UnicodeEncodeError[¶](#UnicodeEncodeError "Link to this definition") : ...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
41e82805-7cf7-5eb0-b0a4-0344d23e9c78
docs
python
python_exceptions
315
34
: Raised when an operation or function receives an argument that has the right type but an inappropriate value, and the situation is not described by a more precise exception such as [`IndexError`](#IndexError "IndexError"). *exception* ZeroDivisionError[¶](#ZeroDivisionError "Link to this definition") : R...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
9474e870-e61a-520d-8381-845cd889d1b9
docs
python
python_exceptions
315
35
### OS exceptions[¶](#os-exceptions "Link to this heading") The following exceptions are subclasses of [`OSError`](#OSError "OSError"), they get raised depending on the system error code. *exception* BlockingIOError[¶](#BlockingIOError "Link to this definition") : Raised when an operation would block on an object (...
large_dataset/raw/docs/python/exceptions/exceptions_315.md
ae829d31-bc35-5971-9683-bbcbdbca805a
docs
python
python_exceptions
315
36
before it blocked. This attribute is available when using the buffered I/O classes from the [`io`](io.html#module-io "io: Core tools for working with streams.") module. *exception* ChildProcessError[¶](#ChildProcessError "Link to this definition") : Raised when an operation on a child process failed....
large_dataset/raw/docs/python/exceptions/exceptions_315.md