blob: bff2c57e067e53e586bf9d11d6e49f66c413783e [file] [log] [blame]
Guido van Rossumd27b4f21997-05-02 04:00:11 +00001#ifndef Py_PYTHON_H
2#define Py_PYTHON_H
Guido van Rossum174f95a1997-05-02 03:55:52 +00003/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
4
Guido van Rossum174f95a1997-05-02 03:55:52 +00005/* Include nearly all Python header files */
6
Guido van Rossumf1176c41999-01-03 12:40:24 +00007#include "patchlevel.h"
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +00008#include "pyconfig.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +00009
Tim Peters943382c2002-07-07 03:59:34 +000010/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
11 * old symbol for the benefit of extension modules written before then
12 * that may be conditionalizing on it. The core doesn't use it anymore.
13 */
14#ifndef WITH_CYCLE_GC
15#define WITH_CYCLE_GC 1
16#endif
17
Fred Draked5fadf72000-09-26 05:46:01 +000018#ifdef HAVE_LIMITS_H
19#include <limits.h>
Tim Peters60519e82002-07-12 05:01:20 +000020#else
21#error "limits.h is required by std C -- why isn't HAVE_LIMITS_H defined?"
Fred Draked5fadf72000-09-26 05:46:01 +000022#endif
23
Skip Montanaroac4ea132003-12-22 16:31:41 +000024#ifndef UCHAR_MAX
25#error "Something's broken. UCHAR_MAX should be defined in limits.h."
26#endif
27
28#if UCHAR_MAX != 255
Tim Peters0490fe92003-12-22 18:10:51 +000029#error "Python's source code assumes C's unsigned char is an 8-bit type."
Skip Montanaroac4ea132003-12-22 16:31:41 +000030#endif
31
Guido van Rossum90ce8481998-05-26 18:38:07 +000032#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
33#define _SGI_MP_SOURCE
34#endif
35
Guido van Rossum174f95a1997-05-02 03:55:52 +000036#include <stdio.h>
Tim Peters4826a892000-09-10 01:02:41 +000037#ifndef NULL
38# error "Python.h requires that stdio.h define NULL."
39#endif
40
Guido van Rossum174f95a1997-05-02 03:55:52 +000041#include <string.h>
42#include <errno.h>
43#ifdef HAVE_STDLIB_H
44#include <stdlib.h>
45#endif
Martin v. Löwiscdc44512002-01-12 11:05:12 +000046#ifdef HAVE_UNISTD_H
47#include <unistd.h>
48#endif
Guido van Rossumb2c075b2001-07-15 16:58:05 +000049
Tim Peters5defb172001-12-04 20:06:11 +000050/* CAUTION: Build setups should ensure that NDEBUG is defined on the
51 * compiler command line when building Python in release mode; else
52 * assert() calls won't be removed.
53 */
Tim Peters8315ea52000-07-23 19:28:35 +000054#include <assert.h>
55
Martin v. Löwis1e1fcef2002-05-15 18:24:06 +000056#include "pyport.h"
57
Jason Tishlerbc488262002-06-04 15:07:08 +000058/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
59#ifndef DL_IMPORT /* declarations for DLL import/export */
60#define DL_IMPORT(RTYPE) RTYPE
61#endif
62#ifndef DL_EXPORT /* declarations for DLL import/export */
63#define DL_EXPORT(RTYPE) RTYPE
64#endif
65
Tim Petersddea2082002-03-23 10:03:50 +000066/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
67 * PYMALLOC_DEBUG is in error if pymalloc is not in use.
68 */
69#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
70#define PYMALLOC_DEBUG
71#endif
72#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
73#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
74#endif
Peter Schneider-Kamp25f68942000-07-31 22:19:30 +000075#include "pymem.h"
76
Guido van Rossum174f95a1997-05-02 03:55:52 +000077#include "object.h"
78#include "objimpl.h"
79
80#include "pydebug.h"
81
Guido van Rossum9e896b32000-04-05 20:11:21 +000082#include "unicodeobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000083#include "intobject.h"
Guido van Rossum77f6a652002-04-03 22:41:51 +000084#include "boolobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000085#include "longobject.h"
86#include "floatobject.h"
87#ifndef WITHOUT_COMPLEX
88#include "complexobject.h"
89#endif
90#include "rangeobject.h"
91#include "stringobject.h"
Guido van Rossum2e19bd71998-10-07 14:36:10 +000092#include "bufferobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000093#include "tupleobject.h"
94#include "listobject.h"
Guido van Rossum2ec90311997-05-13 21:23:32 +000095#include "dictobject.h"
Guido van Rossum7dab2422002-04-26 19:40:56 +000096#include "enumobject.h"
Raymond Hettingera690a992003-11-16 16:17:49 +000097#include "setobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +000098#include "methodobject.h"
99#include "moduleobject.h"
100#include "funcobject.h"
101#include "classobject.h"
102#include "fileobject.h"
103#include "cobject.h"
104#include "traceback.h"
105#include "sliceobject.h"
Jeremy Hyltonfbd849f2001-01-25 20:04:14 +0000106#include "cellobject.h"
Guido van Rossum59d1d2b2001-04-20 19:13:02 +0000107#include "iterobject.h"
Tim Peters6d6c1a32001-08-02 04:15:00 +0000108#include "descrobject.h"
Fred Drake19bc5782001-10-05 21:55:19 +0000109#include "weakrefobject.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000110
Guido van Rossumbd7dfbc2000-03-10 22:34:00 +0000111#include "codecs.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000112#include "pyerrors.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000113
Guido van Rossum618af4b1997-07-18 23:59:26 +0000114#include "pystate.h"
115
Guido van Rossum174f95a1997-05-02 03:55:52 +0000116#include "modsupport.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000117#include "pythonrun.h"
Tim Peters5ba58662001-07-16 02:29:45 +0000118#include "ceval.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000119#include "sysmodule.h"
120#include "intrcheck.h"
121#include "import.h"
Guido van Rossum174f95a1997-05-02 03:55:52 +0000122
Guido van Rossum174f95a1997-05-02 03:55:52 +0000123#include "abstract.h"
124
Raymond Hettinger0ae0c072002-06-20 22:23:15 +0000125/* _Py_Mangle is defined in compile.c */
Mark Hammond91a681d2002-08-12 07:21:58 +0000126PyAPI_FUNC(int) _Py_Mangle(char *p, char *name, \
Raymond Hettinger0ae0c072002-06-20 22:23:15 +0000127 char *buffer, size_t maxlen);
128
Neal Norwitz1543c072002-03-25 22:21:58 +0000129/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
Guido van Rossum174f95a1997-05-02 03:55:52 +0000130#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
Neal Norwitz3a6f9782002-03-25 20:46:46 +0000131
132/* PyArg_NoArgs should not be necessary.
133 Set ml_flags in the PyMethodDef to METH_NOARGS. */
Guido van Rossum174f95a1997-05-02 03:55:52 +0000134#define PyArg_NoArgs(v) PyArg_Parse(v, "")
135
136/* Convert a possibly signed character to a nonnegative int */
137/* XXX This assumes characters are 8 bits wide */
138#ifdef __CHAR_UNSIGNED__
139#define Py_CHARMASK(c) (c)
140#else
141#define Py_CHARMASK(c) ((c) & 0xff)
142#endif
143
144#include "pyfpe.h"
145
Greg Ward95811442000-05-28 20:29:48 +0000146/* These definitions must match corresponding definitions in graminit.h.
Guido van Rossumb05a5c71997-05-07 17:46:13 +0000147 There's code in compile.c that checks that they are the same. */
148#define Py_single_input 256
149#define Py_file_input 257
150#define Py_eval_input 258
151
Guido van Rossum9e8181b2000-09-19 00:46:46 +0000152#ifdef HAVE_PTH
Guido van Rossum07bd90e2000-05-08 13:41:38 +0000153/* GNU pth user-space thread support */
154#include <pth.h>
155#endif
Martin v. Löwisa3fb4f72002-06-09 13:33:54 +0000156
157/* Define macros for inline documentation. */
158#define PyDoc_VAR(name) static char name[]
159#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
160#ifdef WITH_DOC_STRINGS
161#define PyDoc_STR(str) str
162#else
163#define PyDoc_STR(str) ""
164#endif
165
Guido van Rossumd27b4f21997-05-02 04:00:11 +0000166#endif /* !Py_PYTHON_H */