Python Exception Hierarchy
PCEP objective 4.3 is titled Python Built-In Exceptions Hierarchy, and it is one of the few objectives that really is a memorisation task. It is much less work than it looks: the tree has three or four levels, most exceptions sit directly under `Exception`, and the ones that do not are grouped in ways that make sense. This page prints the whole thing out of the interpreter rather than drawing it, because every diagram in circulation gets at least one relationship wrong.
Exceptions Guide 23 of 26 Intermediate
- Python3.14.4
- OSUbuntu 26.04 LTS
- pip25.1.1
- TimeAbout 15 min
- Reviewed23 August 2026
Written against the versions above. The hierarchy is stable. `ModuleNotFoundError` was added in Python 3.6 as a subclass of `ImportError`, and `BaseExceptionGroup` in 3.11 - neither exam examines the second. `RecursionError` was split out of `RuntimeError` in 3.5 and remains a subclass of it.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| RUNNER01 | 192.168.0.27 | Ubuntu 26.04 LTS | Python 3.14.4 - the only machine this path needs | 2 Core | 4 GB | 50 GB |
Before you start
- guide 18 - exceptions are raised by things that fail.
- You will have met most of these already: this path has raised twenty different exceptions before this page.
-
The tree, printed from the classes themselves
-
What sits directly under BaseException
-
Inheritance decides which clause matches
-
The shape worth memorising
-
What the exam does with this objective