@@ -249,7 +249,7 @@ ABC hierarchy::
249249 An abstract method for finding a :term: `spec <module spec> ` for
250250 the specified module. If this is a top-level import, *path * will
251251 be ``None ``. Otherwise, this is a search for a subpackage or
252- module and *path * will be the value of :attr: `__path__ ` from the
252+ module and *path * will be the value of :attr: `~module. __path__ ` from the
253253 parent package. If a spec cannot be found, ``None `` is returned.
254254 When passed in, ``target `` is a module object that the finder may
255255 use to make a more educated guess about what spec to return.
@@ -355,34 +355,12 @@ ABC hierarchy::
355355 (note that some of these attributes can change when a module is
356356 reloaded):
357357
358- - :attr: `__name__ `
359- The module's fully qualified name.
360- It is ``'__main__' `` for an executed module.
361-
362- - :attr: `__file__ `
363- The location the :term: `loader ` used to load the module.
364- For example, for modules loaded from a .py file this is the filename.
365- It is not set on all modules (e.g. built-in modules).
366-
367- - :attr: `__cached__ `
368- The filename of a compiled version of the module's code.
369- It is not set on all modules (e.g. built-in modules).
370-
371- - :attr: `__path__ `
372- The list of locations where the package's submodules will be found.
373- Most of the time this is a single directory.
374- The import system passes this attribute to ``__import__() `` and to finders
375- in the same way as :data: `sys.path ` but just for the package.
376- It is not set on non-package modules so it can be used
377- as an indicator that the module is a package.
378-
379- - :attr: `__package__ `
380- The fully qualified name of the package the module is in (or the
381- empty string for a top-level module).
382- If the module is a package then this is the same as :attr: `__name__ `.
383-
384- - :attr: `__loader__ `
385- The :term: `loader ` used to load the module.
358+ - :attr: `module.__name__ `
359+ - :attr: `module.__file__ `
360+ - :attr: `module.__cached__ ` *(deprecated) *
361+ - :attr: `module.__path__ `
362+ - :attr: `module.__package__ ` *(deprecated) *
363+ - :attr: `module.__loader__ ` *(deprecated) *
386364
387365 When :meth: `exec_module ` is available then backwards-compatible
388366 functionality is provided.
@@ -418,7 +396,8 @@ ABC hierarchy::
418396 can implement this abstract method to give direct access
419397 to the data stored. :exc: `OSError ` is to be raised if the *path * cannot
420398 be found. The *path * is expected to be constructed using a module's
421- :attr: `__file__ ` attribute or an item from a package's :attr: `__path__ `.
399+ :attr: `~module.__file__ ` attribute or an item from a package's
400+ :attr: `~module.__path__ `.
422401
423402 .. versionchanged :: 3.4
424403 Raises :exc: `OSError ` instead of :exc: `NotImplementedError `.
@@ -505,9 +484,9 @@ ABC hierarchy::
505484
506485 .. abstractmethod :: get_filename(fullname)
507486
508- An abstract method that is to return the value of :attr: ` __file__ ` for
509- the specified module. If no path is available, :exc: ` ImportError ` is
510- raised.
487+ An abstract method that is to return the value of
488+ :attr: ` ~module.__file__ ` for the specified module. If no path is
489+ available, :exc: ` ImportError ` is raised.
511490
512491 If source code is available, then the method should return the path to
513492 the source file, regardless of whether a bytecode was used to load the
@@ -1166,43 +1145,45 @@ find and load modules.
11661145.. class :: ModuleSpec(name, loader, *, origin=None, loader_state=None, is_package=None)
11671146
11681147 A specification for a module's import-system-related state. This is
1169- typically exposed as the module's :attr: `__spec__ ` attribute. Many
1148+ typically exposed as the module's :attr: `~module. __spec__ ` attribute. Many
11701149 of these attributes are also available directly on a module: for example,
11711150 ``module.__spec__.origin == module.__file__ ``. Note, however, that
11721151 while the *values * are usually equivalent, they can differ since there is
1173- no synchronization between the two objects. For example, it is possible to update
1174- the module's :attr: `__file__ ` at runtime and this will not be automatically
1175- reflected in the module's :attr: `__spec__.origin `, and vice versa.
1152+ no synchronization between the two objects. For example, it is possible to
1153+ update the module's :attr: `~module.__file__ ` at runtime and this will not be
1154+ automatically reflected in the module's
1155+ :attr: `__spec__.origin <ModuleSpec.origin> `, and vice versa.
11761156
11771157 .. versionadded :: 3.4
11781158
11791159 .. attribute :: name
11801160
1181- The module's fully qualified name
1182- (see :attr: `__name__ ` attributes on modules).
1161+ The module's fully qualified name (see :attr: `module.__name__ `).
11831162 The :term: `finder ` should always set this attribute to a non-empty string.
11841163
11851164 .. attribute :: loader
11861165
1187- The :term: `loader ` used to load the module
1188- (see :attr: `__loader__ ` attributes on modules).
1166+ The :term: `loader ` used to load the module (see :attr: `module.__loader__ `).
11891167 The :term: `finder ` should always set this attribute.
11901168
11911169 .. attribute :: origin
11921170
11931171 The location the :term: `loader ` should use to load the module
1194- (see :attr: `__file__ ` attributes on modules ).
1195- For example, for modules loaded from a .py file this is the filename.
1172+ (see :attr: `module. __file__ `).
1173+ For example, for modules loaded from a `` .py `` file this is the filename.
11961174 The :term: `finder ` should always set this attribute to a meaningful value
11971175 for the :term: `loader ` to use. In the uncommon case that there is not one
11981176 (like for namespace packages), it should be set to ``None ``.
11991177
12001178 .. attribute :: submodule_search_locations
12011179
1202- The list of locations where the package's submodules will be found
1203- (see :attr: `__path__ ` attributes on modules).
1204- Most of the time this is a single directory.
1205- The :term: `finder ` should set this attribute to a list, even an empty one, to indicate
1180+ A (possibly empty) :term: `sequence ` of strings enumerating the locations
1181+ in which a package's submodules will be found
1182+ (see :attr: `module.__path__ `). Most of the time there will only be a
1183+ single directory in this list.
1184+
1185+ The :term: `finder ` should set this attribute to a sequence, even an empty
1186+ one, to indicate
12061187 to the import system that the module is a package. It should be set to ``None `` for
12071188 non-package modules. It is set automatically later to a special object for
12081189 namespace packages.
@@ -1216,22 +1197,22 @@ find and load modules.
12161197 .. attribute :: cached
12171198
12181199 The filename of a compiled version of the module's code
1219- (see :attr: `__cached__ ` attributes on modules ).
1200+ (see :attr: `module. __cached__ `).
12201201 The :term: `finder ` should always set this attribute but it may be ``None ``
12211202 for modules that do not need compiled code stored.
12221203
12231204 .. attribute :: parent
12241205
12251206 (Read-only) The fully qualified name of the package the module is in (or the
12261207 empty string for a top-level module).
1227- See :attr: `__package__ ` attributes on modules .
1208+ See :attr: `module. __package__ `.
12281209 If the module is a package then this is the same as :attr: `name `.
12291210
12301211 .. attribute :: has_location
12311212
12321213 ``True `` if the spec's :attr: `origin ` refers to a loadable location,
1233- ``False `` otherwise. This value impacts how :attr: `origin ` is interpreted
1234- and how the module's :attr: `__file__ ` is populated.
1214+ ``False `` otherwise. This value impacts how :attr: `! origin ` is interpreted
1215+ and how the module's :attr: `~module. __file__ ` is populated.
12351216
12361217
12371218.. class :: AppleFrameworkLoader(name, path)
@@ -1416,8 +1397,8 @@ an :term:`importer`.
14161397
14171398 .. versionchanged :: 3.7
14181399 Raises :exc: `ModuleNotFoundError ` instead of :exc: `AttributeError ` if
1419- **package ** is in fact not a package (i.e. lacks a :attr: ` __path__ `
1420- attribute).
1400+ **package ** is in fact not a package (i.e. lacks a
1401+ :attr: ` ~module.__path__ ` attribute).
14211402
14221403.. function :: module_from_spec(spec)
14231404
0 commit comments