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

ValueError: I/O operation on closed file #11572

Closed
bnomis opened this issue Oct 31, 2023 · 1 comment · Fixed by #11584
Closed

ValueError: I/O operation on closed file #11572

bnomis opened this issue Oct 31, 2023 · 1 comment · Fixed by #11584
Labels
type: bug problem that needs to be addressed

Comments

@bnomis
Copy link
Contributor

bnomis commented Oct 31, 2023

This is a follow-up to this issue #11439

Now the exception comes from sys.__stderr__.fileno()

Maybe it would be better to stash the original value of stderr and use that in unconfigure rather than trying to get it by calling fileno()? Happy to supply a patch.

Traceback (most recent call last):
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/faulthandler.py", line 47, in get_stderr_fileno
    fileno = sys.stderr.fileno()
ValueError: I/O operation on closed file

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/venv3.9/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 192, in console_main
    code = main()
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 169, in main
    ret: Union[ExitCode, int] = config.hook.pytest_cmdline_main(
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_hooks.py", line 493, in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_manager.py", line 115, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_callers.py", line 113, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_callers.py", line 77, in _multicall
    res = hook_impl.function(*args)
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/main.py", line 318, in pytest_cmdline_main
    return wrap_session(config, _main)
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/main.py", line 313, in wrap_session
    config._ensure_unconfigure()
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/config/__init__.py", line 1058, in _ensure_unconfigure
    self.hook.pytest_unconfigure(config=self)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_hooks.py", line 493, in __call__
    return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_manager.py", line 115, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_callers.py", line 113, in _multicall
    raise exception.with_traceback(exception.__traceback__)
  File "/home/venv3.9/lib/python3.9/site-packages/pluggy/_callers.py", line 77, in _multicall
    res = hook_impl.function(*args)
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/faulthandler.py", line 42, in pytest_unconfigure
    faulthandler.enable(file=get_stderr_fileno())
  File "/home/venv3.9/lib/python3.9/site-packages/_pytest/faulthandler.py", line 57, in get_stderr_fileno
    return sys.__stderr__.fileno()
ValueError: I/O operation on closed file

Environment

Python 	3.9.10
Platform 	Linux-5.4.226-129.415.amzn2.x86_64-x86_64-with-glibc2.31
Packages 	

    pytest: 7.4.3
    pluggy: 1.3.0

Plugins 	

    Faker: 19.6.2
    anyio: 4.0.0
    cov: 4.1.0
    csv: 3.0.0
    django: 4.5.2
    factoryboy: 2.5.1
    flake8: 1.1.1
    html: 4.0.2
    icdiff: 0.7
    instafail: 0.5.0
    isort: 3.1.0
    metadata: 3.0.0
    mock: 3.11.1
    mypy: 0.10.3
    ordering: 0.6
    randomly: 3.15.0
    subprocess: 1.5.0
    timeout: 2.1.0
    xdist: 3.3.1
    typeguard: 2.13.3
@martimors

This comment was marked as resolved.

@Zac-HD Zac-HD added the type: bug problem that needs to be addressed label Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants