Skip to content

gh-128816: fix an import warning in test_doctest.py when importing re… - #128817

Merged
serhiy-storchaka merged 11 commits into
python:mainfrom
graingert:fix-test-doctest-warning
Jan 15, 2025
Merged

serhiy-storchaka merged 11 commits into
python:mainfrom
graingert:fix-test-doctest-warning

Conversation

@graingert

@graingert graingert commented Jan 14, 2025 •

Copy link
Copy Markdown
Contributor

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

But it seems that these methods are never called (only checked for existence). I would raise an AssertionError to ensure that they are not called.

@graingert

graingert commented Jan 14, 2025 •

Copy link
Copy Markdown
Contributor Author

I believe they are called, eg when attempting to import readline and it is missing. I will check

Comment thread Lib/test/test_doctest/test_doctest.py
Comment thread Lib/test/test_doctest/test_doctest.py
Comment thread Lib/test/test_doctest/test_doctest.py Outdated
Comment thread Lib/test/test_doctest/test_doctest.py Outdated
@graingert

Copy link
Copy Markdown
Contributor Author

LGTM.

But it seems that these methods are never called (only checked for existence). I would raise an AssertionError to ensure that they are not called.

@serhiy-storchaka I checked and both functions are called, not just checked for existence

@graingert graingert added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Jan 14, 2025

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I missed that it is only reproducible if readline is not available. That is why I was not able to reproduce this issue.

LGTM.

@graingert

Copy link
Copy Markdown
Contributor Author

thanks for the review, but I can't merge it

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On other hand, the test now emit a different warning (even if readline is available):

test_lineendings (test.test_doctest.test_doctest)
Doctest: test.test_doctest.test_doctest.test_lineendings ... .../Lib/test/test_doctest/test_doctest.py:2887: DeprecationWarning: importlib.abc.ResourceLoader is deprecated in favour of supporting resource loading through importlib.resources.abc.ResourceReader.
  self.importer = TestImporter()
ok

And it fails with -Werror.

So this is not a complete fix.

@graingert

Copy link
Copy Markdown
Contributor Author

@graingert

Copy link
Copy Markdown
Contributor Author

I have made the requested changes; please review again

@bedevere-app

bedevere-app Bot commented Jan 15, 2025

Copy link
Copy Markdown

Thanks for making the requested changes!

@serhiy-storchaka: please review the changes made to this pull request.

@serhiy-storchaka serhiy-storchaka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

@miss-islington-app

Copy link
Copy Markdown

Thanks @graingert for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@graingert
graingert deleted the fix-test-doctest-warning branch January 15, 2025 13:18
@ambv ambv added needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes and removed needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Jan 15, 2025
@miss-islington-app

Copy link
Copy Markdown

Thanks @graingert for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app

Copy link
Copy Markdown

Thanks @graingert for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 15, 2025
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
(cherry picked from commit 599be68)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 15, 2025
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
(cherry picked from commit 599be68)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
@bedevere-app

bedevere-app Bot commented Jan 15, 2025

Copy link
Copy Markdown

GH-128870 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Jan 15, 2025
@bedevere-app

bedevere-app Bot commented Jan 15, 2025

Copy link
Copy Markdown

GH-128871 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Jan 15, 2025
serhiy-storchaka pushed a commit that referenced this pull request Jan 16, 2025
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
(cherry picked from commit 599be68)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
serhiy-storchaka pushed a commit that referenced this pull request Jan 16, 2025
* Fix a deprecation warning for using importlib.resources.abc.ResourceReader.
* Fix an import warning when importing readline (if it has not yet been imported).
(cherry picked from commit 599be68)

Co-authored-by: Thomas Grainger <tagrain@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants