Skip to content

Conversation

@mhsmith
Copy link
Member

@mhsmithmhsmith commented Aug 15, 2024

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.

@encukou
Copy link
Member

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

@encukouencukou changed the title Make test_pkgutil clean up spam modulegh-123780: Make test_pkgutil clean up spam moduleSep 6, 2024
@encukouencukou merged commit eca3fe4 into python:mainSep 6, 2024
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 6, 2024
…23036) (cherry picked from commit eca3fe4) Co-authored-by: Malcolm Smith <smith@chaquo.com>
@bedevere-app
Copy link

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

@bedevere-appbedevere-appbot removed the needs backport to 3.13 bugs and security fixes label Sep 6, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 6, 2024
…23036) (cherry picked from commit eca3fe4) Co-authored-by: Malcolm Smith <smith@chaquo.com>
@bedevere-app
Copy link

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

@bedevere-appbedevere-appbot removed the needs backport to 3.12 only security fixes label Sep 6, 2024
Yhg1s pushed a commit that referenced this pull request Sep 6, 2024
#123781) gh-123780: Make test_pkgutil clean up `spam` module (GH-123036) (cherry picked from commit eca3fe4) Co-authored-by: Malcolm Smith <smith@chaquo.com>
encukou pushed a commit that referenced this pull request Sep 9, 2024
GH-123782) (cherry picked from commit eca3fe4) Co-authored-by: Malcolm Smith <smith@chaquo.com>
@mhsmith
Copy link
MemberAuthor

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.

@encukou
Copy link
Member

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

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

Labels

skip newstestsTests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@mhsmith@encukou