Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
8e8898a7
Commit
8e8898a7
authored
Mar 29, 2014
by
Nick Coghlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #19697: document more __main__.__spec__ quirks
parent
7b445858
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
Doc/reference/import.rst
Doc/reference/import.rst
+16
-2
No files found.
Doc/reference/import.rst
View file @
8e8898a7
...
@@ -852,16 +852,30 @@ Depending on how :mod:`__main__` is initialized, ``__main__.__spec__``
...
@@ -852,16 +852,30 @@ Depending on how :mod:`__main__` is initialized, ``__main__.__spec__``
gets
set
appropriately
or
to
``
None
``.
gets
set
appropriately
or
to
``
None
``.
When
Python
is
started
with
the
:
option
:`-
m
`
option
,
``
__spec__
``
is
set
When
Python
is
started
with
the
:
option
:`-
m
`
option
,
``
__spec__
``
is
set
to
the
module
spec
of
the
corresponding
module
.
to
the
module
spec
of
the
corresponding
module
or
package
.
``
__spec__
``
is
also
populated
when
the
``
__main__
``
module
is
loaded
as
part
of
executing
a
directory
,
zipfile
or
other
:
data
:`
sys
.
path
`
entry
.
In
:
ref
:`
the
remaining
cases
<
using
-
on
-
interface
-
options
>`
In
:
ref
:`
the
remaining
cases
<
using
-
on
-
interface
-
options
>`
``
__main__
.
__spec__
``
is
set
to
``
None
``:
``
__main__
.
__spec__
``
is
set
to
``
None
``,
as
the
code
used
to
populate
the
:
mod
:`
__main__
`
does
not
correspond
directly
with
an
importable
module
:
-
interactive
prompt
-
interactive
prompt
-
-
c
switch
-
-
c
switch
-
running
from
stdin
-
running
from
stdin
-
running
directly
from
a
source
or
bytecode
file
-
running
directly
from
a
source
or
bytecode
file
Note
that
``
__main__
.
__spec__
``
is
always
``
None
``
in
the
last
case
,
*
even
if
*
the
file
could
technically
be
imported
directly
as
a
module
instead
.
Use
the
:
option
:`-
m
`
switch
if
valid
module
metadata
is
desired
in
:
mod
:`
__main__
`.
Note
also
that
even
when
``
__main__
``
corresponds
with
an
importable
module
and
``
__main__
.
__spec__
``
is
set
accordingly
,
they
're still considered
*distinct* modules. This is due to the fact that blocks guarded by
``if __name__ == "__main__":`` checks only execute when the module is used
to populate the ``__main__`` namespace, and not during normal import.
Open issues
Open issues
===========
===========
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment