Skip to content

Commit 95f8744

Browse files
committed
whitespace
1 parent b2f8126 commit 95f8744

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

peps/pep-0765.rst

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,15 @@ and among them the script found 203 instances of control flow instructions in a
208208
``continue``. Of these:
209209

210210
- 46 are correct, and appear in tests that target this pattern as a feature (e.g.,
211-
tests for linters that detect it).
211+
tests for linters that detect it).
212212
- 8 seem like they could be correct - either intentionally swallowing exceptions
213-
or appearing where an active exception cannot occur. Despite being correct, it is
214-
not hard to rewrite them to avoid the bad pattern, and it would make the code
215-
clearer: deliberately swallowing exceptions can be more explicitly done with
216-
``except BaseException:``, and ``return`` which doesn't swallow exceptions can be
217-
moved after the ``finally`` block.
213+
or appearing where an active exception cannot occur. Despite being correct, it is
214+
not hard to rewrite them to avoid the bad pattern, and it would make the code
215+
clearer: deliberately swallowing exceptions can be more explicitly done with
216+
``except BaseException:``, and ``return`` which doesn't swallow exceptions can be
217+
moved after the ``finally`` block.
218218
- 149 were clearly incorrect, and can lead to unintended swallowing of exceptions.
219-
These are analyzed in the next section.
219+
These are analyzed in the next section.
220220

221221
**The Error Cases**
222222

@@ -280,8 +280,8 @@ from the code maintainers:
280280
- 20 received reactions acknowleding the problem as one worth looking into.
281281
- 3 replied that the code is no longer maintained so this won't be fixed.
282282
- 2 closed the issue as "works as intended", one said that they intend to
283-
swallow all exceptions, but the other seemed unaware of the distinction
284-
between ``Exception`` and ``BaseException``.
283+
swallow all exceptions, but the other seemed unaware of the distinction
284+
between ``Exception`` and ``BaseException``.
285285

286286
One issue was linked to a pre-existing open issue about non-responsiveness to Ctrl-C,
287287
conjecturing a connection.
@@ -297,17 +297,17 @@ contact the authors in these cases, so we will need to assess the difficulty of
297297
making these changes ourselves.
298298

299299
- In `mosaicml<https://github.com/mosaicml/composer/blob/694e72159cf026b838ba00333ddf413185b4fb4f/composer/cli/launcher.py#L590>`__
300-
there is a return in a finally at the end of the ``main`` function, after an ``except:``
301-
clause which swallows all exceptions. The return in the finally would swallow
302-
an exception raised from within the ``except:`` clause, but this seems to be the
303-
intention in this code. A possible fix would be to assign the return value to a
304-
variable in the ``finally`` clause, dedent the ``return`` statement and wrap the
305-
body of the ``except:`` clause by another ``try``-``except`` to swallow any
306-
exceptions from within it.
300+
there is a return in a finally at the end of the ``main`` function, after an ``except:``
301+
clause which swallows all exceptions. The return in the finally would swallow
302+
an exception raised from within the ``except:`` clause, but this seems to be the
303+
intention in this code. A possible fix would be to assign the return value to a
304+
variable in the ``finally`` clause, dedent the ``return`` statement and wrap the
305+
body of the ``except:`` clause by another ``try``-``except`` to swallow any
306+
exceptions from within it.
307307

308308
- In `webtest<https://github.com/Pylons/webtest/blob/617a2b823c60e8d7c5f6e12a220affbc72e09d7d/webtest/http.py#L131>`__
309-
there is a ``finally`` block that contains only ``return False``. It could be replaced
310-
by
309+
there is a ``finally`` block that contains only ``return False``. It could be replaced
310+
by
311311

312312
.. code-block::
313313
@@ -316,28 +316,28 @@ by
316316
return False
317317
318318
- In `kivy<https://github.com/kivy/kivy/blob/3b744c7ed274c1a99bd013fc55a5191ebd8a6a40/kivy/uix/codeinput.py#L204>`__
319-
there is a ``finally`` that contains only a ``return`` statement. Since there is also a
320-
bare ``except`` just before it, in this case the fix will be to just remove the ``finally:``
321-
block and dedent the ``return`` statement.
319+
there is a ``finally`` that contains only a ``return`` statement. Since there is also a
320+
bare ``except`` just before it, in this case the fix will be to just remove the ``finally:``
321+
block and dedent the ``return`` statement.
322322

323323
- In `logilab-common<https://forge.extranet.logilab.fr/open-source/logilab-common/-/blob/branch/default/test/data/module.py?ref_type=heads#L60>`__
324-
there is, once again, a ``finally`` clause that can be replace by an ``except BaseException``
325-
with the ``return`` dedented one level.
324+
there is, once again, a ``finally`` clause that can be replace by an ``except BaseException``
325+
with the ``return`` dedented one level.
326326

327327
- In `pluggy<https://github.com/pytest-dev/pluggy/blob/c760a77e17d512c3572d54d368fe6c6f9a7ac810/src/pluggy/_callers.py#L141>`__
328-
there is a lengthy ``finally`` with two ``return`` statements (the second on line 182). Here the
329-
return value can be assigned to a variable, and the ``return`` itself can appear after we've
330-
exited the ``finally`` clause.
328+
there is a lengthy ``finally`` with two ``return`` statements (the second on line 182). Here the
329+
return value can be assigned to a variable, and the ``return`` itself can appear after we've
330+
exited the ``finally`` clause.
331331

332332
- In `aws-sam-cli<https://github.com/aws/aws-sam-cli/blob/97e63dcc2738529eded8eecfef4b875abc3a476f/samcli/local/apigw/local_apigw_service.py#L721>`__
333-
there is a conditional return at the end of the block.
334-
From reading the code, it seems that the condition only holds when the exception has
335-
been handled. The conditional block can just move outside of the ``finally`` block and
336-
achieve the same effect.
333+
there is a conditional return at the end of the block.
334+
From reading the code, it seems that the condition only holds when the exception has
335+
been handled. The conditional block can just move outside of the ``finally`` block and
336+
achieve the same effect.
337337

338338
- In `scrappy<https://github.com/scrapy/scrapy/blob/52c072640aa61884de05214cb1bdda07c2a87bef/scrapy/utils/gz.py#L27>`__
339-
there is a ``finally`` that contains only a ``break`` instruction. Assuming that it was the intention
340-
to swallow all exceptions, it can be replaced by
339+
there is a ``finally`` that contains only a ``break`` instruction. Assuming that it was the intention
340+
to swallow all exceptions, it can be replaced by
341341

342342
.. code-block::
343343
@@ -377,11 +377,11 @@ The results indicate that ``return``, ``break`` and ``continue`` in a finally bl
377377
I thank:
378378

379379
- Alyssa Coghlan for
380-
`bringing this issue my attention<https://discuss.python.org/t/pep-760-no-more-bare-excepts/67182/97>`__.
380+
`bringing this issue my attention<https://discuss.python.org/t/pep-760-no-more-bare-excepts/67182/97>`__.
381381

382382
- Guido van Rossum and Hugo van Kemenade for the
383-
`script<https://github.com/faster-cpython/tools/blob/main/scripts/download_packages.py>`__
384-
that downloads the most popular PyPI packages.
383+
`script<https://github.com/faster-cpython/tools/blob/main/scripts/download_packages.py>`__
384+
that downloads the most popular PyPI packages.
385385

386386
- The many code authors I contacted for their responsiveness and grace.
387387

0 commit comments

Comments
 (0)