Skip to content
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

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

Closed
vstinner opened this issue Jun 28, 2022 · 5 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@vstinner
Copy link
Member

vstinner commented Jun 28, 2022

In Python 3.10, the find_loader() and find_module() methods of zipimport were deprecated by commit d2e94bb and commit 57c6cb5.

It's now time to remove them. The find_spec() method should be used instead.

See issue #86301 and PEP 451 for the rationale.

I wrote PR #94380 to remove these methods.

@vstinner vstinner added the type-bug An unexpected behavior, bug, or error label Jun 28, 2022
vstinner added a commit that referenced this issue Jul 5, 2022
…94380)

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.
@warsaw
Copy link
Member

warsaw commented Oct 7, 2022

I'm looking at removing find_loader() everywhere. @brettcannon @ericsnowcurrently

@warsaw
Copy link
Member

warsaw commented Oct 7, 2022

@vstinner Shouldn't this ticket be closed given that the PR you referenced was merged?

@vstinner
Copy link
Member Author

@vstinner Shouldn't this ticket be closed given that the PR you referenced was merged?

First my PR #94380 also tried to remove load_module() but I got issues, so 92bcb26 only removes find_loader() and find_module() methods.

This issue title is only "zipimport: Remove deprecated find_loader() and find_module() methods", so yep, I'm fine with closing it.

@warsaw
Copy link
Member

warsaw commented Oct 10, 2022

Thanks @vstinner. When @brettcannon and I talked about it, we noticed that load_module() only raised ImportWarning in 3.10, so in 3.12 it will raise DeprecationWarning and will be removed in 3.14.

@vstinner
Copy link
Member Author

Ah? I only looked at zipimport.py code:

    # Load and return the module named by 'fullname'.
    def load_module(self, fullname):
        """load_module(fullname) -> module.

        Load the module specified by 'fullname'. 'fullname' must be the
        fully qualified (dotted) module name. It returns the imported
        module, or raises ZipImportError if it could not be imported.

        Deprecated since Python 3.10. Use exec_module() instead.
        """
        msg = ("zipimport.zipimporter.load_module() is deprecated and slated for "
               "removal in Python 3.12; use exec_module() instead")
        _warnings.warn(msg, DeprecationWarning)
        (...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants