annotate Include/Python.h @ 5919:5da18e002b1a legacy-trunk

Mass checkin (more to follow for other directories). Introduce truly separate (sub)interpreter objects. For now, these must be used by separate threads, created from C. See Demo/pysvr for an example of how to use this. This also rationalizes Python's initialization and finalization behavior: Py_Initialize() -- initialize the whole interpreter Py_Finalize() -- finalize the whole interpreter tstate = Py_NewInterpreter() -- create a new (sub)interpreter Py_EndInterpreter(tstate) -- delete a new (sub)interpreter There are also new interfaces relating to threads and the interpreter lock, which can be used to create new threads, and sometimes have to be used to manipulate the interpreter lock when creating or deleting sub-interpreters. These are only defined when WITH_THREAD is defined: PyEval_AcquireLock() -- acquire the interpreter lock PyEval_ReleaseLock() -- release the interpreter lock PyEval_AcquireThread(tstate) -- acquire the lock and make the thread current PyEval_ReleaseThread(tstate) -- release the lock and make NULL current Other administrative changes: - The header file bltinmodule.h is deleted. - The init functions for Import, Sys and Builtin are now internal and declared in pythonrun.h. - Py_Setup() and Py_Cleanup() are no longer declared. - The interpreter state and thread state structures are now linked together in a chain (the chain of interpreters is a static variable in pythonrun.c). - Some members of the interpreter and thread structures have new, shorter, more consistent, names. - Added declarations for _PyImport_{Find,Fixup}Extension() to import.h.
author Guido van Rossum <guido@python.org>
date Sat, 02 Aug 1997 02:56:48 +0000
parents f64a5f750696
children f7c58ed2981d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5398
72b231edfb25 Several oopsies -- Py_ALLOBJECTS_H -> Py_PYTHON_H, temporarily removed
Guido van Rossum <guido@python.org>
parents: 5397
diff changeset
1 #ifndef Py_PYTHON_H
72b231edfb25 Several oopsies -- Py_ALLOBJECTS_H -> Py_PYTHON_H, temporarily removed
Guido van Rossum <guido@python.org>
parents: 5397
diff changeset
2 #define Py_PYTHON_H
5397
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
3 /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
4
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
5 /***********************************************************
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
6 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
7 The Netherlands.
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
8
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
9 All Rights Reserved
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
10
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
11 Permission to use, copy, modify, and distribute this software and its
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
12 documentation for any purpose and without fee is hereby granted,
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
13 provided that the above copyright notice appear in all copies and that
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
14 both that copyright notice and this permission notice appear in
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
15 supporting documentation, and that the names of Stichting Mathematisch
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
16 Centrum or CWI or Corporation for National Research Initiatives or
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
17 CNRI not be used in advertising or publicity pertaining to
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
18 distribution of the software without specific, written prior
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
19 permission.
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
20
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
21 While CWI is the initial source for this software, a modified version
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
22 is made available by the Corporation for National Research Initiatives
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
23 (CNRI) at the Internet address ftp://ftp.python.org.
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
24
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
25 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
26 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
27 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
28 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
29 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
30 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
31 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
32 PERFORMANCE OF THIS SOFTWARE.
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
33
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
34 ******************************************************************/
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
35
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
36 /* Include nearly all Python header files */
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
37
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
38 #include "config.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
39
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
40 /* config.h may or may not define DL_IMPORT */
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
41 #ifndef DL_IMPORT /* declarations for DLL import/export */
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
42 #define DL_IMPORT(RTYPE) RTYPE
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
43 #endif
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
44
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
45 #ifdef SYMANTEC__CFM68K__
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
46 #define UsingSharedLibs
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
47 #endif
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
48
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
49 #include <stdio.h>
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
50 #include <string.h>
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
51 #include <errno.h>
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
52 #ifdef HAVE_STDLIB_H
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
53 #include <stdlib.h>
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
54 #endif
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
55
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
56 #include "myproto.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
57
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
58 #ifdef SYMANTEC__CFM68K__
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
59 #pragma lib_export on
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
60 #endif
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
61
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
62 #include "object.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
63 #include "objimpl.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
64
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
65 #include "pydebug.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
66
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
67 #include "intobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
68 #include "longobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
69 #include "floatobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
70 #ifndef WITHOUT_COMPLEX
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
71 #include "complexobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
72 #endif
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
73 #include "rangeobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
74 #include "stringobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
75 #include "tupleobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
76 #include "listobject.h"
5508
3643f19d5ca1 Subsumed mappingobject.h in dictobject.h.
Guido van Rossum <guido@python.org>
parents: 5438
diff changeset
77 #include "dictobject.h"
5397
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
78 #include "methodobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
79 #include "moduleobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
80 #include "funcobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
81 #include "classobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
82 #include "fileobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
83 #include "cobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
84 #include "traceback.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
85 #include "sliceobject.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
86
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
87 #include "pyerrors.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
88 #include "mymalloc.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
89
5848
f64a5f750696 Include pystate.h earlier so it can be referenced by ceval.h.
Guido van Rossum <guido@python.org>
parents: 5508
diff changeset
90 #include "pystate.h"
f64a5f750696 Include pystate.h earlier so it can be referenced by ceval.h.
Guido van Rossum <guido@python.org>
parents: 5508
diff changeset
91
5397
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
92 #include "modsupport.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
93 #include "ceval.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
94 #include "pythonrun.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
95 #include "sysmodule.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
96 #include "intrcheck.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
97 #include "import.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
98
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
99 #include "abstract.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
100
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
101 #define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
102 #define PyArg_NoArgs(v) PyArg_Parse(v, "")
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
103
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
104 /* Convert a possibly signed character to a nonnegative int */
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
105 /* XXX This assumes characters are 8 bits wide */
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
106 #ifdef __CHAR_UNSIGNED__
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
107 #define Py_CHARMASK(c) (c)
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
108 #else
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
109 #define Py_CHARMASK(c) ((c) & 0xff)
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
110 #endif
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
111
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
112 #include "pyfpe.h"
fd7eb058ce5d Moved allobjects.h to Python.h (without rename2.h).
Guido van Rossum <guido@python.org>
parents: 2129
diff changeset
113
5438
e926c331ebbf Instead of importing graminit.h whenever one of the three grammar 'root'
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
114 /* These definitions much match corresponding definitions in graminit.h.
e926c331ebbf Instead of importing graminit.h whenever one of the three grammar 'root'
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
115 There's code in compile.c that checks that they are the same. */
e926c331ebbf Instead of importing graminit.h whenever one of the three grammar 'root'
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
116 #define Py_single_input 256
e926c331ebbf Instead of importing graminit.h whenever one of the three grammar 'root'
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
117 #define Py_file_input 257
e926c331ebbf Instead of importing graminit.h whenever one of the three grammar 'root'
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
118 #define Py_eval_input 258
e926c331ebbf Instead of importing graminit.h whenever one of the three grammar 'root'
Guido van Rossum <guido@python.org>
parents: 5405
diff changeset
119
5398
72b231edfb25 Several oopsies -- Py_ALLOBJECTS_H -> Py_PYTHON_H, temporarily removed
Guido van Rossum <guido@python.org>
parents: 5397
diff changeset
120 #endif /* !Py_PYTHON_H */