@@ -156,6 +156,48 @@ that their code needs to change. The `empirical evidence <#appendix>`__
156156shows that the changes necessary are typically quite
157157straightforward.
158158
159+ Rejected Ideas
160+ ==============
161+
162+ Emit ``SyntaxError `` in CPython
163+ -------------------------------
164+
165+ :pep: `601 ` proposed that CPython would emit ``SyntaxWarning `` for a couple of
166+ releases and ``SyntaxError `` afterwards. We are leaving it open whether, and
167+ when, this will become a ``SyntaxError `` in CPython, because we believe that a
168+ ``SyntaxWarning `` would provide most of the benefit with less risk.
169+
170+ Change Semantics
171+ ----------------
172+
173+ It `was suggested <https://discuss.python.org/t/pep-765-disallow-return-break-continue-that-exit-a-finally-block/71348/32 >`__
174+ to change the semantics of control flow instructions in ``finally `` such that an
175+ in-flight exception takes precedence over them. In other words, a ``return ``,
176+ ``break `` or ``continue `` would be permitted, and would exit the ``finally ``
177+ block, but the exception would still be raised.
178+
179+ This was rejected for two reasons. First, it would change the semantics of
180+ working code in a way that can be hard to debug: a ``finally `` that was written
181+ with the intention of swallowing all exceptions (correctly using the documented
182+ semantics) would now allow the exception to propagate on. This may happen only
183+ in rare edge cases at runtime, and is not guaranteed to be detected in testing.
184+ Even if the code is wrong, and has an exception swallowing bug, it could be
185+ hard for users to understand why a program started raising exceptions in 3.14,
186+ while it did not in 3.13.
187+ In contrast, a ``SyntaxWarning `` is likely to be seen during testing, it would
188+ point to the precise location of the problem in the code, and it would not
189+ prevent the program from running.
190+
191+ The second objection was about the proposed semantics. The motivation for
192+ allowing control flow statements is not that this would be useful, but rather
193+ the desire for orthogonality of features (which, as we mentioned in the
194+ introduction, is already violated in the case of ``except* `` clauses). However,
195+ the proposed semantics are complicated because they suggest that ``return ``,
196+ ``break `` and ``continue `` behave as they normally do when ``finally `` executes
197+ without an in-flight exception, but turn into something like a bare ``raise ``
198+ when there is one. It is hard to claim that the features are orthogonal if
199+ the presence of one changes the semantics of the other.
200+
159201Appendix
160202========
161203
0 commit comments