Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7921299

Browse files
committed
use isinstance instead of type. Use bool instead of int for flag.
1 parent 48563e8 commit 7921299

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Lib/test/test_support.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,14 @@ def bind_port(sock, host='', preferred_port=54321):
110110
FUZZ = 1e-6
111111

112112
def fcmp(x, y): # fuzzy comparison function
113-
if type(x) == type(0.0) or type(y) == type(0.0):
113+
if isinstance(x, float) or isinstance(y, float):
114114
try:
115-
x, y = coerce(x, y)
116115
fuzz = (abs(x) + abs(y)) * FUZZ
117116
if abs(x-y) <= fuzz:
118117
return 0
119118
except:
120119
pass
121-
elif type(x) == type(y) and type(x) in (type(()), type([])):
120+
elif type(x) == type(y) and isinstance(x, (tuple, list)):
122121
for i in range(min(len(x), len(y))):
123122
outcome = fcmp(x[i], y[i])
124123
if outcome != 0:
@@ -128,9 +127,9 @@ def fcmp(x, y): # fuzzy comparison function
128127

129128
try:
130129
unicode
131-
have_unicode = 1
130+
have_unicode = True
132131
except NameError:
133-
have_unicode = 0
132+
have_unicode = False
134133

135134
is_jython = sys.platform.startswith('java')
136135

0 commit comments

Comments
 (0)