Repository navigation
gh-150544: Fix pdb _pyrepl_available() and make test_gen_colors skip at runtime #150545
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
Open
sendaoYan
wants to merge
8
commits into
python:main
Choose a base branch
from
sendaoYan:gh-150544
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+71
−17
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
857536f
gh-150544: Fix pdb _pyrepl_available() and make test_gen_colors skip …
sendaoYan c454dea
Add NEWS for gh-150544
sendaoYan ed2bd46
Fix GHA Docs warings
sendaoYan 540cf9c
Merge branch 'main' into gh-150544
sendaoYan 56cd0c9
Merge branch 'main' into gh-150544
sendaoYan beee0b5
Merge branch 'main' into gh-150544
sendaoYan 6193bd5
gh-150544: Correct NEWS entries for test_gen_colors
sendaoYan a0e1641
gh-150544: Address review feedback
sendaoYan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Misc/NEWS.d/next/Library/2026-05-28-15-46-46.gh-issue-150544.SNsZ8z.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Fix ``pdb._pyrepl_available()`` to check whether the given stdin/stdout | ||
| streams support pyrepl at call time, instead of relying only on the | ||
| import-time ``_pyrepl.main.CAN_USE_PYREPL`` flag. :class:`pdb.Pdb` now | ||
| passes its streams to ``pdb._pyrepl_available()``. This prevents | ||
| :exc:`AttributeError` when ``pyrepl_input`` is ``None`` because | ||
| ``sys.stdout`` has been replaced by a stream without | ||
| :meth:`~io.IOBase.fileno` (for example by :mod:`unittest` output | ||
| buffering), and avoids failures when ``stdin`` is replaced by doctest | ||
| helpers without ``fileno()``. |
4 changes: 4 additions & 0 deletions
4
Misc/NEWS.d/next/Tests/2026-05-28-15-49-57.gh-issue-150544.iN6-jy.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Fix ``test.test_pdb`` to skip pyrepl-dependent tests at runtime instead of | ||
| using import-time :func:`unittest.skipIf` on ``pdb._pyrepl_available()``. | ||
| This fixes ``PdbTestColorize.test_gen_colors`` errors when the test suite | ||
| is run with ``--junit-xml``. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call is outside the existing fallback. If a custom
fileno()returns an invalid type,os.isatty()can raiseTypeErrorhere. Can the color test exercise color calculation without setting up the terminal?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both fixed.
os.isatty(fileno())can raise TypeError for a non-int fd — added TypeError to the except in _pyrepl_available().gen_colors()only needs pyrepl.utils and the do* command check, so test_gen_colors now exercises it directly and skips only when _pyrepl.utils can't be imported (no TTY/pyrepl input needed).