New submission from Stefan Krah <stefan-use...@bytereef.org>: Hi,
it looks like format_dict['type'] is not always initialized: >>> from decimal import * >>> format(Decimal("0.12345"), "a=-7.0") Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.1/decimal.py", line 3611, in __format__ spec = _parse_format_specifier(specifier, _localeconv=_localeconv) File "/usr/lib/python3.1/decimal.py", line 5595, in _parse_format_specifier if format_dict['type'] in 'gG' or format_dict['type'] is None: TypeError: 'in <string>' requires string as left operand, not NoneType Inserting these two lines somewhere in _parse_format_specifier fixes the problem. (float() uses 'g' as the default, but I got the impression that decimal.py uses uppercase as the default.) if format_dict['type'] is None: format_dict['type'] = 'G' ---------- messages: 92337 nosy: skrah severity: normal status: open title: decimal.py: format_dict['type'] not initialized versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue6850> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com