Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'bool' object is not iterable when running hypothesis test suite #454

Open
Zac-HD opened this issue Nov 29, 2021 · 11 comments
Open

Comments

@Zac-HD
Copy link

Zac-HD commented Nov 29, 2021

I'm trying to add Pyjion to our CI over in HypothesisWorks/hypothesis#3165, but I get the following error:

pyjion -m pytest tests/cover
usage: pyjion [-h] [-m MODULE] [--graph] [--debug] [--no-pgc] [-o OPT_LEVEL]
              [script]
pyjion: error: argument script: not allowed with argument -m

I've poked at __main__.py, but ArgumentParser.parse_known_args() doesn't seem to play nicely with runpy and you still have the problem of any positional arguments to the module being misinterpreted as pyjion's script argument, as in the error above.

@Zac-HD
Copy link
Author

Zac-HD commented Nov 29, 2021

It also looks like pyjion is breaking something in pytest-xdist multiprocess handling:

py310-pyjion run-test: commands[0] | python -m pytest tests/cover tests/pytest tests/nocover -n auto
Traceback (most recent call last):
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 269, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 323, in _main
    config.hook.pytest_runtestloop(session=session)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/xdist/dsession.py", line 112, in pytest_runtestloop
    self.loop_once()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/xdist/dsession.py", line 124, in loop_once
    raise RuntimeError("Unexpectedly no active workers available")
RuntimeError: Unexpectedly no active workers available

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10.0/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pytest/__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/config/__init__.py", line 162, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 316, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 289, in wrap_session
    config.notify_exception(excinfo, config.option)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1038, in notify_exception
    if not any(res):
TypeError: 'bool' object is not iterable

@Zac-HD Zac-HD closed this as completed Nov 29, 2021
@Zac-HD Zac-HD reopened this Nov 29, 2021
@Zac-HD
Copy link
Author

Zac-HD commented Nov 29, 2021

(oops, misclick)

@Zac-HD
Copy link
Author

Zac-HD commented Nov 29, 2021

And then in singleprocess mode I get another error:

py310-pyjion run-test: commands[0] | python -m pytest tests/cover tests/pytest tests/nocover
Traceback (most recent call last):
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 269, in wrap_session
    session.exitstatus = doit(config, session) or 0
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 322, in _main
    config.hook.pytest_collection(session=session)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 333, in pytest_collection
    session.perform_collect()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 641, in perform_collect
    hook.pytest_collection_finish(session=self)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/terminal.py", line 750, in pytest_collection_finish
    self._write_report_lines_from_hooks(lines)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/terminal.py", line 720, in _write_report_lines_from_hooks
    for line_or_lines in reversed(lines):
TypeError: 'NoneType' object is not reversible

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10.0/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/runner/.cache/hypothesis-build-runtimes/python-versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pytest/__main__.py", line 5, in <module>
    raise SystemExit(pytest.console_main())
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/config/__init__.py", line 185, in console_main
    code = main()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/config/__init__.py", line 162, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 316, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/main.py", line 289, in wrap_session
    config.notify_exception(excinfo, config.option)
  File "/home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/lib/python3.10/site-packages/_pytest/config/__init__.py", line 1038, in notify_exception
    if not any(res):
TypeError: 'bool' object is not iterable

@tonybaloney
Copy link
Owner

thanks for the detailed report. Looks like there are 2 or 3 separate issues here.

Which version of pyjion did this run on? The command-line was changed in #440

@Zac-HD
Copy link
Author

Zac-HD commented Nov 30, 2021

Happy to help! This was v1.1.1, with those changes - the linked PR against Hypothesis has the build steps if that helps.

@tonybaloney
Copy link
Owner

Ok, I can easily repro the xdist bug. I'll add an xdist test run in future for regression and get to the bottom of this.

python -m pytest tests -n auto
======================================================================================== test session starts =========================================================================================
platform darwin -- Python 3.10.0rc2+, pytest-6.2.5, py-1.10.0, pluggy-1.0.0
rootdir: /Users/anthonyshaw/CLionProjects/pyjion/tests, configfile: pytest.ini
plugins: xdist-2.4.0, forked-1.3.0
gw0 [747] / gw1 [747] / gw2 [747] / gw3 [747]
..INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/_pytest/main.py", line 269, in wrap_session
INTERNALERROR>     session.exitstatus = doit(config, session) or 0
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/_pytest/main.py", line 323, in _main
INTERNALERROR>     config.hook.pytest_runtestloop(session=session)
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/pluggy/_hooks.py", line 265, in __call__
INTERNALERROR>     return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/pluggy/_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/pluggy/_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/pluggy/_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/pluggy/_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/xdist/dsession.py", line 112, in pytest_runtestloop
INTERNALERROR>     self.loop_once()
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/xdist/dsession.py", line 135, in loop_once
INTERNALERROR>     call(**kwargs)
INTERNALERROR>   File "/Users/anthonyshaw/CLionProjects/pyjion/.venv-3.10d/lib/python3.10/site-packages/xdist/dsession.py", line 174, in worker_workerfinished
INTERNALERROR>     assert not crashitem, (crashitem, node)
INTERNALERROR> AssertionError: ('test_attr.py::test_missing_attr[2]', <WorkerController gw1>)
INTERNALERROR> assert not 'test_attr.py::test_missing_attr[2]'
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>
sys:1: ResourceWarning: unclosed file <_io.TextIOWrapper name=0 mode='r' encoding='UTF-8'>

========================================================================================= 2 passed in 7.34s ==========================================================================================

@tonybaloney tonybaloney changed the title pyjion -m pytest should permit additional arguments to the module TypeError: 'bool' object is not iterable when running hypothesis test suite Dec 6, 2021
@tonybaloney
Copy link
Owner

Related: #458

@tonybaloney
Copy link
Owner

Just to confirm. I ran the test suite from the latest commit and got

 tox -e py310-pyjion
GLOB sdist-make: /Users/anthonyshaw/projects/hypothesis/hypothesis-python/setup.py
py310-pyjion create: /Users/anthonyshaw/projects/hypothesis/hypothesis-python/.tox/py310-pyjion
py310-pyjion installdeps: -r../requirements/test.txt, pyjion
py310-pyjion inst: /Users/anthonyshaw/projects/hypothesis/hypothesis-python/.tox/.tmp/package/1/hypothesis-6.30.1.zip
py310-pyjion installed: attrs==21.2.0,execnet==1.9.0,hypothesis @ file:///Users/anthonyshaw/projects/hypothesis/hypothesis-python/.tox/.tmp/package/1/hypothesis-6.30.1.zip,iniconfig==1.1.1,packaging==21.3,pexpect==4.8.0,pluggy==1.0.0,ptyprocess==0.7.0,py==1.11.0,pyjion==1.1.1,pyparsing==3.0.6,pytest==6.2.5,pytest-forked==1.3.0,pytest-xdist==2.4.0,sortedcontainers==2.4.0,toml==0.10.2
py310-pyjion run-test-pre: PYTHONHASHSEED='3906611803'
py310-pyjion run-test: commands[0] | python -m pytest tests/cover tests/pytest tests/nocover
===================================================== test session starts ======================================================
platform darwin -- Python 3.10.0, pytest-6.2.5, py-1.11.0, pluggy-1.0.0
cachedir: hypothesis-python/.tox/py310-pyjion/.pytest_cache
rootdir: /Users/anthonyshaw/projects/hypothesis, configfile: pytest.ini
plugins: xdist-2.4.0, forked-1.3.0, hypothesis-6.30.1
collected 3347 items

tests/cover/test_annotations.py ..................                                                                       [  0%]
tests/cover/test_arbitrary_data.py ..........                                                                            [  0%]
tests/cover/test_async_def.py .                                                                                          [  0%]
tests/cover/test_asyncio.py ..                                                                                           [  0%]
tests/cover/test_attrs_inference.py .....                                                                                [  1%]
tests/cover/test_cache_implementation.py ....................                                                            [  1%]
tests/cover/test_caching.py .......                                                                                      [  1%]
tests/cover/test_cathetus.py ......................................................................                      [  3%]
tests/cover/test_charmap.py .................                                                                            [  4%]
tests/cover/test_compat.py .................                                                                             [  4%]
tests/cover/test_complex_numbers.py ..............                                                                       [  5%]
tests/cover/test_composite.py .............                                                                              [  5%]
tests/cover/test_composite_kwonlyargs.py .                                                                               [  5%]
tests/cover/test_control.py ...............                                                                              [  6%]
tests/cover/test_core.py .........                                                                                       [  6%]

So the bug was when running with pyjion ... (fixed in #457) and when running -n auto?

@Zac-HD
Copy link
Author

Zac-HD commented Dec 6, 2021

Yep! There was also the mysterious TypeError: 'NoneType' object is not reversible / TypeError: 'bool' object is not iterable exception when running without -n auto, but from your run that's evidently working too 🎉

If you want another confirmation before releasing I can set that tox env to install from a github commit and enable Hypothesis' Pyjion CI job; otherwise I'll do that after release and let you know if we see any regressions.

@tonybaloney
Copy link
Owner

Just shipped 1.2.0, that should have a number of changes that'll help in those test cases

@Zac-HD
Copy link
Author

Zac-HD commented Dec 6, 2021

In HypothesisWorks/hypothesis#3181, I eventually got

tests/cover/test_core.py .........                                       [  6%]
tests/cover/test_custom_reprs.py ......                                  [  6%]
tests/cover/test_database_backend.py ........................            [  7%]
tests/cover/test_datetimes.py ......................................     [  8%]
tests/cover/test_deadline.py ............                                [  8%]
tests/cover/test_debug_information.py .                                  [  8%]
tests/cover/test_deferred_strategies.py .................                [  9%]
tests/cover/test_detection.py .....                                      [  9%]
tests/cover/test_direct_strategies.py ..............................F... [ 10%]
........................................................................ [ 12%]
........................................................................ [ 14%]
........................................................................ [ 17%]
....                                                                     [ 17%]
tests/cover/test_draw_example.py ....................................... [ 18%]
...................................................                      [ 19%]
tests/cover/test_error_in_draw.py .                                      [ 19%]
tests/cover/test_escalation.py ......                                    [ 20%]
tests/cover/test_example.py .........                                    [ 20%]
tests/cover/test_executors.py ......                                     [ 20%]
tests/cover/test_explicit_examples.py ...........................        [ 21%]
tests/cover/test_falsifying_example_output.py ...                        [ 21%]
tests/cover/test_feature_flags.py .......                                [ 21%]
tests/cover/test_filestorage.py ....                                     [ 21%]
tests/cover/test_filter_rewriting.py ....................ERROR: InvocationError for command /home/runner/work/hypothesis/hypothesis/hypothesis-python/.tox/py310-pyjion/bin/pyjion -m pytest tests/cover tests/pytest tests/nocover (exited with code -9 (SIGKILL)) (exited with code -9)
___________________________________ summary ____________________________________
ERROR:   py310-pyjion: commands failed

Not entirely clear what causes (exited with code -9 (SIGKILL)), but a local run has (slowly) made it past that so I suspect it's just CI doing CI things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants