mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
Issue #13959: Deprecate imp.get_suffixes() for new attributes on
importlib.machinery that provide the suffix details for import. The attributes were not put on imp so as to compartmentalize everything importlib needs for setting up imports in importlib.machinery. This also led to an indirect deprecation of inspect.getmoduleinfo() as it directly returned imp.get_suffix's returned tuple which no longer makes sense.
This commit is contained in:
parent
810c64df8f
commit
cb66eb0dec
17 changed files with 160 additions and 69 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import imp
|
||||
from importlib import machinery
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
|
@ -6,10 +7,9 @@ PATH = None
|
|||
EXT = None
|
||||
FILENAME = None
|
||||
NAME = '_testcapi'
|
||||
_file_exts = [x[0] for x in imp.get_suffixes() if x[2] == imp.C_EXTENSION]
|
||||
try:
|
||||
for PATH in sys.path:
|
||||
for EXT in _file_exts:
|
||||
for EXT in machinery.EXTENSION_SUFFIXES:
|
||||
FILENAME = NAME + EXT
|
||||
FILEPATH = os.path.join(PATH, FILENAME)
|
||||
if os.path.exists(os.path.join(PATH, FILENAME)):
|
||||
|
|
@ -18,4 +18,3 @@ try:
|
|||
PATH = EXT = FILENAME = FILEPATH = None
|
||||
except StopIteration:
|
||||
pass
|
||||
del _file_exts
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue