BUG: fix skiprows callable infinite loop
- [X] closes #45585
- [X] tests added / passed
- [X] Ensure all linting tests pass, see [here](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit) for how to run them
- [x] whatsnew entry

Not sure what to do about the `whatsnew` entry. Please advise (I've read the contributing doc but could not find it mentioned).

I'm not sure why that "Test experimental data manager" test fails; it doesn't appear to be related to my code.

EDIT: Also I cannot run this test locally; it requires `numba` which is not compatible with my M1 CPU. > Small comments
> 
> please add a whatsnew

Is the `whatsnew` process documented anywhere? I couldn't figure out what to do! @phofl @rhshadrach ok here? Tests are failing.

- adjustment of whatsnew
- adding a test for read csv

are open points The merge of main seems to have broken something, I can no longer run my test...

```
> python -m pytest pandas/tests/io/excel/test_readers.py -vv -s
ImportError while loading conftest '/Users/bram/Code/nca/pandas/pandas/conftest.py'.
pandas/conftest.py:608: in <module>
    params=[
pandas/conftest.py:611: in <listcomp>
    if not isinstance(indices_dict[key], MultiIndex) and indices_dict[key].is_unique
pandas/_libs/properties.pyx:37: in pandas._libs.properties.CachedProperty.__get__
    val = self.fget(obj)
pandas/core/indexes/base.py:2297: in is_unique
    return self._engine.is_unique
pandas/_libs/properties.pyx:37: in pandas._libs.properties.CachedProperty.__get__
    val = self.fget(obj)
pandas/core/indexes/base.py:873: in _engine
    return libindex.ExtensionEngine(target_values)
E   AttributeError: module 'pandas._libs.index' has no attribute 'ExtensionEngine'``` You have to build pandas again
``
python setup.py build_ext --inplace -j 4
`` Hello @bram2000! Thanks for updating this PR. We checked the lines you've touched for [PEP 8](https://www.python.org/dev/peps/pep-0008) issues, and found:







There are currently no PEP 8 issues detected in this Pull Request. Cheers! :beers: 

##### Comment last updated at 2022-01-31 10:21:49 UTC I've added a similar test for csv... it passes but it doesn't appear to go through my new code anyway. Does it still make sense to mention `read_csv` in the whatsnew? No, don't have to mention in this case

pre-commit is failing precommit is failing with the following, but I'm not sure why as I've copied the form of the other notes in the file.

```
rst ``code`` is two backticks...................................................................................Failed
- hook id: rst-backticks
- exit code: 1

doc/source/whatsnew/v1.5.0.rst:287:- Bug in :meth:`read_excel` results in an infinite loop with certain `skiprows` callables (:issue:`45585`)
``` :func:`read_excel` please

pre-commit is failing because of
`skiprows` -> ``skiprows``

Edit: Two backticks before and after skiprows > I've added a similar test for csv... it passes but it doesn't appear to go through my new code anyway. Does it still make sense to mention `read_csv` in the whatsnew?

You have to add `engine="python"`. When I do this, I'm seeing `_next_line` being hit.

@phofl 

> Edit: Two backticks before and after skiprows

I struggled with this before. In GitHub (and maybe elsewhere?), you can use two different number of backticks to make backticks show up, e.g. `` `backtick` `` or ` ``backtick`` ` @bram2000 can you merge master and address comments I've merged master.

Even if i manually add `engine="python"` to the `read_excel` call it still doesn't hit my debugger in the affected `while` loop. The test iterates through the four engine types anyway, so don't think it's necessary to explicitly set `engine`. > it still doesn't hit my debugger in the affected while loop

Ah, I see - yes, I'm seeing the same. However doesn't the same bug exist in L691 down below? > > it still doesn't hit my debugger in the affected while loop
> 
> Ah, I see - yes, I'm seeing the same. However doesn't the same bug exist in L691 down below?

No it doesn't seem to. I've tried various combinations of skiprow functions and I can't get it to fail. @bram2000 - thanks for checking! Sorry for my confusion, it all makes sense now. @jreback @phofl - good here? @bram2000 - failure look unrelated. Can you merge main. Thanks @bram2000 