summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2020-12-20 18:24:10 (GMT)
committerGitHub <noreply@github.com>2020-12-20 18:24:10 (GMT)
commitc95f8bc2700b42f4568886505a819816c9b0ba28 (patch)
tree105ca01ea2f7d4b5603135d8a3ec30d354335b98
parentb0398a4b7fb5743f6dbb72ac6b2926e0a0c11498 (diff)
downloadcpython-c95f8bc2700b42f4568886505a819816c9b0ba28.zip
cpython-c95f8bc2700b42f4568886505a819816c9b0ba28.tar.gz
cpython-c95f8bc2700b42f4568886505a819816c9b0ba28.tar.bz2
bpo-42669: Document that `except` rejects nested tuples (GH-23822)
In Python 2, it was possible to use `except` with a nested tuple, and occasionally natural. For example, `zope.formlib.interfaces.InputErrors` is a tuple of several exception classes, and one might reasonably think to do something like this: try: self.getInputValue() return True except (InputErrors, SomethingElse): return False As of Python 3.0, this raises `TypeError: catching classes that do not inherit from BaseException is not allowed` instead: one must instead either break it up into multiple `except` clauses or flatten the tuple. However, the reference documentation was never updated to match this new restriction. Make it clear that the definition is no longer recursive. Automerge-Triggered-By: GH:ericvsmith
-rw-r--r--Doc/reference/compound_stmts.rst3
-rw-r--r--Misc/ACKS1
2 files changed, 3 insertions, 1 deletions
diff --git a/Doc/reference/compound_stmts.rst b/Doc/reference/compound_stmts.rst
index a55aacc..8da74c7 100644
--- a/Doc/reference/compound_stmts.rst
+++ b/Doc/reference/compound_stmts.rst
@@ -254,7 +254,8 @@ present, must be last; it matches any exception. For an except clause with an
expression, that expression is evaluated, and the clause matches the exception
if the resulting object is "compatible" with the exception. An object is
compatible with an exception if it is the class or a base class of the exception
-object or a tuple containing an item compatible with the exception.
+object, or a tuple containing an item that is the class or a base class of
+the exception object.
If no except clause matches the exception, the search for an exception handler
continues in the surrounding code and on the invocation stack. [#]_
diff --git a/Misc/ACKS b/Misc/ACKS
index 381aed1..80e51f9 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -1849,6 +1849,7 @@ Zachary Ware
Barry Warsaw
Steve Waterbury
Bob Watson
+Colin Watson
David Watson
Aaron Watters
Henrik Weber