[Python-checkins] r65323 - python/trunk/Lib/test/test_support.py
brett.cannon
python-checkins at python.org
Thu Jul 31 05:00:53 CEST 2008
Author: brett.cannon
Date: Thu Jul 31 05:00:53 2008
New Revision: 65323
Log:
Backport test.support.fcmp() from 3.0 to silence -3 warnings.
Modified:
python/trunk/Lib/test/test_support.py
Modified: python/trunk/Lib/test/test_support.py
==============================================================================
--- python/trunk/Lib/test/test_support.py (original)
+++ python/trunk/Lib/test/test_support.py Thu Jul 31 05:00:53 2008
@@ -224,21 +224,20 @@
FUZZ = 1e-6
def fcmp(x, y): # fuzzy comparison function
- if type(x) == type(0.0) or type(y) == type(0.0):
+ if isinstance(x, float) or isinstance(y, float):
try:
- x, y = coerce(x, y)
fuzz = (abs(x) + abs(y)) * FUZZ
if abs(x-y) <= fuzz:
return 0
except:
pass
- elif type(x) == type(y) and type(x) in (type(()), type([])):
+ elif type(x) == type(y) and isinstance(x, (tuple, list)):
for i in range(min(len(x), len(y))):
outcome = fcmp(x[i], y[i])
if outcome != 0:
return outcome
- return cmp(len(x), len(y))
- return cmp(x, y)
+ return (len(x) > len(y)) - (len(x) < len(y))
+ return (x > y) - (x < y)
try:
unicode
More information about the Python-checkins
mailing list