Skip to content

Commit 24484fd

Browse files
committed
fixes for count
1 parent cd53348 commit 24484fd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

graalpython/lib-graalpython/itertools.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,14 @@ def __setstate__(self, state):
246246
class count(object):
247247
@__graalpython__.builtin_method
248248
def __init__(self, start=0, step=1):
249-
if not isinstance(start, (int, float)) or \
250-
not isinstance(step, (int, float)):
251-
raise TypeError('a number is required')
249+
valid_start = valid_step = False
250+
for o in [start, step]:
251+
if not isinstance(o, complex):
252+
for mm in ["__index__", "__float__", "__int__"]:
253+
if hasattr(o, mm):
254+
break
255+
else:
256+
raise TypeError("a number is required")
252257
self._cnt = start
253258
self._step = step
254259

0 commit comments

Comments
 (0)