From 15a9739952279adfba5abe1db3ec25b08dda352d Mon Sep 17 00:00:00 2001 From: DWesl <22566757+DWesl@users.noreply.github.com> Date: Tue, 22 Mar 2022 15:10:20 -0400 Subject: [PATCH] BUG: Use isinstance for is_iterator on Cygwin Fixes #45158 Keep original implementation if not on Cygwin, and choose the implementation at compile time to avoid performance hits from the extra branch. [Test results on Cygwin are available are available here](https://github.com/DWesl/pandas/runs/5648361139?check_suite_focus=true) --- pandas/_libs/lib.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/lib.pyx b/pandas/_libs/lib.pyx index 18a58902075f2..9a26bdfd36f11 100644 --- a/pandas/_libs/lib.pyx +++ b/pandas/_libs/lib.pyx @@ -268,7 +268,10 @@ def is_iterator(obj: object) -> bool: >>> is_iterator(1) False """ - return PyIter_Check(obj) + IF UNAME_SYSNAME.startswith("CYGWIN"): + return isinstance(obj, abc.Iterator) + ELSE: + return PyIter_Check(obj) def item_from_zerodim(val: object) -> object: