Issue1757
Created on 2008-01-07 21:03 by mark.dickinson, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue1757.patch | mark.dickinson, 2008-01-08 01:12 | |||
| Messages (3) | |||
|---|---|---|---|
| msg59492 - (view) | Author: Mark Dickinson (mark.dickinson) * | Date: 2008-01-07 21:03 | |
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.
|
|||
| msg59514 - (view) | Author: Mark Dickinson (mark.dickinson) * | Date: 2008-01-08 01:12 | |
Here's a patch for the trunk. |
|||
| msg59531 - (view) | Author: Facundo Batista (facundobatista) * | Date: 2008-01-08 12:25 | |
Fixed in r59852. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:29 | admin | set | github: 46097 |
| 2008-01-08 12:25:45 | facundobatista | set | status: open -> closed resolution: fixed messages: + msg59531 |
| 2008-01-08 01:12:48 | mark.dickinson | set | files:
+ issue1757.patch messages: + msg59514 |
| 2008-01-08 00:21:23 | christian.heimes | set | priority: normal |
| 2008-01-07 21:31:20 | facundobatista | set | assignee: facundobatista nosy: + facundobatista |
| 2008-01-07 21:03:57 | mark.dickinson | create | |