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.

作者 mark.dickinson
收信人 facundobatista, jdunck, lorg, mark.dickinson, rhettinger
日期 2009-03-21.20:37:17
SpamBayes Score 2.9976022e-15
Marked as misclassified
Message-id <1237667840.45.0.825973851487.issue2531@psf.upfronthosting.co.za>
In-reply-to
内容
Urk.  That patch produces horrible results when comparing Fractions and 
Decimals:

Python 2.7a0 (unknown, Mar 21 2009, 17:59:48) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from fractions import Fraction
>>> from decimal import Decimal
>>> Decimal('2.5') == Fraction(5, 2)
True
>>> Decimal('1.1') == Fraction(11, 10)
False

Either both results should be True (if comparisons between Fractions and 
Decimals work numerically), or both should be False (refuse to
compare Fraction and Decimal).

It looks like what happens is that the Fraction comparison converts the 
second argument to float before comparing. I'm tempted to call this a 
bug in Fraction.__eq__.
历史
日期 用户 动作 参数
2009-03-21 20:37:20mark.dickinson修改recipients: + mark.dickinson, rhettinger, facundobatista, jdunck, lorg
2009-03-21 20:37:20mark.dickinson修改messageid: <1237667840.45.0.825973851487.issue2531@psf.upfronthosting.co.za>
2009-03-21 20:37:18mark.dickinson链接issue2531 messages
2009-03-21 20:37:17mark.dickinson创建