@@ -209,7 +209,7 @@ Standard names are defined for the following types:
209
209
210
210
.. class :: ModuleType(name, doc=None)
211
211
212
- The type of :term: `modules <module> `. Constructor takes the name of the
212
+ The type of :term: `modules <module> `. The constructor takes the name of the
213
213
module to be created and optionally its :term: `docstring `.
214
214
215
215
.. note ::
@@ -224,12 +224,23 @@ Standard names are defined for the following types:
224
224
225
225
The :term: `loader ` which loaded the module. Defaults to ``None ``.
226
226
227
+ This attribute is to match :attr: `importlib.machinery.ModuleSpec.loader `
228
+ as stored in the attr:`__spec__ ` object.
229
+
230
+ .. note ::
231
+ A future version of Python may stop setting this attribute by default.
232
+ To guard against this potential change, preferrably read from the
233
+ :attr: `__spec__ ` attribute instead or use
234
+ ``getattr(module, "__loader__", None) `` if you explicitly need to use
235
+ this attribute.
236
+
227
237
.. versionchanged :: 3.4
228
238
Defaults to ``None ``. Previously the attribute was optional.
229
239
230
240
.. attribute :: __name__
231
241
232
- The name of the module.
242
+ The name of the module. Expected to match
243
+ :attr: `importlib.machinery.ModuleSpec.name `.
233
244
234
245
.. attribute :: __package__
235
246
@@ -238,9 +249,26 @@ Standard names are defined for the following types:
238
249
to ``'' ``, else it should be set to the name of the package (which can be
239
250
:attr: `__name__ ` if the module is a package itself). Defaults to ``None ``.
240
251
252
+ This attribute is to match :attr: `importlib.machinery.ModuleSpec.parent `
253
+ as stored in the attr:`__spec__ ` object.
254
+
255
+ .. note ::
256
+ A future version of Python may stop setting this attribute by default.
257
+ To guard against this potential change, preferrably read from the
258
+ :attr: `__spec__ ` attribute instead or use
259
+ ``getattr(module, "__package__", None) `` if you explicitly need to use
260
+ this attribute.
261
+
241
262
.. versionchanged :: 3.4
242
263
Defaults to ``None ``. Previously the attribute was optional.
243
264
265
+ .. attribute :: __spec__
266
+
267
+ A record of the the module's import-system-related state. Expected to be
268
+ an instance of :class: `importlib.machinery.ModuleSpec `.
269
+
270
+ .. versionadded :: 3.4
271
+
244
272
245
273
.. class :: TracebackType(tb_next, tb_frame, tb_lasti, tb_lineno)
246
274
0 commit comments