Issue #18864: Add a setter for ModuleSpec.has_location.
This commit is contained in:
parent
85cce1eac7
commit
b282b3d804
@ -901,7 +901,7 @@ find and load modules.
|
|||||||
|
|
||||||
.. attribute:: has_location
|
.. 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.
|
attribute refers to a loadable location.
|
||||||
|
|
||||||
:mod:`importlib.util` -- Utility code for importers
|
:mod:`importlib.util` -- Utility code for importers
|
||||||
|
@ -841,6 +841,10 @@ class ModuleSpec:
|
|||||||
def has_location(self):
|
def has_location(self):
|
||||||
return self._set_fileattr
|
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):
|
def spec_from_loader(name, loader, *, origin=None, is_package=None):
|
||||||
"""Return a module spec based on various loader methods."""
|
"""Return a module spec based on various loader methods."""
|
||||||
|
@ -116,6 +116,13 @@ class ModuleSpecTests:
|
|||||||
self.assertIs(spec.cached, None)
|
self.assertIs(spec.cached, None)
|
||||||
self.assertFalse(spec.has_location)
|
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):
|
def test_equality(self):
|
||||||
other = type(sys.implementation)(name=self.name,
|
other = type(sys.implementation)(name=self.name,
|
||||||
loader=self.loader,
|
loader=self.loader,
|
||||||
|
@ -105,6 +105,8 @@ Library
|
|||||||
- Issue #19698: Removed exec_module() methods from
|
- Issue #19698: Removed exec_module() methods from
|
||||||
importlib.machinery.BuiltinImporter and ExtensionFileLoader.
|
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
|
- Fixed _pickle.Unpickler to not fail when loading empty strings as
|
||||||
persistent IDs.
|
persistent IDs.
|
||||||
|
|
||||||
|
5847
Python/importlib.h
5847
Python/importlib.h
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user