2008-06-05 14:29:38 -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"
|
2008-06-05 09:58:24 -03:00
|
|
|
#include "pymacconfig.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>
|
2006-06-10 09:23:46 -03:00
|
|
|
#ifdef HAVE_ERRNO_H
|
1997-05-02 00:55:52 -03:00
|
|
|
#include <errno.h>
|
2006-05-22 06:15:18 -03:00
|
|
|
#endif
|
1997-05-02 00:55:52 -03:00
|
|
|
#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
|
|
|
|
2008-06-11 15:00:52 -03:00
|
|
|
/* For size_t? */
|
2004-07-27 12:57:24 -03:00
|
|
|
#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
|
2008-04-18 20:13:07 -03:00
|
|
|
#include "pymath.h"
|
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"
|
2009-04-02 18:18:34 -03:00
|
|
|
#include "memoryobject.h"
|
1998-10-07 11:36:10 -03:00
|
|
|
#include "bufferobject.h"
|
Merged revisions 61750,61752,61754,61756,61760,61763,61768,61772,61775,61805,61809,61812,61819,61917,61920,61930,61933-61934 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61750 | christian.heimes | 2008-03-22 20:47:44 +0100 (Sat, 22 Mar 2008) | 1 line
Copied files from py3k w/o modifications
........
r61752 | christian.heimes | 2008-03-22 20:53:20 +0100 (Sat, 22 Mar 2008) | 7 lines
Take One
* Added initialization code, warnings, flags etc. to the appropriate places
* Added new buffer interface to string type
* Modified tests
* Modified Makefile.pre.in to compile the new files
* Added bytesobject.c to Python.h
........
r61754 | christian.heimes | 2008-03-22 21:22:19 +0100 (Sat, 22 Mar 2008) | 2 lines
Disabled bytearray.extend for now since it causes an infinite recursion
Fixed serveral unit tests
........
r61756 | christian.heimes | 2008-03-22 21:43:38 +0100 (Sat, 22 Mar 2008) | 5 lines
Added PyBytes support to several places:
str + bytearray
ord(bytearray)
bytearray(str, encoding)
........
r61760 | christian.heimes | 2008-03-22 21:56:32 +0100 (Sat, 22 Mar 2008) | 1 line
Fixed more unit tests related to type('') is not unicode
........
r61763 | christian.heimes | 2008-03-22 22:20:28 +0100 (Sat, 22 Mar 2008) | 2 lines
Fixed more unit tests
Fixed bytearray.extend
........
r61768 | christian.heimes | 2008-03-22 22:40:50 +0100 (Sat, 22 Mar 2008) | 1 line
Implemented old buffer interface for bytearray
........
r61772 | christian.heimes | 2008-03-22 23:24:52 +0100 (Sat, 22 Mar 2008) | 1 line
Added backport of the io module
........
r61775 | christian.heimes | 2008-03-23 03:50:49 +0100 (Sun, 23 Mar 2008) | 1 line
Fix str assignement to bytearray. Assignment of a str of size 1 is interpreted as a single byte
........
r61805 | christian.heimes | 2008-03-23 19:33:48 +0100 (Sun, 23 Mar 2008) | 3 lines
Fixed more tests
Fixed bytearray() comparsion with unicode()
Fixed iterator assignment of bytearray
........
r61809 | christian.heimes | 2008-03-23 21:02:21 +0100 (Sun, 23 Mar 2008) | 2 lines
str(bytesarray()) now returns the bytes and not the representation of the bytearray object
Enabled and fixed more unit tests
........
r61812 | christian.heimes | 2008-03-23 21:53:08 +0100 (Sun, 23 Mar 2008) | 3 lines
Clear error PyNumber_AsSsize_t() fails
Use CHARMASK for ob_svall access
disabled a test with memoryview again
........
r61819 | christian.heimes | 2008-03-23 23:05:57 +0100 (Sun, 23 Mar 2008) | 1 line
Untested updates to the PCBuild directory
........
r61917 | christian.heimes | 2008-03-26 00:57:06 +0100 (Wed, 26 Mar 2008) | 1 line
The type system of Python 2.6 has subtle differences to 3.0's. I've removed the Py_TPFLAGS_BASETYPE flags from bytearray for now. bytearray can't be subclasses until the issues with bytearray subclasses are fixed.
........
r61920 | christian.heimes | 2008-03-26 01:44:08 +0100 (Wed, 26 Mar 2008) | 2 lines
Disabled last failing test
I don't understand what the test is testing and how it suppose to work. Ka-Ping, please check it out.
........
r61930 | christian.heimes | 2008-03-26 12:46:18 +0100 (Wed, 26 Mar 2008) | 1 line
Re-enabled bytes warning code
........
r61933 | christian.heimes | 2008-03-26 13:20:46 +0100 (Wed, 26 Mar 2008) | 1 line
Fixed a bug in the new buffer protocol. The buffer slots weren't copied into a subclass.
........
r61934 | christian.heimes | 2008-03-26 13:25:09 +0100 (Wed, 26 Mar 2008) | 1 line
Re-enabled bytearray subclassing - all tests are passing.
........
2008-03-26 09:49:49 -03:00
|
|
|
#include "bytesobject.h"
|
2008-05-26 09:29:14 -03:00
|
|
|
#include "bytearrayobject.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"
|
2010-03-24 21:54:54 -03:00
|
|
|
#include "pycapsule.h"
|
1997-05-02 00:55:52 -03:00
|
|
|
#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"
|
2008-04-12 20:44:07 -03:00
|
|
|
#include "warnings.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"
|
|
|
|
|
2005-12-17 16:54:49 -04:00
|
|
|
#include "pyarena.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"
|
|
|
|
|
2009-04-27 16:04:37 -03:00
|
|
|
#include "pyctype.h"
|
2004-06-08 15:52:54 -03:00
|
|
|
#include "pystrtod.h"
|
2007-12-18 19:22:54 -04:00
|
|
|
#include "pystrcmp.h"
|
2009-10-24 09:13:30 -03:00
|
|
|
#include "dtoa.h"
|
2004-06-08 15:52:54 -03:00
|
|
|
|
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, "")
|
|
|
|
|
2010-07-19 10:14:01 -03:00
|
|
|
/* Argument must be a char or an int in [-128, 127] or [0, 255]. */
|
2008-03-28 01:58:51 -03:00
|
|
|
#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff))
|
1997-05-02 00:55:52 -03:00
|
|
|
|
|
|
|
#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 */
|