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 mark.dickinson
Recipients mark.dickinson
Date 2008-01-07.21:03:56
SpamBayes Score 0.024537925
Marked as misclassified No
Message-id <1199739838.21.0.114210159125.issue1757@psf.upfronthosting.co.za>
In-reply-to
Content
The value of the Decimal hash() depends on the current context:

>>> from decimal import *
>>> x = Decimal("123456789.1")
>>> hash(x)
1989332493
>>> getcontext().prec = 6
>>> hash(x)
-2034270682

This has nasty consequences;  e.g.:

>>> s = set([x])
>>> x in s
True
>>> getcontext().prec = 28
>>> x in s
False

hashing a Decimal can also set flags in the context;  again, I think
this is undesirable.

The cause of this bug is clear:  __hash__ calls normalize, which rounds
its argument to the current context.  I'll post a fix when I get around
to it.
History
Date User Action Args
2008-01-07 21:03:58mark.dickinsonsetspambayes_score: 0.0245379 -> 0.024537925
recipients: + mark.dickinson
2008-01-07 21:03:58mark.dickinsonsetspambayes_score: 0.0245379 -> 0.0245379
messageid: <1199739838.21.0.114210159125.issue1757@psf.upfronthosting.co.za>
2008-01-07 21:03:57mark.dickinsonlinkissue1757 messages
2008-01-07 21:03:56mark.dickinsoncreate