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

Remove more deprecated importlib APIs from Python 3.12 #98040

Closed
6 tasks done
warsaw opened this issue Oct 7, 2022 · 8 comments
Closed
6 tasks done

Remove more deprecated importlib APIs from Python 3.12 #98040

warsaw opened this issue Oct 7, 2022 · 8 comments
Labels
type-bug An unexpected behavior, bug, or error

Comments

@warsaw
Copy link
Member

warsaw commented Oct 7, 2022

Issue #97850 is the meta issue tracking removals of long deprecated functions from importlib. This ticket tracks just the removals of the following previously deprecated APIs:

  • find_loader()
  • find_module()
  • imp module
  • importlib.abc.Finder
  • pkgutil.ImpImporter
  • pkgutil.ImpLoader

Linked PRs

@warsaw warsaw added the type-bug An unexpected behavior, bug, or error label Oct 7, 2022
@warsaw
Copy link
Member Author

warsaw commented Oct 7, 2022

Questions:

  • importlib.abs.PathEntryFinder has this comment: "We don't define find_spec() here since that would break hasattr checks we do to support backward compatibility." Do we need to define find_spec() in this ABC?

@warsaw warsaw changed the title Remove find_module() and find_loader() from Python 3.12 Remove find_module(), find_loader(), and NullImporter from Python 3.12 Oct 7, 2022
@warsaw warsaw changed the title Remove find_module(), find_loader(), and NullImporter from Python 3.12 Remove more deprecated importlib APIs from Python 3.12 Oct 7, 2022
@warsaw
Copy link
Member Author

warsaw commented Oct 9, 2022

pkgutil.ImpImporter cannot be removed since pip 22.2.2 still uses it. This is also going to keep pkgutil.ImpLoader and the imp module around. I'm going to pause work on this branch until there's a pip upstream resolution.

@hugovk
Copy link
Member

hugovk commented Apr 8, 2023

Little reminder: we're a month away from the beta freeze to remove these, or to bump removal to 3.13.

@warsaw
Copy link
Member Author

warsaw commented Apr 8, 2023

My plan is to complete this work at the 2023 PyCon sprints.

CAM-Gerlach pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
ericsnowcurrently added a commit that referenced this issue Apr 19, 2023
I recently added some tests to test_imp, but @warsaw is removing that file in gh-98573. The tests are worth keeping so here I'm moving them to test_import.
carljm added a commit to carljm/cpython that referenced this issue Apr 20, 2023
* main: (24 commits)
  pythongh-98040: Move the Single-Phase Init Tests Out of test_imp (pythongh-102561)
  pythongh-83861: Fix datetime.astimezone() method (pythonGH-101545)
  pythongh-102856: Clean some of the PEP 701 tokenizer implementation (python#103634)
  pythongh-102856: Skip test_mismatched_parens in WASI builds (python#103633)
  pythongh-102856: Initial implementation of PEP 701 (python#102855)
  pythongh-103583: Add ref. dependency between multibytecodec modules (python#103589)
  pythongh-83004: Harden msvcrt further (python#103420)
  pythonGH-88342: clarify that `asyncio.as_completed` accepts generators yielding tasks (python#103626)
  pythongh-102778: IDLE - make sys.last_exc available in Shell after traceback (python#103314)
  pythongh-103582: Remove last references to `argparse.REMAINDER` from docs (python#103586)
  pythongh-103583: Always pass multibyte codec structs as const (python#103588)
  pythongh-103617: Fix compiler warning in _iomodule.c (python#103618)
  pythongh-103596: [Enum] do not shadow mixed-in methods/attributes (pythonGH-103600)
  pythonGH-100530: Change the error message for non-class class patterns (pythonGH-103576)
  pythongh-95299: Remove lingering setuptools reference in installer scripts (pythonGH-103613)
  [Doc] Fix a typo in optparse.rst (python#103504)
  pythongh-101100: Fix broken reference `__format__` in `string.rst` (python#103531)
  pythongh-95299: Stop installing setuptools as a part of ensurepip and venv (python#101039)
  pythonGH-103484: Docs: add linkcheck allowed redirects entries for most cases (python#103569)
  pythongh-67230: update whatsnew note for csv changes (python#103598)
  ...
jan-cerny added a commit to jan-cerny/scap-security-guide that referenced this issue Jul 11, 2023
Fixes broken build on Fedora Rawhide.

The deprecated importlib API has been removed from Python 3.12,
see python/cpython#98040.

Addressing:

Traceback (most recent call last):
  File "/builddir/build/BUILD/scap-security-guide-0.1.69/build-scripts/build_templated_content.py", line 9, in <module>
    import ssg.templates
  File "/builddir/build/BUILD/scap-security-guide-0.1.69/ssg/templates.py", line 5, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
musicinmybrain added a commit to musicinmybrain/grpc that referenced this issue Jul 17, 2023
This API was removed in Python 3.12
(python/cpython#98040).

Fixes Python 3.12 support in grpcio tests.
musicinmybrain added a commit to musicinmybrain/grpc that referenced this issue Jul 17, 2023
Do not use importlib find_module API in bazel/_gevent_test_main.py

This API was removed in Python 3.12
(python/cpython#98040).
rhmdnd pushed a commit to openshift/cac-content-fork that referenced this issue Jul 21, 2023
Fixes broken build on Fedora Rawhide.

The deprecated importlib API has been removed from Python 3.12,
see python/cpython#98040.

Addressing:

Traceback (most recent call last):
  File "/builddir/build/BUILD/scap-security-guide-0.1.69/build-scripts/build_templated_content.py", line 9, in <module>
    import ssg.templates
  File "/builddir/build/BUILD/scap-security-guide-0.1.69/ssg/templates.py", line 5, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
gnossen pushed a commit to grpc/grpc that referenced this issue Sep 6, 2023
…33506)

This API was [removed in Python
3.12](python/cpython#98040).

Fixes Python 3.12 support in `grpcio` tests.

This is relevant to #33063.

See also #33492.

----

I have actually only tested this in a form backported to grpc 1.48.4,
and I am not able to test the change to `bazel/_gevent_test_main.py`
directly. However, the backported form allows me to build grpc 1.48.4
for Fedora Rawhide with Python 3.12, and I believe the version in this
PR to be correct—especially, if CI passes for Python 3.11, I believe
this part of the test code will continue to work in Python 3.12.
openstack-mirroring pushed a commit to openstack/oslotest that referenced this issue Jan 7, 2024
find_module function was deprecated in Python 3.4 [1] and later removed
in Python 3.12 [2], the find_spec function should be used instead. This
change is necessary for proper Python 3.12 support.

[1] https://docs.python.org/3.4/library/importlib.html#importlib.abc.MetaPathFinder.find_module
[2] python/cpython#98040

Change-Id: I8354918d6548192dea3492eb2ee682d323559912
Signed-off-by: Petr Vaněk <[email protected]>
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue Jan 7, 2024
* Update oslotest from branch 'master'
  to e8c5d7093a2d999ee343497767eac54126b79ee6
  - Merge "Replace find_module function"
  - Replace find_module function
    
    find_module function was deprecated in Python 3.4 [1] and later removed
    in Python 3.12 [2], the find_spec function should be used instead. This
    change is necessary for proper Python 3.12 support.
    
    [1] https://docs.python.org/3.4/library/importlib.html#importlib.abc.MetaPathFinder.find_module
    [2] python/cpython#98040
    
    Change-Id: I8354918d6548192dea3492eb2ee682d323559912
    Signed-off-by: Petr Vaněk <[email protected]>
yibe added a commit to yibe/ldoce5viewer-pyqt5 that referenced this issue May 10, 2024
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

5 participants
@vstinner @warsaw @encukou @hugovk and others