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-94379: Remove zipimport find_loader() and find_module() methods by vstinner · Pull Request #94380 · python/cpython

Conversation

@vstinner

@vstinner vstinner commented Jun 28, 2022 •
edited by bedevere-bot
Loading

Uh oh!

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

Copy link
Copy Markdown
Member

zipimport: Remove find_loader() and find_module() methods, deprecated
in Python 3.10. Use the find_spec()` method instead. See PEP 451 for
the rationale.

  • Issue: zipimport: Remove deprecated find_loader() and find_module() methods, use find_spec() instead #94379

Sorry, something went wrong.

Uh oh!

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

All reactions
@bedevere-bot bedevere-bot added the awaiting core review label Jun 28, 2022
@vstinner vstinner mentioned this pull request Jun 28, 2022
zipimport: Remove deprecated find_loader() and find_module() methods, use find_spec() instead #94379
Closed
@vstinner

vstinner commented Jun 28, 2022

Copy link
Copy Markdown
Member Author

cc @brettcannon

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
vstinner marked this pull request as ready for review June 28, 2022 14:08
@vstinner
vstinner requested review from brettcannon, encukou, ericsnowcurrently, ncoghlan and warsaw as code owners June 28, 2022 14:08
brettcannon
brettcannon requested changes Jun 28, 2022
View reviewed changes

@brettcannon brettcannon left a comment

Copy link
Copy Markdown
Member

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.

The code removal looks fine, but the doc changes left out the removal of load_module() as well.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/zipimport.py Resolved

Uh oh!

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

@bedevere-bot bedevere-bot removed the awaiting core review label Jun 28, 2022
@bedevere-bot

bedevere-bot commented Jun 28, 2022

Copy link
Copy Markdown

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

All reactions

Sorry, something went wrong.

Uh oh!

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

@bedevere-bot bedevere-bot added the awaiting changes label Jun 28, 2022
@vstinner

vstinner commented Jun 28, 2022

Copy link
Copy Markdown
Member Author

@brettcannon: I updated the PR to mention also load_module() removal, and fix test_zipimport... But now, I feel that I removed too many lines in the tests! Maybe the tests should be fixed instead?

Problem: I don't know how to fix the packdir2 tests:

         mod_path = packdir2 + TESTMOD
         mod_name = module_path_to_dotted_name(mod_path)
-        mod = importlib.import_module(mod_name)
-        self.assertTrue(mod_name in sys.modules)
-        self.assertIsNone(zi.get_source(TESTPACK))
-        self.assertIsNone(zi.get_source(mod_path))
-        self.assertEqual(zi.get_filename(mod_path), mod.__file__)
-        # To pass in the module name instead of the path, we must use the
-        # right importer
-        loader = mod.__spec__.loader
-        self.assertIsNone(loader.get_source(mod_name))
-        self.assertEqual(loader.get_filename(mod_name), mod.__file__)
All reactions

Sorry, something went wrong.

Uh oh!

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

brettcannon
brettcannon requested changes Jun 29, 2022
View reviewed changes
Comment thread Doc/whatsnew/3.12.rst Outdated

@brettcannon brettcannon Jun 29, 2022

Copy link
Copy Markdown
Member

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.

find_spec() only replaces find_loader() and find_module(), so this sentence is a bit misleading. Same is true for the news entry.

Sorry, something went wrong.

Uh oh!

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

All reactions
Comment thread Lib/test/test_zipimport.py Outdated

@brettcannon brettcannon Jun 29, 2022

Copy link
Copy Markdown
Member

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.

Why the test removals for lines that don't directly use the associated methods?

Sorry, something went wrong.

Uh oh!

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

All reactions
@brettcannon

brettcannon commented Jun 29, 2022

Copy link
Copy Markdown
Member

I don't know how to fix the packdir2 test

How is it failing?

Maybe only do the find_*() methods in this PR and worry about load_module() in another one?

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jul 4, 2022

Copy link
Copy Markdown
Member Author

Maybe only do the find_*() methods in this PR and worry about load_module() in another one?

Good idea! I modified this PR to only remove find_loader() and find_module() methods: keep load_module() for now (it can be removed in a separated PR).

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner

vstinner commented Jul 4, 2022

Copy link
Copy Markdown
Member Author

@brettcannon: Would you mind to review the updated PR? Now it only removes find_loader() and find_module() methods, and it only removes the bare minimum lines in test_zipimport.py.

Once the PR gets approved, I will solve the Doc/whatsnew/3.12.rst conflict.

All reactions

Sorry, something went wrong.

Uh oh!

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

warsaw
warsaw approved these changes Jul 4, 2022
View reviewed changes
@bedevere-bot bedevere-bot added awaiting merge and removed awaiting changes labels Jul 4, 2022
brettcannon
brettcannon approved these changes Jul 4, 2022
View reviewed changes
@brettcannon

brettcannon commented Jul 4, 2022

Copy link
Copy Markdown
Member

@vstinner LGTM! And an FYI for anyone else who reviews, the get_filename() function gets used in other places, so it still gets tested.

All reactions

Sorry, something went wrong.

Uh oh!

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

@vstinner
gh-94379: Remove zipimport find_loader() and find_module() methods
9328dfe
zipimport: Remove find_loader() and find_module() methods, deprecated
in Python 3.10: use the find_spec() method instead. See PEP 451 for
the rationale.
@vstinner
vstinner merged commit 92bcb26 into python:main Jul 5, 2022
@bedevere-bot bedevere-bot removed the awaiting merge label Jul 5, 2022
@vstinner
vstinner deleted the zipimport branch July 5, 2022 10:11
@vstinner

vstinner commented Jul 5, 2022

Copy link
Copy Markdown
Member Author

Thanks for the reviews @warsaw and @brettcannon! It's easier to modify zipimport since @serhiy-storchaka rewrote it in pure Python :-)

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

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

Uh oh!

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

Assignees

No one assigned

Labels

None yet

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.

4 participants

@vstinner @bedevere-bot @brettcannon @warsaw
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.