summaryrefslogtreecommitdiffstats
path: root/Doc/library/ast.rst
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2021-12-14 16:48:15 (GMT)
committerGitHub <noreply@github.com>2021-12-14 16:48:15 (GMT)
commitd60457a6673cf0263213c2f2be02c633ec2e2038 (patch)
tree04461db9079cf30a98c5a4070098f795275aa910 /Doc/library/ast.rst
parent850aefc2c651110a784cd5478af9774b1f6287a3 (diff)
downloadcpython-d60457a6673cf0263213c2f2be02c633ec2e2038.zip
cpython-d60457a6673cf0263213c2f2be02c633ec2e2038.tar.gz
cpython-d60457a6673cf0263213c2f2be02c633ec2e2038.tar.bz2
bpo-45292: [PEP-654] add except* (GH-29581)
Diffstat (limited to 'Doc/library/ast.rst')
-rw-r--r--Doc/library/ast.rst31
1 files changed, 31 insertions, 0 deletions
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index e29b5e8..6486ed4 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -1167,6 +1167,37 @@ Control flow
type_ignores=[])
+.. class:: TryStar(body, handlers, orelse, finalbody)
+
+ ``try`` blocks which are followed by ``except*`` clauses. The attributes are the
+ same as for :class:`Try` but the :class:`ExceptHandler` nodes in ``handlers``
+ are interpreted as ``except*`` blocks rather then ``except``.
+
+ .. doctest::
+
+ >>> print(ast.dump(ast.parse("""
+ ... try:
+ ... ...
+ ... except* Exception:
+ ... ...
+ ... """), indent=4))
+ Module(
+ body=[
+ TryStar(
+ body=[
+ Expr(
+ value=Constant(value=Ellipsis))],
+ handlers=[
+ ExceptHandler(
+ type=Name(id='Exception', ctx=Load()),
+ body=[
+ Expr(
+ value=Constant(value=Ellipsis))])],
+ orelse=[],
+ finalbody=[])],
+ type_ignores=[])
+
+
.. class:: ExceptHandler(type, name, body)
A single ``except`` clause. ``type`` is the exception type it will match,