mirror of
https://github.com/python/cpython
synced 2024-09-19 23:31:41 +00:00
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
|
||||
|
||||
(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 @@ def parent(self):
|
|||
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 @@ def test_default_is_package_true(self):
|
|||
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.
|
||||
|
||||
|
|
5847
Python/importlib.h
5847
Python/importlib.h
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue