Python.h revision fdfe62d887d5b695a82dae68006ac3b12c02eb57
1d27b4f2a3f6a90dfcc5eb6fb30c1a895ed60142dGuido van Rossum#ifndef Py_PYTHON_H
2d27b4f2a3f6a90dfcc5eb6fb30c1a895ed60142dGuido van Rossum#define Py_PYTHON_H
3174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
4174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
5174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum/* Include nearly all Python header files */
6174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
7f1176c4815cd628ae443b5c4b0e1841588369776Guido van Rossum#include "patchlevel.h"
84f1cd8bdcbd20bb0acdbe9e240f28c09dd38370fMartin v. Löwis#include "pyconfig.h"
9174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
10d5fadf75e4d18df61db41205ace0cda28d98eeaaFred Drake#include <limits.h>
11d5fadf75e4d18df61db41205ace0cda28d98eeaaFred Drake
12ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#ifndef UCHAR_MAX
13ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#error "Something's broken.  UCHAR_MAX should be defined in limits.h."
14ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#endif
15ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro
16ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#if UCHAR_MAX != 255
170490fe96d882072aca640ef5c6f42ed80a789f0dTim Peters#error "Python's source code assumes C's unsigned char is an 8-bit type."
18ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#endif
19ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro
2090ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
2190ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum#define _SGI_MP_SOURCE
2290ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum#endif
2390ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum
24174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <stdio.h>
254826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters#ifndef NULL
264826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters#   error "Python.h requires that stdio.h define NULL."
274826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters#endif
284826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters
29174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <string.h>
300e3f591aeeef9ed715f8770320f4c4c7332a8794Thomas Wouters#ifdef HAVE_ERRNO_H
31174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <errno.h>
32477c8d5e70240744d24631b18341ad892c8a8e1cThomas Wouters#endif
33174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <stdlib.h>
34cdc445122208cb90a59a468a7396b227e223c43aMartin v. Löwis#ifdef HAVE_UNISTD_H
35cdc445122208cb90a59a468a7396b227e223c43aMartin v. Löwis#include <unistd.h>
36cdc445122208cb90a59a468a7396b227e223c43aMartin v. Löwis#endif
37b2c075bec452f66155d447ed9a1ae1a6479502a8Guido van Rossum
38fdfe62d887d5b695a82dae68006ac3b12c02eb57Amaury Forgeot d'Arc/* For size_t? */
39fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis#ifdef HAVE_STDDEF_H
40fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis#include <stddef.h>
41fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis#endif
42fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis
435defb1736d36ea44bbb8f613cd0031d68816819bTim Peters/* CAUTION:  Build setups should ensure that NDEBUG is defined on the
445defb1736d36ea44bbb8f613cd0031d68816819bTim Peters * compiler command line when building Python in release mode; else
455defb1736d36ea44bbb8f613cd0031d68816819bTim Peters * assert() calls won't be removed.
465defb1736d36ea44bbb8f613cd0031d68816819bTim Peters */
478315ea579046727bb234dc4692ca28c8514eacbeTim Peters#include <assert.h>
488315ea579046727bb234dc4692ca28c8514eacbeTim Peters
491e1fcef756dbec60c9062462b46777ffc2a0594eMartin v. Löwis#include "pyport.h"
501e1fcef756dbec60c9062462b46777ffc2a0594eMartin v. Löwis
51ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
52ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters *  PYMALLOC_DEBUG is in error if pymalloc is not in use.
53ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters */
54ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
55ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#define PYMALLOC_DEBUG
56ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#endif
57ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
58ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
59ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#endif
6053876d9cd8a67d9e67772e082deab92a598f74b3Christian Heimes#include "pymath.h"
6125f68944c20a3a37da6776277057c2d19a80211fPeter Schneider-Kamp#include "pymem.h"
6225f68944c20a3a37da6776277057c2d19a80211fPeter Schneider-Kamp
63174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "object.h"
64174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "objimpl.h"
65174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
66174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pydebug.h"
67174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
682c9c7a5f33d502fa468e38537d57834c7e33aa4dChristian Heimes#include "bytearrayobject.h"
694dfe8a1131b551687659b9339eaee163a24f82f1Guido van Rossum#include "bytesobject.h"
709e896b37c7a554250d7d832566cc4fe7d30d034cGuido van Rossum#include "unicodeobject.h"
71174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "longobject.h"
729f2e346911988cda95fec7c901e8d10d34fa9563Martin v. Löwis#include "longintrepr.h"
739f2e346911988cda95fec7c901e8d10d34fa9563Martin v. Löwis#include "boolobject.h"
74174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "floatobject.h"
75174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#ifndef WITHOUT_COMPLEX
76174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "complexobject.h"
77174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#endif
78174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "rangeobject.h"
79b99f762f10edb2646a634c2290ecb064bd52e5c7Travis E. Oliphant#include "memoryobject.h"
80174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "tupleobject.h"
81174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "listobject.h"
822ec9031b5589db81026f5fc3a11070002ec4d0d7Guido van Rossum#include "dictobject.h"
837dab2426ca0bae36fde565407ddb4b2d2cbf2575Guido van Rossum#include "enumobject.h"
84a690a9967e715663b7a421c9ebdad91381cdf1e4Raymond Hettinger#include "setobject.h"
85174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "methodobject.h"
86174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "moduleobject.h"
87174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "funcobject.h"
88174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "classobject.h"
89174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "fileobject.h"
90174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "cobject.h"
91174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "traceback.h"
92174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "sliceobject.h"
93fbd849f201a4a8c17745a72eb9f0ee3bae34d330Jeremy Hylton#include "cellobject.h"
9459d1d2b434e8cf79e8b1321f148254c68f56c1f7Guido van Rossum#include "iterobject.h"
958d97e33bb76c322cdb08dbf97c26d787cd3488a7Martin v. Löwis#include "genobject.h"
966d6c1a35e08b95a83dbe47dbd9e6474daff00354Tim Peters#include "descrobject.h"
9733fe8093df5c13e41d7dba764279c71c142a4a7dChristian Heimes#include "warnings.h"
9819bc578a0907844cb94fe6f727fa5158736086faFred Drake#include "weakrefobject.h"
99174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
100bd7dfbc146deb31c520d886415ffd2d00f6970b0Guido van Rossum#include "codecs.h"
101174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pyerrors.h"
102174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
103618af4b3ef08d5eee9c36fafd4cd57c54573f95eGuido van Rossum#include "pystate.h"
104618af4b3ef08d5eee9c36fafd4cd57c54573f95eGuido van Rossum
105adb69fcdffdc50ee3e1d33b00cd874020197b445Neal Norwitz#include "pyarena.h"
106174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "modsupport.h"
107174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pythonrun.h"
1085ba58662817b708a453020f0425fe4747ea6d5cbTim Peters#include "ceval.h"
109174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "sysmodule.h"
110174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "intrcheck.h"
111174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "import.h"
112174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
113174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "abstract.h"
114174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
1156e098a15a3493d9c136e18b9e51b67bd48545651Skip Montanaro#include "compile.h"
1166e098a15a3493d9c136e18b9e51b67bd48545651Skip Montanaro#include "eval.h"
1176e098a15a3493d9c136e18b9e51b67bd48545651Skip Montanaro
118737ea82a5abd448b3e214b44d7d3c579b77e8155Martin v. Löwis#include "pystrtod.h"
11999170a5dbf4cfee78b578672b6821e855f92594bChristian Heimes#include "pystrcmp.h"
120737ea82a5abd448b3e214b44d7d3c579b77e8155Martin v. Löwis
1210ae0c076615934ed237b412464b49b58c60c0644Raymond Hettinger/* _Py_Mangle is defined in compile.c */
1223e0055f8c65c407e74ce476b8e2b1fb889723514Jeremy HyltonPyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
1230ae0c076615934ed237b412464b49b58c60c0644Raymond Hettinger
124174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum/* Convert a possibly signed character to a nonnegative int */
125174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum/* XXX This assumes characters are 8 bits wide */
126174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#ifdef __CHAR_UNSIGNED__
127174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#define Py_CHARMASK(c)		(c)
128174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#else
129bbe741dd1b15e9b496028732afb5f99a2a960695Christian Heimes#define Py_CHARMASK(c)		((unsigned char)((c) & 0xff))
130174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#endif
131174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
132174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pyfpe.h"
133174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum
1349581144329e39787b1f584dc575b78f099710595Greg Ward/* These definitions must match corresponding definitions in graminit.h.
135b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum   There's code in compile.c that checks that they are the same. */
136b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum#define Py_single_input 256
137b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum#define Py_file_input 257
138b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum#define Py_eval_input 258
139b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum
1409e8181b809c0dc40f86d66ce7e51db83aaeccd20Guido van Rossum#ifdef HAVE_PTH
14107bd90e92d9cb8982ad541dda59bc0f8867e9414Guido van Rossum/* GNU pth user-space thread support */
14207bd90e92d9cb8982ad541dda59bc0f8867e9414Guido van Rossum#include <pth.h>
14307bd90e92d9cb8982ad541dda59bc0f8867e9414Guido van Rossum#endif
144a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis
145a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis/* Define macros for inline documentation. */
146a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_VAR(name) static char name[]
147a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
148a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#ifdef WITH_DOC_STRINGS
149a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_STR(str) str
150a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#else
151a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_STR(str) ""
152a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#endif
153a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis
154d27b4f2a3f6a90dfcc5eb6fb30c1a895ed60142dGuido van Rossum#endif /* !Py_PYTHON_H */
155