[New-bugs-announce] [issue30978] str.format_map() silences exceptions in __getitem__

Akuli report at bugs.python.org
Thu Jul 20 15:53:55 EDT 2017


New submission from Akuli:

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.

----------
messages: 298747
nosy: Akuli
priority: normal
severity: normal
status: open
title: str.format_map() silences exceptions in __getitem__
type: behavior
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30978>
_______________________________________


More information about the New-bugs-announce mailing list