Skip to content

Expose original file descriptor in CliRunner#3244

Open
kdeldycke wants to merge 1 commit intopallets:stablefrom
kdeldycke:clirunner-fileno
Open

Expose original file descriptor in CliRunner#3244
kdeldycke wants to merge 1 commit intopallets:stablefrom
kdeldycke:clirunner-fileno

Conversation

@kdeldycke
Copy link
Collaborator

@kdeldycke kdeldycke commented Mar 4, 2026

In #2865, a user realized that using standard library's faulthandler is crashing in CliRunner. That's because in CliRunner's isolation, sys.stderr is a _NamedTextIOWrapper around a BytesIO and as such as no fileno().

This PR gives _NamedTextIOWrapper a real fileno() so it can play nice with C-level consumers that need the original file descriptor, like faulthandler, subprocess, C extensions, etc.

Solution is inspired by pytest own's capsys and capfd modes.

This is an adjacent issue of #3139 and #3235, and fix #2865.

@kdeldycke
Copy link
Collaborator Author

The fix in this PR has been tested and validated by the original reporter @ThomasLoke at #2865 (comment) . So I guess this one is ready to be reviewed and merged to stable.

@Rowlando13 Rowlando13 modified the milestones: 8.3.2, 8.3.3 Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug f:test runner feature: cli test runner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants