Skip to content

Commit 878d7e4

Browse files
authored
bpo-21760: fix __file__ description (GH-19097)
1 parent 275d5f7 commit 878d7e4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Doc/reference/import.rst

+8-3
Original file line numberDiff line numberDiff line change
@@ -603,9 +603,14 @@ the module.
603603
.. attribute:: __file__
604604
.. attribute:: __cached__
605605

606-
``__file__`` is optional. If set, this attribute's value must be a
607-
string. The import system may opt to leave ``__file__`` unset if it
608-
has no semantic meaning (e.g. a module loaded from a database).
606+
``__file__`` is optional (if set, value must be a string). It indicates
607+
the pathname of the file from which the module was loaded (if
608+
loaded from a file), or the pathname of the shared libray file
609+
for extension modules loaded dynamically from a shared library.
610+
It might be missing for certain types of modules, such as C
611+
modules that are statically linked into the interpreter, and the
612+
import system may opt to leave it unset if it has no semantic
613+
meaning (e.g. a module loaded from a database).
609614

610615
If ``__file__`` is set, it may also be appropriate to set the
611616
``__cached__`` attribute which is the path to any compiled version of
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
The description for __file__ fixed.
2+
Patch by Furkan Onder

0 commit comments

Comments
 (0)