Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Doc/whatsnew/3.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,12 @@ Build and C API Changes
Deprecated
==========

* The parameter ``name`` in :class:`importlib.machinery.ExtensionFileLoader` is
now deprecated, use ``fullname`` instead. This brings the name in line with
the rest of :mod:`importlib` and what the documentation has always said the
name of the parameter was.
(Contributed by Sayan Chowdhury in :issue:`30274`.)

* The distutils ``bdist_msi`` command is now deprecated, use
``bdist_wheel`` (wheel packages) instead.
(Contributed by Hugo van Kemenade in :issue:`39586`.)
Expand Down
13 changes: 11 additions & 2 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,8 +1092,17 @@ class ExtensionFileLoader(FileLoader, _LoaderBasics):

"""

def __init__(self, name, path):
self.name = name
def __init__(self, fullname=None, path=None, *, name=None):
if name is not None:
_warnings.warn("the 'name' parameter is deprecated; use "
"'fullname' instead", DeprecationWarning,
stacklevel=2)
if fullname is not None:
raise TypeError("'name' and 'fullname' cannot be used "
"simultaneously")
self.name = name
else:
self.name = fullname
self.path = path

def __eq__(self, other):
Expand Down
18 changes: 18 additions & 0 deletions Lib/test/test_importlib/extension/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ def test_load_module_API(self):
with self.assertRaises(ImportError):
self.load_module('XXX')

def test_deprecation_warning_argument_name_and_fullname_use(self):
with self.assertWarns(DeprecationWarning) as cm:
self.machinery.ExtensionFileLoader(
name=util.EXTENSIONS.name,
path=util.EXTENSIONS.file_path)

self.assertIn("fullname", str(cm.warning))

def test_argument_name_and_fullname_use(self):
with self.assertWarns(DeprecationWarning) as warning_cm:
with self.assertRaises(TypeError) as exception_cm:
self.machinery.ExtensionFileLoader(
fullname=util.EXTENSIONS.name,
name=util.EXTENSIONS.name,
path=util.EXTENSIONS.file_path)

self.assertIn("fullname", str(exception_cm.exception))

def test_equality(self):
other = self.machinery.ExtensionFileLoader(util.EXTENSIONS.name,
util.EXTENSIONS.file_path)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Rename *name* argument to *fullname* to
:class:`importlib.machinery.ExtensionFileLoader`. Patch by Sayan Chowdhury.
Loading