
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2017-07-20 19:53 byAkuli, last changed2022-04-11 14:58 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 2790 | merged | serhiy.storchaka,2017-07-21 04:42 | |
| PR 2992 | merged | serhiy.storchaka,2017-08-03 08:50 | |
| Messages (12) | |||
|---|---|---|---|
| msg298747 -(view) | Author: Akuli (Akuli) | Date: 2017-07-20 19:53 | |
Example: class BrokenMapping: def __getitem__(self, key): 1/0 # this silences the ZeroDivisionError and raises KeyError('world') 'hello {world}'.format_map(BrokenMapping())I have tried this on several different CPython versions on Ubuntu 14.04(including the latest Python 3.7.0a0 from github) and they all do this.PyPy passes the ZeroDivisionError through correctly. | |||
| msg298767 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-07-21 04:46 | |
Yet one consequence: this swallows KeyboardInterrupt and converts it to KeyError. | |||
| msg298794 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2017-07-21 10:36 | |
While KeyboardInterrupt and ZeroDivisionError are easy to understand, IndexError converted to KeyError doesn't look like a major bug. So I'm not sure about fixing Python 3.5 and 3.6. Maybe it's ok because this function is rarely used and exceptions are not "expected": I hardly imagine a code explicitly catching KeyError to do something on format_map() error.In short, my vote for backport is +0 :-) | |||
| msg298799 -(view) | Author: Eric V. Smith (eric.smith)*![]() | Date: 2017-07-21 11:02 | |
I'm -0 on a backport. The new behavior is more correct, but I don't like changing the exception type in a micro release. | |||
| msg298809 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-07-21 15:55 | |
What are your thoughts about backporting this Raymond? | |||
| msg298812 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2017-07-21 16:10 | |
For Python 3.5 and 3.6, would it make sense to modify the code to pass though BaseException, but replace all other exceptions with KeyError? It would be a compromise between doing nothing and fixing the bug :-) | |||
| msg298816 -(view) | Author: Raymond Hettinger (rhettinger)*![]() | Date: 2017-07-21 18:35 | |
> What are your thoughts about backporting this Raymond?+0 On the one hand, this can be considered a bug fix. On the other hand, I would suspect that no code that is currently working would benefit. | |||
| msg298818 -(view) | Author: Akuli (Akuli) | Date: 2017-07-21 19:37 | |
I think all exceptions should be passed through. Things likedict.__contains__ don't selectively turn some errors to KeyErroreither; if something is not hashable it's a TypeError, not a KeyError. >>> [] in {} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' | |||
| msg298819 -(view) | Author: Akuli (Akuli) | Date: 2017-07-21 19:40 | |
Oops, I forgot to mention that I have no thoughts about backportingthis. It would be nice to see this fixed in 3.7 though :) | |||
| msg298821 -(view) | Author: Brett Cannon (brett.cannon)*![]() | Date: 2017-07-21 19:51 | |
I'm -0 on the backport since as Raymond and Eric pointed out it won't benefit currently working code and I personally don't like changing what exception is raised in a bugfix release. | |||
| msg299692 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-08-03 08:45 | |
New changeset5075416b8fedc5526b643dabc915f7945fa0d969 by Serhiy Storchaka in branch 'master':bpo-30978: str.format_map() now passes key lookup exceptions through. (#2790)https://github.com/python/cpython/commit/5075416b8fedc5526b643dabc915f7945fa0d969 | |||
| msg299693 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2017-08-03 09:14 | |
New changesetf08b2be4416163e3d18b8d09891e7cda0d8a21d4 by Serhiy Storchaka in branch '3.6':[3.6]bpo-30978: str.format_map() now passes key lookup exceptions through. (GH-2790) (#2992)https://github.com/python/cpython/commit/f08b2be4416163e3d18b8d09891e7cda0d8a21d4 | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:49 | admin | set | github: 75161 |
| 2017-08-03 09:17:00 | serhiy.storchaka | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2017-08-03 09:14:10 | serhiy.storchaka | set | messages: +msg299693 |
| 2017-08-03 08:50:06 | serhiy.storchaka | set | pull_requests: +pull_request3031 |
| 2017-08-03 08:45:28 | serhiy.storchaka | set | messages: +msg299692 |
| 2017-07-21 19:51:19 | brett.cannon | set | nosy: +brett.cannon messages: +msg298821 |
| 2017-07-21 19:40:06 | Akuli | set | messages: +msg298819 |
| 2017-07-21 19:37:18 | Akuli | set | messages: +msg298818 |
| 2017-07-21 18:35:30 | rhettinger | set | messages: +msg298816 |
| 2017-07-21 16:10:39 | vstinner | set | messages: +msg298812 |
| 2017-07-21 15:55:43 | serhiy.storchaka | set | nosy: +rhettinger messages: +msg298809 |
| 2017-07-21 11:02:43 | eric.smith | set | messages: +msg298799 |
| 2017-07-21 10:36:46 | vstinner | set | messages: +msg298794 |
| 2017-07-21 04:46:01 | serhiy.storchaka | set | versions: + Python 3.6, - Python 3.3, Python 3.4 nosy: +ezio.melotti,vstinner,serhiy.storchaka messages: +msg298767 components: + Interpreter Core, Unicode stage: patch review |
| 2017-07-21 04:42:23 | serhiy.storchaka | set | pull_requests: +pull_request2840 |
| 2017-07-20 21:37:12 | eric.smith | set | nosy: +eric.smith |
| 2017-07-20 19:53:55 | Akuli | create | |