summaryrefslogtreecommitdiff
path: root/Doc/library/exceptions.rst
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-03-29 14:45:47 -0700
committerGitHub <noreply@github.com>2022-03-29 14:45:47 -0700
commit66cde7c51a871a86cf8667adf4bd1d03e9b98eb1 (patch)
treed83d2ccf5fa84133000411ad49a475bd2191f530 /Doc/library/exceptions.rst
parent370900d7d8ba29eb52e419c3163599b4ac55f121 (diff)
downloadcpython-git-66cde7c51a871a86cf8667adf4bd1d03e9b98eb1.tar.gz
bpo-42340: Document issues around KeyboardInterrupt (GH-23255)
Update documentation to note that in some circumstances, KeyboardInterrupt may cause code to enter an inconsistent state. Also document sample workaround to avoid KeyboardInterrupt, if needed. (cherry picked from commit d0906c90fcfbc4cfb9bb963eaa6bb152dd543b56) Co-authored-by: benfogle <benfogle@gmail.com>
Diffstat (limited to 'Doc/library/exceptions.rst')
-rw-r--r--Doc/library/exceptions.rst9
1 files changed, 9 insertions, 0 deletions
diff --git a/Doc/library/exceptions.rst b/Doc/library/exceptions.rst
index 2f97bb8131..50a3ff3452 100644
--- a/Doc/library/exceptions.rst
+++ b/Doc/library/exceptions.rst
@@ -246,6 +246,15 @@ The following exceptions are the exceptions that are usually raised.
accidentally caught by code that catches :exc:`Exception` and thus prevent
the interpreter from exiting.
+ .. note::
+
+ Catching a :exc:`KeyboardInterrupt` requires special consideration.
+ Because it can be raised at unpredictable points, it may, in some
+ circumstances, leave the running program in an inconsistent state. It is
+ generally best to allow :exc:`KeyboardInterrupt` to end the program as
+ quickly as possible or avoid raising it entirely. (See
+ :ref:`handlers-and-exceptions`.)
+
.. exception:: MemoryError