This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients skrah
Date 2009-09-06.21:34:26
SpamBayes Score 2.3606304e-08
Marked as misclassified No
Message-id <1252272868.18.0.127348789237.issue6850@psf.upfronthosting.co.za>
In-reply-to
Content
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'
History
Date User Action Args
2009-09-06 21:34:28skrahsetrecipients: + skrah
2009-09-06 21:34:28skrahsetmessageid: <1252272868.18.0.127348789237.issue6850@psf.upfronthosting.co.za>
2009-09-06 21:34:26skrahlinkissue6850 messages
2009-09-06 21:34:26skrahcreate