Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Doc/c-api/import.rst

    r2 r391  
    77
    88
    9 .. cfunction:: PyObject* PyImport_ImportModule(const char *name)
     9.. c:function:: PyObject* PyImport_ImportModule(const char *name)
    1010
    1111   .. index::
     
    1414      single: modules (in module sys)
    1515
    16    This is a simplified interface to :cfunc:`PyImport_ImportModuleEx` below,
     16   This is a simplified interface to :c:func:`PyImport_ImportModuleEx` below,
    1717   leaving the *globals* and *locals* arguments set to *NULL* and *level* set
    1818   to 0.  When the *name*
     
    3535
    3636
    37 .. cfunction:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
    38 
    39    This version of :cfunc:`PyImport_ImportModule` does not block. It's intended
     37.. c:function:: PyObject* PyImport_ImportModuleNoBlock(const char *name)
     38
     39   This version of :c:func:`PyImport_ImportModule` does not block. It's intended
    4040   to be used in C functions that import other modules to execute a function.
    4141   The import may block if another thread holds the import lock. The function
    42    :cfunc:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch
    43    the module from sys.modules and falls back to :cfunc:`PyImport_ImportModule`
     42   :c:func:`PyImport_ImportModuleNoBlock` never blocks. It first tries to fetch
     43   the module from sys.modules and falls back to :c:func:`PyImport_ImportModule`
    4444   unless the lock is held, in which case the function will raise an
    4545   :exc:`ImportError`.
     
    4848
    4949
    50 .. cfunction:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
     50.. c:function:: PyObject* PyImport_ImportModuleEx(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist)
    5151
    5252   .. index:: builtin: __import__
     
    6666
    6767   .. versionchanged:: 2.6
    68       The function is an alias for :cfunc:`PyImport_ImportModuleLevel` with
     68      The function is an alias for :c:func:`PyImport_ImportModuleLevel` with
    6969      -1 as level, meaning relative import.
    7070
    7171
    72 .. cfunction:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
     72.. c:function:: PyObject* PyImport_ImportModuleLevel(char *name, PyObject *globals, PyObject *locals, PyObject *fromlist, int level)
    7373
    7474   Import a module.  This is best described by referring to the built-in Python
     
    8484
    8585
    86 .. cfunction:: PyObject* PyImport_Import(PyObject *name)
     86.. c:function:: PyObject* PyImport_Import(PyObject *name)
    8787
    8888   .. index::
     
    9999
    100100
    101 .. cfunction:: PyObject* PyImport_ReloadModule(PyObject *m)
     101.. c:function:: PyObject* PyImport_ReloadModule(PyObject *m)
    102102
    103103   .. index:: builtin: reload
     
    109109
    110110
    111 .. cfunction:: PyObject* PyImport_AddModule(const char *name)
     111.. c:function:: PyObject* PyImport_AddModule(const char *name)
    112112
    113113   Return the module object corresponding to a module name.  The *name* argument
     
    119119
    120120      This function does not load or import the module; if the module wasn't already
    121       loaded, you will get an empty module object. Use :cfunc:`PyImport_ImportModule`
     121      loaded, you will get an empty module object. Use :c:func:`PyImport_ImportModule`
    122122      or one of its variants to import a module.  Package structures implied by a
    123123      dotted name for *name* are not created if not already present.
    124124
    125125
    126 .. cfunction:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
     126.. c:function:: PyObject* PyImport_ExecCodeModule(char *name, PyObject *co)
    127127
    128128   .. index:: builtin: compile
     
    134134   module could still be created in error cases.  Starting with Python 2.4, *name*
    135135   is removed from :attr:`sys.modules` in error cases, and even if *name* was already
    136    in :attr:`sys.modules` on entry to :cfunc:`PyImport_ExecCodeModule`.  Leaving
     136   in :attr:`sys.modules` on entry to :c:func:`PyImport_ExecCodeModule`.  Leaving
    137137   incompletely initialized modules in :attr:`sys.modules` is dangerous, as imports of
    138138   such modules have no way to know that the module object is an unknown (and
    139139   probably damaged with respect to the module author's intents) state.
    140140
     141   The module's :attr:`__file__` attribute will be set to the code object's
     142   :c:member:`co_filename`.
     143
    141144   This function will reload the module if it was already imported.  See
    142    :cfunc:`PyImport_ReloadModule` for the intended way to reload a module.
     145   :c:func:`PyImport_ReloadModule` for the intended way to reload a module.
    143146
    144147   If *name* points to a dotted name of the form ``package.module``, any package
     
    149152
    150153
    151 .. cfunction:: long PyImport_GetMagicNumber()
     154.. c:function:: PyObject* PyImport_ExecCodeModuleEx(char *name, PyObject *co, char *pathname)
     155
     156   Like :c:func:`PyImport_ExecCodeModule`, but the :attr:`__file__` attribute of
     157   the module object is set to *pathname* if it is non-``NULL``.
     158
     159
     160.. c:function:: long PyImport_GetMagicNumber()
    152161
    153162   Return the magic number for Python bytecode files (a.k.a. :file:`.pyc` and
     
    156165
    157166
    158 .. cfunction:: PyObject* PyImport_GetModuleDict()
     167.. c:function:: PyObject* PyImport_GetModuleDict()
    159168
    160169   Return the dictionary used for the module administration (a.k.a.
     
    162171
    163172
    164 .. cfunction:: PyObject* PyImport_GetImporter(PyObject *path)
     173.. c:function:: PyObject* PyImport_GetImporter(PyObject *path)
    165174
    166175   Return an importer object for a :data:`sys.path`/:attr:`pkg.__path__` item
     
    175184
    176185
    177 .. cfunction:: void _PyImport_Init()
     186.. c:function:: void _PyImport_Init()
    178187
    179188   Initialize the import mechanism.  For internal use only.
    180189
    181190
    182 .. cfunction:: void PyImport_Cleanup()
     191.. c:function:: void PyImport_Cleanup()
    183192
    184193   Empty the module table.  For internal use only.
    185194
    186195
    187 .. cfunction:: void _PyImport_Fini()
     196.. c:function:: void _PyImport_Fini()
    188197
    189198   Finalize the import mechanism.  For internal use only.
    190199
    191200
    192 .. cfunction:: PyObject* _PyImport_FindExtension(char *, char *)
     201.. c:function:: PyObject* _PyImport_FindExtension(char *, char *)
    193202
    194203   For internal use only.
    195204
    196205
    197 .. cfunction:: PyObject* _PyImport_FixupExtension(char *, char *)
     206.. c:function:: PyObject* _PyImport_FixupExtension(char *, char *)
    198207
    199208   For internal use only.
    200209
    201210
    202 .. cfunction:: int PyImport_ImportFrozenModule(char *name)
     211.. c:function:: int PyImport_ImportFrozenModule(char *name)
    203212
    204213   Load a frozen module named *name*.  Return ``1`` for success, ``0`` if the
    205214   module is not found, and ``-1`` with an exception set if the initialization
    206215   failed.  To access the imported module on a successful load, use
    207    :cfunc:`PyImport_ImportModule`.  (Note the misnomer --- this function would
     216   :c:func:`PyImport_ImportModule`.  (Note the misnomer --- this function would
    208217   reload the module if it was already imported.)
    209218
    210219
    211 .. ctype:: struct _frozen
     220.. c:type:: struct _frozen
    212221
    213222   .. index:: single: freeze utility
     
    225234
    226235
    227 .. cvar:: struct _frozen* PyImport_FrozenModules
    228 
    229    This pointer is initialized to point to an array of :ctype:`struct _frozen`
     236.. c:var:: struct _frozen* PyImport_FrozenModules
     237
     238   This pointer is initialized to point to an array of :c:type:`struct _frozen`
    230239   records, terminated by one whose members are all *NULL* or zero.  When a frozen
    231240   module is imported, it is searched in this table.  Third-party code could play
     
    233242
    234243
    235 .. cfunction:: int PyImport_AppendInittab(char *name, void (*initfunc)(void))
     244.. c:function:: int PyImport_AppendInittab(const char *name, void (*initfunc)(void))
    236245
    237246   Add a single module to the existing table of built-in modules.  This is a
    238    convenience wrapper around :cfunc:`PyImport_ExtendInittab`, returning ``-1`` if
     247   convenience wrapper around :c:func:`PyImport_ExtendInittab`, returning ``-1`` if
    239248   the table could not be extended.  The new module can be imported by the name
    240249   *name*, and uses the function *initfunc* as the initialization function called
    241250   on the first attempted import.  This should be called before
    242    :cfunc:`Py_Initialize`.
    243 
    244 
    245 .. ctype:: struct _inittab
     251   :c:func:`Py_Initialize`.
     252
     253
     254.. c:type:: struct _inittab
    246255
    247256   Structure describing a single entry in the list of built-in modules.  Each of
    248257   these structures gives the name and initialization function for a module built
    249258   into the interpreter.  Programs which embed Python may use an array of these
    250    structures in conjunction with :cfunc:`PyImport_ExtendInittab` to provide
     259   structures in conjunction with :c:func:`PyImport_ExtendInittab` to provide
    251260   additional built-in modules.  The structure is defined in
    252261   :file:`Include/import.h` as::
     
    258267
    259268
    260 .. cfunction:: int PyImport_ExtendInittab(struct _inittab *newtab)
     269.. c:function:: int PyImport_ExtendInittab(struct _inittab *newtab)
    261270
    262271   Add a collection of modules to the table of built-in modules.  The *newtab*
     
    265274   Returns ``0`` on success or ``-1`` if insufficient memory could be allocated to
    266275   extend the internal table.  In the event of failure, no modules are added to the
    267    internal table.  This should be called before :cfunc:`Py_Initialize`.
     276   internal table.  This should be called before :c:func:`Py_Initialize`.
Note: See TracChangeset for help on using the changeset viewer.