Python.h revision 4d0d471a8031de90a2b1ce99c4ac4780e60b3bc9
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" 9fcaf910a1fe9739afcf3be41ac2db31e8286c40fGeorg Brandl#include "pymacconfig.h" 10174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 11d5fadf75e4d18df61db41205ace0cda28d98eeaaFred Drake#include <limits.h> 12d5fadf75e4d18df61db41205ace0cda28d98eeaaFred Drake 13ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#ifndef UCHAR_MAX 14ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#error "Something's broken. UCHAR_MAX should be defined in limits.h." 15ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#endif 16ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro 17ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#if UCHAR_MAX != 255 180490fe96d882072aca640ef5c6f42ed80a789f0dTim Peters#error "Python's source code assumes C's unsigned char is an 8-bit type." 19ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro#endif 20ac4ea13a3aec87bf3e6ceb54e867e20f1fbd4253Skip Montanaro 2190ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) 2290ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum#define _SGI_MP_SOURCE 2390ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum#endif 2490ce8488481521e5ddd1fe5ed942e1df4acd6365Guido van Rossum 25174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <stdio.h> 264826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters#ifndef NULL 274826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters# error "Python.h requires that stdio.h define NULL." 284826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters#endif 294826a894c5afa6f8b61d2b94c5a8b07588cb692aTim Peters 30174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <string.h> 310e3f591aeeef9ed715f8770320f4c4c7332a8794Thomas Wouters#ifdef HAVE_ERRNO_H 32174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <errno.h> 33477c8d5e70240744d24631b18341ad892c8a8e1cThomas Wouters#endif 34174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include <stdlib.h> 35cdc445122208cb90a59a468a7396b227e223c43aMartin v. Löwis#ifdef HAVE_UNISTD_H 36cdc445122208cb90a59a468a7396b227e223c43aMartin v. Löwis#include <unistd.h> 37cdc445122208cb90a59a468a7396b227e223c43aMartin v. Löwis#endif 38b2c075bec452f66155d447ed9a1ae1a6479502a8Guido van Rossum 39fdfe62d887d5b695a82dae68006ac3b12c02eb57Amaury Forgeot d'Arc/* For size_t? */ 40fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis#ifdef HAVE_STDDEF_H 41fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis#include <stddef.h> 42fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis#endif 43fe393f47c662c307d2d3e90f785edf5821d54a8dMartin v. Löwis 445defb1736d36ea44bbb8f613cd0031d68816819bTim Peters/* CAUTION: Build setups should ensure that NDEBUG is defined on the 455defb1736d36ea44bbb8f613cd0031d68816819bTim Peters * compiler command line when building Python in release mode; else 465defb1736d36ea44bbb8f613cd0031d68816819bTim Peters * assert() calls won't be removed. 475defb1736d36ea44bbb8f613cd0031d68816819bTim Peters */ 488315ea579046727bb234dc4692ca28c8514eacbeTim Peters#include <assert.h> 498315ea579046727bb234dc4692ca28c8514eacbeTim Peters 501e1fcef756dbec60c9062462b46777ffc2a0594eMartin v. Löwis#include "pyport.h" 511e1fcef756dbec60c9062462b46777ffc2a0594eMartin v. Löwis 5239370830a96068ecbad006fe38fdb13107d8cd6bJeffrey Yasskin#include "pyatomic.h" 5339370830a96068ecbad006fe38fdb13107d8cd6bJeffrey Yasskin 54ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. 55ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters * PYMALLOC_DEBUG is in error if pymalloc is not in use. 56ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters */ 57ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) 58ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#define PYMALLOC_DEBUG 59ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#endif 60ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) 61ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#error "PYMALLOC_DEBUG requires WITH_PYMALLOC" 62ddea208be9e2a8fa281e25ebbc890378dd2aa286Tim Peters#endif 6353876d9cd8a67d9e67772e082deab92a598f74b3Christian Heimes#include "pymath.h" 646fc4ade2bb44a176555703ebc2dbfb54b57e1148Alexander Belopolsky#include "pytime.h" 6525f68944c20a3a37da6776277057c2d19a80211fPeter Schneider-Kamp#include "pymem.h" 6625f68944c20a3a37da6776277057c2d19a80211fPeter Schneider-Kamp 67174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "object.h" 68174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "objimpl.h" 694d0d471a8031de90a2b1ce99c4ac4780e60b3bc9Martin v. Löwis#include "typeslots.h" 70174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 71174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pydebug.h" 72174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 732c9c7a5f33d502fa468e38537d57834c7e33aa4dChristian Heimes#include "bytearrayobject.h" 744dfe8a1131b551687659b9339eaee163a24f82f1Guido van Rossum#include "bytesobject.h" 759e896b37c7a554250d7d832566cc4fe7d30d034cGuido van Rossum#include "unicodeobject.h" 76174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "longobject.h" 779f2e346911988cda95fec7c901e8d10d34fa9563Martin v. Löwis#include "longintrepr.h" 789f2e346911988cda95fec7c901e8d10d34fa9563Martin v. Löwis#include "boolobject.h" 79174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "floatobject.h" 80174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "complexobject.h" 81174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "rangeobject.h" 82b99f762f10edb2646a634c2290ecb064bd52e5c7Travis E. Oliphant#include "memoryobject.h" 83174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "tupleobject.h" 84174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "listobject.h" 852ec9031b5589db81026f5fc3a11070002ec4d0d7Guido van Rossum#include "dictobject.h" 867dab2426ca0bae36fde565407ddb4b2d2cbf2575Guido van Rossum#include "enumobject.h" 87a690a9967e715663b7a421c9ebdad91381cdf1e4Raymond Hettinger#include "setobject.h" 88174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "methodobject.h" 89174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "moduleobject.h" 90174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "funcobject.h" 91174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "classobject.h" 92174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "fileobject.h" 93b173f7853e4e3a4215a661d98174291e379cf6fbBenjamin Peterson#include "pycapsule.h" 94174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "traceback.h" 95174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "sliceobject.h" 96fbd849f201a4a8c17745a72eb9f0ee3bae34d330Jeremy Hylton#include "cellobject.h" 9759d1d2b434e8cf79e8b1321f148254c68f56c1f7Guido van Rossum#include "iterobject.h" 988d97e33bb76c322cdb08dbf97c26d787cd3488a7Martin v. Löwis#include "genobject.h" 996d6c1a35e08b95a83dbe47dbd9e6474daff00354Tim Peters#include "descrobject.h" 10033fe8093df5c13e41d7dba764279c71c142a4a7dChristian Heimes#include "warnings.h" 10119bc578a0907844cb94fe6f727fa5158736086faFred Drake#include "weakrefobject.h" 10271c23d447322307572fbe0ca68b61fad97e10021Georg Brandl#include "structseq.h" 103174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 1044d0d471a8031de90a2b1ce99c4ac4780e60b3bc9Martin v. Löwis 105bd7dfbc146deb31c520d886415ffd2d00f6970b0Guido van Rossum#include "codecs.h" 106174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pyerrors.h" 107174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 108618af4b3ef08d5eee9c36fafd4cd57c54573f95eGuido van Rossum#include "pystate.h" 109618af4b3ef08d5eee9c36fafd4cd57c54573f95eGuido van Rossum 110adb69fcdffdc50ee3e1d33b00cd874020197b445Neal Norwitz#include "pyarena.h" 111174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "modsupport.h" 112174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pythonrun.h" 1135ba58662817b708a453020f0425fe4747ea6d5cbTim Peters#include "ceval.h" 114174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "sysmodule.h" 115174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "intrcheck.h" 116174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "import.h" 117174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 118174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "abstract.h" 1198bc5b681599b66887f69ca54631d6e1ce4894252Benjamin Peterson#include "bltinmodule.h" 120174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 1216e098a15a3493d9c136e18b9e51b67bd48545651Skip Montanaro#include "compile.h" 1226e098a15a3493d9c136e18b9e51b67bd48545651Skip Montanaro#include "eval.h" 1236e098a15a3493d9c136e18b9e51b67bd48545651Skip Montanaro 1246dc46f5eaa14c8aa33b8ae5b41642a00a1b25807Eric Smith#include "pyctype.h" 125737ea82a5abd448b3e214b44d7d3c579b77e8155Martin v. Löwis#include "pystrtod.h" 12699170a5dbf4cfee78b578672b6821e855f92594bChristian Heimes#include "pystrcmp.h" 127b08a53a99def3fa949643974f713b5b189e21bc7Mark Dickinson#include "dtoa.h" 1284e31443c4d2c1fb211a6ea90fc6a8fbd9ff81c97Victor Stinner#include "fileutils.h" 129737ea82a5abd448b3e214b44d7d3c579b77e8155Martin v. Löwis 130dfa66c1dda47ffea27500c871bbc867d2bce29bdCollin Winter#ifdef __cplusplus 131dfa66c1dda47ffea27500c871bbc867d2bce29bdCollin Winterextern "C" { 132dfa66c1dda47ffea27500c871bbc867d2bce29bdCollin Winter#endif 133f2e08b34f1fa50e99f8cab0a21721be2d1bb38b8Victor Stinner 1340ae0c076615934ed237b412464b49b58c60c0644Raymond Hettinger/* _Py_Mangle is defined in compile.c */ 1354d0d471a8031de90a2b1ce99c4ac4780e60b3bc9Martin v. Löwis#ifndef Py_LIMITED_API 1363e0055f8c65c407e74ce476b8e2b1fb889723514Jeremy HyltonPyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); 1374d0d471a8031de90a2b1ce99c4ac4780e60b3bc9Martin v. Löwis#endif 1380ae0c076615934ed237b412464b49b58c60c0644Raymond Hettinger 139dfa66c1dda47ffea27500c871bbc867d2bce29bdCollin Winter#ifdef __cplusplus 140dfa66c1dda47ffea27500c871bbc867d2bce29bdCollin Winter} 141dfa66c1dda47ffea27500c871bbc867d2bce29bdCollin Winter#endif 142e53de3dc4a9021b5edabd44fd495df7770b6249cPhilip Jenvey 14336d2e67db9a53175accad32454af6316d6b12b82Stefan Krah/* Argument must be a char or an int in [-128, 127] or [0, 255]. */ 144bbe741dd1b15e9b496028732afb5f99a2a960695Christian Heimes#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) 145174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 146174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum#include "pyfpe.h" 147174f95adf7ee1251738a291d0fb52760ea1b25c0Guido van Rossum 1489581144329e39787b1f584dc575b78f099710595Greg Ward/* These definitions must match corresponding definitions in graminit.h. 149b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum There's code in compile.c that checks that they are the same. */ 150b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum#define Py_single_input 256 151b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum#define Py_file_input 257 152b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum#define Py_eval_input 258 153b05a5c7698cd8dff3e5c02e513db765ba12281f0Guido van Rossum 1549e8181b809c0dc40f86d66ce7e51db83aaeccd20Guido van Rossum#ifdef HAVE_PTH 15507bd90e92d9cb8982ad541dda59bc0f8867e9414Guido van Rossum/* GNU pth user-space thread support */ 15607bd90e92d9cb8982ad541dda59bc0f8867e9414Guido van Rossum#include <pth.h> 15707bd90e92d9cb8982ad541dda59bc0f8867e9414Guido van Rossum#endif 158a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis 159a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis/* Define macros for inline documentation. */ 160a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_VAR(name) static char name[] 161a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) 162a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#ifdef WITH_DOC_STRINGS 163a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_STR(str) str 164a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#else 165a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#define PyDoc_STR(str) "" 166a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis#endif 167a3fb4f78164e55ddecfd875b9b33791850213dfdMartin v. Löwis 168d27b4f2a3f6a90dfcc5eb6fb30c1a895ed60142dGuido van Rossum#endif /* !Py_PYTHON_H */ 169