GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-123780: Make test_pkgutil clean up `spam` module by mhsmith · Pull Request #123036 · python/cpython

Conversation

@mhsmith

@mhsmith mhsmith commented Aug 15, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

When running the tests with --randomize, as is done by the buildbots, I came across this failure:

======================================================================
ERROR: test_find_class (test.test_pickle.CUnpicklerTests.test_find_class)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/msmith/git/python/cpython/Lib/test/pickletester.py", line 1265, in test_find_class
    self.assertRaises(ModuleNotFoundError, unpickler.find_class, 'spam', 'log')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/msmith/git/python/cpython/Lib/unittest/case.py", line 804, in assertRaises
    return context.handle('assertRaises', args, kwargs)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/msmith/git/python/cpython/Lib/unittest/case.py", line 238, in handle
    callable_obj(*args, **kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
AttributeError: module 'spam' has no attribute 'log'

======================================================================
ERROR: test_find_class (test.test_pickle.PyUnpicklerTests.test_find_class)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/msmith/git/python/cpython/Lib/test/pickletester.py", line 1265, in test_find_class
    self.assertRaises(ModuleNotFoundError, unpickler.find_class, 'spam', 'log')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/msmith/git/python/cpython/Lib/unittest/case.py", line 804, in assertRaises
    return context.handle('assertRaises', args, kwargs)
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/msmith/git/python/cpython/Lib/unittest/case.py", line 238, in handle
    callable_obj(*args, **kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/Users/msmith/git/python/cpython/Lib/pickle.py", line 1620, in find_class
    return getattr(sys.modules[module], name)
AttributeError: module 'spam' has no attribute 'log'

----------------------------------------------------------------------
Ran 857 tests in 2.954s

FAILED (errors=2, skipped=31)
test test_pickle failed

This can be reproduced by running only test_pkgutil and test_pickle, in that order. test_pkgutil leaves behind a spam module in sys.modules, while test_pickle assumes there is no such module.

  • Issue: test_pkgutil should clean up spam module #123780

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mhsmith
Make test_pkgutil clean up spam module
b527b73
@mhsmith mhsmith added skip issue skip news needs backport to 3.12 only security fixes needs backport to 3.13 only security fixes labels Aug 15, 2024
@mhsmith
mhsmith requested a review from ericsnowcurrently as a code owner August 15, 2024 13:27
@bedevere-app bedevere-app Bot added tests Tests in the Lib/test dir awaiting review labels Aug 15, 2024
@mhsmith mhsmith mentioned this pull request Aug 15, 2024
gh-116622: Add Android test script #121595
Merged
encukou
encukou approved these changes Sep 6, 2024
View reviewed changes
@bedevere-app bedevere-app Bot added awaiting merge and removed awaiting review labels Sep 6, 2024
@encukou encukou removed the skip issue label Sep 6, 2024
@encukou

encukou commented Sep 6, 2024

Copy link
Copy Markdown
Member

PRs that need backporting should not skip issue; the issue number helps keep related PRs grouped together.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou encukou changed the title Make test_pkgutil clean up spam module gh-123780: Make test_pkgutil clean up spam module Sep 6, 2024
@bedevere-app bedevere-app Bot mentioned this pull request Sep 6, 2024
test_pkgutil should clean up spam module #123780
Closed
@encukou
encukou merged commit eca3fe4 into python:main Sep 6, 2024
@bedevere-app bedevere-app Bot removed the awaiting merge label Sep 6, 2024
@miss-islington-app

miss-islington-app Bot commented Sep 6, 2024

Copy link
Copy Markdown

Thanks @mhsmith for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 6, 2024
@mhsmith @miss-islington
pythongh-123780: Make test_pkgutil clean up spam module (pythonGH-1…
6405a6a
…23036)

(cherry picked from commit eca3fe4)

Co-authored-by: Malcolm Smith <[email protected]>
@bedevere-app

bedevere-app Bot commented Sep 6, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 only security fixes label Sep 6, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 6, 2024
@mhsmith @miss-islington
pythongh-123780: Make test_pkgutil clean up spam module (pythonGH-1…
81cfee7
…23036)

(cherry picked from commit eca3fe4)

Co-authored-by: Malcolm Smith <[email protected]>
@bedevere-app

bedevere-app Bot commented Sep 6, 2024

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Sep 6, 2024
@Wulian233 Wulian233 mentioned this pull request Sep 6, 2024
gh-97850: remove find_loader and get_loader from pkgutil #119656
Merged
Yhg1s pushed a commit that referenced this pull request Sep 6, 2024
@miss-islington @mhsmith
[3.13] gh-123780: Make test_pkgutil clean up spam module (GH-123036) (
72cdd2a
#123781)

gh-123780: Make test_pkgutil clean up `spam` module (GH-123036)
(cherry picked from commit eca3fe4)

Co-authored-by: Malcolm Smith <[email protected]>
encukou pushed a commit that referenced this pull request Sep 9, 2024
@miss-islington @mhsmith
[3.12] gh-123780: Make test_pkgutil clean up spam module (GH-123036) (
349cc27
GH-123782)

(cherry picked from commit eca3fe4)

Co-authored-by: Malcolm Smith <[email protected]>
@mhsmith

mhsmith commented Sep 11, 2024

Copy link
Copy Markdown
Member Author

PRs that need backporting should not skip issue; the issue number helps keep related PRs grouped together.

OK, I'll remember that. But doesn't the original PR provide enough grouping already? It links to the backports, and the backports link to it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@encukou

encukou commented Sep 12, 2024

Copy link
Copy Markdown
Member

Well, not as clearly as the issue's Linked PRs section :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@encukou encukou encukou approved these changes
@ericsnowcurrently ericsnowcurrently Awaiting requested review from ericsnowcurrently ericsnowcurrently is a code owner

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@mhsmith @encukou
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.