1997-05-02 01:00:11 -03:00
|
|
|
#ifndef Py_PYTHON_H
|
|
|
|
#define Py_PYTHON_H
|
1997-05-02 00:55:52 -03:00
|
|
|
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
|
|
|
|
|
|
|
|
/* Include nearly all Python header files */
|
|
|
|
|
1999-01-03 08:40:24 -04:00
|
|
|
#include "patchlevel.h"
|
2001-07-26 10:41:06 -03:00
|
|
|
#include "pyconfig.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
|
2002-07-07 00:59:34 -03:00
|
|
|
/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
|
|
|
|
* old symbol for the benefit of extension modules written before then
|
|
|
|
* that may be conditionalizing on it. The core doesn't use it anymore.
|
|
|
|
*/
|
|
|
|
#ifndef WITH_CYCLE_GC
|
|
|
|
#define WITH_CYCLE_GC 1
|
|
|
|
#endif
|
|
|
|
|
2000-09-26 02:46:01 -03:00
|
|
|
#include <limits.h>
|
|
|
|
|
2003-12-22 12:31:41 -04:00
|
|
|
#ifndef UCHAR_MAX
|
|
|
|
#error "Something's broken. UCHAR_MAX should be defined in limits.h."
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if UCHAR_MAX != 255
|
2003-12-22 14:10:51 -04:00
|
|
|
#error "Python's source code assumes C's unsigned char is an 8-bit type."
|
2003-12-22 12:31:41 -04:00
|
|
|
#endif
|
|
|
|
|
1998-05-26 15:38:07 -03:00
|
|
|
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
|
|
|
|
#define _SGI_MP_SOURCE
|
|
|
|
#endif
|
|
|
|
|
1997-05-02 00:55:52 -03:00
|
|
|
#include <stdio.h>
|
2000-09-09 22:02:41 -03:00
|
|
|
#ifndef NULL
|
|
|
|
# error "Python.h requires that stdio.h define NULL."
|
|
|
|
#endif
|
|
|
|
|
1997-05-02 00:55:52 -03:00
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
2002-01-12 07:05:12 -04:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
2001-07-15 13:58:05 -03:00
|
|
|
|
2004-07-27 12:57:24 -03:00
|
|
|
/* For uintptr_t, intptr_t */
|
|
|
|
#ifdef HAVE_STDDEF_H
|
|
|
|
#include <stddef.h>
|
|
|
|
#endif
|
|
|
|
|
2001-12-04 16:06:11 -04:00
|
|
|
/* CAUTION: Build setups should ensure that NDEBUG is defined on the
|
|
|
|
* compiler command line when building Python in release mode; else
|
|
|
|
* assert() calls won't be removed.
|
|
|
|
*/
|
2000-07-23 16:28:35 -03:00
|
|
|
#include <assert.h>
|
|
|
|
|
2002-05-15 15:24:06 -03:00
|
|
|
#include "pyport.h"
|
|
|
|
|
2002-06-04 12:07:08 -03:00
|
|
|
/* pyconfig.h or pyport.h may or may not define DL_IMPORT */
|
|
|
|
#ifndef DL_IMPORT /* declarations for DLL import/export */
|
|
|
|
#define DL_IMPORT(RTYPE) RTYPE
|
|
|
|
#endif
|
|
|
|
#ifndef DL_EXPORT /* declarations for DLL import/export */
|
|
|
|
#define DL_EXPORT(RTYPE) RTYPE
|
|
|
|
#endif
|
|
|
|
|
Give Python a debug-mode pymalloc, much as sketched on Python-Dev.
When WITH_PYMALLOC is defined, define PYMALLOC_DEBUG to enable the debug
allocator. This can be done independent of build type (release or debug).
A debug build automatically defines PYMALLOC_DEBUG when pymalloc is
enabled. It's a detected error to define PYMALLOC_DEBUG when pymalloc
isn't enabled.
Two debugging entry points defined only under PYMALLOC_DEBUG:
+ _PyMalloc_DebugCheckAddress(const void *p) can be used (e.g., from gdb)
to sanity-check a memory block obtained from pymalloc. It sprays
info to stderr (see next) and dies via Py_FatalError if the block is
detectably damaged.
+ _PyMalloc_DebugDumpAddress(const void *p) can be used to spray info
about a debug memory block to stderr.
A tiny start at implementing "API family" checks isn't good for
anything yet.
_PyMalloc_DebugRealloc() has been optimized to do little when the new
size is <= old size. However, if the new size is larger, it really
can't call the underlying realloc() routine without either violating its
contract, or knowing something non-trivial about how the underlying
realloc() works. A memcpy is always done in this case.
This was a disaster for (and only) one of the std tests: test_bufio
creates single text file lines up to a million characters long. On
Windows, fileobject.c's get_line() uses the horridly funky
getline_via_fgets(), which keeps growing and growing a string object
hoping to find a newline. It grew the string object 1000 bytes each
time, so for a million-character string it took approximately forever
(I gave up after a few minutes).
So, also:
fileobject.c, getline_via_fgets(): When a single line is outrageously
long, grow the string object at a mildly exponential rate, instead of
just 1000 bytes at a time.
That's enough so that a debug-build test_bufio finishes in about 5 seconds
on my Win98SE box. I'm curious to try this on Win2K, because it has very
different memory behavior than Win9X, and test_bufio always took a factor
of 10 longer to complete on Win2K. It *could* be that the endless
reallocs were simply killing it on Win2K even in the release build.
2002-03-23 06:03:50 -04:00
|
|
|
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
|
|
|
|
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
|
|
|
|
*/
|
|
|
|
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
|
|
|
|
#define PYMALLOC_DEBUG
|
|
|
|
#endif
|
|
|
|
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
|
|
|
|
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
|
|
|
|
#endif
|
2000-07-31 19:19:30 -03:00
|
|
|
#include "pymem.h"
|
|
|
|
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "object.h"
|
|
|
|
#include "objimpl.h"
|
|
|
|
|
|
|
|
#include "pydebug.h"
|
|
|
|
|
2000-04-05 17:11:21 -03:00
|
|
|
#include "unicodeobject.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "intobject.h"
|
2002-04-03 18:41:51 -04:00
|
|
|
#include "boolobject.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "longobject.h"
|
|
|
|
#include "floatobject.h"
|
|
|
|
#ifndef WITHOUT_COMPLEX
|
|
|
|
#include "complexobject.h"
|
|
|
|
#endif
|
|
|
|
#include "rangeobject.h"
|
|
|
|
#include "stringobject.h"
|
1998-10-07 11:36:10 -03:00
|
|
|
#include "bufferobject.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "tupleobject.h"
|
|
|
|
#include "listobject.h"
|
1997-05-13 18:23:32 -03:00
|
|
|
#include "dictobject.h"
|
2002-04-26 16:40:56 -03:00
|
|
|
#include "enumobject.h"
|
2003-11-16 12:17:49 -04:00
|
|
|
#include "setobject.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "methodobject.h"
|
|
|
|
#include "moduleobject.h"
|
|
|
|
#include "funcobject.h"
|
|
|
|
#include "classobject.h"
|
|
|
|
#include "fileobject.h"
|
|
|
|
#include "cobject.h"
|
|
|
|
#include "traceback.h"
|
|
|
|
#include "sliceobject.h"
|
2001-01-25 16:04:14 -04:00
|
|
|
#include "cellobject.h"
|
2001-04-20 16:13:02 -03:00
|
|
|
#include "iterobject.h"
|
2004-06-27 12:43:12 -03:00
|
|
|
#include "genobject.h"
|
2001-08-02 01:15:00 -03:00
|
|
|
#include "descrobject.h"
|
2001-10-05 18:55:19 -03:00
|
|
|
#include "weakrefobject.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
|
2000-03-10 18:34:00 -04:00
|
|
|
#include "codecs.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "pyerrors.h"
|
|
|
|
|
1997-07-18 20:59:26 -03:00
|
|
|
#include "pystate.h"
|
|
|
|
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "modsupport.h"
|
|
|
|
#include "pythonrun.h"
|
2001-07-15 23:29:45 -03:00
|
|
|
#include "ceval.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#include "sysmodule.h"
|
|
|
|
#include "intrcheck.h"
|
|
|
|
#include "import.h"
|
|
|
|
|
|
|
|
#include "abstract.h"
|
|
|
|
|
2004-03-13 19:11:44 -04:00
|
|
|
#include "compile.h"
|
|
|
|
#include "eval.h"
|
|
|
|
|
2004-06-08 15:52:54 -03:00
|
|
|
#include "pystrtod.h"
|
|
|
|
|
2002-06-20 19:23:15 -03:00
|
|
|
/* _Py_Mangle is defined in compile.c */
|
2005-10-20 16:59:25 -03:00
|
|
|
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
2002-06-20 19:23:15 -03:00
|
|
|
|
2002-03-25 18:21:58 -04:00
|
|
|
/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */
|
1997-05-02 00:55:52 -03:00
|
|
|
#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a))
|
2002-03-25 16:46:46 -04:00
|
|
|
|
|
|
|
/* PyArg_NoArgs should not be necessary.
|
|
|
|
Set ml_flags in the PyMethodDef to METH_NOARGS. */
|
1997-05-02 00:55:52 -03:00
|
|
|
#define PyArg_NoArgs(v) PyArg_Parse(v, "")
|
|
|
|
|
|
|
|
/* Convert a possibly signed character to a nonnegative int */
|
|
|
|
/* XXX This assumes characters are 8 bits wide */
|
|
|
|
#ifdef __CHAR_UNSIGNED__
|
|
|
|
#define Py_CHARMASK(c) (c)
|
|
|
|
#else
|
|
|
|
#define Py_CHARMASK(c) ((c) & 0xff)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "pyfpe.h"
|
|
|
|
|
2000-05-28 17:29:48 -03:00
|
|
|
/* These definitions must match corresponding definitions in graminit.h.
|
1997-05-07 14:46:13 -03:00
|
|
|
There's code in compile.c that checks that they are the same. */
|
|
|
|
#define Py_single_input 256
|
|
|
|
#define Py_file_input 257
|
|
|
|
#define Py_eval_input 258
|
|
|
|
|
2000-09-18 21:46:46 -03:00
|
|
|
#ifdef HAVE_PTH
|
2000-05-08 10:41:38 -03:00
|
|
|
/* GNU pth user-space thread support */
|
|
|
|
#include <pth.h>
|
|
|
|
#endif
|
2002-06-09 10:33:54 -03:00
|
|
|
|
|
|
|
/* Define macros for inline documentation. */
|
|
|
|
#define PyDoc_VAR(name) static char name[]
|
|
|
|
#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str)
|
|
|
|
#ifdef WITH_DOC_STRINGS
|
|
|
|
#define PyDoc_STR(str) str
|
|
|
|
#else
|
|
|
|
#define PyDoc_STR(str) ""
|
|
|
|
#endif
|
|
|
|
|
1997-05-02 01:00:11 -03:00
|
|
|
#endif /* !Py_PYTHON_H */
|