Issue32822
Created on 2018-02-11 22:18 by David Rebbe, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| finally_test.py | David Rebbe, 2018-02-11 22:18 | shows exception handling differences in finally block | ||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 25600 | merged | robertohueso, 2021-04-25 17:31 | |
| PR 25890 | merged | miss-islington, 2021-05-04 12:36 | |
| PR 25893 | merged | miss-islington, 2021-05-04 12:51 | |
| Messages (10) | |||
|---|---|---|---|
| msg312014 - (view) | Author: David Rebbe (David Rebbe) | Date: 2018-02-11 22:18 | |
According to the docs: "When an exception has occurred in the try clause and has not been handled by an except clause (or it has occurred in an except or else clause), it is re-raised after the finally clause has been executed." https://docs.python.org/2/tutorial/errors.html#defining-clean-up-actions This seems to not be the case if return inside a finally block, the exception needing to be thrown looks like its tossed out. I'm not sure if this is intended behavior and the docs need to be updated or python isn't doing the correct behavior. Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. |
|||
| msg312015 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-02-11 22:44 | |
This is intended and documented behavior. https://docs.python.org/3/reference/compound_stmts.html#the-try-statement |
|||
| msg312017 - (view) | Author: David Rebbe (David Rebbe) | Date: 2018-02-11 23:19 | |
Oops I didn't realize I referenced the tutorial documentation. Maybe it would be better to mention this behavior in the tutorial documentation also. I've always assumed exception raises take priority over any return/break/continues. Behavior is backwards from what I'd expect but makes sense. |
|||
| msg313858 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-03-15 08:42 | |
I'm not sure that the tutorial should contain such details. But if you provide a pull request with a short and clear documenting of this behavior, it will be reviewed and may be accepted (not by me, I'm not native English and not tech writer). Otherwise this issue will be closed. |
|||
| msg313968 - (view) | Author: David Rebbe (David Rebbe) | Date: 2018-03-16 18:56 | |
I'll have to look into this as I have yet to commit anything but I'll put it on my list of things to do. |
|||
| msg388690 - (view) | Author: Irit Katriel (iritkatriel) * ![]() |
Date: 2021-03-14 22:03 | |
The doc has a lot more detail now: https://docs.python.org/3.10/tutorial/errors.html#defining-clean-up-actions but this point is still not mentioned. |
|||
| msg391949 - (view) | Author: Roberto Hueso (robertohueso) * | Date: 2021-04-26 16:52 | |
Just opened PR 25600, if the changes are ok then I can backport it to 3.9 and 3.8 docs. |
|||
| msg392886 - (view) | Author: Łukasz Langa (lukasz.langa) * ![]() |
Date: 2021-05-04 12:50 | |
3.8 is in security fixes mode but I'll happily take this for 3.9. |
|||
| msg392889 - (view) | Author: Łukasz Langa (lukasz.langa) * ![]() |
Date: 2021-05-04 13:17 | |
New changeset 91cb1e20e6a432b8b2c1b5db37b03c84b15384fa by Miss Islington (bot) in branch '3.9': bpo-32822: Add finally with return/break/continue to the tutorial (GH-25600) (#25890) https://github.com/python/cpython/commit/91cb1e20e6a432b8b2c1b5db37b03c84b15384fa |
|||
| msg392890 - (view) | Author: Łukasz Langa (lukasz.langa) * ![]() |
Date: 2021-05-04 13:17 | |
New changeset 8655521de8760e8a695bcce92937800c079ea2b2 by Miss Islington (bot) in branch '3.10': bpo-32822: Add finally with return/break/continue to the tutorial (GH-25600) (#25893) https://github.com/python/cpython/commit/8655521de8760e8a695bcce92937800c079ea2b2 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:57 | admin | set | github: 77003 |
| 2021-07-18 15:30:36 | pablogsal | set | pull_requests: - pull_request25774 |
| 2021-07-18 15:26:31 | pablogsal | set | nosy:
+ pablogsal pull_requests: + pull_request25774 |
| 2021-05-04 13:18:24 | lukasz.langa | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2021-05-04 13:17:43 | lukasz.langa | set | messages: + msg392890 |
| 2021-05-04 13:17:24 | lukasz.langa | set | messages: + msg392889 |
| 2021-05-04 12:51:30 | miss-islington | set | pull_requests: + pull_request24567 |
| 2021-05-04 12:50:35 | lukasz.langa | set | nosy:
+ lukasz.langa messages:
+ msg392886 |
| 2021-05-04 12:36:11 | miss-islington | set | nosy:
+ miss-islington pull_requests: + pull_request24564 |
| 2021-04-26 16:52:32 | robertohueso | set | messages: + msg391949 |
| 2021-04-25 17:31:48 | robertohueso | set | keywords:
+ patch nosy: + robertohueso pull_requests:
+ pull_request24317 |
| 2021-03-14 22:03:56 | iritkatriel | set | versions:
+ Python 3.9, Python 3.10, - Python 2.7, Python 3.6, Python 3.7 nosy: + iritkatriel messages: + msg388690 keywords: + easy |
| 2018-03-16 18:56:03 | David Rebbe | set | messages: + msg313968 |
| 2018-03-15 08:42:38 | serhiy.storchaka | set | status: pending -> open nosy:
+ docs@python |
| 2018-03-15 08:42:13 | serhiy.storchaka | set | status: open -> pending messages: + msg313858 |
| 2018-02-11 23:19:05 | David Rebbe | set | messages: + msg312017 |
| 2018-02-11 22:44:33 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg312015 |
| 2018-02-11 22:18:17 | David Rebbe | create | |
