Commit b282b3d8 authored by Eric Snow's avatar Eric Snow

Issue #18864: Add a setter for ModuleSpec.has_location.

parent 85cce1ea
......@@ -901,7 +901,7 @@ find and load modules.
.. attribute:: has_location
(Read-only) Boolean indicating whether or not the module's "origin"
Boolean indicating whether or not the module's "origin"
attribute refers to a loadable location.
:mod:`importlib.util` -- Utility code for importers
......
......@@ -841,6 +841,10 @@ class ModuleSpec:
def has_location(self):
return self._set_fileattr
@has_location.setter
def has_location(self, value):
self._set_fileattr = bool(value)
def spec_from_loader(name, loader, *, origin=None, is_package=None):
"""Return a module spec based on various loader methods."""
......
......@@ -116,6 +116,13 @@ class ModuleSpecTests:
self.assertIs(spec.cached, None)
self.assertFalse(spec.has_location)
def test_has_location_setter(self):
spec = self.machinery.ModuleSpec(self.name, self.loader,
origin='somewhere')
self.assertFalse(spec.has_location)
spec.has_location = True
self.assertTrue(spec.has_location)
def test_equality(self):
other = type(sys.implementation)(name=self.name,
loader=self.loader,
......
......@@ -105,6 +105,8 @@ Library
- Issue #19698: Removed exec_module() methods from
importlib.machinery.BuiltinImporter and ExtensionFileLoader.
- Issue #18864: Added a setter for ModuleSpec.has_location.
- Fixed _pickle.Unpickler to not fail when loading empty strings as
persistent IDs.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment