2019-05-17 06:55:34 -03:00
|
|
|
.. highlight:: c
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
.. _importing:
|
|
|
|
|
|
|
|
Importing Modules
|
|
|
|
=================
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ImportModule(const char *name)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
.. index::
|
|
|
|
single: package variable; __all__
|
|
|
|
single: __all__ (package variable)
|
|
|
|
single: modules (in module sys)
|
|
|
|
|
2024-02-02 12:31:55 -04:00
|
|
|
This is a wrapper around :c:func:`PyImport_Import()` which takes a
|
|
|
|
:c:expr:`const char *` as an argument instead of a :c:expr:`PyObject *`.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2012-05-17 13:55:59 -03:00
|
|
|
This function is a deprecated alias of :c:func:`PyImport_ImportModule`.
|
|
|
|
|
|
|
|
.. versionchanged:: 3.3
|
|
|
|
This function used to fail immediately when the import lock was held
|
|
|
|
by another thread. In Python 3.3 though, the locking scheme switched
|
|
|
|
to per-module locks for most purposes, so this function's special
|
|
|
|
behaviour isn't needed anymore.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-06-09 05:30:57 -03:00
|
|
|
.. deprecated-removed:: 3.13 3.15
|
|
|
|
Use :c:func:`PyImport_ImportModule` instead.
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2015-06-21 11:11:21 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ImportModuleEx(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-05-06 00:54:08 -03:00
|
|
|
.. index:: pair: built-in function; __import__
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Import a module. This is best described by referring to the built-in Python
|
2012-08-10 19:55:08 -03:00
|
|
|
function :func:`__import__`.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2008-05-12 15:05:20 -03:00
|
|
|
The return value is a new reference to the imported module or top-level
|
2019-10-30 07:03:20 -03:00
|
|
|
package, or ``NULL`` with an exception set on failure. Like for
|
2008-05-12 15:05:20 -03:00
|
|
|
:func:`__import__`, the return value when a submodule of a package was
|
|
|
|
requested is normally the top-level package, unless a non-empty *fromlist*
|
|
|
|
was given.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Failing imports remove incomplete module objects, like with
|
2010-10-06 07:11:56 -03:00
|
|
|
:c:func:`PyImport_ImportModule`.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2011-03-14 16:54:52 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Import a module. This is best described by referring to the built-in Python
|
|
|
|
function :func:`__import__`, as the standard :func:`__import__` function calls
|
|
|
|
this function directly.
|
|
|
|
|
|
|
|
The return value is a new reference to the imported module or top-level package,
|
2019-10-30 07:03:20 -03:00
|
|
|
or ``NULL`` with an exception set on failure. Like for :func:`__import__`,
|
2008-01-20 05:30:57 -04:00
|
|
|
the return value when a submodule of a package was requested is normally the
|
|
|
|
top-level package, unless a non-empty *fromlist* was given.
|
|
|
|
|
2011-03-14 16:54:52 -03:00
|
|
|
.. versionadded:: 3.3
|
|
|
|
|
|
|
|
|
2015-06-21 11:11:21 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ImportModuleLevel(const char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
|
2011-03-14 16:54:52 -03:00
|
|
|
|
2016-04-14 23:14:19 -03:00
|
|
|
Similar to :c:func:`PyImport_ImportModuleLevelObject`, but the name is a
|
2011-03-14 16:54:52 -03:00
|
|
|
UTF-8 encoded string instead of a Unicode object.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2012-08-10 19:55:08 -03:00
|
|
|
.. versionchanged:: 3.3
|
2012-09-20 02:33:53 -03:00
|
|
|
Negative values for *level* are no longer accepted.
|
2012-08-10 19:55:08 -03:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PyImport_Import(PyObject *name)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
This is a higher-level interface that calls the current "import hook
|
|
|
|
function" (with an explicit *level* of 0, meaning absolute import). It
|
|
|
|
invokes the :func:`__import__` function from the ``__builtins__`` of the
|
|
|
|
current globals. This means that the import is done using whatever import
|
|
|
|
hooks are installed in the current environment.
|
|
|
|
|
Merged revisions 73930-73932,73937-73939,73945,73951,73954,73962-73963,73970 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r73930 | amaury.forgeotdarc | 2009-07-10 12:47:42 -0400 (Fri, 10 Jul 2009) | 2 lines
#6447: typo in subprocess docstring
........
r73931 | ezio.melotti | 2009-07-10 16:25:56 -0400 (Fri, 10 Jul 2009) | 1 line
more cleanups and if zlib -> skipUnless(zlib)
........
r73932 | kristjan.jonsson | 2009-07-11 04:44:43 -0400 (Sat, 11 Jul 2009) | 3 lines
http://bugs.python.org/issue6460
Need to be careful with thread switching when testing the xmlrpc server. The server thread may not have updated stats when the client thread tests them.
........
r73937 | georg.brandl | 2009-07-11 06:12:36 -0400 (Sat, 11 Jul 2009) | 1 line
Fix style.
........
r73938 | georg.brandl | 2009-07-11 06:14:54 -0400 (Sat, 11 Jul 2009) | 1 line
#6446: fix import_spam() function to use correct error and reference handling.
........
r73939 | georg.brandl | 2009-07-11 06:18:10 -0400 (Sat, 11 Jul 2009) | 1 line
#6448: clarify docs for find_module().
........
r73945 | georg.brandl | 2009-07-11 06:51:31 -0400 (Sat, 11 Jul 2009) | 1 line
#6456: clarify the meaning of constants used as arguments to nl_langinfo().
........
r73951 | georg.brandl | 2009-07-11 10:23:38 -0400 (Sat, 11 Jul 2009) | 2 lines
array.array is actually a class.
........
r73954 | tarek.ziade | 2009-07-11 13:21:00 -0400 (Sat, 11 Jul 2009) | 1 line
reverted changes for #6459 (doesn't apply on 2.x)
........
r73962 | benjamin.peterson | 2009-07-11 18:15:13 -0400 (Sat, 11 Jul 2009) | 1 line
put downloaded test support files in Lib/test/data instead of the cwd
........
r73963 | benjamin.peterson | 2009-07-11 18:25:24 -0400 (Sat, 11 Jul 2009) | 1 line
ignore things in Lib/test/data/
........
r73970 | hirokazu.yamamoto | 2009-07-11 22:04:47 -0400 (Sat, 11 Jul 2009) | 1 line
Fixed distutils test.
........
2009-07-17 07:42:05 -03:00
|
|
|
This function always uses absolute imports.
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ReloadModule(PyObject *m)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2019-10-30 07:03:20 -03:00
|
|
|
Reload a module. Return a new reference to the reloaded module, or ``NULL`` with
|
2008-01-20 05:30:57 -04:00
|
|
|
an exception set on failure (the module still exists in this case).
|
|
|
|
|
|
|
|
|
2023-06-20 03:48:14 -03:00
|
|
|
.. c:function:: PyObject* PyImport_AddModuleRef(const char *name)
|
|
|
|
|
|
|
|
Return the module object corresponding to a module name.
|
|
|
|
|
|
|
|
The *name* argument may be of the form ``package.module``. First check the
|
|
|
|
modules dictionary if there's one there, and if not, create a new one and
|
|
|
|
insert it in the modules dictionary.
|
|
|
|
|
|
|
|
Return a :term:`strong reference` to the module on success. Return ``NULL``
|
|
|
|
with an exception set on failure.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-06-20 03:48:14 -03:00
|
|
|
The module name *name* is decoded from UTF-8.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-06-20 03:48:14 -03:00
|
|
|
This function does not load or import the module; if the module wasn't
|
|
|
|
already loaded, you will get an empty module object. Use
|
|
|
|
:c:func:`PyImport_ImportModule` or one of its variants to import a module.
|
|
|
|
Package structures implied by a dotted name for *name* are not created if
|
|
|
|
not already present.
|
|
|
|
|
|
|
|
.. versionadded:: 3.13
|
|
|
|
|
|
|
|
|
|
|
|
.. c:function:: PyObject* PyImport_AddModuleObject(PyObject *name)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-06-20 03:48:14 -03:00
|
|
|
Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed
|
|
|
|
reference` and *name* is a Python :class:`str` object.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2011-03-04 08:57:09 -04:00
|
|
|
.. versionadded:: 3.3
|
|
|
|
|
|
|
|
|
|
|
|
.. c:function:: PyObject* PyImport_AddModule(const char *name)
|
|
|
|
|
2023-06-20 03:48:14 -03:00
|
|
|
Similar to :c:func:`PyImport_AddModuleRef`, but return a :term:`borrowed
|
|
|
|
reference`.
|
2011-03-04 08:57:09 -04:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2013-10-19 15:03:34 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ExecCodeModule(const char *name, PyObject *co)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-05-06 00:54:08 -03:00
|
|
|
.. index:: pair: built-in function; compile
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Given a module name (possibly of the form ``package.module``) and a code object
|
|
|
|
read from a Python bytecode file or obtained from the built-in function
|
|
|
|
:func:`compile`, load the module. Return a new reference to the module object,
|
2019-10-30 07:03:20 -03:00
|
|
|
or ``NULL`` with an exception set if an error occurred. *name*
|
2023-07-21 06:34:30 -03:00
|
|
|
is removed from :data:`sys.modules` in error cases, even if *name* was already
|
|
|
|
in :data:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`. Leaving
|
|
|
|
incompletely initialized modules in :data:`sys.modules` is dangerous, as imports of
|
2008-01-20 05:30:57 -04:00
|
|
|
such modules have no way to know that the module object is an unknown (and
|
|
|
|
probably damaged with respect to the module author's intents) state.
|
|
|
|
|
2024-10-09 07:53:57 -03:00
|
|
|
The module's :attr:`~module.__spec__` and :attr:`~module.__loader__` will be
|
|
|
|
set, if not set already, with the appropriate values. The spec's loader
|
|
|
|
will be set to the module's :attr:`!__loader__` (if set) and to an instance
|
|
|
|
of :class:`~importlib.machinery.SourceFileLoader` otherwise.
|
2014-05-12 20:54:55 -03:00
|
|
|
|
2024-10-09 07:53:57 -03:00
|
|
|
The module's :attr:`~module.__file__` attribute will be set to the code
|
|
|
|
object's :attr:`~codeobject.co_filename`. If applicable,
|
|
|
|
:attr:`~module.__cached__` will also be set.
|
Merged revisions 79307,79408,79430,79533,79542,79579-79580,79585-79587,79607-79608,79622,79717,79820,79822,79828,79862,79875,79923-79924,79941-79943,79945,79947,79951-79952 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79307 | florent.xicluna | 2010-03-22 17:45:50 -0500 (Mon, 22 Mar 2010) | 2 lines
#7667: Fix doctest failures with non-ASCII paths.
........
r79408 | victor.stinner | 2010-03-24 20:18:38 -0500 (Wed, 24 Mar 2010) | 2 lines
Fix a gcc warning introduced by r79397.
........
r79430 | brian.curtin | 2010-03-25 18:48:54 -0500 (Thu, 25 Mar 2010) | 2 lines
Fix #6538. Markup RegexObject and MatchObject as classes. Patch by Ryan Arana.
........
r79533 | barry.warsaw | 2010-03-31 16:07:16 -0500 (Wed, 31 Mar 2010) | 6 lines
- Issue #8233: When run as a script, py_compile.py optionally takes a single
argument `-` which tells it to read files to compile from stdin. Each line
is read on demand and the named file is compiled immediately. (Original
patch by Piotr O?\197?\188arowski).
........
r79542 | r.david.murray | 2010-03-31 20:28:39 -0500 (Wed, 31 Mar 2010) | 3 lines
A couple small grammar fixes in test.rst, and rewrite the
check_warnings docs to be clearer.
........
r79579 | georg.brandl | 2010-04-02 03:34:41 -0500 (Fri, 02 Apr 2010) | 1 line
Add 2.6.5.
........
r79580 | georg.brandl | 2010-04-02 03:39:09 -0500 (Fri, 02 Apr 2010) | 1 line
#2768: add a note on how to get a file descriptor.
........
r79585 | georg.brandl | 2010-04-02 04:03:18 -0500 (Fri, 02 Apr 2010) | 1 line
Remove col-spanning cells in logging docs.
........
r79586 | georg.brandl | 2010-04-02 04:07:42 -0500 (Fri, 02 Apr 2010) | 1 line
Document PyImport_ExecCodeModuleEx().
........
r79587 | georg.brandl | 2010-04-02 04:11:49 -0500 (Fri, 02 Apr 2010) | 1 line
#8012: clarification in generator glossary entry.
........
r79607 | andrew.kuchling | 2010-04-02 12:48:23 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: document that catch_warnings is not thread-safe
........
r79608 | andrew.kuchling | 2010-04-02 12:54:26 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: add note to two examples
........
r79622 | tarek.ziade | 2010-04-02 16:34:19 -0500 (Fri, 02 Apr 2010) | 1 line
removed documentation on code that was reverted and pushed into distutils2
........
r79717 | antoine.pitrou | 2010-04-03 16:22:38 -0500 (Sat, 03 Apr 2010) | 4 lines
Fix wording / typography, and a slightly misleading statement
(memoryviews don't support complex structures right now)
........
r79820 | benjamin.peterson | 2010-04-05 22:34:09 -0500 (Mon, 05 Apr 2010) | 1 line
ready _sre types
........
r79822 | georg.brandl | 2010-04-06 03:18:15 -0500 (Tue, 06 Apr 2010) | 1 line
#8320: document return value of recv_into().
........
r79828 | georg.brandl | 2010-04-06 09:33:44 -0500 (Tue, 06 Apr 2010) | 1 line
Add JP.
........
r79862 | georg.brandl | 2010-04-06 15:27:59 -0500 (Tue, 06 Apr 2010) | 1 line
Fix syntax.
........
r79875 | mark.dickinson | 2010-04-06 17:18:23 -0500 (Tue, 06 Apr 2010) | 1 line
More NaN consistency doc fixes.
........
r79923 | georg.brandl | 2010-04-10 06:15:24 -0500 (Sat, 10 Apr 2010) | 1 line
#8360: skipTest was added in 2.7.
........
r79924 | georg.brandl | 2010-04-10 06:16:59 -0500 (Sat, 10 Apr 2010) | 1 line
#8346: update version.
........
r79941 | andrew.kuchling | 2010-04-10 20:39:36 -0500 (Sat, 10 Apr 2010) | 1 line
Two grammar fixes
........
r79942 | andrew.kuchling | 2010-04-10 20:40:06 -0500 (Sat, 10 Apr 2010) | 1 line
Punctuation fix
........
r79943 | andrew.kuchling | 2010-04-10 20:40:30 -0500 (Sat, 10 Apr 2010) | 1 line
Add various items
........
r79945 | andrew.kuchling | 2010-04-10 20:40:49 -0500 (Sat, 10 Apr 2010) | 1 line
name correct
........
r79947 | andrew.kuchling | 2010-04-10 20:44:13 -0500 (Sat, 10 Apr 2010) | 1 line
Remove distutils section
........
r79951 | andrew.kuchling | 2010-04-11 07:48:08 -0500 (Sun, 11 Apr 2010) | 1 line
Two typo fixes
........
r79952 | andrew.kuchling | 2010-04-11 07:49:37 -0500 (Sun, 11 Apr 2010) | 1 line
Add two items
........
2010-04-11 13:12:57 -03:00
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
This function will reload the module if it was already imported. See
|
2010-10-06 07:11:56 -03:00
|
|
|
:c:func:`PyImport_ReloadModule` for the intended way to reload a module.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
If *name* points to a dotted name of the form ``package.module``, any package
|
|
|
|
structures not already created will still not be created.
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
See also :c:func:`PyImport_ExecCodeModuleEx` and
|
|
|
|
:c:func:`PyImport_ExecCodeModuleWithPathnames`.
|
2010-04-16 21:19:56 -03:00
|
|
|
|
2022-10-06 19:40:22 -03:00
|
|
|
.. versionchanged:: 3.12
|
2024-10-09 07:53:57 -03:00
|
|
|
The setting of :attr:`~module.__cached__` and :attr:`~module.__loader__`
|
|
|
|
is deprecated. See :class:`~importlib.machinery.ModuleSpec` for
|
2022-10-06 19:40:22 -03:00
|
|
|
alternatives.
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2013-10-19 15:03:34 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ExecCodeModuleEx(const char *name, PyObject *co, const char *pathname)
|
Merged revisions 79307,79408,79430,79533,79542,79579-79580,79585-79587,79607-79608,79622,79717,79820,79822,79828,79862,79875,79923-79924,79941-79943,79945,79947,79951-79952 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79307 | florent.xicluna | 2010-03-22 17:45:50 -0500 (Mon, 22 Mar 2010) | 2 lines
#7667: Fix doctest failures with non-ASCII paths.
........
r79408 | victor.stinner | 2010-03-24 20:18:38 -0500 (Wed, 24 Mar 2010) | 2 lines
Fix a gcc warning introduced by r79397.
........
r79430 | brian.curtin | 2010-03-25 18:48:54 -0500 (Thu, 25 Mar 2010) | 2 lines
Fix #6538. Markup RegexObject and MatchObject as classes. Patch by Ryan Arana.
........
r79533 | barry.warsaw | 2010-03-31 16:07:16 -0500 (Wed, 31 Mar 2010) | 6 lines
- Issue #8233: When run as a script, py_compile.py optionally takes a single
argument `-` which tells it to read files to compile from stdin. Each line
is read on demand and the named file is compiled immediately. (Original
patch by Piotr O?\197?\188arowski).
........
r79542 | r.david.murray | 2010-03-31 20:28:39 -0500 (Wed, 31 Mar 2010) | 3 lines
A couple small grammar fixes in test.rst, and rewrite the
check_warnings docs to be clearer.
........
r79579 | georg.brandl | 2010-04-02 03:34:41 -0500 (Fri, 02 Apr 2010) | 1 line
Add 2.6.5.
........
r79580 | georg.brandl | 2010-04-02 03:39:09 -0500 (Fri, 02 Apr 2010) | 1 line
#2768: add a note on how to get a file descriptor.
........
r79585 | georg.brandl | 2010-04-02 04:03:18 -0500 (Fri, 02 Apr 2010) | 1 line
Remove col-spanning cells in logging docs.
........
r79586 | georg.brandl | 2010-04-02 04:07:42 -0500 (Fri, 02 Apr 2010) | 1 line
Document PyImport_ExecCodeModuleEx().
........
r79587 | georg.brandl | 2010-04-02 04:11:49 -0500 (Fri, 02 Apr 2010) | 1 line
#8012: clarification in generator glossary entry.
........
r79607 | andrew.kuchling | 2010-04-02 12:48:23 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: document that catch_warnings is not thread-safe
........
r79608 | andrew.kuchling | 2010-04-02 12:54:26 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: add note to two examples
........
r79622 | tarek.ziade | 2010-04-02 16:34:19 -0500 (Fri, 02 Apr 2010) | 1 line
removed documentation on code that was reverted and pushed into distutils2
........
r79717 | antoine.pitrou | 2010-04-03 16:22:38 -0500 (Sat, 03 Apr 2010) | 4 lines
Fix wording / typography, and a slightly misleading statement
(memoryviews don't support complex structures right now)
........
r79820 | benjamin.peterson | 2010-04-05 22:34:09 -0500 (Mon, 05 Apr 2010) | 1 line
ready _sre types
........
r79822 | georg.brandl | 2010-04-06 03:18:15 -0500 (Tue, 06 Apr 2010) | 1 line
#8320: document return value of recv_into().
........
r79828 | georg.brandl | 2010-04-06 09:33:44 -0500 (Tue, 06 Apr 2010) | 1 line
Add JP.
........
r79862 | georg.brandl | 2010-04-06 15:27:59 -0500 (Tue, 06 Apr 2010) | 1 line
Fix syntax.
........
r79875 | mark.dickinson | 2010-04-06 17:18:23 -0500 (Tue, 06 Apr 2010) | 1 line
More NaN consistency doc fixes.
........
r79923 | georg.brandl | 2010-04-10 06:15:24 -0500 (Sat, 10 Apr 2010) | 1 line
#8360: skipTest was added in 2.7.
........
r79924 | georg.brandl | 2010-04-10 06:16:59 -0500 (Sat, 10 Apr 2010) | 1 line
#8346: update version.
........
r79941 | andrew.kuchling | 2010-04-10 20:39:36 -0500 (Sat, 10 Apr 2010) | 1 line
Two grammar fixes
........
r79942 | andrew.kuchling | 2010-04-10 20:40:06 -0500 (Sat, 10 Apr 2010) | 1 line
Punctuation fix
........
r79943 | andrew.kuchling | 2010-04-10 20:40:30 -0500 (Sat, 10 Apr 2010) | 1 line
Add various items
........
r79945 | andrew.kuchling | 2010-04-10 20:40:49 -0500 (Sat, 10 Apr 2010) | 1 line
name correct
........
r79947 | andrew.kuchling | 2010-04-10 20:44:13 -0500 (Sat, 10 Apr 2010) | 1 line
Remove distutils section
........
r79951 | andrew.kuchling | 2010-04-11 07:48:08 -0500 (Sun, 11 Apr 2010) | 1 line
Two typo fixes
........
r79952 | andrew.kuchling | 2010-04-11 07:49:37 -0500 (Sun, 11 Apr 2010) | 1 line
Add two items
........
2010-04-11 13:12:57 -03:00
|
|
|
|
2024-10-09 07:53:57 -03:00
|
|
|
Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`~module.__file__`
|
|
|
|
attribute of the module object is set to *pathname* if it is non-``NULL``.
|
Merged revisions 79307,79408,79430,79533,79542,79579-79580,79585-79587,79607-79608,79622,79717,79820,79822,79828,79862,79875,79923-79924,79941-79943,79945,79947,79951-79952 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79307 | florent.xicluna | 2010-03-22 17:45:50 -0500 (Mon, 22 Mar 2010) | 2 lines
#7667: Fix doctest failures with non-ASCII paths.
........
r79408 | victor.stinner | 2010-03-24 20:18:38 -0500 (Wed, 24 Mar 2010) | 2 lines
Fix a gcc warning introduced by r79397.
........
r79430 | brian.curtin | 2010-03-25 18:48:54 -0500 (Thu, 25 Mar 2010) | 2 lines
Fix #6538. Markup RegexObject and MatchObject as classes. Patch by Ryan Arana.
........
r79533 | barry.warsaw | 2010-03-31 16:07:16 -0500 (Wed, 31 Mar 2010) | 6 lines
- Issue #8233: When run as a script, py_compile.py optionally takes a single
argument `-` which tells it to read files to compile from stdin. Each line
is read on demand and the named file is compiled immediately. (Original
patch by Piotr O?\197?\188arowski).
........
r79542 | r.david.murray | 2010-03-31 20:28:39 -0500 (Wed, 31 Mar 2010) | 3 lines
A couple small grammar fixes in test.rst, and rewrite the
check_warnings docs to be clearer.
........
r79579 | georg.brandl | 2010-04-02 03:34:41 -0500 (Fri, 02 Apr 2010) | 1 line
Add 2.6.5.
........
r79580 | georg.brandl | 2010-04-02 03:39:09 -0500 (Fri, 02 Apr 2010) | 1 line
#2768: add a note on how to get a file descriptor.
........
r79585 | georg.brandl | 2010-04-02 04:03:18 -0500 (Fri, 02 Apr 2010) | 1 line
Remove col-spanning cells in logging docs.
........
r79586 | georg.brandl | 2010-04-02 04:07:42 -0500 (Fri, 02 Apr 2010) | 1 line
Document PyImport_ExecCodeModuleEx().
........
r79587 | georg.brandl | 2010-04-02 04:11:49 -0500 (Fri, 02 Apr 2010) | 1 line
#8012: clarification in generator glossary entry.
........
r79607 | andrew.kuchling | 2010-04-02 12:48:23 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: document that catch_warnings is not thread-safe
........
r79608 | andrew.kuchling | 2010-04-02 12:54:26 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: add note to two examples
........
r79622 | tarek.ziade | 2010-04-02 16:34:19 -0500 (Fri, 02 Apr 2010) | 1 line
removed documentation on code that was reverted and pushed into distutils2
........
r79717 | antoine.pitrou | 2010-04-03 16:22:38 -0500 (Sat, 03 Apr 2010) | 4 lines
Fix wording / typography, and a slightly misleading statement
(memoryviews don't support complex structures right now)
........
r79820 | benjamin.peterson | 2010-04-05 22:34:09 -0500 (Mon, 05 Apr 2010) | 1 line
ready _sre types
........
r79822 | georg.brandl | 2010-04-06 03:18:15 -0500 (Tue, 06 Apr 2010) | 1 line
#8320: document return value of recv_into().
........
r79828 | georg.brandl | 2010-04-06 09:33:44 -0500 (Tue, 06 Apr 2010) | 1 line
Add JP.
........
r79862 | georg.brandl | 2010-04-06 15:27:59 -0500 (Tue, 06 Apr 2010) | 1 line
Fix syntax.
........
r79875 | mark.dickinson | 2010-04-06 17:18:23 -0500 (Tue, 06 Apr 2010) | 1 line
More NaN consistency doc fixes.
........
r79923 | georg.brandl | 2010-04-10 06:15:24 -0500 (Sat, 10 Apr 2010) | 1 line
#8360: skipTest was added in 2.7.
........
r79924 | georg.brandl | 2010-04-10 06:16:59 -0500 (Sat, 10 Apr 2010) | 1 line
#8346: update version.
........
r79941 | andrew.kuchling | 2010-04-10 20:39:36 -0500 (Sat, 10 Apr 2010) | 1 line
Two grammar fixes
........
r79942 | andrew.kuchling | 2010-04-10 20:40:06 -0500 (Sat, 10 Apr 2010) | 1 line
Punctuation fix
........
r79943 | andrew.kuchling | 2010-04-10 20:40:30 -0500 (Sat, 10 Apr 2010) | 1 line
Add various items
........
r79945 | andrew.kuchling | 2010-04-10 20:40:49 -0500 (Sat, 10 Apr 2010) | 1 line
name correct
........
r79947 | andrew.kuchling | 2010-04-10 20:44:13 -0500 (Sat, 10 Apr 2010) | 1 line
Remove distutils section
........
r79951 | andrew.kuchling | 2010-04-11 07:48:08 -0500 (Sun, 11 Apr 2010) | 1 line
Two typo fixes
........
r79952 | andrew.kuchling | 2010-04-11 07:49:37 -0500 (Sun, 11 Apr 2010) | 1 line
Add two items
........
2010-04-11 13:12:57 -03:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
See also :c:func:`PyImport_ExecCodeModuleWithPathnames`.
|
2010-04-16 21:19:56 -03:00
|
|
|
|
|
|
|
|
2011-03-04 08:57:09 -04:00
|
|
|
.. c:function:: PyObject* PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname, PyObject *cpathname)
|
2010-04-16 21:19:56 -03:00
|
|
|
|
2024-10-09 07:53:57 -03:00
|
|
|
Like :c:func:`PyImport_ExecCodeModuleEx`, but the :attr:`~module.__cached__`
|
2010-04-16 21:19:56 -03:00
|
|
|
attribute of the module object is set to *cpathname* if it is
|
|
|
|
non-``NULL``. Of the three functions, this is the preferred one to use.
|
|
|
|
|
2011-03-04 08:57:09 -04:00
|
|
|
.. versionadded:: 3.3
|
|
|
|
|
2022-10-06 19:40:22 -03:00
|
|
|
.. versionchanged:: 3.12
|
2024-10-09 07:53:57 -03:00
|
|
|
Setting :attr:`~module.__cached__` is deprecated. See
|
2022-10-06 19:40:22 -03:00
|
|
|
:class:`~importlib.machinery.ModuleSpec` for alternatives.
|
|
|
|
|
2011-03-04 08:57:09 -04:00
|
|
|
|
2013-10-19 15:03:34 -03:00
|
|
|
.. c:function:: PyObject* PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co, const char *pathname, const char *cpathname)
|
2011-03-04 08:57:09 -04:00
|
|
|
|
|
|
|
Like :c:func:`PyImport_ExecCodeModuleObject`, but *name*, *pathname* and
|
2012-07-13 14:57:03 -03:00
|
|
|
*cpathname* are UTF-8 encoded strings. Attempts are also made to figure out
|
|
|
|
what the value for *pathname* should be from *cpathname* if the former is
|
|
|
|
set to ``NULL``.
|
2011-03-04 08:57:09 -04:00
|
|
|
|
2010-12-16 02:28:48 -04:00
|
|
|
.. versionadded:: 3.2
|
2012-07-13 14:57:03 -03:00
|
|
|
.. versionchanged:: 3.3
|
2024-08-30 08:34:09 -03:00
|
|
|
Uses :func:`!imp.source_from_cache` in calculating the source path if
|
2012-07-13 14:57:03 -03:00
|
|
|
only the bytecode path is provided.
|
2023-04-28 20:17:58 -03:00
|
|
|
.. versionchanged:: 3.12
|
2023-05-03 09:29:42 -03:00
|
|
|
No longer uses the removed :mod:`!imp` module.
|
Merged revisions 79307,79408,79430,79533,79542,79579-79580,79585-79587,79607-79608,79622,79717,79820,79822,79828,79862,79875,79923-79924,79941-79943,79945,79947,79951-79952 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79307 | florent.xicluna | 2010-03-22 17:45:50 -0500 (Mon, 22 Mar 2010) | 2 lines
#7667: Fix doctest failures with non-ASCII paths.
........
r79408 | victor.stinner | 2010-03-24 20:18:38 -0500 (Wed, 24 Mar 2010) | 2 lines
Fix a gcc warning introduced by r79397.
........
r79430 | brian.curtin | 2010-03-25 18:48:54 -0500 (Thu, 25 Mar 2010) | 2 lines
Fix #6538. Markup RegexObject and MatchObject as classes. Patch by Ryan Arana.
........
r79533 | barry.warsaw | 2010-03-31 16:07:16 -0500 (Wed, 31 Mar 2010) | 6 lines
- Issue #8233: When run as a script, py_compile.py optionally takes a single
argument `-` which tells it to read files to compile from stdin. Each line
is read on demand and the named file is compiled immediately. (Original
patch by Piotr O?\197?\188arowski).
........
r79542 | r.david.murray | 2010-03-31 20:28:39 -0500 (Wed, 31 Mar 2010) | 3 lines
A couple small grammar fixes in test.rst, and rewrite the
check_warnings docs to be clearer.
........
r79579 | georg.brandl | 2010-04-02 03:34:41 -0500 (Fri, 02 Apr 2010) | 1 line
Add 2.6.5.
........
r79580 | georg.brandl | 2010-04-02 03:39:09 -0500 (Fri, 02 Apr 2010) | 1 line
#2768: add a note on how to get a file descriptor.
........
r79585 | georg.brandl | 2010-04-02 04:03:18 -0500 (Fri, 02 Apr 2010) | 1 line
Remove col-spanning cells in logging docs.
........
r79586 | georg.brandl | 2010-04-02 04:07:42 -0500 (Fri, 02 Apr 2010) | 1 line
Document PyImport_ExecCodeModuleEx().
........
r79587 | georg.brandl | 2010-04-02 04:11:49 -0500 (Fri, 02 Apr 2010) | 1 line
#8012: clarification in generator glossary entry.
........
r79607 | andrew.kuchling | 2010-04-02 12:48:23 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: document that catch_warnings is not thread-safe
........
r79608 | andrew.kuchling | 2010-04-02 12:54:26 -0500 (Fri, 02 Apr 2010) | 1 line
#6647: add note to two examples
........
r79622 | tarek.ziade | 2010-04-02 16:34:19 -0500 (Fri, 02 Apr 2010) | 1 line
removed documentation on code that was reverted and pushed into distutils2
........
r79717 | antoine.pitrou | 2010-04-03 16:22:38 -0500 (Sat, 03 Apr 2010) | 4 lines
Fix wording / typography, and a slightly misleading statement
(memoryviews don't support complex structures right now)
........
r79820 | benjamin.peterson | 2010-04-05 22:34:09 -0500 (Mon, 05 Apr 2010) | 1 line
ready _sre types
........
r79822 | georg.brandl | 2010-04-06 03:18:15 -0500 (Tue, 06 Apr 2010) | 1 line
#8320: document return value of recv_into().
........
r79828 | georg.brandl | 2010-04-06 09:33:44 -0500 (Tue, 06 Apr 2010) | 1 line
Add JP.
........
r79862 | georg.brandl | 2010-04-06 15:27:59 -0500 (Tue, 06 Apr 2010) | 1 line
Fix syntax.
........
r79875 | mark.dickinson | 2010-04-06 17:18:23 -0500 (Tue, 06 Apr 2010) | 1 line
More NaN consistency doc fixes.
........
r79923 | georg.brandl | 2010-04-10 06:15:24 -0500 (Sat, 10 Apr 2010) | 1 line
#8360: skipTest was added in 2.7.
........
r79924 | georg.brandl | 2010-04-10 06:16:59 -0500 (Sat, 10 Apr 2010) | 1 line
#8346: update version.
........
r79941 | andrew.kuchling | 2010-04-10 20:39:36 -0500 (Sat, 10 Apr 2010) | 1 line
Two grammar fixes
........
r79942 | andrew.kuchling | 2010-04-10 20:40:06 -0500 (Sat, 10 Apr 2010) | 1 line
Punctuation fix
........
r79943 | andrew.kuchling | 2010-04-10 20:40:30 -0500 (Sat, 10 Apr 2010) | 1 line
Add various items
........
r79945 | andrew.kuchling | 2010-04-10 20:40:49 -0500 (Sat, 10 Apr 2010) | 1 line
name correct
........
r79947 | andrew.kuchling | 2010-04-10 20:44:13 -0500 (Sat, 10 Apr 2010) | 1 line
Remove distutils section
........
r79951 | andrew.kuchling | 2010-04-11 07:48:08 -0500 (Sun, 11 Apr 2010) | 1 line
Two typo fixes
........
r79952 | andrew.kuchling | 2010-04-11 07:49:37 -0500 (Sun, 11 Apr 2010) | 1 line
Add two items
........
2010-04-11 13:12:57 -03:00
|
|
|
|
2011-03-04 08:57:09 -04:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: long PyImport_GetMagicNumber()
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2015-04-13 15:21:02 -03:00
|
|
|
Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` file).
|
|
|
|
The magic number should be present in the first four bytes of the bytecode
|
2016-10-27 15:41:19 -03:00
|
|
|
file, in little-endian byte order. Returns ``-1`` on error.
|
2012-07-09 17:09:00 -03:00
|
|
|
|
|
|
|
.. versionchanged:: 3.3
|
2016-10-27 15:41:19 -03:00
|
|
|
Return value of ``-1`` upon failure.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: const char * PyImport_GetMagicTag()
|
2010-04-16 21:19:56 -03:00
|
|
|
|
|
|
|
Return the magic tag string for :pep:`3147` format Python bytecode file
|
2012-07-09 15:22:12 -03:00
|
|
|
names. Keep in mind that the value at ``sys.implementation.cache_tag`` is
|
|
|
|
authoritative and should be used instead of this function.
|
2010-04-16 21:19:56 -03:00
|
|
|
|
2010-12-16 02:28:48 -04:00
|
|
|
.. versionadded:: 3.2
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PyImport_GetModuleDict()
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Return the dictionary used for the module administration (a.k.a.
|
|
|
|
``sys.modules``). Note that this is a per-interpreter variable.
|
|
|
|
|
2017-09-15 19:35:20 -03:00
|
|
|
.. c:function:: PyObject* PyImport_GetModule(PyObject *name)
|
|
|
|
|
|
|
|
Return the already imported module with the given name. If the
|
2019-10-30 16:37:16 -03:00
|
|
|
module has not been imported yet then returns ``NULL`` but does not set
|
|
|
|
an error. Returns ``NULL`` and sets an error if the lookup failed.
|
2017-09-15 19:35:20 -03:00
|
|
|
|
|
|
|
.. versionadded:: 3.7
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: PyObject* PyImport_GetImporter(PyObject *path)
|
Merged revisions 61687-61688,61696,61700,61704-61705,61707-61709,61711-61712,61714-61716,61718-61722 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61687 | jeffrey.yasskin | 2008-03-21 06:02:44 +0100 (Fri, 21 Mar 2008) | 2 lines
Speed up test_signal from ~24s to 4s by avoiding nearly all of the sleep calls.
........
r61688 | jeffrey.yasskin | 2008-03-21 06:51:37 +0100 (Fri, 21 Mar 2008) | 5 lines
Try to fix test_signal breakages on Linux due to r61687. It appears that at
least two of the linux build bots aren't leaving zombie processes around for
os.waitpid to wait for, causing ECHILD errors. This would be a symptom of a bug
somewhere, but probably not in signal itself.
........
r61696 | georg.brandl | 2008-03-21 15:32:33 +0100 (Fri, 21 Mar 2008) | 2 lines
Mark the descitems in the tutorial as "noindex" so that :meth: cross-refs don't link to them.
........
r61700 | georg.brandl | 2008-03-21 18:19:29 +0100 (Fri, 21 Mar 2008) | 2 lines
Fix markup.
........
r61704 | jeffrey.yasskin | 2008-03-21 19:25:06 +0100 (Fri, 21 Mar 2008) | 3 lines
Try to fix test_signal on FreeBSD. I'm assuming that os.kill is failing to
raise a signal, but switching to subprocess makes the code cleaner anyway.
........
r61705 | jeffrey.yasskin | 2008-03-21 19:48:04 +0100 (Fri, 21 Mar 2008) | 7 lines
Speed test_threading up from 14s to .5s, and avoid a deadlock on certain
failures. The test for enumerate-after-join is now a little less rigorous, but
the bug it references says the error happened in the first couple iterations,
so 100 iterations should still be enough.
cProfile was useful for identifying the slow tests here.
........
r61707 | georg.brandl | 2008-03-21 20:14:38 +0100 (Fri, 21 Mar 2008) | 2 lines
Fix a code block in __future__ docs.
........
r61708 | georg.brandl | 2008-03-21 20:20:21 +0100 (Fri, 21 Mar 2008) | 2 lines
Add docs for __func__ and __self__ on methods.
........
r61709 | georg.brandl | 2008-03-21 20:37:57 +0100 (Fri, 21 Mar 2008) | 2 lines
Add docs for print_function and future_builtins. Fixes #2442.
........
r61711 | georg.brandl | 2008-03-21 20:54:00 +0100 (Fri, 21 Mar 2008) | 2 lines
#2136: allow single quotes in realm spec.
........
r61712 | georg.brandl | 2008-03-21 21:01:51 +0100 (Fri, 21 Mar 2008) | 3 lines
Issue #2432: give DictReader the dialect and line_num attributes
advertised in the docs.
........
r61714 | georg.brandl | 2008-03-21 21:11:46 +0100 (Fri, 21 Mar 2008) | 2 lines
#2358: add py3k warning to sys.exc_clear().
........
r61715 | georg.brandl | 2008-03-21 21:21:46 +0100 (Fri, 21 Mar 2008) | 2 lines
#2346/#2347: add py3k warning for __methods__ and __members__. Patch by Jack Diederich.
........
r61716 | georg.brandl | 2008-03-21 21:38:24 +0100 (Fri, 21 Mar 2008) | 2 lines
#2348: add py3k warning for file.softspace.
........
r61718 | georg.brandl | 2008-03-21 21:55:20 +0100 (Fri, 21 Mar 2008) | 2 lines
#2160: document PyImport_GetImporter.
........
r61719 | georg.brandl | 2008-03-21 21:55:51 +0100 (Fri, 21 Mar 2008) | 2 lines
Update doc ACKS.
........
r61720 | steven.bethard | 2008-03-21 22:01:18 +0100 (Fri, 21 Mar 2008) | 1 line
Replace hack in regrtest.py with use of sys.py3kwarning.
........
r61721 | georg.brandl | 2008-03-21 22:05:03 +0100 (Fri, 21 Mar 2008) | 2 lines
Add missing versionadded tag.
........
r61722 | christian.heimes | 2008-03-22 00:49:44 +0100 (Sat, 22 Mar 2008) | 3 lines
Applied patch #1657 epoll and kqueue wrappers for the select module
The patch adds wrappers for the Linux epoll syscalls and the BSD kqueue syscalls. Thanks to Thomas Herve and the Twisted people for their support and help.
TODO: Finish documentation documentation
........
2008-03-21 21:47:35 -03:00
|
|
|
|
2023-07-26 21:52:40 -03:00
|
|
|
Return a finder object for a :data:`sys.path`/:attr:`!pkg.__path__` item
|
Merged revisions 61687-61688,61696,61700,61704-61705,61707-61709,61711-61712,61714-61716,61718-61722 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61687 | jeffrey.yasskin | 2008-03-21 06:02:44 +0100 (Fri, 21 Mar 2008) | 2 lines
Speed up test_signal from ~24s to 4s by avoiding nearly all of the sleep calls.
........
r61688 | jeffrey.yasskin | 2008-03-21 06:51:37 +0100 (Fri, 21 Mar 2008) | 5 lines
Try to fix test_signal breakages on Linux due to r61687. It appears that at
least two of the linux build bots aren't leaving zombie processes around for
os.waitpid to wait for, causing ECHILD errors. This would be a symptom of a bug
somewhere, but probably not in signal itself.
........
r61696 | georg.brandl | 2008-03-21 15:32:33 +0100 (Fri, 21 Mar 2008) | 2 lines
Mark the descitems in the tutorial as "noindex" so that :meth: cross-refs don't link to them.
........
r61700 | georg.brandl | 2008-03-21 18:19:29 +0100 (Fri, 21 Mar 2008) | 2 lines
Fix markup.
........
r61704 | jeffrey.yasskin | 2008-03-21 19:25:06 +0100 (Fri, 21 Mar 2008) | 3 lines
Try to fix test_signal on FreeBSD. I'm assuming that os.kill is failing to
raise a signal, but switching to subprocess makes the code cleaner anyway.
........
r61705 | jeffrey.yasskin | 2008-03-21 19:48:04 +0100 (Fri, 21 Mar 2008) | 7 lines
Speed test_threading up from 14s to .5s, and avoid a deadlock on certain
failures. The test for enumerate-after-join is now a little less rigorous, but
the bug it references says the error happened in the first couple iterations,
so 100 iterations should still be enough.
cProfile was useful for identifying the slow tests here.
........
r61707 | georg.brandl | 2008-03-21 20:14:38 +0100 (Fri, 21 Mar 2008) | 2 lines
Fix a code block in __future__ docs.
........
r61708 | georg.brandl | 2008-03-21 20:20:21 +0100 (Fri, 21 Mar 2008) | 2 lines
Add docs for __func__ and __self__ on methods.
........
r61709 | georg.brandl | 2008-03-21 20:37:57 +0100 (Fri, 21 Mar 2008) | 2 lines
Add docs for print_function and future_builtins. Fixes #2442.
........
r61711 | georg.brandl | 2008-03-21 20:54:00 +0100 (Fri, 21 Mar 2008) | 2 lines
#2136: allow single quotes in realm spec.
........
r61712 | georg.brandl | 2008-03-21 21:01:51 +0100 (Fri, 21 Mar 2008) | 3 lines
Issue #2432: give DictReader the dialect and line_num attributes
advertised in the docs.
........
r61714 | georg.brandl | 2008-03-21 21:11:46 +0100 (Fri, 21 Mar 2008) | 2 lines
#2358: add py3k warning to sys.exc_clear().
........
r61715 | georg.brandl | 2008-03-21 21:21:46 +0100 (Fri, 21 Mar 2008) | 2 lines
#2346/#2347: add py3k warning for __methods__ and __members__. Patch by Jack Diederich.
........
r61716 | georg.brandl | 2008-03-21 21:38:24 +0100 (Fri, 21 Mar 2008) | 2 lines
#2348: add py3k warning for file.softspace.
........
r61718 | georg.brandl | 2008-03-21 21:55:20 +0100 (Fri, 21 Mar 2008) | 2 lines
#2160: document PyImport_GetImporter.
........
r61719 | georg.brandl | 2008-03-21 21:55:51 +0100 (Fri, 21 Mar 2008) | 2 lines
Update doc ACKS.
........
r61720 | steven.bethard | 2008-03-21 22:01:18 +0100 (Fri, 21 Mar 2008) | 1 line
Replace hack in regrtest.py with use of sys.py3kwarning.
........
r61721 | georg.brandl | 2008-03-21 22:05:03 +0100 (Fri, 21 Mar 2008) | 2 lines
Add missing versionadded tag.
........
r61722 | christian.heimes | 2008-03-22 00:49:44 +0100 (Sat, 22 Mar 2008) | 3 lines
Applied patch #1657 epoll and kqueue wrappers for the select module
The patch adds wrappers for the Linux epoll syscalls and the BSD kqueue syscalls. Thanks to Thomas Herve and the Twisted people for their support and help.
TODO: Finish documentation documentation
........
2008-03-21 21:47:35 -03:00
|
|
|
*path*, possibly by fetching it from the :data:`sys.path_importer_cache`
|
|
|
|
dict. If it wasn't yet cached, traverse :data:`sys.path_hooks` until a hook
|
|
|
|
is found that can handle the path item. Return ``None`` if no hook could;
|
2016-09-07 04:52:20 -03:00
|
|
|
this tells our caller that the :term:`path based finder` could not find a
|
|
|
|
finder for this path item. Cache the result in :data:`sys.path_importer_cache`.
|
|
|
|
Return a new reference to the finder object.
|
Merged revisions 61687-61688,61696,61700,61704-61705,61707-61709,61711-61712,61714-61716,61718-61722 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61687 | jeffrey.yasskin | 2008-03-21 06:02:44 +0100 (Fri, 21 Mar 2008) | 2 lines
Speed up test_signal from ~24s to 4s by avoiding nearly all of the sleep calls.
........
r61688 | jeffrey.yasskin | 2008-03-21 06:51:37 +0100 (Fri, 21 Mar 2008) | 5 lines
Try to fix test_signal breakages on Linux due to r61687. It appears that at
least two of the linux build bots aren't leaving zombie processes around for
os.waitpid to wait for, causing ECHILD errors. This would be a symptom of a bug
somewhere, but probably not in signal itself.
........
r61696 | georg.brandl | 2008-03-21 15:32:33 +0100 (Fri, 21 Mar 2008) | 2 lines
Mark the descitems in the tutorial as "noindex" so that :meth: cross-refs don't link to them.
........
r61700 | georg.brandl | 2008-03-21 18:19:29 +0100 (Fri, 21 Mar 2008) | 2 lines
Fix markup.
........
r61704 | jeffrey.yasskin | 2008-03-21 19:25:06 +0100 (Fri, 21 Mar 2008) | 3 lines
Try to fix test_signal on FreeBSD. I'm assuming that os.kill is failing to
raise a signal, but switching to subprocess makes the code cleaner anyway.
........
r61705 | jeffrey.yasskin | 2008-03-21 19:48:04 +0100 (Fri, 21 Mar 2008) | 7 lines
Speed test_threading up from 14s to .5s, and avoid a deadlock on certain
failures. The test for enumerate-after-join is now a little less rigorous, but
the bug it references says the error happened in the first couple iterations,
so 100 iterations should still be enough.
cProfile was useful for identifying the slow tests here.
........
r61707 | georg.brandl | 2008-03-21 20:14:38 +0100 (Fri, 21 Mar 2008) | 2 lines
Fix a code block in __future__ docs.
........
r61708 | georg.brandl | 2008-03-21 20:20:21 +0100 (Fri, 21 Mar 2008) | 2 lines
Add docs for __func__ and __self__ on methods.
........
r61709 | georg.brandl | 2008-03-21 20:37:57 +0100 (Fri, 21 Mar 2008) | 2 lines
Add docs for print_function and future_builtins. Fixes #2442.
........
r61711 | georg.brandl | 2008-03-21 20:54:00 +0100 (Fri, 21 Mar 2008) | 2 lines
#2136: allow single quotes in realm spec.
........
r61712 | georg.brandl | 2008-03-21 21:01:51 +0100 (Fri, 21 Mar 2008) | 3 lines
Issue #2432: give DictReader the dialect and line_num attributes
advertised in the docs.
........
r61714 | georg.brandl | 2008-03-21 21:11:46 +0100 (Fri, 21 Mar 2008) | 2 lines
#2358: add py3k warning to sys.exc_clear().
........
r61715 | georg.brandl | 2008-03-21 21:21:46 +0100 (Fri, 21 Mar 2008) | 2 lines
#2346/#2347: add py3k warning for __methods__ and __members__. Patch by Jack Diederich.
........
r61716 | georg.brandl | 2008-03-21 21:38:24 +0100 (Fri, 21 Mar 2008) | 2 lines
#2348: add py3k warning for file.softspace.
........
r61718 | georg.brandl | 2008-03-21 21:55:20 +0100 (Fri, 21 Mar 2008) | 2 lines
#2160: document PyImport_GetImporter.
........
r61719 | georg.brandl | 2008-03-21 21:55:51 +0100 (Fri, 21 Mar 2008) | 2 lines
Update doc ACKS.
........
r61720 | steven.bethard | 2008-03-21 22:01:18 +0100 (Fri, 21 Mar 2008) | 1 line
Replace hack in regrtest.py with use of sys.py3kwarning.
........
r61721 | georg.brandl | 2008-03-21 22:05:03 +0100 (Fri, 21 Mar 2008) | 2 lines
Add missing versionadded tag.
........
r61722 | christian.heimes | 2008-03-22 00:49:44 +0100 (Sat, 22 Mar 2008) | 3 lines
Applied patch #1657 epoll and kqueue wrappers for the select module
The patch adds wrappers for the Linux epoll syscalls and the BSD kqueue syscalls. Thanks to Thomas Herve and the Twisted people for their support and help.
TODO: Finish documentation documentation
........
2008-03-21 21:47:35 -03:00
|
|
|
|
|
|
|
|
2011-03-19 21:50:21 -03:00
|
|
|
.. c:function:: int PyImport_ImportFrozenModuleObject(PyObject *name)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Load a frozen module named *name*. Return ``1`` for success, ``0`` if the
|
|
|
|
module is not found, and ``-1`` with an exception set if the initialization
|
|
|
|
failed. To access the imported module on a successful load, use
|
2010-10-06 07:11:56 -03:00
|
|
|
:c:func:`PyImport_ImportModule`. (Note the misnomer --- this function would
|
2008-01-20 05:30:57 -04:00
|
|
|
reload the module if it was already imported.)
|
|
|
|
|
2011-03-19 21:50:21 -03:00
|
|
|
.. versionadded:: 3.3
|
|
|
|
|
2014-04-04 11:01:46 -03:00
|
|
|
.. versionchanged:: 3.4
|
|
|
|
The ``__file__`` attribute is no longer set on the module.
|
|
|
|
|
2011-03-19 21:50:21 -03:00
|
|
|
|
2013-10-19 15:03:34 -03:00
|
|
|
.. c:function:: int PyImport_ImportFrozenModule(const char *name)
|
2011-03-19 21:50:21 -03:00
|
|
|
|
2011-03-20 14:08:19 -03:00
|
|
|
Similar to :c:func:`PyImport_ImportFrozenModuleObject`, but the name is a
|
2011-03-19 21:50:21 -03:00
|
|
|
UTF-8 encoded string instead of a Unicode object.
|
|
|
|
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2022-10-04 20:26:14 -03:00
|
|
|
.. c:struct:: _frozen
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
.. index:: single: freeze utility
|
|
|
|
|
|
|
|
This is the structure type definition for frozen module descriptors, as
|
|
|
|
generated by the :program:`freeze` utility (see :file:`Tools/freeze/` in the
|
|
|
|
Python source distribution). Its definition, found in :file:`Include/import.h`,
|
|
|
|
is::
|
|
|
|
|
|
|
|
struct _frozen {
|
2017-03-30 04:01:03 -03:00
|
|
|
const char *name;
|
|
|
|
const unsigned char *code;
|
2008-01-20 05:30:57 -04:00
|
|
|
int size;
|
2022-02-04 13:57:03 -04:00
|
|
|
bool is_package;
|
2008-01-20 05:30:57 -04:00
|
|
|
};
|
|
|
|
|
2022-02-04 13:57:03 -04:00
|
|
|
.. versionchanged:: 3.11
|
|
|
|
The new ``is_package`` field indicates whether the module is a package or not.
|
|
|
|
This replaces setting the ``size`` field to a negative value.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2016-05-14 21:13:04 -03:00
|
|
|
.. c:var:: const struct _frozen* PyImport_FrozenModules
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2022-10-04 20:26:14 -03:00
|
|
|
This pointer is initialized to point to an array of :c:struct:`_frozen`
|
2019-10-30 07:03:20 -03:00
|
|
|
records, terminated by one whose members are all ``NULL`` or zero. When a frozen
|
2008-01-20 05:30:57 -04:00
|
|
|
module is imported, it is searched in this table. Third-party code could play
|
|
|
|
tricks with this to provide a dynamically created collection of frozen modules.
|
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PyImport_AppendInittab(const char *name, PyObject* (*initfunc)(void))
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Add a single module to the existing table of built-in modules. This is a
|
2010-10-06 07:11:56 -03:00
|
|
|
convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning ``-1`` if
|
2008-01-20 05:30:57 -04:00
|
|
|
the table could not be extended. The new module can be imported by the name
|
|
|
|
*name*, and uses the function *initfunc* as the initialization function called
|
|
|
|
on the first attempted import. This should be called before
|
2010-10-06 07:11:56 -03:00
|
|
|
:c:func:`Py_Initialize`.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2022-10-04 20:26:14 -03:00
|
|
|
.. c:struct:: _inittab
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-07-27 02:52:54 -03:00
|
|
|
Structure describing a single entry in the list of built-in modules.
|
|
|
|
Programs which
|
2011-03-07 13:34:59 -04:00
|
|
|
embed Python may use an array of these structures in conjunction with
|
|
|
|
:c:func:`PyImport_ExtendInittab` to provide additional built-in modules.
|
2023-07-27 02:52:54 -03:00
|
|
|
The structure consists of two members:
|
2008-01-20 05:30:57 -04:00
|
|
|
|
2023-07-27 02:52:54 -03:00
|
|
|
.. c:member:: const char *name
|
|
|
|
|
|
|
|
The module name, as an ASCII encoded string.
|
|
|
|
|
2024-03-07 04:05:03 -04:00
|
|
|
.. c:member:: PyObject* (*initfunc)(void)
|
2023-07-27 02:52:54 -03:00
|
|
|
|
|
|
|
Initialization function for a module built into the interpreter.
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
|
2010-10-06 07:11:56 -03:00
|
|
|
.. c:function:: int PyImport_ExtendInittab(struct _inittab *newtab)
|
2008-01-20 05:30:57 -04:00
|
|
|
|
|
|
|
Add a collection of modules to the table of built-in modules. The *newtab*
|
2023-07-27 02:52:54 -03:00
|
|
|
array must end with a sentinel entry which contains ``NULL`` for the :c:member:`~_inittab.name`
|
2008-01-20 05:30:57 -04:00
|
|
|
field; failure to provide the sentinel value can result in a memory fault.
|
|
|
|
Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to
|
|
|
|
extend the internal table. In the event of failure, no modules are added to the
|
2021-06-23 09:13:27 -03:00
|
|
|
internal table. This must be called before :c:func:`Py_Initialize`.
|
|
|
|
|
|
|
|
If Python is initialized multiple times, :c:func:`PyImport_AppendInittab` or
|
|
|
|
:c:func:`PyImport_ExtendInittab` must be called before each Python
|
|
|
|
initialization.
|