Merge branches/pep-0384.
authorMartin v. Löwis <martin@v.loewis.de>
Fri, 3 Dec 2010 20:14:31 +0000 (20:14 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Fri, 3 Dec 2010 20:14:31 +0000 (20:14 +0000)
102 files changed:
Doc/c-api/veryhigh.rst
Doc/faq/extending.rst
Doc/whatsnew/3.2.rst
Include/Python.h
Include/abstract.h
Include/bytearrayobject.h
Include/bytes_methods.h
Include/bytesobject.h
Include/cellobject.h
Include/ceval.h
Include/classobject.h
Include/code.h
Include/codecs.h
Include/compile.h
Include/complexobject.h
Include/datetime.h
Include/descrobject.h
Include/dictobject.h
Include/dtoa.h
Include/eval.h
Include/fileobject.h
Include/floatobject.h
Include/frameobject.h
Include/funcobject.h
Include/genobject.h
Include/import.h
Include/listobject.h
Include/longintrepr.h
Include/longobject.h
Include/marshal.h
Include/memoryobject.h
Include/methodobject.h
Include/modsupport.h
Include/moduleobject.h
Include/object.h
Include/objimpl.h
Include/parsetok.h
Include/pyarena.h
Include/pyatomic.h
Include/pyctype.h
Include/pydebug.h
Include/pyerrors.h
Include/pygetopt.h
Include/pymath.h
Include/pystate.h
Include/pystrtod.h
Include/pythonrun.h
Include/pytime.h
Include/setobject.h
Include/sliceobject.h
Include/structseq.h
Include/symtable.h
Include/sysmodule.h
Include/timefuncs.h
Include/token.h
Include/traceback.h
Include/tupleobject.h
Include/typeslots.h [new file with mode: 0644]
Include/ucnhash.h
Include/unicodeobject.h
Include/warnings.h
Include/weakrefobject.h
Makefile.pre.in
Misc/NEWS
Modules/_ctypes/_ctypes.c
Modules/_ctypes/cfield.c
Modules/_elementtree.c
Modules/_testcapimodule.c
Modules/arraymodule.c
Modules/getpath.c
Modules/mmapmodule.c
Modules/xxlimited.c [new file with mode: 0644]
Objects/bytearrayobject.c
Objects/bytesobject.c
Objects/funcobject.c
Objects/listobject.c
Objects/memoryobject.c
Objects/moduleobject.c
Objects/object.c
Objects/rangeobject.c
Objects/sliceobject.c
Objects/structseq.c
Objects/tupleobject.c
Objects/typeobject.c
Objects/typeslots.inc [new file with mode: 0644]
Objects/typeslots.py [new file with mode: 0644]
Objects/unicodeobject.c
PC/getpathp.c
PC/pyconfig.h
PC/python3.def [new file with mode: 0644]
PC/python3dll.c [new file with mode: 0644]
PCbuild/pcbuild.sln
PCbuild/python3dll.vcproj [new file with mode: 0644]
PCbuild/xxlimited.vcproj [new file with mode: 0644]
Python/bltinmodule.c
Python/ceval.c
Python/dynload_shlib.c
Python/dynload_win.c
Python/import.c
Python/pythonrun.c
Tools/scripts/abitype.py [new file with mode: 0644]
setup.py

index 7cc1dc1d51dd2984f0a7a0fb8514b60eab97d19b..5b9332560ce7fea116152fa4321e0891193f6fbe 100644 (file)
@@ -239,14 +239,14 @@ the same library that the Python runtime is using.
    be parsed or compiled.
 
 
-.. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
+.. c:function:: PyObject* PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
 
    This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just
    the code object, and the dictionaries of global and local variables.
    The other arguments are set to *NULL*.
 
 
-.. c:function:: PyObject* PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
+.. c:function:: PyObject* PyEval_EvalCodeEx(PyObject *co, PyObject *globals, PyObject *locals, PyObject **args, int argcount, PyObject **kws, int kwcount, PyObject **defs, int defcount, PyObject *closure)
 
    Evaluate a precompiled code object, given a particular environment for its
    evaluation.  This environment consists of dictionaries of global and local
index 59e54224239b06fdf50bebc0ca0f7d6e2bcc88a2..678f1bd5da69da9187301f3fabedeef0438427d0 100644 (file)
@@ -379,7 +379,7 @@ complete example using the GNU readline library (you may want to ignore
            if (ps1  == prompt ||                  /* ">>> " or */
                '\n' == code[i + j - 1])           /* "... " and double '\n' */
            {                                               /* so execute it */
-             dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc);
+             dum = PyEval_EvalCode (src, glb, loc);
              Py_XDECREF (dum);
              Py_XDECREF (src);
              free (code);
index db88e4abad0032de99b267101fe3ff81c446bae8..8d0f0f5e9111ab3af9cf1f8ca251e471a83d6072 100644 (file)
 
 This article explains the new features in Python 3.2, compared to 3.1.
 
+PEP 382: Defining a Stable ABI
+==============================
+
+In the past, extension modules built for one Python version were often
+not usable with other Python versions. Particularly on Windows, every
+feature release of Python required rebuilding all extension modules that
+one wanted to use. This requirement was the result of the free access to
+Python interpreter internals that extension modules could use.
+
+With Python 3.2, an alternative approach becomes available: extension
+modules with restrict themselves to a limited API (by defining
+Py_LIMITED_API) cannot use many of the internals, but are constrained
+to a set of API functions that are promised to be stable for several
+releases. As a consequence, extension modules built for 3.2 in that
+mode will also work with 3.3, 3.4, and so on. Extension modules that
+make use of details of memory structures can still be built, but will
+need to be recompiled for every feature release.
+
 
 PEP 391:  Dictionary Based Configuration for Logging
 ====================================================
index a49753ff297094c704a0dc477d3122869af3ffbe..db33a76cd4e4e48c454aecd616d0aa0c09ced60f 100644 (file)
@@ -66,6 +66,7 @@
 
 #include "object.h"
 #include "objimpl.h"
+#include "typeslots.h"
 
 #include "pydebug.h"
 
 #include "weakrefobject.h"
 #include "structseq.h"
 
+
 #include "codecs.h"
 #include "pyerrors.h"
 
@@ -130,7 +132,9 @@ extern "C" {
 #endif
 
 /* _Py_Mangle is defined in compile.c */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
+#endif
 
 #ifdef __cplusplus
 }
index 23990799e79240f92d56d9ded5ad2a0c25db805d..53c9dc7216851a03529bd17ca152eb74ee9b9488 100644 (file)
@@ -387,7 +387,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
      PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
 #define PyObject_Length PyObject_Size
 
+#ifndef Py_LIMITED_API
      PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t);
+#endif
 
        /*
      Guess the size of object o using len(o) or o.__length_hint__().
@@ -765,9 +767,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
      that can accept a char* naming integral's type.
        */
 
+#ifndef Py_LIMITED_API
      PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
          PyObject *integral,
          const char* error_format);
+#endif
 
        /*
     Returns the object converted to Py_ssize_t by going through
@@ -1057,11 +1061,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
      Use __contains__ if possible, else _PySequence_IterSearch().
        */
 
+#ifndef Py_LIMITED_API
 #define PY_ITERSEARCH_COUNT    1
 #define PY_ITERSEARCH_INDEX    2
 #define PY_ITERSEARCH_CONTAINS 3
      PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
                                         PyObject *obj, int operation);
+#endif
     /*
       Iterate over seq.  Result depends on the operation:
       PY_ITERSEARCH_COUNT:  return # of times obj appears in seq; -1 if
@@ -1228,6 +1234,7 @@ PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
       /* issubclass(object, typeorclass) */
 
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
 
 PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
@@ -1235,6 +1242,7 @@ PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
 PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self);
 
 PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]);
+#endif
 
 /* For internal use by buffer API functions */
 PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
index e1281a628c76642521d028df82aae17f2e69482e..eccd44c751790fcce6c7efe241e067d0ffdd99cb 100644 (file)
@@ -19,6 +19,7 @@ extern "C" {
  */
 
 /* Object layout */
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
@@ -26,6 +27,7 @@ typedef struct {
     Py_ssize_t ob_alloc; /* How many bytes allocated */
     char *ob_bytes;
 } PyByteArrayObject;
+#endif
 
 /* Type object */
 PyAPI_DATA(PyTypeObject) PyByteArray_Type;
@@ -44,12 +46,14 @@ PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
 PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
 
 /* Macros, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyByteArray_AS_STRING(self) \
     (assert(PyByteArray_Check(self)), \
      Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
 #define PyByteArray_GET_SIZE(self)  (assert(PyByteArray_Check(self)),Py_SIZE(self))
 
 PyAPI_DATA(char) _PyByteArray_empty_string[];
+#endif
 
 #ifdef __cplusplus
 }
index d0a6242d7a6772ecef85b7f3047f320aa184b31b..1498b8f83c2b059c8c52c99ee5ffc919060a72e3 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_BYTES_CTYPE_H
 #define Py_BYTES_CTYPE_H
 
@@ -42,3 +43,4 @@ extern const char _Py_maketrans__doc__[];
 #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
 
 #endif /* !Py_BYTES_CTYPE_H */
+#endif /* !Py_LIMITED_API */
index 3c69d25b50344445fed5c1e5d7e9fc327965ac66..e1af89f9c95e980caff4a55a6edf32c94da8e54b 100644 (file)
@@ -27,6 +27,7 @@ functions should be applied to nil objects.
 /* Caching the hash (ob_shash) saves recalculation of a string's hash value.
    This significantly speeds up dict lookups. */
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     Py_hash_t ob_shash;
@@ -38,6 +39,7 @@ typedef struct {
      *     ob_shash is the hash of the string or -1 if not computed yet.
      */
 } PyBytesObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyBytes_Type;
 PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
@@ -58,21 +60,27 @@ PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
 PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
 PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
 PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
 PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
                                                  int, char**, int*);
+#endif
 PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
                                                   const char *, Py_ssize_t,
                                                   const char *);
 
 /* Macro, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
                                 (((PyBytesObject *)(op))->ob_sval))
 #define PyBytes_GET_SIZE(op)  (assert(PyBytes_Check(op)),Py_SIZE(op))
+#endif
 
 /* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
    x must be an iterable object. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
+#endif
 
 /* Provides access to the internal data buffer and size of a string
    object or the default encoded version of an Unicode object. Passing
@@ -90,7 +98,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
 /* Using the current locale, insert the thousands grouping
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
-
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer,
                                                    Py_ssize_t n_buffer,
                                                    char *digits,
@@ -107,6 +115,7 @@ PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer,
                                                    Py_ssize_t min_width,
                                                    const char *grouping,
                                                    const char *thousands_sep);
+#endif
 
 /* Flags used by string formatting */
 #define F_LJUST (1<<0)
index c927ee5da12678c43a1b820f259a7fbfc73aac18..a0aa4d947c22115f8bc609c8d4f7ca57a2aa3773 100644 (file)
@@ -1,5 +1,5 @@
 /* Cell object interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_CELLOBJECT_H
 #define Py_CELLOBJECT_H
 #ifdef __cplusplus
@@ -26,3 +26,4 @@ PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
 }
 #endif
 #endif /* !Py_TUPLEOBJECT_H */
+#endif /* Py_LIMITED_API */
index 2acde13a65499dd306f6b78392d1619d2d7021a4..6811367d7625fbaf7f9602aa517fed5e540a01e0 100644 (file)
@@ -20,8 +20,10 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
                                          const char *methodname,
                                          const char *format, ...);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
 PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
+#endif
 
 struct _frame; /* Avoid including frameobject.h */
 
@@ -33,7 +35,9 @@ PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
 /* Look at the current frame's (if any) code's co_flags, and turn on
    the corresponding compiler flags in cf->cf_flags.  Return 1 if any
    flag was set, else return 0. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
+#endif
 
 PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
 PyAPI_FUNC(int) Py_MakePendingCalls(void);
@@ -167,8 +171,10 @@ PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
 PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
 PyAPI_FUNC(void) PyEval_ReInitThreads(void);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
 PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
+#endif
 
 #define Py_BEGIN_ALLOW_THREADS { \
                         PyThreadState *_save; \
@@ -187,8 +193,10 @@ PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
 
 #endif /* !WITH_THREAD */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
 PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
+#endif
 
 
 #ifdef __cplusplus
index b7eebe5e952e125504e8df0ac47e3448b280fcb9..eeeb3e95a87e717ee4d262bed635fd8862325209 100644 (file)
@@ -2,6 +2,7 @@
 
 /* Revealing some structures (not for general use) */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_CLASSOBJECT_H
 #define Py_CLASSOBJECT_H
 #ifdef __cplusplus
@@ -54,3 +55,4 @@ PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
 }
 #endif
 #endif /* !Py_CLASSOBJECT_H */
+#endif /* Py_LIMITED_API */
index 11ecc9562c6979f5e24fe22ade7a8f775140b911..e773b6a47ce83793c44de1017273787a000baac2 100644 (file)
@@ -1,5 +1,6 @@
 /* Definitions for bytecode */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_CODE_H
 #define Py_CODE_H
 #ifdef __cplusplus
@@ -93,8 +94,10 @@ typedef struct _addr_pair {
 /* Update *bounds to describe the first and one-past-the-last instructions in the
    same line as lasti.  Return the number of that line.
 */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
                                         int lasti, PyAddrPair *bounds);
+#endif
 
 PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
                                       PyObject *names, PyObject *lineno_obj);
@@ -103,3 +106,4 @@ PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
 }
 #endif
 #endif /* !Py_CODE_H */
+#endif /* Py_LIMITED_API */
index 4ea934e861d612cdbfc47c7c09d7de9936bae8bb..dff09e778bae2606cf84e3313445390b99be29b1 100644 (file)
@@ -45,9 +45,11 @@ PyAPI_FUNC(int) PyCodec_Register(
 
  */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
        const char *encoding
        );
+#endif
 
 /* Codec registry encoding check API.
 
index 7c329b3e6db981d0cc991acf5e018d84530c1a6b..4a5ebe67783f4897bd33440744698307e7e40b2d 100644 (file)
@@ -1,4 +1,4 @@
-
+#ifndef Py_LIMITED_API
 #ifndef Py_COMPILE_H
 #define Py_COMPILE_H
 
@@ -38,3 +38,4 @@ PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *);
 }
 #endif
 #endif /* !Py_COMPILE_H */
+#endif /* !Py_LIMITED_API */
index 8290a6dc4f5eb7d1069f35c90d2d9973002fd6e9..c379b08916fc971c7b0dc223eece63eec43676f9 100644 (file)
@@ -6,6 +6,7 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 typedef struct {
     double real;
     double imag;
@@ -28,7 +29,7 @@ PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex);
 PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex);
 PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex);
 PyAPI_FUNC(double) c_abs(Py_complex);
-
+#endif
 
 /* Complex object interface */
 
@@ -36,29 +37,36 @@ PyAPI_FUNC(double) c_abs(Py_complex);
 PyComplexObject represents a complex number with double-precision
 real and imaginary parts.
 */
-
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     Py_complex cval;
-} PyComplexObject;     
+} PyComplexObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyComplex_Type;
 
 #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
 #define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
+#endif
 PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
 
 PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
 PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
+#endif
 
 /* Format the object based on the format_spec, as defined in PEP 3101
    (Advanced String Formatting). */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj,
                                                  Py_UNICODE *format_spec,
                                                  Py_ssize_t format_spec_len);
+#endif
 
 #ifdef __cplusplus
 }
index 2d71fced8dc6d3633a957143dac94a8a143d2a7b..db57a18e66b34803f360e3956b9de9f4bc737e64 100644 (file)
@@ -1,6 +1,6 @@
 /*  datetime.h
  */
-
+#ifndef Py_LIMITED_API
 #ifndef DATETIME_H
 #define DATETIME_H
 #ifdef __cplusplus
@@ -234,3 +234,4 @@ static PyDateTime_CAPI *PyDateTimeAPI = NULL;
 }
 #endif
 #endif
+#endif /* !Py_LIMITED_API */
index 4f0c6932bed8d7c7595f130ccd0f9a0a2f4237ff..f715fe116012ea7ba3cc480a1ec5d97ce0fa6384 100644 (file)
@@ -16,6 +16,7 @@ typedef struct PyGetSetDef {
     void *closure;
 } PyGetSetDef;
 
+#ifndef Py_LIMITED_API
 typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
                                  void *wrapped);
 
@@ -68,6 +69,7 @@ typedef struct {
     struct wrapperbase *d_base;
     void *d_wrapped; /* This can be any function pointer */
 } PyWrapperDescrObject;
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
 PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
@@ -78,13 +80,16 @@ PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
 
 PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
 PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
+struct PyMemberDef; /* forward declaration for following prototype */
 PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
                                                struct PyMemberDef *);
 PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
                                                struct PyGetSetDef *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
                                                 struct wrapperbase *, void *);
 #define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
+#endif
 
 PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
index 024a688d2a9b52b458361fd0bdfbfc4989b759dd..b02678591973fab574bb4267ae13452a53107d5e 100644 (file)
@@ -45,6 +45,7 @@ meaning otherwise.
  * majority of dicts (consisting mostly of usually-small instance dicts and
  * usually-small dicts created to pass keyword arguments).
  */
+#ifndef Py_LIMITED_API
 #define PyDict_MINSIZE 8
 
 typedef struct {
@@ -84,6 +85,7 @@ struct _dictobject {
     PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, Py_hash_t hash);
     PyDictEntry ma_smalltable[PyDict_MINSIZE];
 };
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PyDict_Type;
 PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
@@ -112,18 +114,22 @@ PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
 PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
 PyAPI_FUNC(int) PyDict_Next(
     PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyDict_Next(
     PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
+#endif
 PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
 PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
 PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
 PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
 PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
 PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
 PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
 PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
 PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
+#endif
 
 /* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
 PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
index 9b434b77b6ed653bd90ffd5f6ce3613d7da4c91e..819bd0f207069c3fbb0a56f41638997de1de8b67 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef PY_NO_SHORT_FLOAT_REPR
 #ifdef __cplusplus
 extern "C" {
@@ -13,3 +14,4 @@ PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
 }
 #endif
 #endif
+#endif
index 1d03c972f73b7a2839733ecba082d20de7b63dff..a1c6e817dd342568fd79182cc4bedbce7c52dc4c 100644 (file)
@@ -7,9 +7,9 @@
 extern "C" {
 #endif
 
-PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *);
+PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
 
-PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
+PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
                                        PyObject *globals,
                                        PyObject *locals,
                                        PyObject **args, int argc,
@@ -17,7 +17,9 @@ PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co,
                                        PyObject **defs, int defc,
                                        PyObject *kwdefs, PyObject *closure);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
+#endif
 
 #ifdef __cplusplus
 }
index 20545fa85f0575b49f3d4e913a8f8508ab51b974..c4a2a2bb15c035ab395ce813a4d690d5e5ffce45 100644 (file)
@@ -14,7 +14,9 @@ PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
 PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
 PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
 PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
+#endif
 
 /* The default encoding used by the platform file system APIs
    If non-NULL, this is different than the default encoding for strings
@@ -26,6 +28,7 @@ PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
 
    The std printer acts as a preliminary sys.stderr until the new io
    infrastructure is in place. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
 PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
 
@@ -39,6 +42,7 @@ int _PyVerify_fd(int fd);
 #else
 #define _PyVerify_fd(A) (1) /* dummy */
 #endif
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 }
index 364b913b47275631c5b79b91eca89baf02cb82a6..90f0a454aa2b10812d6e14780fe84a5c2272307a 100644 (file)
@@ -11,10 +11,12 @@ PyFloatObject represents a (double precision) floating point number.
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     double ob_fval;
 } PyFloatObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyFloat_Type;
 
@@ -45,8 +47,11 @@ PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double);
 /* Extract C double from Python float.  The macro version trades safety for
    speed. */
 PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
+#ifndef Py_LIMITED_API
 #define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
+#endif
 
+#ifndef Py_LIMITED_API
 /* _PyFloat_{Pack,Unpack}{4,8}
  *
  * The struct and pickle (at least) modules need an efficient platform-
@@ -110,6 +115,7 @@ PyAPI_FUNC(int) PyFloat_ClearFreeList(void);
 PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj,
                                               Py_UNICODE *format_spec,
                                               Py_ssize_t format_spec_len);
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 }
index 944097397117229ea003328e47375b8b80b50e0d..1fb64bb2681b83e5148b4133bdbeb4416664cd28 100644 (file)
@@ -1,6 +1,7 @@
 
 /* Frame object interface */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_FRAMEOBJECT_H
 #define Py_FRAMEOBJECT_H
 #ifdef __cplusplus
@@ -85,3 +86,4 @@ PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
 }
 #endif
 #endif /* !Py_FRAMEOBJECT_H */
+#endif /* Py_LIMITED_API */
index 058c6bff36c980b5beec1dad4fc7acf4753ab07f..521d87bf9f16ffad9556ef79eac50c9f7be4dd98 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Function object interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_FUNCOBJECT_H
 #define Py_FUNCOBJECT_H
 #ifdef __cplusplus
@@ -84,3 +84,4 @@ PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
 }
 #endif
 #endif /* !Py_FUNCOBJECT_H */
+#endif /* Py_LIMITED_API */
index 135561b701b025804016c6bf0c181e013214ff1d..d29fb1ed1dfcbd2e9a90d598876b7c5a7fd76c24 100644 (file)
@@ -1,6 +1,7 @@
 
 /* Generator object interface */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_GENOBJECT_H
 #define Py_GENOBJECT_H
 #ifdef __cplusplus
@@ -38,3 +39,4 @@ PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
 }
 #endif
 #endif /* !Py_GENOBJECT_H */
+#endif /* Py_LIMITED_API */
index 3e81e78a8b51071ffb446fa9391dd9542c36fe50..2df94ff11ca87a1b43773f58283a6d340154b454 100644 (file)
@@ -30,6 +30,7 @@ PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
 PyAPI_FUNC(void) PyImport_Cleanup(void);
 PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *);
 
+#ifndef Py_LIMITED_API
 #ifdef WITH_THREAD
 PyAPI_FUNC(void) _PyImport_AcquireLock(void);
 PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
@@ -49,13 +50,15 @@ struct _inittab {
     char *name;
     PyObject* (*initfunc)(void);
 };
+PyAPI_DATA(struct _inittab *) PyImport_Inittab;
+PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
-PyAPI_DATA(struct _inittab *) PyImport_Inittab;
 
 PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, PyObject* (*initfunc)(void));
-PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
 
+#ifndef Py_LIMITED_API
 struct _frozen {
     char *name;
     unsigned char *code;
@@ -66,6 +69,7 @@ struct _frozen {
    collection of frozen modules: */
 
 PyAPI_DATA(struct _frozen *) PyImport_FrozenModules;
+#endif
 
 #ifdef __cplusplus
 }
index 755fbbea8fa4295bbc9438aa530a7c35410fa371..949b1a3e3191910637ce1830dcbddb08567a6715 100644 (file)
@@ -19,6 +19,7 @@ returned item's reference count.
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     /* Vector of pointers to list elements.  list[0] is ob_item[0], etc. */
@@ -37,6 +38,7 @@ typedef struct {
      */
     Py_ssize_t allocated;
 } PyListObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyList_Type;
 PyAPI_DATA(PyTypeObject) PyListIter_Type;
@@ -58,12 +60,16 @@ PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
 PyAPI_FUNC(int) PyList_Sort(PyObject *);
 PyAPI_FUNC(int) PyList_Reverse(PyObject *);
 PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
+#endif
 
 /* Macro, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i])
 #define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v))
 #define PyList_GET_SIZE(op)    Py_SIZE(op)
+#endif
 
 #ifdef __cplusplus
 }
index 3d71a35e7374a5ed459990a8575d615bed8de34f..b94f7b2e2c5cccb8e4562a7d13785351ad34d594 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_LONGINTREPR_H
 #define Py_LONGINTREPR_H
 #ifdef __cplusplus
@@ -99,3 +100,4 @@ PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);
 }
 #endif
 #endif /* !Py_LONGINTREPR_H */
+#endif /* Py_LIMITED_API */
index 6adf2620d2d47ccd2696ed322ff381a4eaceb32f..c09565a117904ea04433985472cddf28b46680fd 100644 (file)
@@ -50,7 +50,9 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
 #endif /* SIZEOF_PID_T */
 
 /* Used by Python/mystrtoul.c. */
+#ifndef Py_LIMITED_API
 PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
+#endif
 
 /* _PyLong_Frexp returns a double x and an exponent e such that the
    true value is approximately equal to x * 2**e.  e is >= 0.  x is
@@ -58,7 +60,9 @@ PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
    zeroes); otherwise, 0.5 <= abs(x) < 1.0.  On overflow, which is
    possible if the number of bits doesn't fit into a Py_ssize_t, sets
    OverflowError and returns -1.0 for x, 0 for e. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
+#endif
 
 PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
 PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
@@ -74,8 +78,11 @@ PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *);
 #endif /* HAVE_LONG_LONG */
 
 PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
+#endif
 
+#ifndef Py_LIMITED_API
 /* _PyLong_Sign.  Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
    v must not be NULL, and must be a normalized long.
    There are no error cases.
@@ -150,6 +157,7 @@ PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base);
 PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj,
                                              Py_UNICODE *format_spec,
                                              Py_ssize_t format_spec_len);
+#endif /* Py_LIMITED_API */
 
 /* These aren't really part of the long object, but they're handy. The
    functions are in Python/mystrtoul.c.
index 411fdca36762554db242dd7f9257f107e8dd2653..e96d062b18bac2f797b34d802d071dc94735b11d 100644 (file)
@@ -13,10 +13,12 @@ PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
 PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
 PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
 PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
 PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
 PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
+#endif
 PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t);
 
 #ifdef __cplusplus
index 5bbfb05ab57ffa36195491ae5f7004ab279d33c6..f763531b382601fe239758f72ff8a38cae9bbc47 100644 (file)
@@ -10,10 +10,12 @@ PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
 
 #define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type)
 
+#ifndef Py_LIMITED_API
 /* Get a pointer to the underlying Py_buffer of a memoryview object. */
 #define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
 /* Get a pointer to the PyObject from which originates a memoryview object. */
 #define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
+#endif
 
 
 PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, 
@@ -61,11 +63,12 @@ PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info);
 /* The struct is declared here so that macros can work, but it shouldn't
    be considered public. Don't access those fields directly, use the macros
    and functions instead! */
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     Py_buffer view;
 } PyMemoryViewObject;
-
+#endif
 
 #ifdef __cplusplus
 }
index 81e84ceae4d4150bd36ab7508be02558143219bf..7e67c0bf9aab716a46072b22148e72863c82fbaf 100644 (file)
@@ -26,12 +26,14 @@ PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
 
 /* Macros for direct access to these values. Type checks are *not*
    done, so use with care. */
+#ifndef Py_LIMITED_API
 #define PyCFunction_GET_FUNCTION(func) \
         (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
 #define PyCFunction_GET_SELF(func) \
        (((PyCFunctionObject *)func) -> m_self)
 #define PyCFunction_GET_FLAGS(func) \
        (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
+#endif
 PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
 
 struct PyMethodDef {
@@ -68,12 +70,14 @@ PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
 
 #define METH_COEXIST   0x0040
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     PyMethodDef *m_ml; /* Description of the C function to call */
     PyObject    *m_self; /* Passed as 'self' arg to the C func, can be NULL */
     PyObject    *m_module; /* The __module__ attribute, can be anything */
 } PyCFunctionObject;
+#endif
 
 PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
 
index 57886df8905e3cd57d1c8412661e5510720bdd1f..bf6478f4c2c5f15efa97bdf4f7bab2a29e48a2a9 100644 (file)
@@ -31,7 +31,9 @@ PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
 PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
 PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
 PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
+#endif
 
 PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
 PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
@@ -92,6 +94,12 @@ PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char
    9-Jan-1995  GvR     Initial version (incompatible with older API)
 */
 
+/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
+   Python 3, it will stay at the value of 3; changes to the limited API
+   must be performed in a strictly backwards-compatible manner. */
+#define PYTHON_ABI_VERSION 3
+#define PYTHON_ABI_STRING "3"
+
 #ifdef Py_TRACE_REFS
  /* When we are tracing reference counts, rename PyModule_Create2 so
     modules compiled with incompatible settings will generate a
@@ -102,10 +110,17 @@ PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char
 PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
                                      int apiver);
 
+#ifdef Py_LIMITED_API
+#define PyModule_Create(module) \
+       PyModule_Create2(module, PYTHON_ABI_VERSION)
+#else
 #define PyModule_Create(module) \
        PyModule_Create2(module, PYTHON_API_VERSION)
+#endif
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(char *) _Py_PackageContext;
+#endif
 
 #ifdef __cplusplus
 }
index 34fa8109326d83397890714ebe03268b62755fa8..338cf4bb93acbf7dcfedd155b45663be4aade7fe 100644 (file)
@@ -17,7 +17,9 @@ PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
 PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
 PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
 PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
+#endif
 PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
 PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
 
index bc528fdee1ffee27e00d1353f19bf4cd6ec1ad29..78bb13bfc7e82665ccaa0b19db848e2639b5e257 100644 (file)
@@ -61,6 +61,10 @@ whose size is determined when the object is allocated.
 #define Py_REF_DEBUG
 #endif
 
+#if defined(Py_LIMITED_API) && defined(Py_REF_DEBUG)
+#error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG
+#endif
+
 #ifdef Py_TRACE_REFS
 /* Define pointers to support a doubly-linked list of all live heap objects. */
 #define _PyObject_HEAD_EXTRA            \
@@ -196,6 +200,7 @@ typedef int (*objobjproc)(PyObject *, PyObject *);
 typedef int (*visitproc)(PyObject *, void *);
 typedef int (*traverseproc)(PyObject *, visitproc, void *);
 
+#ifndef Py_LIMITED_API
 typedef struct {
     /* Number implementations must check *both*
        arguments for proper type and implement the necessary conversions
@@ -265,10 +270,17 @@ typedef struct {
      getbufferproc bf_getbuffer;
      releasebufferproc bf_releasebuffer;
 } PyBufferProcs;
+#endif /* Py_LIMITED_API */
 
 typedef void (*freefunc)(void *);
 typedef void (*destructor)(PyObject *);
+#ifndef Py_LIMITED_API
+/* We can't provide a full compile-time check that limited-API
+   users won't implement tp_print. However, not defining printfunc
+   and making tp_print of a different function pointer type
+   should at least cause a warning in most cases. */
 typedef int (*printfunc)(PyObject *, FILE *, int);
+#endif
 typedef PyObject *(*getattrfunc)(PyObject *, char *);
 typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
 typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
@@ -284,6 +296,9 @@ typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
 typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *);
 typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t);
 
+#ifdef Py_LIMITED_API
+typedef struct _typeobject PyTypeObject; /* opaque */
+#else
 typedef struct _typeobject {
     PyObject_VAR_HEAD
     const char *tp_name; /* For printing, in format "<module>.<name>" */
@@ -371,8 +386,25 @@ typedef struct _typeobject {
     struct _typeobject *tp_next;
 #endif
 } PyTypeObject;
+#endif
 
+typedef struct{
+    int slot;    /* slot id, see below */
+    void *pfunc; /* function pointer */
+} PyType_Slot;
 
+typedef struct{
+    const char* name;
+    const char* doc;
+    int basicsize;
+    int itemsize;
+    int flags;
+    PyType_Slot *slots; /* terminated by slot==0. */
+} PyType_Spec;
+
+PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
+
+#ifndef Py_LIMITED_API
 /* The *real* layout of a type object when allocated on the heap */
 typedef struct _heaptypeobject {
     /* Note: there's a dependency on the order of these members
@@ -393,7 +425,7 @@ typedef struct _heaptypeobject {
 /* access macro to the members which are floating "behind" the object */
 #define PyHeapType_GET_MEMBERS(etype) \
     ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
-
+#endif
 
 /* Generic type check */
 PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
@@ -412,15 +444,19 @@ PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
 PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
 PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
                                                PyObject *, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
 PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, char *, PyObject **);
+#endif
 PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
 PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);
 
 /* Generic operations on objects */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
 PyAPI_FUNC(void) _Py_BreakPoint(void);
 PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
 PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *);
@@ -433,9 +469,13 @@ PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *);
 PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
+#endif
 PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
 PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *,
                                               PyObject *, PyObject *);
@@ -469,8 +509,10 @@ PyAPI_FUNC(int) Py_ReprEnter(PyObject *);
 PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
 
 /* Helpers for hash functions */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_hash_t) _Py_HashDouble(double);
 PyAPI_FUNC(Py_hash_t) _Py_HashPointer(void*);
+#endif
 
 /* Helper for passing objects to printf and the like */
 #define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
@@ -649,9 +691,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
 
 #define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
 
+#ifdef Py_LIMITED_API
+PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
+#else
 #define _Py_Dealloc(op) (                               \
     _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA          \
     (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op)))
+#endif
 #endif /* !Py_TRACE_REFS */
 
 #define Py_INCREF(op) (                         \
index 29800314de19520680cbb3b2f479e2c5c03d3247..3fef376d61c44ad7cc096094a32ad49a65df7671 100644 (file)
@@ -246,6 +246,7 @@ PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
 #define _PyObject_GC_Del PyObject_GC_Del
 
 /* GC information is stored BEFORE the object structure. */
+#ifndef Py_LIMITED_API
 typedef union _gc_head {
     struct {
         union _gc_head *gc_next;
@@ -298,7 +299,7 @@ extern PyGC_Head *_PyGC_generation0;
 #define _PyObject_GC_MAY_BE_TRACKED(obj) \
     (PyObject_IS_GC(obj) && \
         (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj)))
-
+#endif /* Py_LIMITED_API */
 
 PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t);
 PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
index af805705db8c34d281808c5e784586f942dc8761..d183784801a896c230a877b8c671e2dc519f6a3a 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Parser-tokenizer link interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_PARSETOK_H
 #define Py_PARSETOK_H
 #ifdef __cplusplus
@@ -64,3 +64,4 @@ PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
 }
 #endif
 #endif /* !Py_PARSETOK_H */
+#endif /* !Py_LIMITED_API */
index 5f193feceeaa25bd8644454156703b680d63db59..db3ad0188fe1cd9f685d7c27d3869adae912d574 100644 (file)
@@ -1,6 +1,7 @@
 /* An arena-like memory interface for the compiler.
  */
 
+#ifndef Py_LIMITED_API
 #ifndef Py_PYARENA_H
 #define Py_PYARENA_H
 
@@ -60,3 +61,4 @@ extern "C" {
 #endif
 
 #endif /* !Py_PYARENA_H */
+#endif /* Py_LIMITED_API */
index 7d3449d7e1e1a7553e0def4b708c7e79c27a0e1a..b0028fd92fa37c6fe086658e3e822b4476290778 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_ATOMIC_H
 #define Py_ATOMIC_H
 /* XXX: When compilers start offering a stdatomic.h with lock-free
@@ -177,3 +178,4 @@ _Py_ANNOTATE_MEMORY_ORDER(const volatile void *address, _Py_memory_order order)
 #endif
 
 #endif  /* Py_ATOMIC_H */
+#endif  /* Py_LIMITED_API */
index c5cc61431d08e0cc8e3b58511b4d618b154c42de..787c1b9a11177c7c3e08bd0f5e9035716cc09c74 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef PYCTYPE_H
 #define PYCTYPE_H
 
@@ -29,3 +30,4 @@ extern const unsigned char _Py_ctype_toupper[256];
 #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
 
 #endif /* !PYCTYPE_H */
+#endif /* !Py_LIMITED_API */
index 0a31f5ba01e1aa47aa01b1f845b53d544232c47d..1cbb342e4731fa700a596e2c06eaff7f802108cb 100644 (file)
@@ -1,4 +1,4 @@
-
+#ifndef Py_LIMITED_API
 #ifndef Py_PYDEBUG_H
 #define Py_PYDEBUG_H
 #ifdef __cplusplus
@@ -31,3 +31,4 @@ PyAPI_FUNC(void) Py_FatalError(const char *message);
 }
 #endif
 #endif /* !Py_PYDEBUG_H */
+#endif /* Py_LIMITED_API */
index f717afa21113fb143eb9c892d021465ed3f5468a..d72ce072610a262994caa5ecf0d724877ecfc06c 100644 (file)
@@ -6,6 +6,7 @@ extern "C" {
 
 /* Error objects */
 
+#ifndef Py_LIMITED_API
 /* PyException_HEAD defines the initial segment of every exception class. */
 #define PyException_HEAD PyObject_HEAD PyObject *dict;\
              PyObject *args; PyObject *traceback;\
@@ -55,6 +56,7 @@ typedef struct {
     PyObject *winerror;
 } PyWindowsErrorObject;
 #endif
+#endif
 
 /* Error handling definitions */
 
@@ -68,8 +70,9 @@ PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
 PyAPI_FUNC(void) PyErr_Clear(void);
 PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
 PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
+PyAPI_FUNC(void) Py_FatalError(const char *message);
 
-#ifdef Py_DEBUG
+#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
 #define _PyErr_OCCURRED() PyErr_Occurred()
 #else
 #define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type)
@@ -183,7 +186,7 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
     PyObject *exc,
     const char *filename   /* decoded from the filesystem encoding */
     );
-#ifdef MS_WINDOWS
+#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
 PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
     PyObject *, const Py_UNICODE *);
 #endif /* MS_WINDOWS */
@@ -199,15 +202,20 @@ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject(
     int, const char *);
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
     int, const char *);
+#ifndef Py_LIMITED_API
+/* XXX redeclare to use WSTRING */
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
     int, const Py_UNICODE *);
+#endif
 PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
     PyObject *,int, PyObject *);
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
     PyObject *,int, const char *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
     PyObject *,int, const Py_UNICODE *);
+#endif
 PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
 #endif /* MS_WINDOWS */
 
@@ -230,7 +238,9 @@ PyAPI_FUNC(int) PyErr_CheckSignals(void);
 PyAPI_FUNC(void) PyErr_SetInterrupt(void);
 
 /* In signalmodule.c */
+#ifndef Py_LIMITED_API
 int PySignal_SetWakeupFd(int fd);
+#endif
 
 /* Support for adding program text to SyntaxErrors */
 PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int);
@@ -245,12 +255,16 @@ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
     const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
 
 /* create a UnicodeEncodeError object */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
     const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+#endif
 
 /* create a UnicodeTranslateError object */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
     const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *);
+#endif
 
 /* get the encoding attribute */
 PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
index 19e3fd1d301ec3f8d985ef9cbc24f93a8572062c..4de8c0045d9366f2ff77668c83713bcd3c30ed76 100644 (file)
@@ -5,9 +5,11 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(int) _PyOS_opterr;
 PyAPI_DATA(int) _PyOS_optind;
 PyAPI_DATA(wchar_t *) _PyOS_optarg;
+#endif
 
 PyAPI_FUNC(int) _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring);
 
index e3cf22b823740e2046d8c0132d31cc9a993a86c7..b4eda66e6e270444d23905580fb55b9b29120608 100644 (file)
@@ -67,6 +67,7 @@ extern double copysign(double, double);
    nothing. */
 
 /* we take double rounding as evidence of x87 usage */
+#ifndef Py_LIMITED_API
 #ifndef Py_FORCE_DOUBLE
 #  ifdef X87_DOUBLE_ROUNDING
 PyAPI_FUNC(double) _Py_force_double(double);
@@ -75,11 +76,14 @@ PyAPI_FUNC(double) _Py_force_double(double);
 #    define Py_FORCE_DOUBLE(X) (X)
 #  endif
 #endif
+#endif
 
+#ifndef Py_LIMITED_API
 #ifdef HAVE_GCC_ASM_FOR_X87
 PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);
 PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
 #endif
+#endif
 
 /* Py_IS_NAN(X)
  * Return 1 if float or double arg is a NaN, else 0.
index 7b6b60294b4ee17653cd35ce9cf9aaaf803dab6d..50245c2c0adf1803662fa6a60b33a62425901e7d 100644 (file)
@@ -13,6 +13,9 @@ extern "C" {
 struct _ts; /* Forward */
 struct _is; /* Forward */
 
+#ifdef Py_LIMITED_API
+typedef struct _is PyInterpreterState;
+#else
 typedef struct _is {
 
     struct _is *next;
@@ -37,12 +40,14 @@ typedef struct _is {
 #endif
 
 } PyInterpreterState;
+#endif
 
 
 /* State unique per thread */
 
 struct _frame; /* Avoid including frameobject.h */
 
+#ifndef Py_LIMITED_API
 /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
 typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
 
@@ -54,7 +59,11 @@ typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *);
 #define PyTrace_C_CALL 4
 #define PyTrace_C_EXCEPTION 5
 #define PyTrace_C_RETURN 6
+#endif
 
+#ifdef Py_LIMITED_API
+typedef struct _ts PyThreadState;
+#else
 typedef struct _ts {
     /* See Python/ceval.c for comments explaining most fields */
 
@@ -106,6 +115,7 @@ typedef struct _ts {
     /* XXX signal handlers should also be here */
 
 } PyThreadState;
+#endif
 
 
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
@@ -133,9 +143,11 @@ PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
 
 /* Assuming the current thread holds the GIL, this is the
    PyThreadState for the current thread. */
+#ifndef Py_LIMITED_API
 PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
+#endif
 
-#ifdef Py_DEBUG
+#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
 #define PyThreadState_GET() PyThreadState_Get()
 #else
 #define PyThreadState_GET() \
@@ -190,19 +202,25 @@ PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
 /* The implementation of sys._current_frames()  Returns a dict mapping
    thread id to that thread's current frame.
 */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
+#endif
 
 /* Routines for advanced debuggers, requested by David Beazley.
    Don't use unless you know what you are doing! */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
 PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
 PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
 
 typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
+#endif
 
 /* hook for PyEval_GetFrame(), requested for Psyco */
+#ifndef Py_LIMITED_API
 PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
+#endif
 
 #ifdef __cplusplus
 }
index d7bae122343f813b1a0100f40a075eec2e9736df..23fd1c62551c039ee554e66d0db0ce2fe4a5486a 100644 (file)
@@ -18,7 +18,9 @@ PyAPI_FUNC(char *) PyOS_double_to_string(double val,
                                          int flags,
                                          int *type);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr);
+#endif
 
 
 /* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */
index 108b6473799f766588f1cf21b96466811f812cf4..95bdf9e219e1d48940fe6632173ba0970783c808 100644 (file)
@@ -16,9 +16,11 @@ extern "C" {
 #define PyCF_ONLY_AST 0x0400
 #define PyCF_IGNORE_COOKIE 0x0800
 
+#ifndef Py_LIMITED_API
 typedef struct {
     int cf_flags;  /* bitmask of CO_xxx flags relevant to future */
 } PyCompilerFlags;
+#endif
 
 PyAPI_FUNC(void) Py_SetProgramName(wchar_t *);
 PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
@@ -33,9 +35,10 @@ PyAPI_FUNC(int) Py_IsInitialized(void);
 PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
 PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
 
+#ifndef Py_LIMITED_API
+PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
 PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
 PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
-PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
 PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *);
 PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *);
 PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *);
@@ -48,25 +51,35 @@ PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *,
                                                char *, char *,
                                                PyCompilerFlags *, int *,
                                                PyArena *);
+#endif
+
+#ifndef PyParser_SimpleParseString
 #define PyParser_SimpleParseString(S, B) \
     PyParser_SimpleParseStringFlags(S, B, 0)
 #define PyParser_SimpleParseFile(FP, S, B) \
     PyParser_SimpleParseFileFlags(FP, S, B, 0)
+#endif
 PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
                                                           int);
 PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
                                                         int, int);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
                                          PyObject *, PyCompilerFlags *);
 
 PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int,
                                          PyObject *, PyObject *, int,
                                          PyCompilerFlags *);
+#endif
 
+#ifdef Py_LIMITED_API
+PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int);
+#else
 #define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL)
 PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int,
                                              PyCompilerFlags *);
+#endif
 PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int);
 
 PyAPI_FUNC(void) PyErr_Print(void);
@@ -76,19 +89,24 @@ PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
 /* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
  * exit functions.
  */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(void));
+#endif
 PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
 
 PyAPI_FUNC(void) Py_Exit(int);
 
 /* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _Py_RestoreSignals(void);
 
 PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
+#endif
 
 /* Bootstrap */
 PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
 
+#ifndef Py_LIMITED_API
 /* Use macros for a bunch of old variants */
 #define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL)
 #define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL)
@@ -107,6 +125,7 @@ PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
     PyRun_FileExFlags(fp, p, s, g, l, c, NULL)
 #define PyRun_FileFlags(fp, p, s, g, l, flags) \
     PyRun_FileExFlags(fp, p, s, g, l, 0, flags)
+#endif
 
 /* In getpath.c */
 PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
@@ -114,6 +133,9 @@ PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
 PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
 PyAPI_FUNC(wchar_t *) Py_GetPath(void);
 PyAPI_FUNC(void)      Py_SetPath(const wchar_t *);
+#ifdef MS_WINDOWS
+int _Py_CheckPython3();
+#endif
 
 /* In their own files */
 PyAPI_FUNC(const char *) Py_GetVersion(void);
@@ -121,11 +143,14 @@ PyAPI_FUNC(const char *) Py_GetPlatform(void);
 PyAPI_FUNC(const char *) Py_GetCopyright(void);
 PyAPI_FUNC(const char *) Py_GetCompiler(void);
 PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(const char *) _Py_svnversion(void);
 PyAPI_FUNC(const char *) Py_SubversionRevision(void);
 PyAPI_FUNC(const char *) Py_SubversionShortBranch(void);
+#endif
 
 /* Internal -- various one-time initializations */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
 PyAPI_FUNC(PyObject *) _PySys_Init(void);
 PyAPI_FUNC(void) _PyImport_Init(void);
@@ -134,8 +159,10 @@ PyAPI_FUNC(void) _PyImportHooks_Init(void);
 PyAPI_FUNC(int) _PyFrame_Init(void);
 PyAPI_FUNC(void) _PyFloat_Init(void);
 PyAPI_FUNC(int) PyByteArray_Init(void);
+#endif
 
 /* Various internal finalizers */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyExc_Fini(void);
 PyAPI_FUNC(void) _PyImport_Fini(void);
 PyAPI_FUNC(void) PyMethod_Fini(void);
@@ -150,12 +177,17 @@ PyAPI_FUNC(void) PyByteArray_Fini(void);
 PyAPI_FUNC(void) PyFloat_Fini(void);
 PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
 PyAPI_FUNC(void) _PyGC_Fini(void);
+#endif
 
 /* Stuff with no proper home (yet) */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *);
+#endif
 PyAPI_DATA(int) (*PyOS_InputHook)(void);
 PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *);
+#ifndef Py_LIMITED_API
 PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
+#endif
 
 /* Stack size, in "pointers" (so we get extra safety margins
    on 64-bit platforms).  On a 32-bit platform, this translates
index 964d0968b0b07fcbfd25fb34574ff655c1a1f69a..d707bdb9a87c7c31cec598fab828f86a8c3ef217 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_PYTIME_H
 #define Py_PYTIME_H
 
@@ -44,3 +45,4 @@ PyAPI_FUNC(void) _PyTime_Init(void);
 #endif
 
 #endif /* Py_PYTIME_H */
+#endif /* Py_LIMITED_API */
index 023c5fa758182567da7a2dd078836cb67dda87da..623411101d5ba8506a9f07cf8a91042ab4bd3339 100644 (file)
@@ -18,7 +18,7 @@ Note: .pop() abuses the hash field of an Unused or Dummy slot to
 hold a search finger.  The hash field of Unused or Dummy slots has
 no meaning otherwise.
 */
-
+#ifndef Py_LIMITED_API
 #define PySet_MINSIZE 8
 
 typedef struct {
@@ -56,6 +56,7 @@ struct _setobject {
     Py_hash_t hash;                  /* only used by frozenset objects */
     PyObject *weakreflist;      /* List of weak references */
 };
+#endif /* Py_LIMITED_API */
 
 PyAPI_DATA(PyTypeObject) PySet_Type;
 PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
@@ -85,14 +86,20 @@ PyAPI_DATA(PyTypeObject) PySetIter_Type;
 PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
 PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
 PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
+#ifndef Py_LIMITED_API
 #define PySet_GET_SIZE(so) (((PySetObject *)(so))->used)
+#endif
 PyAPI_FUNC(int) PySet_Clear(PyObject *set);
 PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
 PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
 PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
+#endif
 PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
+#endif
 
 #ifdef __cplusplus
 }
index 8ab62dd4f8f37276ddf46b5672a544636a1e7614..8bec17909d676b275688d3fd366a7a2c73eab6e0 100644 (file)
@@ -18,11 +18,12 @@ A slice object containing start, stop, and step data members (the
 names are from range).  After much talk with Guido, it was decided to
 let these be any arbitrary python type.  Py_None stands for omitted values.
 */
-
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     PyObject *start, *stop, *step;     /* not NULL */
 } PySliceObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PySlice_Type;
 PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
@@ -31,10 +32,12 @@ PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
 
 PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
                                   PyObject* step);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
-PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
+#endif
+PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
                                   Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
-PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
+PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
                                    Py_ssize_t *start, Py_ssize_t *stop, 
                                    Py_ssize_t *step, Py_ssize_t *slicelength);
 
index a5d7b2e07f7af3bdfa1bcecc629880591bd6d0d7..30c52aca9bac0af030c7eb245116ab844983d179 100644 (file)
@@ -21,18 +21,25 @@ typedef struct PyStructSequence_Desc {
 
 extern char* PyStructSequence_UnnamedField;
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
                                            PyStructSequence_Desc *desc);
+#endif
+PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
 
 PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
 
+#ifndef Py_LIMITED_API
 typedef PyTupleObject PyStructSequence;
 
 /* Macro, *only* to be used to fill in brand new objects */
 #define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v)
 
 #define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
+#endif
 
+PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
+PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
 
 #ifdef __cplusplus
 }
index 9b1b75b8237160f6b422e5d4131936ceb88b0751..2ad204dd03600702bacc23b7c8d252f5142b777f 100644 (file)
@@ -1,3 +1,4 @@
+#ifndef Py_LIMITED_API
 #ifndef Py_SYMTABLE_H
 #define Py_SYMTABLE_H
 
@@ -102,3 +103,4 @@ PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
 }
 #endif
 #endif /* !Py_SYMTABLE_H */
+#endif /* Py_LIMITED_API */
index c00901b1798aa8ae54757d015d22b97cc59be6d8..010e6e080a94dc1c2e4a73362bf09f963d526513 100644 (file)
@@ -20,7 +20,9 @@ PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
 PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...);
 PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...);
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(PyObject *) _PySys_TraceFunc, *_PySys_ProfileFunc;
+#endif
 
 PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
 PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *);
index 553142dba0fcd76f0429ac6de23ddce88628e406..3c4357505ac26dba5e7930fb5247a2a8d33351dc 100644 (file)
@@ -14,7 +14,9 @@ extern "C" {
  * to fit in a time_t.  ValueError is set on return iff the return
  * value is (time_t)-1 and PyErr_Occurred().
  */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x);
+#endif
 
 
 #ifdef __cplusplus
index 9c19f5ce9d1d7386f8e050ce747ff1c3b3451941..a462c64db93cd1df957860a387239ecda93d7057 100644 (file)
@@ -1,6 +1,6 @@
 
 /* Token types */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_TOKEN_H
 #define Py_TOKEN_H
 #ifdef __cplusplus
@@ -85,3 +85,4 @@ PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int);
 }
 #endif
 #endif /* !Py_TOKEN_H */
+#endif /* Py_LIMITED_API */
index fc0c586b8906a74c7d6b070da05fed8046b6b397..69e3d05453bb6de04515fad484b427ca5dbc3076 100644 (file)
@@ -8,7 +8,7 @@ extern "C" {
 struct _frame;
 
 /* Traceback interface */
-
+#ifndef Py_LIMITED_API
 typedef struct _traceback {
     PyObject_HEAD
     struct _traceback *tb_next;
@@ -16,10 +16,13 @@ typedef struct _traceback {
     int tb_lasti;
     int tb_lineno;
 } PyTracebackObject;
+#endif
 
 PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
 PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
+#endif
 
 /* Reveal traceback type so we can typecheck traceback objects */
 PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
index 19fe7a53a5855d81f2ddce50b1d74180c0c3fabf..f17b7882bed9e021d39f49d3d0d10994ab0ea74f 100644 (file)
@@ -21,6 +21,7 @@ inserted in the tuple.  Similarly, PyTuple_GetItem does not increment the
 returned item's reference count.
 */
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_VAR_HEAD
     PyObject *ob_item[1];
@@ -30,6 +31,7 @@ typedef struct {
      * the tuple is not yet visible outside the function that builds it.
      */
 } PyTupleObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyTuple_Type;
 PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
@@ -43,16 +45,22 @@ PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
 PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
 PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
 PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
+#endif
 PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
+#endif
 
 /* Macro, trading safety for speed */
+#ifndef Py_LIMITED_API
 #define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i])
 #define PyTuple_GET_SIZE(op)    Py_SIZE(op)
 
 /* Macro, *only* to be used to fill in brand new tuples */
 #define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
+#endif
 
 PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
 
diff --git a/Include/typeslots.h b/Include/typeslots.h
new file mode 100644 (file)
index 0000000..9ab9850
--- /dev/null
@@ -0,0 +1,71 @@
+#define Py_bf_getbuffer 1
+#define Py_bf_releasebuffer 2
+#define Py_mp_ass_subscript 3
+#define Py_mp_length 4
+#define Py_mp_subscript 5
+#define Py_nb_absolute 6
+#define Py_nb_add 7
+#define Py_nb_and 8
+#define Py_nb_bool 9
+#define Py_nb_divmod 10
+#define Py_nb_float 11
+#define Py_nb_floor_divide 12
+#define Py_nb_index 13
+#define Py_nb_inplace_add 14
+#define Py_nb_inplace_and 15
+#define Py_nb_inplace_floor_divide 16
+#define Py_nb_inplace_lshift 17
+#define Py_nb_inplace_multiply 18
+#define Py_nb_inplace_or 19
+#define Py_nb_inplace_power 20
+#define Py_nb_inplace_remainder 21
+#define Py_nb_inplace_rshift 22
+#define Py_nb_inplace_subtract 23
+#define Py_nb_inplace_true_divide 24
+#define Py_nb_inplace_xor 25
+#define Py_nb_int 26
+#define Py_nb_invert 27
+#define Py_nb_lshift 28
+#define Py_nb_multiply 29
+#define Py_nb_negative 30
+#define Py_nb_or 31
+#define Py_nb_positive 32
+#define Py_nb_power 33
+#define Py_nb_remainder 34
+#define Py_nb_rshift 35
+#define Py_nb_subtract 36
+#define Py_nb_true_divide 37
+#define Py_nb_xor 38
+#define Py_sq_ass_item 39
+#define Py_sq_concat 40
+#define Py_sq_contains 41
+#define Py_sq_inplace_concat 42
+#define Py_sq_inplace_repeat 43
+#define Py_sq_item 44
+#define Py_sq_length 45
+#define Py_sq_repeat 46
+#define Py_tp_alloc 47
+#define Py_tp_base 48
+#define Py_tp_bases 49
+#define Py_tp_call 50
+#define Py_tp_clear 51
+#define Py_tp_dealloc 52
+#define Py_tp_del 53
+#define Py_tp_descr_get 54
+#define Py_tp_descr_set 55
+#define Py_tp_doc 56
+#define Py_tp_getattr 57
+#define Py_tp_getattro 58
+#define Py_tp_hash 59
+#define Py_tp_init 60
+#define Py_tp_is_gc 61
+#define Py_tp_iter 62
+#define Py_tp_iternext 63
+#define Py_tp_methods 64
+#define Py_tp_new 65
+#define Py_tp_repr 66
+#define Py_tp_richcompare 67
+#define Py_tp_setattr 68
+#define Py_tp_setattro 69
+#define Py_tp_str 70
+#define Py_tp_traverse 71
index 69b7774a97fc51f4d86ff771b46b7dff22a423a7..70fdf130694d89002d096aa503fa3e17dcd43cbe 100644 (file)
@@ -1,5 +1,5 @@
 /* Unicode name database interface */
-
+#ifndef Py_LIMITED_API
 #ifndef Py_UCNHASH_H
 #define Py_UCNHASH_H
 #ifdef __cplusplus
@@ -31,3 +31,4 @@ typedef struct {
 }
 #endif
 #endif /* !Py_UCNHASH_H */
+#endif /* !Py_LIMITED_API */
index 2a207797f30adaee0bb3836b2780a2472d611064..116bb8258faa0f501bae9a252dba8272962de796 100644 (file)
@@ -131,7 +131,9 @@ typedef unsigned long Py_UCS4;
    Python and represents a single Unicode element in the Unicode
    type. */
 
+#ifndef Py_LIMITED_API
 typedef PY_UNICODE_TYPE Py_UNICODE;
+#endif
 
 /* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */
 
@@ -318,6 +320,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
    _Py_ascii_whitespace (see below) with an inlined check.
 
  */
+#ifndef Py_LIMITED_API
 #define Py_UNICODE_ISSPACE(ch) \
     ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
 
@@ -362,6 +365,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
     ((*((string)->str + (offset)) == *((substring)->str)) && \
     ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \
      !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE)))
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 extern "C" {
@@ -369,6 +373,7 @@ extern "C" {
 
 /* --- Unicode Type ------------------------------------------------------- */
 
+#ifndef Py_LIMITED_API
 typedef struct {
     PyObject_HEAD
     Py_ssize_t length;          /* Length of raw Unicode data in buffer */
@@ -381,6 +386,7 @@ typedef struct {
                                    string, or NULL; this is used for
                                    implementing the buffer protocol */
 } PyUnicodeObject;
+#endif
 
 PyAPI_DATA(PyTypeObject) PyUnicode_Type;
 PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
@@ -394,6 +400,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
 #define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type)
 
 /* Fast access macros */
+#ifndef Py_LIMITED_API
 #define PyUnicode_GET_SIZE(op) \
     (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->length))
 #define PyUnicode_GET_DATA_SIZE(op) \
@@ -402,6 +409,7 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
     (assert(PyUnicode_Check(op)),(((PyUnicodeObject *)(op))->str))
 #define PyUnicode_AS_DATA(op) \
     (assert(PyUnicode_Check(op)),((const char *)((PyUnicodeObject *)(op))->str))
+#endif
 
 /* --- Constants ---------------------------------------------------------- */
 
@@ -426,10 +434,12 @@ PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
 
    The buffer is copied into the new object. */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
     const Py_UNICODE *u,        /* Unicode buffer */
     Py_ssize_t size             /* size of buffer */
     );
+#endif
 
 /* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */
 PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize(
@@ -446,9 +456,11 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromString(
 /* Return a read-only pointer to the Unicode object's internal
    Py_UNICODE buffer. */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
     PyObject *unicode           /* Unicode object */
     );
+#endif
 
 /* Get the length of the Unicode object. */
 
@@ -456,8 +468,10 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 /* Get the maximum ordinal for a Unicode character. */
 PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void);
+#endif
 
 /* Resize an already allocated Unicode object to the new size length.
 
@@ -527,16 +541,20 @@ PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(
     ...
     );
 
+#ifndef Py_LIMITED_API
 /* Format the object based on the format_spec, as defined in PEP 3101
    (Advanced String Formatting). */
 PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj,
                                                  Py_UNICODE *format_spec,
                                                  Py_ssize_t format_spec_len);
+#endif
 
 PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **);
 PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **);
 PyAPI_FUNC(PyObject *) PyUnicode_InternFromString(const char *);
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(void) _Py_ReleaseInternedUnicodeStrings(void);
+#endif
 
 /* Use only if you know it's a string */
 #define PyUnicode_CHECK_INTERNED(op) (((PyUnicodeObject *)(op))->state)
@@ -568,7 +586,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar(
    error. */
 
 PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
-    PyUnicodeObject *unicode,   /* Unicode object */
+    PyObject *unicode,          /* Unicode object */
     register wchar_t *w,        /* wchar_t buffer */
     Py_ssize_t size             /* size of buffer */
     );
@@ -646,9 +664,11 @@ PyAPI_FUNC(int) PyUnicode_ClearFreeList(void);
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
     PyObject *unicode,
     const char *errors);
+#endif
 
 /* Returns a pointer to the default encoding (UTF-8) of the
    Unicode object unicode and the size of the encoded representation
@@ -664,9 +684,11 @@ PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) _PyUnicode_AsStringAndSize(
     PyObject *unicode,
     Py_ssize_t *size);
+#endif
 
 /* Returns a pointer to the default encoding (UTF-8) of the
    Unicode object unicode.
@@ -682,7 +704,9 @@ PyAPI_FUNC(char *) _PyUnicode_AsStringAndSize(
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(char *) _PyUnicode_AsString(PyObject *unicode);
+#endif
 
 /* Returns "utf-8".  */
 
@@ -721,12 +745,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode(
 /* Encodes a Py_UNICODE buffer of the given size and returns a
    Python string object. */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_Encode(
     const Py_UNICODE *s,        /* Unicode char buffer */
     Py_ssize_t size,            /* number of Py_UNICODE chars to encode */
     const char *encoding,       /* encoding */
     const char *errors          /* error handling */
     );
+#endif
 
 /* Encodes a Unicode object and returns the result as Python
    object. */
@@ -776,6 +802,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful(
     Py_ssize_t *consumed        /* bytes consumed */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
@@ -783,6 +810,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
     int base64WhiteSpace,       /* Encode whitespace (sp, ht, nl, cr) in base64 */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- UTF-8 Codecs ------------------------------------------------------- */
 
@@ -803,11 +831,13 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- UTF-32 Codecs ------------------------------------------------------ */
 
@@ -876,12 +906,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String(
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
     const char *errors,         /* error handling */
     int byteorder               /* byteorder to use 0=BOM+native;-1=LE,1=BE */
     );
+#endif
 
 /* --- UTF-16 Codecs ------------------------------------------------------ */
 
@@ -954,12 +986,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String(
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* number of Py_UNICODE chars to encode */
     const char *errors,         /* error handling */
     int byteorder               /* byteorder to use 0=BOM+native;-1=LE,1=BE */
     );
+#endif
 
 /* --- Unicode-Escape Codecs ---------------------------------------------- */
 
@@ -973,10 +1007,12 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length           /* Number of Py_UNICODE chars to encode */
     );
+#endif
 
 /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */
 
@@ -990,20 +1026,24 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length           /* Number of Py_UNICODE chars to encode */
     );
+#endif
 
 /* --- Unicode Internal Codec ---------------------------------------------
 
     Only for internal use in _codecsmodule.c */
 
+#ifndef Py_LIMITED_API
 PyObject *_PyUnicode_DecodeUnicodeInternal(
     const char *string,
     Py_ssize_t length,
     const char *errors
     );
+#endif
 
 /* --- Latin-1 Codecs -----------------------------------------------------
 
@@ -1021,11 +1061,13 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- ASCII Codecs -------------------------------------------------------
 
@@ -1043,11 +1085,13 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- Character Map Codecs -----------------------------------------------
 
@@ -1085,6 +1129,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString(
                                    (unicode ordinal -> char ordinal) */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
@@ -1092,6 +1137,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
                                    (unicode ordinal -> char ordinal) */
     const char *errors          /* error handling */
     );
+#endif
 
 /* Translate a Py_UNICODE buffer of the given length by applying a
    character mapping table to it and return the resulting Unicode
@@ -1106,12 +1152,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     PyObject *table,            /* Translate table */
     const char *errors          /* error handling */
     );
+#endif
 
 #ifdef MS_WIN32
 
@@ -1134,11 +1182,13 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString(
     PyObject *unicode           /* Unicode object */
     );
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
     const Py_UNICODE *data,     /* Unicode char buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     const char *errors          /* error handling */
     );
+#endif
 
 #endif /* MS_WIN32 */
 
@@ -1166,12 +1216,14 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
 
 */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
     Py_UNICODE *s,              /* Unicode buffer */
     Py_ssize_t length,          /* Number of Py_UNICODE chars to encode */
     char *output,               /* Output buffer; must have size >= length */
     const char *errors          /* error handling */
     );
+#endif
 
 /* --- File system encoding ---------------------------------------------- */
 
@@ -1438,26 +1490,31 @@ PyAPI_FUNC(int) PyUnicode_Contains(
 
 PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s);
 
+#ifndef Py_LIMITED_API
 /* Externally visible for str.strip(unicode) */
 PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
     PyUnicodeObject *self,
     int striptype,
     PyObject *sepobj
     );
+#endif
 
 /* Using the current locale, insert the thousands grouping
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGroupingLocale(Py_UNICODE *buffer,
                                                    Py_ssize_t n_buffer,
                                                    Py_UNICODE *digits,
                                                    Py_ssize_t n_digits,
                                                    Py_ssize_t min_width);
+#endif
 
 /* Using explicit passed-in values, insert the thousands grouping
    into the string pointed to by buffer.  For the argument descriptions,
    see Objects/stringlib/localeutil.h */
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
                                                    Py_ssize_t n_buffer,
                                                    Py_UNICODE *digits,
@@ -1465,10 +1522,12 @@ PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(Py_UNICODE *buffer,
                                                    Py_ssize_t min_width,
                                                    const char *grouping,
                                                    const char *thousands_sep);
+#endif
 /* === Characters Type APIs =============================================== */
 
 /* Helper array used by Py_UNICODE_ISSPACE(). */
 
+#ifndef Py_LIMITED_API
 PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
 
 /* These should not be used directly. Use the Py_UNICODE_IS* and
@@ -1594,6 +1653,7 @@ PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr(
 PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy(
     PyObject *unicode
     );
+#endif /* Py_LIMITED_API */
 
 #ifdef __cplusplus
 }
index c84cb9f27433622cd671b08b489a673a936ea128..82abb1169e1cf6d6565a8d94685b90e8b8f275c5 100644 (file)
@@ -4,7 +4,9 @@
 extern "C" {
 #endif
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(PyObject*) _PyWarnings_Init(void);
+#endif
 
 PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
 PyAPI_FUNC(int) PyErr_WarnFormat(PyObject *, Py_ssize_t, const char *, ...);
@@ -12,7 +14,9 @@ PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
                                     const char *, PyObject *);
 
 /* DEPRECATED: Use PyErr_WarnEx() instead. */
+#ifndef Py_LIMITED_API
 #define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
+#endif
 
 #ifdef __cplusplus
 }
index b201d0814cc8f7d6a0d7e99f202232d52aaaad88..725838726dee385f6cd35986f52d13829741962a 100644 (file)
@@ -12,6 +12,7 @@ typedef struct _PyWeakReference PyWeakReference;
 /* PyWeakReference is the base struct for the Python ReferenceType, ProxyType,
  * and CallableProxyType.
  */
+#ifndef Py_LIMITED_API
 struct _PyWeakReference {
     PyObject_HEAD
 
@@ -37,6 +38,7 @@ struct _PyWeakReference {
     PyWeakReference *wr_prev;
     PyWeakReference *wr_next;
 };
+#endif
 
 PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
 PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
@@ -62,9 +64,11 @@ PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
                                                 PyObject *callback);
 PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
 
+#ifndef Py_LIMITED_API
 PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
 
 PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
+#endif
 
 #define PyWeakref_GET_OBJECT(ref) (((PyWeakReference *)(ref))->wr_object)
 
index 28b3001ee81209f6bc0c8eb22f1812b3e575f9d4..7193135ed72dd3e6fdf8c3a010da8d489163eb00 100644 (file)
@@ -641,6 +641,9 @@ Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
                                $(BYTESTR_DEPS) \
                                $(srcdir)/Objects/stringlib/formatter.h
 
+Objects/typeobject.o: $(srcdir)/Objects/typeslots.inc
+$(srcdir)/Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
+       $(PYTHON) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h > $(srcdir)/Objects/typeslots.inc
 
 ############################################################################
 # Header files
index cab89de95a4c5fafb3f3d9b884baeafbf08b8cc9..6b012e300465116659912a410348d1e263256c0d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -10,6 +10,8 @@ What's New in Python 3.2 Beta 1?
 Core and Builtins
 -----------------
 
+- PEP 384 (Defining a Stable ABI) is implemented.
+
 - Issue #2690: Range objects support negative indices and slicing
 
 - Issue #9915: Speed up sorting with a key.
index c074574e361099fea097678280c5d22cf61004f6..ed7c66a5ee27e52e0f77340d1e77346a5b12ce44 100644 (file)
@@ -1155,7 +1155,7 @@ WCharArray_set_value(CDataObject *self, PyObject *value)
         result = -1;
         goto done;
     }
-    result = PyUnicode_AsWideChar((PyUnicodeObject *)value,
+    result = PyUnicode_AsWideChar(value,
                                   (wchar_t *)self->b_ptr,
                                   self->b_size/sizeof(wchar_t));
     if (result >= 0 && (size_t)result < self->b_size/sizeof(wchar_t))
@@ -4174,7 +4174,7 @@ Array_subscript(PyObject *_self, PyObject *item)
         PyObject *np;
         Py_ssize_t start, stop, step, slicelen, cur, i;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  self->b_length, &start, &stop,
                                  &step, &slicelen) < 0) {
             return NULL;
@@ -4308,7 +4308,7 @@ Array_ass_subscript(PyObject *_self, PyObject *item, PyObject *value)
     else if (PySlice_Check(item)) {
         Py_ssize_t start, stop, step, slicelen, otherlen, i, cur;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  self->b_length, &start, &stop,
                                  &step, &slicelen) < 0) {
             return -1;
index d2fa00558535ffdc22221f520bb313b41c31dca1..ccaa3c9d703e6ca7ea55aad45b53c34f5ed52ef0 100644 (file)
@@ -1214,7 +1214,7 @@ u_set(void *ptr, PyObject *value, Py_ssize_t size)
     } else
         Py_INCREF(value);
 
-    len = PyUnicode_AsWideChar((PyUnicodeObject *)value, chars, 2);
+    len = PyUnicode_AsWideChar(value, chars, 2);
     if (len != 1) {
         Py_DECREF(value);
         PyErr_SetString(PyExc_TypeError,
@@ -1292,7 +1292,7 @@ U_set(void *ptr, PyObject *value, Py_ssize_t length)
     } else if (size < length-1)
         /* copy terminating NUL character if there is space */
         size += 1;
-    PyUnicode_AsWideChar((PyUnicodeObject *)value, (wchar_t *)ptr, size);
+    PyUnicode_AsWideChar(value, (wchar_t *)ptr, size);
     return value;
 }
 
index 851eed2c33c9db54e98e7f8b1d12156561b5e915..4fed46eb6b0c8fc95c35a67d4c75b32421dad826 100644 (file)
@@ -1272,7 +1272,7 @@ element_subscr(PyObject* self_, PyObject* item)
         if (!self->extra)
             return PyList_New(0);
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                 self->extra->length,
                 &start, &stop, &step, &slicelen) < 0) {
             return NULL;
@@ -1331,7 +1331,7 @@ element_ass_subscr(PyObject* self_, PyObject* item, PyObject* value)
         if (!self->extra)
             element_new_extra(self, NULL);
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                 self->extra->length,
                 &start, &stop, &step, &slicelen) < 0) {
             return -1;
index 84136419e3436d68f506313e3d350ec66257b1a4..42d0bcd464719b55467f45ed9daa64dfa0fa87e4 100644 (file)
@@ -1398,7 +1398,7 @@ unicode_aswidechar(PyObject *self, PyObject *args)
     if (buffer == NULL)
         return PyErr_NoMemory();
 
-    size = PyUnicode_AsWideChar((PyUnicodeObject*)unicode, buffer, buflen);
+    size = PyUnicode_AsWideChar(unicode, buffer, buflen);
     if (size == -1) {
         PyMem_Free(buffer);
         return NULL;
index 024109a60aeea9a23bd3bf6b4e5bb71e095c4cd8..18e5e665c4c148aea448150436a787919d7bdfde 100644 (file)
@@ -2112,7 +2112,7 @@ array_subscr(arrayobject* self, PyObject* item)
         arrayobject* ar;
         int itemsize = self->ob_descr->itemsize;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
+        if (PySlice_GetIndicesEx(item, Py_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
@@ -2183,7 +2183,7 @@ array_ass_subscr(arrayobject* self, PyObject* item, PyObject* value)
             return (*self->ob_descr->setitem)(self, i, value);
     }
     else if (PySlice_Check(item)) {
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  Py_SIZE(self), &start, &stop,
                                  &step, &slicelength) < 0) {
             return -1;
index 16b3b2a008f7b911c82139b8a5376678423ec64e..59623d79fcd385d93e975a72cd5678894093d940 100644 (file)
@@ -361,7 +361,7 @@ search_for_exec_prefix(wchar_t *argv0_path, wchar_t *home, wchar_t *_exec_prefix
             decoded = PyUnicode_DecodeUTF8(buf, n, "surrogateescape");
             if (decoded != NULL) {
                 Py_ssize_t k;
-                k = PyUnicode_AsWideChar((PyUnicodeObject*)decoded,
+                k = PyUnicode_AsWideChar(decoded,
                                          rel_builddir_path, MAXPATHLEN);
                 Py_DECREF(decoded);
                 if (k >= 0) {
index 13d7f5580af931e5e025c60e289e1701f0012726..8a227527a54848f4333eb106000cd227fbce5a12 100644 (file)
@@ -762,7 +762,7 @@ mmap_subscript(mmap_object *self, PyObject *item)
     else if (PySlice_Check(item)) {
         Py_ssize_t start, stop, step, slicelen;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item, self->size,
+        if (PySlice_GetIndicesEx(item, self->size,
                          &start, &stop, &step, &slicelen) < 0) {
             return NULL;
         }
@@ -888,7 +888,7 @@ mmap_ass_subscript(mmap_object *self, PyObject *item, PyObject *value)
         Py_ssize_t start, stop, step, slicelen;
         Py_buffer vbuf;
 
-        if (PySlice_GetIndicesEx((PySliceObject *)item,
+        if (PySlice_GetIndicesEx(item,
                                  self->size, &start, &stop,
                                  &step, &slicelen) < 0) {
             return -1;
diff --git a/Modules/xxlimited.c b/Modules/xxlimited.c
new file mode 100644 (file)
index 0000000..bd3f178
--- /dev/null
@@ -0,0 +1,283 @@
+
+/* Use this file as a template to start implementing a module that
+   also declares object types. All occurrences of 'Xxo' should be changed
+   to something reasonable for your objects. After that, all other
+   occurrences of 'xx' should be changed to something reasonable for your
+   module. If your module is named foo your sourcefile should be named
+   foomodule.c.
+
+   You will probably want to delete all references to 'x_attr' and add
+   your own types of attributes instead.  Maybe you want to name your
+   local variables other than 'self'.  If your object type is needed in
+   other files, you'll have to create a file "foobarobject.h"; see
+   floatobject.h for an example. */
+
+/* Xxo objects */
+
+#include "Python.h"
+
+static PyObject *ErrorObject;
+
+typedef struct {
+    PyObject_HEAD
+    PyObject            *x_attr;        /* Attributes dictionary */
+} XxoObject;
+
+static PyObject *Xxo_Type;
+
+#define XxoObject_Check(v)      (Py_TYPE(v) == Xxo_Type)
+
+static XxoObject *
+newXxoObject(PyObject *arg)
+{
+    XxoObject *self;
+    self = PyObject_New(XxoObject, (PyTypeObject*)Xxo_Type);
+    if (self == NULL)
+        return NULL;
+    self->x_attr = NULL;
+    return self;
+}
+
+/* Xxo methods */
+
+static void
+Xxo_dealloc(XxoObject *self)
+{
+    Py_XDECREF(self->x_attr);
+    PyObject_Del(self);
+}
+
+static PyObject *
+Xxo_demo(XxoObject *self, PyObject *args)
+{
+    if (!PyArg_ParseTuple(args, ":demo"))
+        return NULL;
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+static PyMethodDef Xxo_methods[] = {
+    {"demo",            (PyCFunction)Xxo_demo,  METH_VARARGS,
+        PyDoc_STR("demo() -> None")},
+    {NULL,              NULL}           /* sentinel */
+};
+
+static PyObject *
+Xxo_getattro(XxoObject *self, PyObject *name)
+{
+    if (self->x_attr != NULL) {
+        PyObject *v = PyDict_GetItem(self->x_attr, name);
+        if (v != NULL) {
+            Py_INCREF(v);
+            return v;
+        }
+    }
+    return PyObject_GenericGetAttr((PyObject *)self, name);
+}
+
+static int
+Xxo_setattr(XxoObject *self, char *name, PyObject *v)
+{
+    if (self->x_attr == NULL) {
+        self->x_attr = PyDict_New();
+        if (self->x_attr == NULL)
+            return -1;
+    }
+    if (v == NULL) {
+        int rv = PyDict_DelItemString(self->x_attr, name);
+        if (rv < 0)
+            PyErr_SetString(PyExc_AttributeError,
+                "delete non-existing Xxo attribute");
+        return rv;
+    }
+    else
+        return PyDict_SetItemString(self->x_attr, name, v);
+}
+
+static PyType_Slot Xxo_Type_slots[] = {
+    {Py_tp_dealloc, Xxo_dealloc},
+    {Py_tp_getattro, Xxo_getattro},
+    {Py_tp_setattr, Xxo_setattr},
+    {Py_tp_methods, Xxo_methods},
+    {0, 0},
+};
+
+static PyType_Spec Xxo_Type_spec = {
+    "xxmodule.Xxo",
+    NULL,
+    sizeof(XxoObject),
+    0,
+    Py_TPFLAGS_DEFAULT,
+    Xxo_Type_slots
+};
+
+/* --------------------------------------------------------------------- */
+
+/* Function of two integers returning integer */
+
+PyDoc_STRVAR(xx_foo_doc,
+"foo(i,j)\n\
+\n\
+Return the sum of i and j.");
+
+static PyObject *
+xx_foo(PyObject *self, PyObject *args)
+{
+    long i, j;
+    long res;
+    if (!PyArg_ParseTuple(args, "ll:foo", &i, &j))
+        return NULL;
+    res = i+j; /* XXX Do something here */
+    return PyLong_FromLong(res);
+}
+
+
+/* Function of no arguments returning new Xxo object */
+
+static PyObject *
+xx_new(PyObject *self, PyObject *args)
+{
+    XxoObject *rv;
+
+    if (!PyArg_ParseTuple(args, ":new"))
+        return NULL;
+    rv = newXxoObject(args);
+    if (rv == NULL)
+        return NULL;
+    return (PyObject *)rv;
+}
+
+/* Test bad format character */
+
+static PyObject *
+xx_roj(PyObject *self, PyObject *args)
+{
+    PyObject *a;
+    long b;
+    if (!PyArg_ParseTuple(args, "O#:roj", &a, &b))
+        return NULL;
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+
+/* ---------- */
+
+static PyType_Slot Str_Type_slots[] = {    
+    {Py_tp_base, NULL}, /* filled out in module init function */
+    {0, 0},
+};
+
+static PyType_Spec Str_Type_spec = {
+    "xxlimited.Str",
+    0,
+    0,
+    0,
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+    Str_Type_slots
+};
+
+/* ---------- */
+
+static PyObject *
+null_richcompare(PyObject *self, PyObject *other, int op)
+{
+    Py_INCREF(Py_NotImplemented);
+    return Py_NotImplemented;
+}
+
+static PyType_Slot Null_Type_slots[] = {
+    {Py_tp_base, NULL}, /* filled out in module init */
+    {Py_tp_new, NULL},
+    {Py_tp_richcompare, null_richcompare},
+    {0, 0}
+};
+
+static PyType_Spec Null_Type_spec = {
+    "xxlimited.Null",
+    NULL,            /* doc */
+    0,               /* basicsize */
+    0,               /* itemsize */
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+    Null_Type_slots
+};
+
+/* ---------- */
+
+/* List of functions defined in the module */
+
+static PyMethodDef xx_methods[] = {
+    {"roj",             xx_roj,         METH_VARARGS,
+        PyDoc_STR("roj(a,b) -> None")},
+    {"foo",             xx_foo,         METH_VARARGS,
+        xx_foo_doc},
+    {"new",             xx_new,         METH_VARARGS,
+        PyDoc_STR("new() -> new Xx object")},
+    {NULL,              NULL}           /* sentinel */
+};
+
+PyDoc_STRVAR(module_doc,
+"This is a template module just for instruction.");
+
+/* Initialization function for the module (*must* be called PyInit_xx) */
+
+
+static struct PyModuleDef xxmodule = {
+    PyModuleDef_HEAD_INIT,
+    "xx",
+    module_doc,
+    -1,
+    xx_methods,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+
+PyMODINIT_FUNC
+PyInit_xxlimited(void)
+{
+    PyObject *m = NULL;
+    PyObject *o;
+
+    /* Due to cross platform compiler issues the slots must be filled
+     * here. It's required for portability to Windows without requiring
+     * C++. */
+    Null_Type_slots[0].pfunc = &PyBaseObject_Type;
+    Null_Type_slots[1].pfunc = PyType_GenericNew;
+    Str_Type_slots[0].pfunc = &PyUnicode_Type;
+
+    Xxo_Type = PyType_FromSpec(&Xxo_Type_spec);
+    if (Xxo_Type == NULL)
+        goto fail;
+
+    /* Create the module and add the functions */
+    m = PyModule_Create(&xxmodule);
+    if (m == NULL)
+        goto fail;
+
+    /* Add some symbolic constants to the module */
+    if (ErrorObject == NULL) {
+        ErrorObject = PyErr_NewException("xx.error", NULL, NULL);
+        if (ErrorObject == NULL)
+            goto fail;
+    }
+    Py_INCREF(ErrorObject);
+    PyModule_AddObject(m, "error", ErrorObject);
+
+    /* Add Str */
+    o = PyType_FromSpec(&Str_Type_spec);
+    if (o == NULL)
+        goto fail;
+    PyModule_AddObject(m, "Str", o);
+
+    /* Add Null */
+    o = PyType_FromSpec(&Null_Type_spec);
+    if (o == NULL)
+        goto fail;
+    PyModule_AddObject(m, "Null", o);
+    return m;
+ fail:
+    Py_XDECREF(m);
+    return NULL;
+}
index 6ca096afd72eb3e95e6b4590f6279c15d25d377f..32b8bb574b9e5d5291261e82641c18617f37e168 100644 (file)
@@ -389,7 +389,7 @@ bytearray_subscript(PyByteArrayObject *self, PyObject *index)
     }
     else if (PySlice_Check(index)) {
         Py_ssize_t start, stop, step, slicelength, cur, i;
-        if (PySlice_GetIndicesEx((PySliceObject *)index,
+        if (PySlice_GetIndicesEx(index,
                                  PyByteArray_GET_SIZE(self),
                                  &start, &stop, &step, &slicelength) < 0) {
             return NULL;
@@ -573,7 +573,7 @@ bytearray_ass_subscript(PyByteArrayObject *self, PyObject *index, PyObject *valu
         }
     }
     else if (PySlice_Check(index)) {
-        if (PySlice_GetIndicesEx((PySliceObject *)index,
+        if (PySlice_GetIndicesEx(index,
                                  PyByteArray_GET_SIZE(self),
                                  &start, &stop, &step, &slicelen) < 0) {
             return -1;
index d3b8a4fe80422b2a5b361de07effd602e707c1b9..4aa0748f09c17fe468d422a39b93ac620da4028b 100644 (file)
@@ -911,7 +911,7 @@ bytes_subscript(PyBytesObject* self, PyObject* item)
         char* result_buf;
         PyObject* result;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item,
+        if (PySlice_GetIndicesEx(item,
                          PyBytes_GET_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;
index 221f368ae22e819168bcac474de7a2e28ae12f1d..45f9f57578176252f6d82caae5a01a6050c75947 100644 (file)
@@ -627,7 +627,7 @@ function_call(PyObject *func, PyObject *arg, PyObject *kw)
     }
 
     result = PyEval_EvalCodeEx(
-        (PyCodeObject *)PyFunction_GET_CODE(func),
+        PyFunction_GET_CODE(func),
         PyFunction_GET_GLOBALS(func), (PyObject *)NULL,
         &PyTuple_GET_ITEM(arg, 0), PyTuple_GET_SIZE(arg),
         k, nk, d, nd,
index fbc05fda4ae1881e0892fdea3d8f7c9b935ba916..bcc6bc0c9ba52cdaf387783cf2cc05401c195ac7 100644 (file)
@@ -2397,7 +2397,7 @@ list_subscript(PyListObject* self, PyObject* item)
         PyObject* it;
         PyObject **src, **dest;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
+        if (PySlice_GetIndicesEx(item, Py_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
@@ -2446,7 +2446,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value)
     else if (PySlice_Check(item)) {
         Py_ssize_t start, stop, step, slicelength;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, Py_SIZE(self),
+        if (PySlice_GetIndicesEx(item, Py_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return -1;
         }
index ba9e08b9ab058d5599135a95dfd4f5ffe98eb222..a05b97b977bfeddf80b48d909831296dda064c01 100644 (file)
@@ -599,7 +599,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key)
     else if (PySlice_Check(key)) {
         Py_ssize_t start, stop, step, slicelength;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)key, get_shape0(view),
+        if (PySlice_GetIndicesEx(key, get_shape0(view),
                                  &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
@@ -678,7 +678,7 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
     else if (PySlice_Check(key)) {
         Py_ssize_t stop, step;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)key, get_shape0(view),
+        if (PySlice_GetIndicesEx(key, get_shape0(view),
                          &start, &stop, &step, &len) < 0) {
             return -1;
         }
index 1e3349d0a3581706067f85e53a634a73153d631f..2c095a096870aa2022fab6d247d85914c2250e58 100644 (file)
@@ -74,7 +74,7 @@ PyModule_Create2(struct PyModuleDef* module, int module_api_version)
         module->m_base.m_index = max_module_number;
     }
     name = module->m_name;
-    if (module_api_version != PYTHON_API_VERSION) {
+    if (module_api_version != PYTHON_API_VERSION && module_api_version != PYTHON_ABI_VERSION) {
         int err;
         err = PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
             "Python C API version mismatch for module %.100s: "
index 082dd78e9584016ec8395582a6d09f1e290025c7..17e5069ef513943c35828a0b27c357bad3cb8062 100644 (file)
@@ -1755,7 +1755,6 @@ _Py_GetObjects(PyObject *self, PyObject *args)
 
 #endif
 
-
 /* Hack to force loading of pycapsule.o */
 PyTypeObject *_PyCapsule_hack = &PyCapsule_Type;
 
@@ -1900,6 +1899,19 @@ _PyTrash_destroy_chain(void)
     }
 }
 
+#ifndef Py_TRACE_REFS
+/* For Py_LIMITED_API, we need an out-of-line version of _Py_Dealloc.
+   Define this here, so we can undefine the macro. */
+#undef _Py_Dealloc
+PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
+void
+_Py_Dealloc(PyObject *op)
+{
+    _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA
+    (*Py_TYPE(op)->tp_dealloc)(op);
+}
+#endif
+
 #ifdef __cplusplus
 }
 #endif
index bf42b1e321f610a2c9790c97530fb63c0ffa7f19..3ac829a6d23bac6897837581b0d6ac1f93213bd6 100644 (file)
@@ -431,7 +431,6 @@ range_subscript(rangeobject* self, PyObject* item)
         return range_item(self, i);
     }
     if (PySlice_Check(item)) {
-        PySliceObject *slice = (PySliceObject*)item;
         Py_ssize_t start, stop, step, len, rlen;
         rangeobject *result;
         PyObject *substart = NULL, *substep = NULL, *substop = NULL;
@@ -441,7 +440,7 @@ range_subscript(rangeobject* self, PyObject* item)
             return NULL;
         }
 
-        if (PySlice_GetIndicesEx(slice, rlen,
+        if (PySlice_GetIndicesEx(item, rlen,
                                 &start, &stop, &step, &len) < 0) {
             return NULL;
         }
@@ -450,7 +449,7 @@ range_subscript(rangeobject* self, PyObject* item)
             Py_INCREF(substep);
         } else {
             /* NB: slice step != Py_None here */
-            substep = PyNumber_Multiply(self->step, slice->step);
+            substep = PyNumber_Multiply(self->step, ((PySliceObject*)item)->step);
             if (substep == NULL)
                 goto fail;
         }
index b6178914239a7a0de49c5ac13208e488c6c2f1ab..51c53a8a11c3c33778d1b4d4d8247e4b279d0387 100644 (file)
@@ -99,9 +99,10 @@ _PySlice_FromIndices(Py_ssize_t istart, Py_ssize_t istop)
 }
 
 int
-PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
+PySlice_GetIndices(PyObject *_r, Py_ssize_t length,
                    Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step)
 {
+    PySliceObject *r = (PySliceObject*)_r;
     /* XXX support long ints */
     if (r->step == Py_None) {
         *step = 1;
@@ -130,10 +131,11 @@ PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
 }
 
 int
-PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
+PySlice_GetIndicesEx(PyObject *_r, Py_ssize_t length,
                      Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step,
                      Py_ssize_t *slicelength)
 {
+    PySliceObject *r = (PySliceObject*)_r;
     /* this is harder to get right than you might think */
 
     Py_ssize_t defstart, defstop;
@@ -256,7 +258,7 @@ slice_indices(PySliceObject* self, PyObject* len)
         return NULL;
     }
 
-    if (PySlice_GetIndicesEx(self, ilen, &start, &stop,
+    if (PySlice_GetIndicesEx((PyObject*)self, ilen, &start, &stop,
                              &step, &slicelength) < 0) {
         return NULL;
     }
index 75e2250bf9c0342d67d2f30c45827b0a2f9d24b0..ef17f49a31400eac6af35a7539c528510005cc0e 100644 (file)
@@ -43,6 +43,18 @@ PyStructSequence_New(PyTypeObject *type)
     return (PyObject*)obj;
 }
 
+void
+PyStructSequence_SetItem(PyObject* op, Py_ssize_t i, PyObject* v)
+{
+    PyStructSequence_SET_ITEM(op, i, v);
+}
+
+PyObject*
+PyStructSequence_GetItem(PyObject* op, Py_ssize_t i)
+{
+    return PyStructSequence_GET_ITEM(op, i);
+}
+
 static void
 structseq_dealloc(PyStructSequence *obj)
 {
@@ -365,3 +377,11 @@ PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)
     SET_DICT_FROM_INT(real_length_key, n_members);
     SET_DICT_FROM_INT(unnamed_fields_key, n_unnamed_members);
 }
+
+PyTypeObject*
+PyStructSequence_NewType(PyStructSequence_Desc *desc)
+{
+    PyTypeObject *result = (PyTypeObject*)PyType_GenericAlloc(&PyType_Type, 0);
+    PyStructSequence_InitType(result, desc);
+    return result;
+}
index 390b670f200776cce88da0c8b71975c897fda4ca..72b79c917a8667b662a4b339f66b72ba48d26f0b 100644 (file)
@@ -689,7 +689,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item)
         PyObject* it;
         PyObject **src, **dest;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item,
+        if (PySlice_GetIndicesEx(item,
                          PyTuple_GET_SIZE(self),
                          &start, &stop, &step, &slicelength) < 0) {
             return NULL;
index e0001db189ed9a244fd67bc24d0e182a6cc458b5..a5863dd0a4f9432a58015646620c549fd4a73405 100644 (file)
@@ -2304,6 +2304,44 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds)
     return (PyObject *)type;
 }
 
+static short slotoffsets[] = {
+    -1, /* invalid slot */
+#include "typeslots.inc"
+};
+
+PyObject* PyType_FromSpec(PyType_Spec *spec)
+{
+    PyHeapTypeObject *res = (PyHeapTypeObject*)PyType_GenericAlloc(&PyType_Type, 0);
+    char *res_start = (char*)res;
+    PyType_Slot *slot;
+
+    res->ht_name = PyUnicode_FromString(spec->name);
+    if (!res->ht_name)
+       goto fail;
+    res->ht_type.tp_name = _PyUnicode_AsString(res->ht_name);
+    if (!res->ht_type.tp_name)
+       goto fail;
+
+    res->ht_type.tp_basicsize = spec->basicsize;
+    res->ht_type.tp_itemsize = spec->itemsize;
+    res->ht_type.tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
+    
+    for (slot = spec->slots; slot->slot; slot++) {
+       if (slot->slot >= sizeof(slotoffsets)/sizeof(slotoffsets[0])) {
+           PyErr_SetString(PyExc_RuntimeError, "invalid slot offset");
+           goto fail;
+       }
+       *(void**)(res_start + slotoffsets[slot->slot]) = slot->pfunc;
+    }
+
+    return (PyObject*)res;
+    
+ fail:
+    Py_DECREF(res);
+    return NULL;
+}
+
+
 /* Internal API to look for a name through the MRO.
    This returns a borrowed reference, and doesn't set an exception! */
 PyObject *
diff --git a/Objects/typeslots.inc b/Objects/typeslots.inc
new file mode 100644 (file)
index 0000000..79e3db8
--- /dev/null
@@ -0,0 +1,71 @@
+offsetof(PyHeapTypeObject, as_buffer.bf_getbuffer),
+offsetof(PyHeapTypeObject, as_buffer.bf_releasebuffer),
+offsetof(PyHeapTypeObject, as_mapping.mp_ass_subscript),
+offsetof(PyHeapTypeObject, as_mapping.mp_length),
+offsetof(PyHeapTypeObject, as_mapping.mp_subscript),
+offsetof(PyHeapTypeObject, as_number.nb_absolute),
+offsetof(PyHeapTypeObject, as_number.nb_add),
+offsetof(PyHeapTypeObject, as_number.nb_and),
+offsetof(PyHeapTypeObject, as_number.nb_bool),
+offsetof(PyHeapTypeObject, as_number.nb_divmod),
+offsetof(PyHeapTypeObject, as_number.nb_float),
+offsetof(PyHeapTypeObject, as_number.nb_floor_divide),
+offsetof(PyHeapTypeObject, as_number.nb_index),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_add),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_and),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_floor_divide),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_lshift),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_multiply),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_or),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_power),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_remainder),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_rshift),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_subtract),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_true_divide),
+offsetof(PyHeapTypeObject, as_number.nb_inplace_xor),
+offsetof(PyHeapTypeObject, as_number.nb_int),
+offsetof(PyHeapTypeObject, as_number.nb_invert),
+offsetof(PyHeapTypeObject, as_number.nb_lshift),
+offsetof(PyHeapTypeObject, as_number.nb_multiply),
+offsetof(PyHeapTypeObject, as_number.nb_negative),
+offsetof(PyHeapTypeObject, as_number.nb_or),
+offsetof(PyHeapTypeObject, as_number.nb_positive),
+offsetof(PyHeapTypeObject, as_number.nb_power),
+offsetof(PyHeapTypeObject, as_number.nb_remainder),
+offsetof(PyHeapTypeObject, as_number.nb_rshift),
+offsetof(PyHeapTypeObject, as_number.nb_subtract),
+offsetof(PyHeapTypeObject, as_number.nb_true_divide),
+offsetof(PyHeapTypeObject, as_number.nb_xor),
+offsetof(PyHeapTypeObject, as_sequence.sq_ass_item),
+offsetof(PyHeapTypeObject, as_sequence.sq_concat),
+offsetof(PyHeapTypeObject, as_sequence.sq_contains),
+offsetof(PyHeapTypeObject, as_sequence.sq_inplace_concat),
+offsetof(PyHeapTypeObject, as_sequence.sq_inplace_repeat),
+offsetof(PyHeapTypeObject, as_sequence.sq_item),
+offsetof(PyHeapTypeObject, as_sequence.sq_length),
+offsetof(PyHeapTypeObject, as_sequence.sq_repeat),
+offsetof(PyHeapTypeObject, ht_type.tp_alloc),
+offsetof(PyHeapTypeObject, ht_type.tp_base),
+offsetof(PyHeapTypeObject, ht_type.tp_bases),
+offsetof(PyHeapTypeObject, ht_type.tp_call),
+offsetof(PyHeapTypeObject, ht_type.tp_clear),
+offsetof(PyHeapTypeObject, ht_type.tp_dealloc),
+offsetof(PyHeapTypeObject, ht_type.tp_del),
+offsetof(PyHeapTypeObject, ht_type.tp_descr_get),
+offsetof(PyHeapTypeObject, ht_type.tp_descr_set),
+offsetof(PyHeapTypeObject, ht_type.tp_doc),
+offsetof(PyHeapTypeObject, ht_type.tp_getattr),
+offsetof(PyHeapTypeObject, ht_type.tp_getattro),
+offsetof(PyHeapTypeObject, ht_type.tp_hash),
+offsetof(PyHeapTypeObject, ht_type.tp_init),
+offsetof(PyHeapTypeObject, ht_type.tp_is_gc),
+offsetof(PyHeapTypeObject, ht_type.tp_iter),
+offsetof(PyHeapTypeObject, ht_type.tp_iternext),
+offsetof(PyHeapTypeObject, ht_type.tp_methods),
+offsetof(PyHeapTypeObject, ht_type.tp_new),
+offsetof(PyHeapTypeObject, ht_type.tp_repr),
+offsetof(PyHeapTypeObject, ht_type.tp_richcompare),
+offsetof(PyHeapTypeObject, ht_type.tp_setattr),
+offsetof(PyHeapTypeObject, ht_type.tp_setattro),
+offsetof(PyHeapTypeObject, ht_type.tp_str),
+offsetof(PyHeapTypeObject, ht_type.tp_traverse),
diff --git a/Objects/typeslots.py b/Objects/typeslots.py
new file mode 100644 (file)
index 0000000..bcc3196
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/python
+# Usage: typeslots.py < Include/typeslots.h > typeslots.inc
+
+import sys, re
+
+res = {}
+for line in sys.stdin:
+    m = re.match("#define Py_([a-z_]+) ([0-9]+)", line)
+    member = m.group(1)
+    if member.startswith("tp_"):
+        member = "ht_type."+member
+    elif member.startswith("nb_"):
+        member = "as_number."+member
+    elif member.startswith("mp_"):
+        member = "as_mapping."+member
+    elif member.startswith("sq_"):
+        member = "as_sequence."+member
+    elif member.startswith("bf_"):
+        member = "as_buffer."+member
+    res[int(m.group(2))] = member
+
+M = max(res.keys())+1
+for i in range(1,M):
+    print "offsetof(PyHeapTypeObject, %s)," % res[i]
index f66773e26a64e17b2375dcc4cd8e20c4996ec6ed..d3a2d1b715c10d17992ed58ac0d281f8b9fe9445 100644 (file)
@@ -1263,7 +1263,7 @@ unicode_aswidechar(PyUnicodeObject *unicode,
 }
 
 Py_ssize_t
-PyUnicode_AsWideChar(PyUnicodeObject *unicode,
+PyUnicode_AsWideChar(PyObject *unicode,
                      wchar_t *w,
                      Py_ssize_t size)
 {
@@ -1271,7 +1271,7 @@ PyUnicode_AsWideChar(PyUnicodeObject *unicode,
         PyErr_BadInternalCall();
         return -1;
     }
-    return unicode_aswidechar(unicode, w, size);
+    return unicode_aswidechar((PyUnicodeObject*)unicode, w, size);
 }
 
 wchar_t*
@@ -9222,7 +9222,7 @@ unicode_subscript(PyUnicodeObject* self, PyObject* item)
         Py_UNICODE* result_buf;
         PyObject* result;
 
-        if (PySlice_GetIndicesEx((PySliceObject*)item, PyUnicode_GET_SIZE(self),
+        if (PySlice_GetIndicesEx(item, PyUnicode_GET_SIZE(self),
                                  &start, &stop, &step, &slicelength) < 0) {
             return NULL;
         }
index 3a87411d0fd091e17eaa980e037bd35473d7890f..cd3a4b25044144af6a89f6908e753d14445d35eb 100644 (file)
@@ -707,3 +707,38 @@ Py_GetProgramFullPath(void)
         calculate_path();
     return progpath;
 }
+
+/* Load python3.dll before loading any extension module that might refer 
+   to it. That way, we can be sure that always the python3.dll corresponding 
+   to this python DLL is loaded, not a python3.dll that might be on the path
+   by chance.
+   Return whether the DLL was found.
+*/
+static int python3_checked = 0;
+static HANDLE hPython3;
+int
+_Py_CheckPython3()
+{
+    wchar_t py3path[MAXPATHLEN+1];
+    wchar_t *s;
+    if (python3_checked)
+        return hPython3 != NULL;
+    python3_checked = 1;
+
+    /* If there is a python3.dll next to the python3y.dll,
+       assume this is a build tree; use that DLL */
+    wcscpy(py3path, dllpath);
+    s = wcsrchr(py3path, L'\\');
+    if (!s)
+        s = py3path;
+    wcscpy(s, L"\\python3.dll");
+    hPython3 = LoadLibraryExW(py3path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+    if (hPython3 != NULL)
+        return 1;
+
+    /* Check sys.prefix\DLLs\python3.dll */
+    wcscpy(py3path, Py_GetPrefix());
+    wcscat(py3path, L"\\DLLs\\python3.dll");
+    hPython3 = LoadLibraryExW(py3path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+    return hPython3 != NULL;
+}
index 913b2dc932449ba4828df56dc0cc5f7ac7d83557..cbddbd87c9a0dc5038b43c4bf0e01941931a43e3 100644 (file)
@@ -318,8 +318,10 @@ Py_NO_ENABLE_SHARED to find out.  Also support MS_NO_COREDLL for b/w compat */
                        /* So MSVC users need not specify the .lib file in
                        their Makefile (other compilers are generally
                        taken care of by distutils.) */
-#                      ifdef _DEBUG
+#                      if defined(_DEBUG)
 #                              pragma comment(lib,"python32_d.lib")
+#                      elif defined(Py_LIMITED_API)
+#                              pragma comment(lib,"python3.lib")
 #                      else
 #                              pragma comment(lib,"python32.lib")
 #                      endif /* _DEBUG */
diff --git a/PC/python3.def b/PC/python3.def
new file mode 100644 (file)
index 0000000..082d428
--- /dev/null
@@ -0,0 +1,698 @@
+LIBRARY        "python3"\r
+EXPORTS\r
+  PyArg_Parse=python32.PyArg_Parse\r
+  PyArg_ParseTuple=python32.PyArg_ParseTuple\r
+  PyArg_ParseTupleAndKeywords=python32.PyArg_ParseTupleAndKeywords\r
+  PyArg_UnpackTuple=python32.PyArg_UnpackTuple\r
+  PyArg_VaParse=python32.PyArg_VaParse\r
+  PyArg_VaParseTupleAndKeywords=python32.PyArg_VaParseTupleAndKeywords\r
+  PyArg_ValidateKeywordArguments=python32.PyArg_ValidateKeywordArguments\r
+  PyBaseObject_Type=python32.PyBaseObject_Type DATA\r
+  PyBool_FromLong=python32.PyBool_FromLong\r
+  PyBool_Type=python32.PyBool_Type DATA\r
+  PyBuffer_FillContiguousStrides=python32.PyBuffer_FillContiguousStrides\r
+  PyBuffer_FillInfo=python32.PyBuffer_FillInfo\r
+  PyBuffer_FromContiguous=python32.PyBuffer_FromContiguous\r
+  PyBuffer_GetPointer=python32.PyBuffer_GetPointer\r
+  PyBuffer_IsContiguous=python32.PyBuffer_IsContiguous\r
+  PyBuffer_Release=python32.PyBuffer_Release\r
+  PyBuffer_ToContiguous=python32.PyBuffer_ToContiguous\r
+  PyByteArrayIter_Type=python32.PyByteArrayIter_Type DATA\r
+  PyByteArray_AsString=python32.PyByteArray_AsString\r
+  PyByteArray_Concat=python32.PyByteArray_Concat\r
+  PyByteArray_FromObject=python32.PyByteArray_FromObject\r
+  PyByteArray_FromStringAndSize=python32.PyByteArray_FromStringAndSize\r
+  PyByteArray_Resize=python32.PyByteArray_Resize\r
+  PyByteArray_Size=python32.PyByteArray_Size\r
+  PyByteArray_Type=python32.PyByteArray_Type DATA\r
+  PyBytesIter_Type=python32.PyBytesIter_Type DATA\r
+  PyBytes_AsString=python32.PyBytes_AsString\r
+  PyBytes_AsStringAndSize=python32.PyBytes_AsStringAndSize\r
+  PyBytes_Concat=python32.PyBytes_Concat\r
+  PyBytes_ConcatAndDel=python32.PyBytes_ConcatAndDel\r
+  PyBytes_DecodeEscape=python32.PyBytes_DecodeEscape\r
+  PyBytes_FromFormat=python32.PyBytes_FromFormat\r
+  PyBytes_FromFormatV=python32.PyBytes_FromFormatV\r
+  PyBytes_FromObject=python32.PyBytes_FromObject\r
+  PyBytes_FromString=python32.PyBytes_FromString\r
+  PyBytes_FromStringAndSize=python32.PyBytes_FromStringAndSize\r
+  PyBytes_Repr=python32.PyBytes_Repr\r
+  PyBytes_Size=python32.PyBytes_Size\r
+  PyBytes_Type=python32.PyBytes_Type DATA\r
+  PyCFunction_Call=python32.PyCFunction_Call\r
+  PyCFunction_ClearFreeList=python32.PyCFunction_ClearFreeList\r
+  PyCFunction_GetFlags=python32.PyCFunction_GetFlags\r
+  PyCFunction_GetFunction=python32.PyCFunction_GetFunction\r
+  PyCFunction_GetSelf=python32.PyCFunction_GetSelf\r
+  PyCFunction_NewEx=python32.PyCFunction_NewEx\r
+  PyCFunction_Type=python32.PyCFunction_Type DATA\r
+  PyCallIter_New=python32.PyCallIter_New\r
+  PyCallIter_Type=python32.PyCallIter_Type DATA\r
+  PyCallable_Check=python32.PyCallable_Check\r
+  PyCapsule_GetContext=python32.PyCapsule_GetContext\r
+  PyCapsule_GetDestructor=python32.PyCapsule_GetDestructor\r
+  PyCapsule_GetName=python32.PyCapsule_GetName\r
+  PyCapsule_GetPointer=python32.PyCapsule_GetPointer\r
+  PyCapsule_Import=python32.PyCapsule_Import\r
+  PyCapsule_IsValid=python32.PyCapsule_IsValid\r
+  PyCapsule_New=python32.PyCapsule_New\r
+  PyCapsule_SetContext=python32.PyCapsule_SetContext\r
+  PyCapsule_SetDestructor=python32.PyCapsule_SetDestructor\r
+  PyCapsule_SetName=python32.PyCapsule_SetName\r
+  PyCapsule_SetPointer=python32.PyCapsule_SetPointer\r
+  PyCapsule_Type=python32.PyCapsule_Type DATA\r
+  PyClassMethodDescr_Type=python32.PyClassMethodDescr_Type DATA\r
+  PyCodec_BackslashReplaceErrors=python32.PyCodec_BackslashReplaceErrors\r
+  PyCodec_Decode=python32.PyCodec_Decode\r
+  PyCodec_Decoder=python32.PyCodec_Decoder\r
+  PyCodec_Encode=python32.PyCodec_Encode\r
+  PyCodec_Encoder=python32.PyCodec_Encoder\r
+  PyCodec_IgnoreErrors=python32.PyCodec_IgnoreErrors\r
+  PyCodec_IncrementalDecoder=python32.PyCodec_IncrementalDecoder\r
+  PyCodec_IncrementalEncoder=python32.PyCodec_IncrementalEncoder\r
+  PyCodec_KnownEncoding=python32.PyCodec_KnownEncoding\r
+  PyCodec_LookupError=python32.PyCodec_LookupError\r
+  PyCodec_Register=python32.PyCodec_Register\r
+  PyCodec_RegisterError=python32.PyCodec_RegisterError\r
+  PyCodec_ReplaceErrors=python32.PyCodec_ReplaceErrors\r
+  PyCodec_StreamReader=python32.PyCodec_StreamReader\r
+  PyCodec_StreamWriter=python32.PyCodec_StreamWriter\r
+  PyCodec_StrictErrors=python32.PyCodec_StrictErrors\r
+  PyCodec_XMLCharRefReplaceErrors=python32.PyCodec_XMLCharRefReplaceErrors\r
+  PyComplex_FromDoubles=python32.PyComplex_FromDoubles\r
+  PyComplex_ImagAsDouble=python32.PyComplex_ImagAsDouble\r
+  PyComplex_RealAsDouble=python32.PyComplex_RealAsDouble\r
+  PyComplex_Type=python32.PyComplex_Type DATA\r
+  PyDescr_NewClassMethod=python32.PyDescr_NewClassMethod\r
+  PyDescr_NewGetSet=python32.PyDescr_NewGetSet\r
+  PyDescr_NewMember=python32.PyDescr_NewMember\r
+  PyDescr_NewMethod=python32.PyDescr_NewMethod\r
+  PyDictItems_Type=python32.PyDictItems_Type DATA\r
+  PyDictIterItem_Type=python32.PyDictIterItem_Type DATA\r
+  PyDictIterKey_Type=python32.PyDictIterKey_Type DATA\r
+  PyDictIterValue_Type=python32.PyDictIterValue_Type DATA\r
+  PyDictKeys_Type=python32.PyDictKeys_Type DATA\r
+  PyDictProxy_New=python32.PyDictProxy_New\r
+  PyDictProxy_Type=python32.PyDictProxy_Type DATA\r
+  PyDictValues_Type=python32.PyDictValues_Type DATA\r
+  PyDict_Clear=python32.PyDict_Clear\r
+  PyDict_Contains=python32.PyDict_Contains\r
+  PyDict_Copy=python32.PyDict_Copy\r
+  PyDict_DelItem=python32.PyDict_DelItem\r
+  PyDict_DelItemString=python32.PyDict_DelItemString\r
+  PyDict_GetItem=python32.PyDict_GetItem\r
+  PyDict_GetItemString=python32.PyDict_GetItemString\r
+  PyDict_GetItemWithError=python32.PyDict_GetItemWithError\r
+  PyDict_Items=python32.PyDict_Items\r
+  PyDict_Keys=python32.PyDict_Keys\r
+  PyDict_Merge=python32.PyDict_Merge\r
+  PyDict_MergeFromSeq2=python32.PyDict_MergeFromSeq2\r
+  PyDict_New=python32.PyDict_New\r
+  PyDict_Next=python32.PyDict_Next\r
+  PyDict_SetItem=python32.PyDict_SetItem\r
+  PyDict_SetItemString=python32.PyDict_SetItemString\r
+  PyDict_Size=python32.PyDict_Size\r
+  PyDict_Type=python32.PyDict_Type DATA\r
+  PyDict_Update=python32.PyDict_Update\r
+  PyDict_Values=python32.PyDict_Values\r
+  PyEllipsis_Type=python32.PyEllipsis_Type DATA\r
+  PyEnum_Type=python32.PyEnum_Type DATA\r
+  PyErr_BadArgument=python32.PyErr_BadArgument\r
+  PyErr_BadInternalCall=python32.PyErr_BadInternalCall\r
+  PyErr_CheckSignals=python32.PyErr_CheckSignals\r
+  PyErr_Clear=python32.PyErr_Clear\r
+  PyErr_Display=python32.PyErr_Display\r
+  PyErr_ExceptionMatches=python32.PyErr_ExceptionMatches\r
+  PyErr_Fetch=python32.PyErr_Fetch\r
+  PyErr_Format=python32.PyErr_Format\r
+  PyErr_GivenExceptionMatches=python32.PyErr_GivenExceptionMatches\r
+  PyErr_NewException=python32.PyErr_NewException\r
+  PyErr_NewExceptionWithDoc=python32.PyErr_NewExceptionWithDoc\r
+  PyErr_NoMemory=python32.PyErr_NoMemory\r
+  PyErr_NormalizeException=python32.PyErr_NormalizeException\r
+  PyErr_Occurred=python32.PyErr_Occurred\r
+  PyErr_Print=python32.PyErr_Print\r
+  PyErr_PrintEx=python32.PyErr_PrintEx\r
+  PyErr_ProgramText=python32.PyErr_ProgramText\r
+  PyErr_Restore=python32.PyErr_Restore\r
+  PyErr_SetFromErrno=python32.PyErr_SetFromErrno\r
+  PyErr_SetFromErrnoWithFilename=python32.PyErr_SetFromErrnoWithFilename\r
+  PyErr_SetFromErrnoWithFilenameObject=python32.PyErr_SetFromErrnoWithFilenameObject\r
+  PyErr_SetInterrupt=python32.PyErr_SetInterrupt\r
+  PyErr_SetNone=python32.PyErr_SetNone\r
+  PyErr_SetObject=python32.PyErr_SetObject\r
+  PyErr_SetString=python32.PyErr_SetString\r
+  PyErr_SyntaxLocation=python32.PyErr_SyntaxLocation\r
+  PyErr_WarnEx=python32.PyErr_WarnEx\r
+  PyErr_WarnExplicit=python32.PyErr_WarnExplicit\r
+  PyErr_WarnFormat=python32.PyErr_WarnFormat\r
+  PyErr_WriteUnraisable=python32.PyErr_WriteUnraisable\r
+  PyEval_AcquireLock=python32.PyEval_AcquireLock\r
+  PyEval_AcquireThread=python32.PyEval_AcquireThread\r
+  PyEval_CallFunction=python32.PyEval_CallFunction\r
+  PyEval_CallMethod=python32.PyEval_CallMethod\r
+  PyEval_CallObjectWithKeywords=python32.PyEval_CallObjectWithKeywords\r
+  PyEval_EvalCode=python32.PyEval_EvalCode\r
+  PyEval_EvalCodeEx=python32.PyEval_EvalCodeEx\r
+  PyEval_EvalFrame=python32.PyEval_EvalFrame\r
+  PyEval_EvalFrameEx=python32.PyEval_EvalFrameEx\r
+  PyEval_GetBuiltins=python32.PyEval_GetBuiltins\r
+  PyEval_GetCallStats=python32.PyEval_GetCallStats\r
+  PyEval_GetFrame=python32.PyEval_GetFrame\r
+  PyEval_GetFuncDesc=python32.PyEval_GetFuncDesc\r
+  PyEval_GetFuncName=python32.PyEval_GetFuncName\r
+  PyEval_GetGlobals=python32.PyEval_GetGlobals\r
+  PyEval_GetLocals=python32.PyEval_GetLocals\r
+  PyEval_InitThreads=python32.PyEval_InitThreads\r
+  PyEval_ReInitThreads=python32.PyEval_ReInitThreads\r
+  PyEval_ReleaseLock=python32.PyEval_ReleaseLock\r
+  PyEval_ReleaseThread=python32.PyEval_ReleaseThread\r
+  PyEval_RestoreThread=python32.PyEval_RestoreThread\r
+  PyEval_SaveThread=python32.PyEval_SaveThread\r
+  PyEval_ThreadsInitialized=python32.PyEval_ThreadsInitialized\r
+  PyExc_ArithmeticError=python32.PyExc_ArithmeticError DATA\r
+  PyExc_AssertionError=python32.PyExc_AssertionError DATA\r
+  PyExc_AttributeError=python32.PyExc_AttributeError DATA\r
+  PyExc_BaseException=python32.PyExc_BaseException DATA\r
+  PyExc_BufferError=python32.PyExc_BufferError DATA\r
+  PyExc_BytesWarning=python32.PyExc_BytesWarning DATA\r
+  PyExc_DeprecationWarning=python32.PyExc_DeprecationWarning DATA\r
+  PyExc_EOFError=python32.PyExc_EOFError DATA\r
+  PyExc_EnvironmentError=python32.PyExc_EnvironmentError DATA\r
+  PyExc_Exception=python32.PyExc_Exception DATA\r
+  PyExc_FloatingPointError=python32.PyExc_FloatingPointError DATA\r
+  PyExc_FutureWarning=python32.PyExc_FutureWarning DATA\r
+  PyExc_GeneratorExit=python32.PyExc_GeneratorExit DATA\r
+  PyExc_IOError=python32.PyExc_IOError DATA\r
+  PyExc_ImportError=python32.PyExc_ImportError DATA\r
+  PyExc_ImportWarning=python32.PyExc_ImportWarning DATA\r
+  PyExc_IndentationError=python32.PyExc_IndentationError DATA\r
+  PyExc_IndexError=python32.PyExc_IndexError DATA\r
+  PyExc_KeyError=python32.PyExc_KeyError DATA\r
+  PyExc_KeyboardInterrupt=python32.PyExc_KeyboardInterrupt DATA\r
+  PyExc_LookupError=python32.PyExc_LookupError DATA\r
+  PyExc_MemoryError=python32.PyExc_MemoryError DATA\r
+  PyExc_MemoryErrorInst=python32.PyExc_MemoryErrorInst DATA\r
+  PyExc_NameError=python32.PyExc_NameError DATA\r
+  PyExc_NotImplementedError=python32.PyExc_NotImplementedError DATA\r
+  PyExc_OSError=python32.PyExc_OSError DATA\r
+  PyExc_OverflowError=python32.PyExc_OverflowError DATA\r
+  PyExc_PendingDeprecationWarning=python32.PyExc_PendingDeprecationWarning DATA\r
+  PyExc_RecursionErrorInst=python32.PyExc_RecursionErrorInst DATA\r
+  PyExc_ReferenceError=python32.PyExc_ReferenceError DATA\r
+  PyExc_RuntimeError=python32.PyExc_RuntimeError DATA\r
+  PyExc_RuntimeWarning=python32.PyExc_RuntimeWarning DATA\r
+  PyExc_StopIteration=python32.PyExc_StopIteration DATA\r
+  PyExc_SyntaxError=python32.PyExc_SyntaxError DATA\r
+  PyExc_SyntaxWarning=python32.PyExc_SyntaxWarning DATA\r
+  PyExc_SystemError=python32.PyExc_SystemError DATA\r
+  PyExc_SystemExit=python32.PyExc_SystemExit DATA\r
+  PyExc_TabError=python32.PyExc_TabError DATA\r
+  PyExc_TypeError=python32.PyExc_TypeError DATA\r
+  PyExc_UnboundLocalError=python32.PyExc_UnboundLocalError DATA\r
+  PyExc_UnicodeDecodeError=python32.PyExc_UnicodeDecodeError DATA\r
+  PyExc_UnicodeEncodeError=python32.PyExc_UnicodeEncodeError DATA\r
+  PyExc_UnicodeError=python32.PyExc_UnicodeError DATA\r
+  PyExc_UnicodeTranslateError=python32.PyExc_UnicodeTranslateError DATA\r
+  PyExc_UnicodeWarning=python32.PyExc_UnicodeWarning DATA\r
+  PyExc_UserWarning=python32.PyExc_UserWarning DATA\r
+  PyExc_ValueError=python32.PyExc_ValueError DATA\r
+  PyExc_Warning=python32.PyExc_Warning DATA\r
+  PyExc_ZeroDivisionError=python32.PyExc_ZeroDivisionError DATA\r
+  PyException_GetCause=python32.PyException_GetCause\r
+  PyException_GetContext=python32.PyException_GetContext\r
+  PyException_GetTraceback=python32.PyException_GetTraceback\r
+  PyException_SetCause=python32.PyException_SetCause\r
+  PyException_SetContext=python32.PyException_SetContext\r
+  PyException_SetTraceback=python32.PyException_SetTraceback\r
+  PyFile_FromFd=python32.PyFile_FromFd\r
+  PyFile_GetLine=python32.PyFile_GetLine\r
+  PyFile_WriteObject=python32.PyFile_WriteObject\r
+  PyFile_WriteString=python32.PyFile_WriteString\r
+  PyFilter_Type=python32.PyFilter_Type DATA\r
+  PyFloat_AsDouble=python32.PyFloat_AsDouble\r
+  PyFloat_FromDouble=python32.PyFloat_FromDouble\r
+  PyFloat_FromString=python32.PyFloat_FromString\r
+  PyFloat_GetInfo=python32.PyFloat_GetInfo\r
+  PyFloat_GetMax=python32.PyFloat_GetMax\r
+  PyFloat_GetMin=python32.PyFloat_GetMin\r
+  PyFloat_Type=python32.PyFloat_Type DATA\r
+  PyFrozenSet_New=python32.PyFrozenSet_New\r
+  PyFrozenSet_Type=python32.PyFrozenSet_Type DATA\r
+  PyGC_Collect=python32.PyGC_Collect\r
+  PyGILState_Ensure=python32.PyGILState_Ensure\r
+  PyGILState_GetThisThreadState=python32.PyGILState_GetThisThreadState\r
+  PyGILState_Release=python32.PyGILState_Release\r
+  PyGetSetDescr_Type=python32.PyGetSetDescr_Type DATA\r
+  PyImport_AddModule=python32.PyImport_AddModule\r
+  PyImport_AppendInittab=python32.PyImport_AppendInittab\r
+  PyImport_Cleanup=python32.PyImport_Cleanup\r
+  PyImport_ExecCodeModule=python32.PyImport_ExecCodeModule\r
+  PyImport_ExecCodeModuleEx=python32.PyImport_ExecCodeModuleEx\r
+  PyImport_ExecCodeModuleWithPathnames=python32.PyImport_ExecCodeModuleWithPathnames\r
+  PyImport_GetImporter=python32.PyImport_GetImporter\r
+  PyImport_GetMagicNumber=python32.PyImport_GetMagicNumber\r
+  PyImport_GetMagicTag=python32.PyImport_GetMagicTag\r
+  PyImport_GetModuleDict=python32.PyImport_GetModuleDict\r
+  PyImport_Import=python32.PyImport_Import\r
+  PyImport_ImportFrozenModule=python32.PyImport_ImportFrozenModule\r
+  PyImport_ImportModule=python32.PyImport_ImportModule\r
+  PyImport_ImportModuleLevel=python32.PyImport_ImportModuleLevel\r
+  PyImport_ImportModuleNoBlock=python32.PyImport_ImportModuleNoBlock\r
+  PyImport_ReloadModule=python32.PyImport_ReloadModule\r
+  PyInterpreterState_Clear=python32.PyInterpreterState_Clear\r
+  PyInterpreterState_Delete=python32.PyInterpreterState_Delete\r
+  PyInterpreterState_New=python32.PyInterpreterState_New\r
+  PyIter_Next=python32.PyIter_Next\r
+  PyListIter_Type=python32.PyListIter_Type DATA\r
+  PyListRevIter_Type=python32.PyListRevIter_Type DATA\r
+  PyList_Append=python32.PyList_Append\r
+  PyList_AsTuple=python32.PyList_AsTuple\r
+  PyList_GetItem=python32.PyList_GetItem\r
+  PyList_GetSlice=python32.PyList_GetSlice\r
+  PyList_Insert=python32.PyList_Insert\r
+  PyList_New=python32.PyList_New\r
+  PyList_Reverse=python32.PyList_Reverse\r
+  PyList_SetItem=python32.PyList_SetItem\r
+  PyList_SetSlice=python32.PyList_SetSlice\r
+  PyList_Size=python32.PyList_Size\r
+  PyList_Sort=python32.PyList_Sort\r
+  PyList_Type=python32.PyList_Type DATA\r
+  PyLongRangeIter_Type=python32.PyLongRangeIter_Type DATA\r
+  PyLong_AsDouble=python32.PyLong_AsDouble\r
+  PyLong_AsLong=python32.PyLong_AsLong\r
+  PyLong_AsLongAndOverflow=python32.PyLong_AsLongAndOverflow\r
+  PyLong_AsLongLong=python32.PyLong_AsLongLong\r
+  PyLong_AsLongLongAndOverflow=python32.PyLong_AsLongLongAndOverflow\r
+  PyLong_AsSize_t=python32.PyLong_AsSize_t\r
+  PyLong_AsSsize_t=python32.PyLong_AsSsize_t\r
+  PyLong_AsUnsignedLong=python32.PyLong_AsUnsignedLong\r
+  PyLong_AsUnsignedLongLong=python32.PyLong_AsUnsignedLongLong\r
+  PyLong_AsUnsignedLongLongMask=python32.PyLong_AsUnsignedLongLongMask\r
+  PyLong_AsUnsignedLongMask=python32.PyLong_AsUnsignedLongMask\r
+  PyLong_AsVoidPtr=python32.PyLong_AsVoidPtr\r
+  PyLong_FromDouble=python32.PyLong_FromDouble\r
+  PyLong_FromLong=python32.PyLong_FromLong\r
+  PyLong_FromLongLong=python32.PyLong_FromLongLong\r
+  PyLong_FromSize_t=python32.PyLong_FromSize_t\r
+  PyLong_FromSsize_t=python32.PyLong_FromSsize_t\r
+  PyLong_FromString=python32.PyLong_FromString\r
+  PyLong_FromUnsignedLong=python32.PyLong_FromUnsignedLong\r
+  PyLong_FromUnsignedLongLong=python32.PyLong_FromUnsignedLongLong\r
+  PyLong_FromVoidPtr=python32.PyLong_FromVoidPtr\r
+  PyLong_GetInfo=python32.PyLong_GetInfo\r
+  PyLong_Type=python32.PyLong_Type DATA\r
+  PyMap_Type=python32.PyMap_Type DATA\r
+  PyMapping_Check=python32.PyMapping_Check\r
+  PyMapping_GetItemString=python32.PyMapping_GetItemString\r
+  PyMapping_HasKey=python32.PyMapping_HasKey\r
+  PyMapping_HasKeyString=python32.PyMapping_HasKeyString\r
+  PyMapping_Items=python32.PyMapping_Items\r
+  PyMapping_Keys=python32.PyMapping_Keys\r
+  PyMapping_Length=python32.PyMapping_Length\r
+  PyMapping_SetItemString=python32.PyMapping_SetItemString\r
+  PyMapping_Size=python32.PyMapping_Size\r
+  PyMapping_Values=python32.PyMapping_Values\r
+  PyMem_Free=python32.PyMem_Free\r
+  PyMem_Malloc=python32.PyMem_Malloc\r
+  PyMem_Realloc=python32.PyMem_Realloc\r
+  PyMemberDescr_Type=python32.PyMemberDescr_Type DATA\r
+  PyMemoryView_FromBuffer=python32.PyMemoryView_FromBuffer\r
+  PyMemoryView_FromObject=python32.PyMemoryView_FromObject\r
+  PyMemoryView_GetContiguous=python32.PyMemoryView_GetContiguous\r
+  PyMemoryView_Type=python32.PyMemoryView_Type DATA\r
+  PyMethodDescr_Type=python32.PyMethodDescr_Type DATA\r
+  PyModule_AddIntConstant=python32.PyModule_AddIntConstant\r
+  PyModule_AddObject=python32.PyModule_AddObject\r
+  PyModule_AddStringConstant=python32.PyModule_AddStringConstant\r
+  PyModule_Create2=python32.PyModule_Create2\r
+  PyModule_GetDef=python32.PyModule_GetDef\r
+  PyModule_GetDict=python32.PyModule_GetDict\r
+  PyModule_GetFilename=python32.PyModule_GetFilename\r
+  PyModule_GetFilenameObject=python32.PyModule_GetFilenameObject\r
+  PyModule_GetName=python32.PyModule_GetName\r
+  PyModule_GetState=python32.PyModule_GetState\r
+  PyModule_New=python32.PyModule_New\r
+  PyModule_Type=python32.PyModule_Type DATA\r
+  PyNullImporter_Type=python32.PyNullImporter_Type DATA\r
+  PyNumber_Absolute=python32.PyNumber_Absolute\r
+  PyNumber_Add=python32.PyNumber_Add\r
+  PyNumber_And=python32.PyNumber_And\r
+  PyNumber_AsSsize_t=python32.PyNumber_AsSsize_t\r
+  PyNumber_Check=python32.PyNumber_Check\r
+  PyNumber_Divmod=python32.PyNumber_Divmod\r
+  PyNumber_Float=python32.PyNumber_Float\r
+  PyNumber_FloorDivide=python32.PyNumber_FloorDivide\r
+  PyNumber_InPlaceAdd=python32.PyNumber_InPlaceAdd\r
+  PyNumber_InPlaceAnd=python32.PyNumber_InPlaceAnd\r
+  PyNumber_InPlaceFloorDivide=python32.PyNumber_InPlaceFloorDivide\r
+  PyNumber_InPlaceLshift=python32.PyNumber_InPlaceLshift\r
+  PyNumber_InPlaceMultiply=python32.PyNumber_InPlaceMultiply\r
+  PyNumber_InPlaceOr=python32.PyNumber_InPlaceOr\r
+  PyNumber_InPlacePower=python32.PyNumber_InPlacePower\r
+  PyNumber_InPlaceRemainder=python32.PyNumber_InPlaceRemainder\r
+  PyNumber_InPlaceRshift=python32.PyNumber_InPlaceRshift\r
+  PyNumber_InPlaceSubtract=python32.PyNumber_InPlaceSubtract\r
+  PyNumber_InPlaceTrueDivide=python32.PyNumber_InPlaceTrueDivide\r
+  PyNumber_InPlaceXor=python32.PyNumber_InPlaceXor\r
+  PyNumber_Index=python32.PyNumber_Index\r
+  PyNumber_Invert=python32.PyNumber_Invert\r
+  PyNumber_Long=python32.PyNumber_Long\r
+  PyNumber_Lshift=python32.PyNumber_Lshift\r
+  PyNumber_Multiply=python32.PyNumber_Multiply\r
+  PyNumber_Negative=python32.PyNumber_Negative\r
+  PyNumber_Or=python32.PyNumber_Or\r
+  PyNumber_Positive=python32.PyNumber_Positive\r
+  PyNumber_Power=python32.PyNumber_Power\r
+  PyNumber_Remainder=python32.PyNumber_Remainder\r
+  PyNumber_Rshift=python32.PyNumber_Rshift\r
+  PyNumber_Subtract=python32.PyNumber_Subtract\r
+  PyNumber_ToBase=python32.PyNumber_ToBase\r
+  PyNumber_TrueDivide=python32.PyNumber_TrueDivide\r
+  PyNumber_Xor=python32.PyNumber_Xor\r
+  PyOS_AfterFork=python32.PyOS_AfterFork\r
+  PyOS_InitInterrupts=python32.PyOS_InitInterrupts\r
+  PyOS_InputHook=python32.PyOS_InputHook DATA\r
+  PyOS_InterruptOccurred=python32.PyOS_InterruptOccurred\r
+  PyOS_ReadlineFunctionPointer=python32.PyOS_ReadlineFunctionPointer DATA\r
+  PyOS_double_to_string=python32.PyOS_double_to_string\r
+  PyOS_getsig=python32.PyOS_getsig\r
+  PyOS_mystricmp=python32.PyOS_mystricmp\r
+  PyOS_mystrnicmp=python32.PyOS_mystrnicmp\r
+  PyOS_setsig=python32.PyOS_setsig\r
+  PyOS_snprintf=python32.PyOS_snprintf\r
+  PyOS_string_to_double=python32.PyOS_string_to_double\r
+  PyOS_strtol=python32.PyOS_strtol\r
+  PyOS_strtoul=python32.PyOS_strtoul\r
+  PyOS_vsnprintf=python32.PyOS_vsnprintf\r
+  PyObject_ASCII=python32.PyObject_ASCII\r
+  PyObject_AsCharBuffer=python32.PyObject_AsCharBuffer\r
+  PyObject_AsFileDescriptor=python32.PyObject_AsFileDescriptor\r
+  PyObject_AsReadBuffer=python32.PyObject_AsReadBuffer\r
+  PyObject_AsWriteBuffer=python32.PyObject_AsWriteBuffer\r
+  PyObject_Bytes=python32.PyObject_Bytes\r
+  PyObject_Call=python32.PyObject_Call\r
+  PyObject_CallFunction=python32.PyObject_CallFunction\r
+  PyObject_CallFunctionObjArgs=python32.PyObject_CallFunctionObjArgs\r
+  PyObject_CallMethod=python32.PyObject_CallMethod\r
+  PyObject_CallMethodObjArgs=python32.PyObject_CallMethodObjArgs\r
+  PyObject_CallObject=python32.PyObject_CallObject\r
+  PyObject_CheckReadBuffer=python32.PyObject_CheckReadBuffer\r
+  PyObject_ClearWeakRefs=python32.PyObject_ClearWeakRefs\r
+  PyObject_CopyData=python32.PyObject_CopyData\r
+  PyObject_DelItem=python32.PyObject_DelItem\r
+  PyObject_DelItemString=python32.PyObject_DelItemString\r
+  PyObject_Dir=python32.PyObject_Dir\r
+  PyObject_Format=python32.PyObject_Format\r
+  PyObject_Free=python32.PyObject_Free\r
+  PyObject_GC_Del=python32.PyObject_GC_Del\r
+  PyObject_GC_Track=python32.PyObject_GC_Track\r
+  PyObject_GC_UnTrack=python32.PyObject_GC_UnTrack\r
+  PyObject_GenericGetAttr=python32.PyObject_GenericGetAttr\r
+  PyObject_GenericSetAttr=python32.PyObject_GenericSetAttr\r
+  PyObject_GetAttr=python32.PyObject_GetAttr\r
+  PyObject_GetAttrString=python32.PyObject_GetAttrString\r
+  PyObject_GetBuffer=python32.PyObject_GetBuffer\r
+  PyObject_GetItem=python32.PyObject_GetItem\r
+  PyObject_GetIter=python32.PyObject_GetIter\r
+  PyObject_HasAttr=python32.PyObject_HasAttr\r
+  PyObject_HasAttrString=python32.PyObject_HasAttrString\r
+  PyObject_Hash=python32.PyObject_Hash\r
+  PyObject_HashNotImplemented=python32.PyObject_HashNotImplemented\r
+  PyObject_Init=python32.PyObject_Init\r
+  PyObject_InitVar=python32.PyObject_InitVar\r
+  PyObject_IsInstance=python32.PyObject_IsInstance\r
+  PyObject_IsSubclass=python32.PyObject_IsSubclass\r
+  PyObject_IsTrue=python32.PyObject_IsTrue\r
+  PyObject_Length=python32.PyObject_Length\r
+  PyObject_Malloc=python32.PyObject_Malloc\r
+  PyObject_Not=python32.PyObject_Not\r
+  PyObject_Realloc=python32.PyObject_Realloc\r
+  PyObject_Repr=python32.PyObject_Repr\r
+  PyObject_RichCompare=python32.PyObject_RichCompare\r
+  PyObject_RichCompareBool=python32.PyObject_RichCompareBool\r
+  PyObject_SelfIter=python32.PyObject_SelfIter\r
+  PyObject_SetAttr=python32.PyObject_SetAttr\r
+  PyObject_SetAttrString=python32.PyObject_SetAttrString\r
+  PyObject_SetItem=python32.PyObject_SetItem\r
+  PyObject_Size=python32.PyObject_Size\r
+  PyObject_Str=python32.PyObject_Str\r
+  PyObject_Type=python32.PyObject_Type DATA\r
+  PyParser_SimpleParseFileFlags=python32.PyParser_SimpleParseFileFlags\r
+  PyParser_SimpleParseStringFlags=python32.PyParser_SimpleParseStringFlags\r
+  PyProperty_Type=python32.PyProperty_Type DATA\r
+  PyRangeIter_Type=python32.PyRangeIter_Type DATA\r
+  PyRange_Type=python32.PyRange_Type DATA\r
+  PyReversed_Type=python32.PyReversed_Type DATA\r
+  PySeqIter_New=python32.PySeqIter_New\r
+  PySeqIter_Type=python32.PySeqIter_Type DATA\r
+  PySequence_Check=python32.PySequence_Check\r
+  PySequence_Concat=python32.PySequence_Concat\r
+  PySequence_Contains=python32.PySequence_Contains\r
+  PySequence_Count=python32.PySequence_Count\r
+  PySequence_DelItem=python32.PySequence_DelItem\r
+  PySequence_DelSlice=python32.PySequence_DelSlice\r
+  PySequence_Fast=python32.PySequence_Fast\r
+  PySequence_GetItem=python32.PySequence_GetItem\r
+  PySequence_GetSlice=python32.PySequence_GetSlice\r
+  PySequence_In=python32.PySequence_In\r
+  PySequence_InPlaceConcat=python32.PySequence_InPlaceConcat\r
+  PySequence_InPlaceRepeat=python32.PySequence_InPlaceRepeat\r
+  PySequence_Index=python32.PySequence_Index\r
+  PySequence_Length=python32.PySequence_Length\r
+  PySequence_List=python32.PySequence_List\r
+  PySequence_Repeat=python32.PySequence_Repeat\r
+  PySequence_SetItem=python32.PySequence_SetItem\r
+  PySequence_SetSlice=python32.PySequence_SetSlice\r
+  PySequence_Size=python32.PySequence_Size\r
+  PySequence_Tuple=python32.PySequence_Tuple\r
+  PySetIter_Type=python32.PySetIter_Type DATA\r
+  PySet_Add=python32.PySet_Add\r
+  PySet_Clear=python32.PySet_Clear\r
+  PySet_Contains=python32.PySet_Contains\r
+  PySet_Discard=python32.PySet_Discard\r
+  PySet_New=python32.PySet_New\r
+  PySet_Pop=python32.PySet_Pop\r
+  PySet_Size=python32.PySet_Size\r
+  PySet_Type=python32.PySet_Type DATA\r
+  PySlice_GetIndices=python32.PySlice_GetIndices\r
+  PySlice_GetIndicesEx=python32.PySlice_GetIndicesEx\r
+  PySlice_New=python32.PySlice_New\r
+  PySlice_Type=python32.PySlice_Type DATA\r
+  PySortWrapper_Type=python32.PySortWrapper_Type DATA\r
+  PyState_FindModule=python32.PyState_FindModule\r
+  PyStructSequence_GetItem=python32.PyStructSequence_GetItem\r
+  PyStructSequence_New=python32.PyStructSequence_New\r
+  PyStructSequence_NewType=python32.PyStructSequence_NewType\r
+  PyStructSequence_SetItem=python32.PyStructSequence_SetItem\r
+  PySuper_Type=python32.PySuper_Type DATA\r
+  PySys_AddWarnOption=python32.PySys_AddWarnOption\r
+  PySys_AddWarnOptionUnicode=python32.PySys_AddWarnOptionUnicode\r
+  PySys_FormatStderr=python32.PySys_FormatStderr\r
+  PySys_FormatStdout=python32.PySys_FormatStdout\r
+  PySys_GetObject=python32.PySys_GetObject\r
+  PySys_HasWarnOptions=python32.PySys_HasWarnOptions\r
+  PySys_ResetWarnOptions=python32.PySys_ResetWarnOptions\r
+  PySys_SetArgv=python32.PySys_SetArgv\r
+  PySys_SetArgvEx=python32.PySys_SetArgvEx\r
+  PySys_SetObject=python32.PySys_SetObject\r
+  PySys_SetPath=python32.PySys_SetPath\r
+  PySys_WriteStderr=python32.PySys_WriteStderr\r
+  PySys_WriteStdout=python32.PySys_WriteStdout\r
+  PyThreadState_Clear=python32.PyThreadState_Clear\r
+  PyThreadState_Delete=python32.PyThreadState_Delete\r
+  PyThreadState_DeleteCurrent=python32.PyThreadState_DeleteCurrent\r
+  PyThreadState_Get=python32.PyThreadState_Get\r
+  PyThreadState_GetDict=python32.PyThreadState_GetDict\r
+  PyThreadState_New=python32.PyThreadState_New\r
+  PyThreadState_SetAsyncExc=python32.PyThreadState_SetAsyncExc\r
+  PyThreadState_Swap=python32.PyThreadState_Swap\r
+  PyTraceBack_Here=python32.PyTraceBack_Here\r
+  PyTraceBack_Print=python32.PyTraceBack_Print\r
+  PyTraceBack_Type=python32.PyTraceBack_Type DATA\r
+  PyTupleIter_Type=python32.PyTupleIter_Type DATA\r
+  PyTuple_ClearFreeList=python32.PyTuple_ClearFreeList\r
+  PyTuple_GetItem=python32.PyTuple_GetItem\r
+  PyTuple_GetSlice=python32.PyTuple_GetSlice\r
+  PyTuple_New=python32.PyTuple_New\r
+  PyTuple_Pack=python32.PyTuple_Pack\r
+  PyTuple_SetItem=python32.PyTuple_SetItem\r
+  PyTuple_Size=python32.PyTuple_Size\r
+  PyTuple_Type=python32.PyTuple_Type DATA\r
+  PyType_ClearCache=python32.PyType_ClearCache\r
+  PyType_FromSpec=python32.PyType_FromSpec\r
+  PyType_GenericAlloc=python32.PyType_GenericAlloc\r
+  PyType_GenericNew=python32.PyType_GenericNew\r
+  PyType_IsSubtype=python32.PyType_IsSubtype\r
+  PyType_Modified=python32.PyType_Modified\r
+  PyType_Ready=python32.PyType_Ready\r
+  PyType_Type=python32.PyType_Type DATA\r
+  PyUnicodeDecodeError_Create=python32.PyUnicodeDecodeError_Create\r
+  PyUnicodeDecodeError_GetEncoding=python32.PyUnicodeDecodeError_GetEncoding\r
+  PyUnicodeDecodeError_GetEnd=python32.PyUnicodeDecodeError_GetEnd\r
+  PyUnicodeDecodeError_GetObject=python32.PyUnicodeDecodeError_GetObject\r
+  PyUnicodeDecodeError_GetReason=python32.PyUnicodeDecodeError_GetReason\r
+  PyUnicodeDecodeError_GetStart=python32.PyUnicodeDecodeError_GetStart\r
+  PyUnicodeDecodeError_SetEnd=python32.PyUnicodeDecodeError_SetEnd\r
+  PyUnicodeDecodeError_SetReason=python32.PyUnicodeDecodeError_SetReason\r
+  PyUnicodeDecodeError_SetStart=python32.PyUnicodeDecodeError_SetStart\r
+  PyUnicodeEncodeError_GetEncoding=python32.PyUnicodeEncodeError_GetEncoding\r
+  PyUnicodeEncodeError_GetEnd=python32.PyUnicodeEncodeError_GetEnd\r
+  PyUnicodeEncodeError_GetObject=python32.PyUnicodeEncodeError_GetObject\r
+  PyUnicodeEncodeError_GetReason=python32.PyUnicodeEncodeError_GetReason\r
+  PyUnicodeEncodeError_GetStart=python32.PyUnicodeEncodeError_GetStart\r
+  PyUnicodeEncodeError_SetEnd=python32.PyUnicodeEncodeError_SetEnd\r
+  PyUnicodeEncodeError_SetReason=python32.PyUnicodeEncodeError_SetReason\r
+  PyUnicodeEncodeError_SetStart=python32.PyUnicodeEncodeError_SetStart\r
+  PyUnicodeIter_Type=python32.PyUnicodeIter_Type DATA\r
+  PyUnicodeTranslateError_GetEnd=python32.PyUnicodeTranslateError_GetEnd\r
+  PyUnicodeTranslateError_GetObject=python32.PyUnicodeTranslateError_GetObject\r
+  PyUnicodeTranslateError_GetReason=python32.PyUnicodeTranslateError_GetReason\r
+  PyUnicodeTranslateError_GetStart=python32.PyUnicodeTranslateError_GetStart\r
+  PyUnicodeTranslateError_SetEnd=python32.PyUnicodeTranslateError_SetEnd\r
+  PyUnicodeTranslateError_SetReason=python32.PyUnicodeTranslateError_SetReason\r
+  PyUnicodeTranslateError_SetStart=python32.PyUnicodeTranslateError_SetStart\r
+  PyUnicode_Append=python32.PyUnicodeUCS2_Append\r
+  PyUnicode_AppendAndDel=python32.PyUnicodeUCS2_AppendAndDel\r
+  PyUnicode_AsASCIIString=python32.PyUnicodeUCS2_AsASCIIString\r
+  PyUnicode_AsCharmapString=python32.PyUnicodeUCS2_AsCharmapString\r
+  PyUnicode_AsDecodedObject=python32.PyUnicodeUCS2_AsDecodedObject\r
+  PyUnicode_AsDecodedUnicode=python32.PyUnicodeUCS2_AsDecodedUnicode\r
+  PyUnicode_AsEncodedObject=python32.PyUnicodeUCS2_AsEncodedObject\r
+  PyUnicode_AsEncodedString=python32.PyUnicodeUCS2_AsEncodedString\r
+  PyUnicode_AsEncodedUnicode=python32.PyUnicodeUCS2_AsEncodedUnicode\r
+  PyUnicode_AsLatin1String=python32.PyUnicodeUCS2_AsLatin1String\r
+  PyUnicode_AsRawUnicodeEscapeString=python32.PyUnicodeUCS2_AsRawUnicodeEscapeString\r
+  PyUnicode_AsUTF16String=python32.PyUnicodeUCS2_AsUTF16String\r
+  PyUnicode_AsUTF32String=python32.PyUnicodeUCS2_AsUTF32String\r
+  PyUnicode_AsUTF8String=python32.PyUnicodeUCS2_AsUTF8String\r
+  PyUnicode_AsUnicodeEscapeString=python32.PyUnicodeUCS2_AsUnicodeEscapeString\r
+  PyUnicode_AsWideChar=python32.PyUnicodeUCS2_AsWideChar\r
+  PyUnicode_ClearFreelist=python32.PyUnicodeUCS2_ClearFreelist\r
+  PyUnicode_Compare=python32.PyUnicodeUCS2_Compare\r
+  PyUnicode_Concat=python32.PyUnicodeUCS2_Concat\r
+  PyUnicode_Contains=python32.PyUnicodeUCS2_Contains\r
+  PyUnicode_Count=python32.PyUnicodeUCS2_Count\r
+  PyUnicode_Decode=python32.PyUnicodeUCS2_Decode\r
+  PyUnicode_DecodeASCII=python32.PyUnicodeUCS2_DecodeASCII\r
+  PyUnicode_DecodeCharmap=python32.PyUnicodeUCS2_DecodeCharmap\r
+  PyUnicode_DecodeFSDefault=python32.PyUnicodeUCS2_DecodeFSDefault\r
+  PyUnicode_DecodeFSDefaultAndSize=python32.PyUnicodeUCS2_DecodeFSDefaultAndSize\r
+  PyUnicode_DecodeLatin1=python32.PyUnicodeUCS2_DecodeLatin1\r
+  PyUnicode_DecodeRawUnicodeEscape=python32.PyUnicodeUCS2_DecodeRawUnicodeEscape\r
+  PyUnicode_DecodeUTF16=python32.PyUnicodeUCS2_DecodeUTF16\r
+  PyUnicode_DecodeUTF16Stateful=python32.PyUnicodeUCS2_DecodeUTF16Stateful\r
+  PyUnicode_DecodeUTF32=python32.PyUnicodeUCS2_DecodeUTF32\r
+  PyUnicode_DecodeUTF32Stateful=python32.PyUnicodeUCS2_DecodeUTF32Stateful\r
+  PyUnicode_DecodeUTF8=python32.PyUnicodeUCS2_DecodeUTF8\r
+  PyUnicode_DecodeUTF8Stateful=python32.PyUnicodeUCS2_DecodeUTF8Stateful\r
+  PyUnicode_DecodeUnicodeEscape=python32.PyUnicodeUCS2_DecodeUnicodeEscape\r
+  PyUnicode_FSConverter=python32.PyUnicodeUCS2_FSConverter\r
+  PyUnicode_FSDecoder=python32.PyUnicodeUCS2_FSDecoder\r
+  PyUnicode_Find=python32.PyUnicodeUCS2_Find\r
+  PyUnicode_Format=python32.PyUnicodeUCS2_Format\r
+  PyUnicode_FromEncodedObject=python32.PyUnicodeUCS2_FromEncodedObject\r
+  PyUnicode_FromFormat=python32.PyUnicodeUCS2_FromFormat\r
+  PyUnicode_FromFormatV=python32.PyUnicodeUCS2_FromFormatV\r
+  PyUnicode_FromObject=python32.PyUnicodeUCS2_FromObject\r
+  PyUnicode_FromOrdinal=python32.PyUnicodeUCS2_FromOrdinal\r
+  PyUnicode_FromString=python32.PyUnicodeUCS2_FromString\r
+  PyUnicode_FromStringAndSize=python32.PyUnicodeUCS2_FromStringAndSize\r
+  PyUnicode_FromWideChar=python32.PyUnicodeUCS2_FromWideChar\r
+  PyUnicode_GetDefaultEncoding=python32.PyUnicodeUCS2_GetDefaultEncoding\r
+  PyUnicode_GetSize=python32.PyUnicodeUCS2_GetSize\r
+  PyUnicode_IsIdentifier=python32.PyUnicodeUCS2_IsIdentifier\r
+  PyUnicode_Join=python32.PyUnicodeUCS2_Join\r
+  PyUnicode_Partition=python32.PyUnicodeUCS2_Partition\r
+  PyUnicode_RPartition=python32.PyUnicodeUCS2_RPartition\r
+  PyUnicode_RSplit=python32.PyUnicodeUCS2_RSplit\r
+  PyUnicode_Replace=python32.PyUnicodeUCS2_Replace\r
+  PyUnicode_Resize=python32.PyUnicodeUCS2_Resize\r
+  PyUnicode_RichCompare=python32.PyUnicodeUCS2_RichCompare\r
+  PyUnicode_SetDefaultEncoding=python32.PyUnicodeUCS2_SetDefaultEncoding\r
+  PyUnicode_Split=python32.PyUnicodeUCS2_Split\r
+  PyUnicode_Splitlines=python32.PyUnicodeUCS2_Splitlines\r
+  PyUnicode_Tailmatch=python32.PyUnicodeUCS2_Tailmatch\r
+  PyUnicode_Translate=python32.PyUnicodeUCS2_Translate\r
+  PyUnicode_BuildEncodingMap=python32.PyUnicode_BuildEncodingMap\r
+  PyUnicode_CompareWithASCIIString=python32.PyUnicode_CompareWithASCIIString\r
+  PyUnicode_DecodeUTF7=python32.PyUnicode_DecodeUTF7\r
+  PyUnicode_DecodeUTF7Stateful=python32.PyUnicode_DecodeUTF7Stateful\r
+  PyUnicode_EncodeFSDefault=python32.PyUnicode_EncodeFSDefault\r
+  PyUnicode_InternFromString=python32.PyUnicode_InternFromString\r
+  PyUnicode_InternImmortal=python32.PyUnicode_InternImmortal\r
+  PyUnicode_InternInPlace=python32.PyUnicode_InternInPlace\r
+  PyUnicode_Type=python32.PyUnicode_Type DATA\r
+  PyWeakref_GetObject=python32.PyWeakref_GetObject DATA\r
+  PyWeakref_NewProxy=python32.PyWeakref_NewProxy\r
+  PyWeakref_NewRef=python32.PyWeakref_NewRef\r
+  PyWrapperDescr_Type=python32.PyWrapperDescr_Type DATA\r
+  PyWrapper_New=python32.PyWrapper_New\r
+  PyZip_Type=python32.PyZip_Type DATA\r
+  Py_AddPendingCall=python32.Py_AddPendingCall\r
+  Py_AtExit=python32.Py_AtExit\r
+  Py_BuildValue=python32.Py_BuildValue\r
+  Py_CompileStringFlags=python32.Py_CompileStringFlags\r
+  Py_DecRef=python32.Py_DecRef\r
+  Py_EndInterpreter=python32.Py_EndInterpreter\r
+  Py_Exit=python32.Py_Exit\r
+  Py_FatalError=python32.Py_FatalError\r
+  Py_FileSystemDefaultEncoding=python32.Py_FileSystemDefaultEncoding DATA\r
+  Py_Finalize=python32.Py_Finalize\r
+  Py_GetBuildInfo=python32.Py_GetBuildInfo\r
+  Py_GetCompiler=python32.Py_GetCompiler\r
+  Py_GetCopyright=python32.Py_GetCopyright\r
+  Py_GetExecPrefix=python32.Py_GetExecPrefix\r
+  Py_GetPath=python32.Py_GetPath\r
+  Py_GetPlatform=python32.Py_GetPlatform\r
+  Py_GetPrefix=python32.Py_GetPrefix\r
+  Py_GetProgramFullPath=python32.Py_GetProgramFullPath\r
+  Py_GetProgramName=python32.Py_GetProgramName\r
+  Py_GetPythonHome=python32.Py_GetPythonHome\r
+  Py_GetRecursionLimit=python32.Py_GetRecursionLimit\r
+  Py_GetVersion=python32.Py_GetVersion\r
+  Py_HasFileSystemDefaultEncoding=python32.Py_HasFileSystemDefaultEncoding DATA\r
+  Py_IncRef=python32.Py_IncRef\r
+  Py_Initialize=python32.Py_Initialize\r
+  Py_InitializeEx=python32.Py_InitializeEx\r
+  Py_IsInitialized=python32.Py_IsInitialized\r
+  Py_Main=python32.Py_Main\r
+  Py_MakePendingCalls=python32.Py_MakePendingCalls\r
+  Py_NewInterpreter=python32.Py_NewInterpreter\r
+  Py_ReprEnter=python32.Py_ReprEnter\r
+  Py_ReprLeave=python32.Py_ReprLeave\r
+  Py_SetProgramName=python32.Py_SetProgramName\r
+  Py_SetPythonHome=python32.Py_SetPythonHome\r
+  Py_SetRecursionLimit=python32.Py_SetRecursionLimit\r
+  Py_SymtableString=python32.Py_SymtableString\r
+  Py_VaBuildValue=python32.Py_VaBuildValue\r
+  _PyErr_BadInternalCall=python32._PyErr_BadInternalCall\r
+  _PyObject_CallFunction_SizeT=python32._PyObject_CallFunction_SizeT\r
+  _PyObject_CallMethod_SizeT=python32._PyObject_CallMethod_SizeT\r
+  _PyObject_GC_Malloc=python32._PyObject_GC_Malloc\r
+  _PyObject_GC_New=python32._PyObject_GC_New\r
+  _PyObject_GC_NewVar=python32._PyObject_GC_NewVar\r
+  _PyObject_GC_Resize=python32._PyObject_GC_Resize\r
+  _PyObject_New=python32._PyObject_New\r
+  _PyObject_NewVar=python32._PyObject_NewVar\r
+  _PyState_AddModule=python32._PyState_AddModule\r
+  _PyThreadState_Init=python32._PyThreadState_Init\r
+  _PyThreadState_Prealloc=python32._PyThreadState_Prealloc\r
+  _PyTrash_delete_later=python32._PyTrash_delete_later DATA\r
+  _PyTrash_delete_nesting=python32._PyTrash_delete_nesting DATA\r
+  _PyTrash_deposit_object=python32._PyTrash_deposit_object\r
+  _PyTrash_destroy_chain=python32._PyTrash_destroy_chain\r
+  _PyWeakref_CallableProxyType=python32._PyWeakref_CallableProxyType DATA\r
+  _PyWeakref_ProxyType=python32._PyWeakref_ProxyType DATA\r
+  _PyWeakref_RefType=python32._PyWeakref_RefType DATA\r
+  _Py_BuildValue_SizeT=python32._Py_BuildValue_SizeT\r
+  _Py_CheckRecursionLimit=python32._Py_CheckRecursionLimit DATA\r
+  _Py_CheckRecursiveCall=python32._Py_CheckRecursiveCall\r
+  _Py_Dealloc=python32._Py_Dealloc\r
+  _Py_EllipsisObject=python32._Py_EllipsisObject DATA\r
+  _Py_FalseStruct=python32._Py_FalseStruct DATA\r
+  _Py_NoneStruct=python32.Py_GetCopyright\r
+  _Py_NotImplementedStruct=python32._Py_NotImplementedStruct DATA\r
+  _Py_SwappedOp=python32._Py_SwappedOp DATA\r
+  _Py_TrueStruct=python32._Py_TrueStruct DATA\r
+  _Py_VaBuildValue_SizeT=python32._Py_VaBuildValue_SizeT\r
diff --git a/PC/python3dll.c b/PC/python3dll.c
new file mode 100644 (file)
index 0000000..b171fca
--- /dev/null
@@ -0,0 +1,9 @@
+#include <windows.h>\r
+\r
+BOOL WINAPI\r
+DllMain(HINSTANCE hInstDLL,\r
+        DWORD fdwReason,\r
+        LPVOID lpReserved)\r
+{\r
+    return TRUE;\r
+}
\ No newline at end of file
index 956a7eab4870481a0ae742c76f703b43285d1120..9e103a1d2a7ef3ed70c90b8ac383048fd8021aa9 100644 (file)
@@ -133,6 +133,13 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ssl", "ssl.vcproj", "{E5B04
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kill_python", "kill_python.vcproj", "{6DE10744-E396-40A5-B4E2-1B69AA7C8D31}"\r
 EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python3dll", "python3dll.vcproj", "{885D4898-D08D-4091-9C40-C700CFE3FC5A}"\r
+       ProjectSection(ProjectDependencies) = postProject\r
+               {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}\r
+       EndProjectSection\r
+EndProject\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xxlimited", "xxlimited.vcproj", "{F749B822-B489-4CA5-A3AD-CE078F5F338A}"\r
+EndProject\r
 Global\r
        GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
                Debug|Win32 = Debug|Win32\r
@@ -553,6 +560,32 @@ Global
                {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|Win32.Build.0 = Release|Win32\r
                {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.ActiveCfg = Release|x64\r
                {6DE10744-E396-40A5-B4E2-1B69AA7C8D31}.Release|x64.Build.0 = Release|x64\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.Debug|Win32.ActiveCfg = PGUpdate|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.Debug|x64.ActiveCfg = PGUpdate|x64\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|Win32.Build.0 = PGInstrument|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGInstrument|x64.ActiveCfg = PGInstrument|x64\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|Win32.Build.0 = PGUpdate|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.PGUpdate|x64.ActiveCfg = PGUpdate|x64\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|Win32.ActiveCfg = Release|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|Win32.Build.0 = Release|Win32\r
+               {885D4898-D08D-4091-9C40-C700CFE3FC5A}.Release|x64.ActiveCfg = Release|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|Win32.ActiveCfg = PGUpdate|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|x64.ActiveCfg = PGUpdate|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Debug|x64.Build.0 = PGUpdate|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|Win32.ActiveCfg = PGInstrument|Win32\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|Win32.Build.0 = PGInstrument|Win32\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|x64.ActiveCfg = PGInstrument|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGInstrument|x64.Build.0 = PGInstrument|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|Win32.ActiveCfg = PGUpdate|Win32\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|Win32.Build.0 = PGUpdate|Win32\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|x64.ActiveCfg = PGUpdate|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.PGUpdate|x64.Build.0 = PGUpdate|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|Win32.ActiveCfg = Release|Win32\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|Win32.Build.0 = Release|Win32\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|x64.ActiveCfg = Release|x64\r
+               {F749B822-B489-4CA5-A3AD-CE078F5F338A}.Release|x64.Build.0 = Release|x64\r
        EndGlobalSection\r
        GlobalSection(SolutionProperties) = preSolution\r
                HideSolutionNode = FALSE\r
diff --git a/PCbuild/python3dll.vcproj b/PCbuild/python3dll.vcproj
new file mode 100644 (file)
index 0000000..8dcd90a
--- /dev/null
@@ -0,0 +1,434 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="9,00"\r
+       Name="python3dll"\r
+       ProjectGUID="{885D4898-D08D-4091-9C40-C700CFE3FC5A}"\r
+       RootNamespace="python3dll"\r
+       Keyword="Win32Proj"\r
+       TargetFrameworkVersion="196613"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+               <Platform\r
+                       Name="x64"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyproject.vsprops;.\release.vsprops"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               Optimization="2"\r
+                               EnableIntrinsicFunctions="true"\r
+                               PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;PYTHON3DLL_EXPORTS"\r
+                               RuntimeLibrary="2"\r
+                               BufferSecurityCheck="false"\r
+                               EnableFunctionLevelLinking="true"\r
+                               UsePrecompiledHeader="0"\r
+                               WarningLevel="3"\r
+                               DebugInformationFormat="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="..\PC\python32.lib"\r
+                               OutputFile="$(OutDir)\python3.dll"\r
+                               LinkIncremental="1"\r
+                               IgnoreAllDefaultLibraries="true"\r
+                               ModuleDefinitionFile="..\PC\python3.def"\r
+                               GenerateDebugInformation="true"\r
+                               SubSystem="2"\r
+                               OptimizeReferences="2"\r
+                               EnableCOMDATFolding="2"\r
+                               EntryPointSymbol="DllMain"\r
+                               TargetMachine="1"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|x64"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops;.\release.vsprops"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(OutDir)\python3.dll"\r
+                               ModuleDefinitionFile="..\PC\python3.def"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGInstrument|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyproject.vsprops;.\release.vsprops;.\pginstrument.vsprops"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="python32.lib"\r
+                               OutputFile="$(OutDir)\python3.dll"\r
+                               ModuleDefinitionFile="..\PC\python3.def"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGInstrument|x64"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops;.\release.vsprops;.\pginstrument.vsprops"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(OutDir)\python3.dll"\r
+                               ModuleDefinitionFile="..\PC\python3.def"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGUpdate|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyproject.vsprops;.\release.vsprops;.\pgupdate.vsprops"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="python32.lib"\r
+                               OutputFile="$(OutDir)\python3.dll"\r
+                               ModuleDefinitionFile="..\PC\python3.def"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGUpdate|x64"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyproject.vsprops;.\x64.vsprops;.\release.vsprops;.\pgupdate.vsprops"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(OutDir)\python3.dll"\r
+                               ModuleDefinitionFile="..\PC\python3.def"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
+                       UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\PC\python3.def"\r
+                               >\r
+                       </File>\r
+                       <File\r
+                               RelativePath="..\PC\python3dll.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+               <Filter\r
+                       Name="Header Files"\r
+                       Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
+                       UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
+                       >\r
+               </Filter>\r
+               <Filter\r
+                       Name="Resource Files"\r
+                       Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
+                       UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\PC\python_nt.rc"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/PCbuild/xxlimited.vcproj b/PCbuild/xxlimited.vcproj
new file mode 100644 (file)
index 0000000..dc923e8
--- /dev/null
@@ -0,0 +1,417 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="9,00"\r
+       Name="xxlimited"\r
+       ProjectGUID="{F749B822-B489-4CA5-A3AD-CE078F5F338A}"\r
+       RootNamespace="xxlimited"\r
+       Keyword="Win32Proj"\r
+       TargetFrameworkVersion="196613"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+               <Platform\r
+                       Name="x64"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyd.vsprops"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               PreprocessorDefinitions="NDEBUG;_WIN32;_WINDLL;Py_LIMITED_API;$(NOINHERIT)"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="wsock32.lib"\r
+                               IgnoreDefaultLibraryNames="libc"\r
+                               BaseAddress="0x1D110000"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|x64"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyd.vsprops;.\x64.vsprops"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="wsock32.lib"\r
+                               IgnoreDefaultLibraryNames="libc"\r
+                               BaseAddress="0x1D110000"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGInstrument|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyd.vsprops;.\pginstrument.vsprops"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               PreprocessorDefinitions="Py_LIMITED_API"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="wsock32.lib"\r
+                               IgnoreDefaultLibraryNames="libc"\r
+                               BaseAddress="0x1D110000"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGInstrument|x64"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyd.vsprops;.\x64.vsprops;.\pginstrument.vsprops"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="wsock32.lib"\r
+                               IgnoreDefaultLibraryNames="libc"\r
+                               BaseAddress="0x1D110000"\r
+                               TargetMachine="17"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGUpdate|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyd.vsprops;.\pgupdate.vsprops"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               PreprocessorDefinitions="Py_LIMITED_API"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="wsock32.lib"\r
+                               IgnoreDefaultLibraryNames="libc"\r
+                               BaseAddress="0x1D110000"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="PGUpdate|x64"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets=".\pyd.vsprops;.\x64.vsprops;.\pgupdate.vsprops"\r
+                       CharacterSet="0"\r
+                       WholeProgramOptimization="1"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               AdditionalDependencies="wsock32.lib"\r
+                               IgnoreDefaultLibraryNames="libc"\r
+                               BaseAddress="0x1D110000"\r
+                               TargetMachine="17"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <Filter\r
+                       Name="Source Files"\r
+                       >\r
+                       <File\r
+                               RelativePath="..\Modules\xxlimited.c"\r
+                               >\r
+                       </File>\r
+               </Filter>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
index f300ab2a7b057624f6f9113c79da4d2045b18968..765464a73e9d60c1401a6498468d415f3810ed4b 100644 (file)
@@ -727,7 +727,7 @@ builtin_eval(PyObject *self, PyObject *args)
         "code object passed to eval() may not contain free variables");
             return NULL;
         }
-        return PyEval_EvalCode((PyCodeObject *) cmd, globals, locals);
+        return PyEval_EvalCode(cmd, globals, locals);
     }
 
     cf.cf_flags = PyCF_SOURCE_IS_UTF8;
@@ -803,7 +803,7 @@ builtin_exec(PyObject *self, PyObject *args)
                 "contain free variables");
             return NULL;
         }
-        v = PyEval_EvalCode((PyCodeObject *) prog, globals, locals);
+        v = PyEval_EvalCode(prog, globals, locals);
     }
     else {
         char *str;
index 140112fc1395925d47dd0cb7e12ab3523aed1470..684c6c28f34d4d339493629ca058e98099d2aeb6 100644 (file)
@@ -755,7 +755,7 @@ static int _Py_TracingPossible = 0;
 
 
 PyObject *
-PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
+PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
 {
     return PyEval_EvalCodeEx(co,
                       globals, locals,
@@ -3059,10 +3059,11 @@ exit_eval_frame:
    the test in the if statements in Misc/gdbinit (pystack and pystackv). */
 
 PyObject *
-PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
+PyEval_EvalCodeEx(PyObject *_co, PyObject *globals, PyObject *locals,
            PyObject **args, int argcount, PyObject **kws, int kwcount,
            PyObject **defs, int defcount, PyObject *kwdefs, PyObject *closure)
 {
+    PyCodeObject* co = (PyCodeObject*)_co;
     register PyFrameObject *f;
     register PyObject *retval = NULL;
     register PyObject **fastlocals, **freevars;
@@ -3968,7 +3969,7 @@ fast_function(PyObject *func, PyObject ***pp_stack, int n, int na, int nk)
         d = &PyTuple_GET_ITEM(argdefs, 0);
         nd = Py_SIZE(argdefs);
     }
-    return PyEval_EvalCodeEx(co, globals,
+    return PyEval_EvalCodeEx((PyObject*)co, globals,
                              (PyObject *)NULL, (*pp_stack)-n, na,
                              (*pp_stack)-2*nk, nk, d, nd, kwdefs,
                              PyFunction_GET_CLOSURE(func));
index 3d0fb5eb01afc9c240ec4fd1fb2a169e85cf9a6f..7ea510e862dfabd2834779f1d2338f61b903ef72 100644 (file)
@@ -53,6 +53,8 @@ const struct filedescr _PyImport_DynLoadFiletab[] = {
 #else  /* !__VMS */
     {"." SOABI ".so", "rb", C_EXTENSION},
     {"module." SOABI ".so", "rb", C_EXTENSION},
+    {".abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION},
+    {"module.abi" PYTHON_ABI_STRING ".so", "rb", C_EXTENSION},
     {".so", "rb", C_EXTENSION},
     {"module.so", "rb", C_EXTENSION},
 #endif  /* __VMS */
index e7d61ce8e0fe902a1cab40beb2e68d2b098d164f..73a1dcf897f723941edc4e109f329d0443398972 100644 (file)
@@ -134,6 +134,15 @@ static char *GetPythonImport (HINSTANCE hModule)
                 !strncmp(import_name,"python",6)) {
                 char *pch;
 
+#ifndef _DEBUG
+                /* In a release version, don't claim that python3.dll is
+                   a Python DLL. */
+                if (strcmp(import_name, "python3.dll") == 0) {
+                    import_data += 20;
+                    continue;
+                }
+#endif
+
                 /* Ensure python prefix is followed only
                    by numbers to the end of the basename */
                 pch = import_name + 6;
@@ -162,13 +171,16 @@ static char *GetPythonImport (HINSTANCE hModule)
     return NULL;
 }
 
-
 dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
                                     const char *pathname, FILE *fp)
 {
     dl_funcptr p;
     char funcname[258], *import_python;
 
+#ifndef _DEBUG
+    _Py_CheckPython3();
+#endif
+
     PyOS_snprintf(funcname, sizeof(funcname), "PyInit_%.200s", shortname);
 
     {
index ce7cbc297e1eb2aa53bd02e9941eeeaf39fd6e55..23752eeb720c0e7da562c5f63e3028eb70fd2102 100644 (file)
@@ -806,7 +806,7 @@ PyImport_ExecCodeModuleWithPathnames(char *name, PyObject *co, char *pathname,
         PyErr_Clear(); /* Not important enough to report */
     Py_DECREF(v);
 
-    v = PyEval_EvalCode((PyCodeObject *)co, d, d);
+    v = PyEval_EvalCode(co, d, d);
     if (v == NULL)
         goto error;
     Py_DECREF(v);
index de8e9da4b66ce4ea4b3b56f4c10d6fc8527ee22c..3f6385d455c99bea849b9fdc45036f414f882ac2 100644 (file)
@@ -1755,7 +1755,7 @@ run_mod(mod_ty mod, const char *filename, PyObject *globals, PyObject *locals,
     co = PyAST_Compile(mod, filename, flags, arena);
     if (co == NULL)
         return NULL;
-    v = PyEval_EvalCode(co, globals, locals);
+    v = PyEval_EvalCode((PyObject*)co, globals, locals);
     Py_DECREF(co);
     return v;
 }
@@ -1785,7 +1785,7 @@ run_pyc_file(FILE *fp, const char *filename, PyObject *globals,
         return NULL;
     }
     co = (PyCodeObject *)v;
-    v = PyEval_EvalCode(co, globals, locals);
+    v = PyEval_EvalCode((PyObject*)co, globals, locals);
     if (v && flags)
         flags->cf_flags |= (co->co_flags & PyCF_MASK);
     Py_DECREF(co);
@@ -1817,6 +1817,14 @@ Py_CompileStringFlags(const char *str, const char *filename, int start,
     return (PyObject *)co;
 }
 
+/* For use in Py_LIMITED_API */
+#undef Py_CompileString
+PyObject *
+PyCompileString(const char *str, const char *filename, int start)
+{
+    return Py_CompileStringFlags(str, filename, start, NULL);
+}
+
 struct symtable *
 Py_SymtableString(const char *str, const char *filename, int start)
 {
diff --git a/Tools/scripts/abitype.py b/Tools/scripts/abitype.py
new file mode 100644 (file)
index 0000000..afb104b
--- /dev/null
@@ -0,0 +1,200 @@
+# This script converts a C file to use the PEP 384 type definition API
+# Usage: abitype.py < old_code > new_code
+import re, sys
+
+############ Simplistic C scanner ##################################
+tokenizer = re.compile(
+    r"(?P<preproc>#.*\n)"
+    r"|(?P<comment>/\*.*?\*/)"
+    r"|(?P<ident>[a-zA-Z_][a-zA-Z0-9_]*)"
+    r"|(?P<ws>[ \t\n]+)"
+    r"|(?P<other>.)",
+    re.MULTILINE)
+
+tokens = []
+source = sys.stdin.read()
+pos = 0
+while pos != len(source):
+    m = tokenizer.match(source, pos)
+    tokens.append([m.lastgroup, m.group()])
+    pos += len(tokens[-1][1])
+    if tokens[-1][0] == 'preproc':
+        # continuation lines are considered
+        # only in preprocess statements
+        while tokens[-1][1].endswith('\\\n'):
+            nl = source.find('\n', pos)
+            if nl == -1:
+                line = source[pos:]
+            else:
+                line = source[pos:nl+1]
+            tokens[-1][1] += line
+            pos += len(line)
+
+###### Replacement of PyTypeObject static instances ##############
+
+# classify each token, giving it a one-letter code:
+# S: static
+# T: PyTypeObject
+# I: ident
+# W: whitespace
+# =, {, }, ; : themselves
+def classify():
+    res = []
+    for t,v in tokens:
+        if t == 'other' and v in "={};":
+            res.append(v)
+        elif t == 'ident':
+            if v == 'PyTypeObject':
+                res.append('T')
+            elif v == 'static':
+                res.append('S')
+            else:
+                res.append('I')
+        elif t == 'ws':
+            res.append('W')
+        else:
+            res.append('.')
+    return ''.join(res)
+
+# Obtain a list of fields of a PyTypeObject, in declaration order,
+# skipping ob_base
+# All comments are dropped from the variable (which are typically
+# just the slot names, anyway), and information is discarded whether
+# the original type was static.
+def get_fields(start, real_end):
+    pos = start
+    # static?
+    if tokens[pos][1] == 'static':
+        pos += 2
+    # PyTypeObject
+    pos += 2
+    # name
+    name = tokens[pos][1]
+    pos += 1
+    while tokens[pos][1] != '{':
+        pos += 1
+    pos += 1
+    # PyVarObject_HEAD_INIT
+    while tokens[pos][0] in ('ws', 'comment'):
+        pos += 1
+    if tokens[pos][1] != 'PyVarObject_HEAD_INIT':
+        raise Exception, '%s has no PyVarObject_HEAD_INIT' % name
+    while tokens[pos][1] != ')':
+        pos += 1
+    pos += 1
+    # field definitions: various tokens, comma-separated
+    fields = []
+    while True:
+        while tokens[pos][0] in ('ws', 'comment'):
+            pos += 1
+        end = pos
+        while tokens[end][1] not in ',}':
+            if tokens[end][1] == '(':
+                nesting = 1
+                while nesting:
+                    end += 1
+                    if tokens[end][1] == '(': nesting+=1
+                    if tokens[end][1] == ')': nesting-=1
+            end += 1
+        assert end < real_end
+        # join field, excluding separator and trailing ws
+        end1 = end-1
+        while tokens[end1][0] in ('ws', 'comment'):
+            end1 -= 1
+        fields.append(''.join(t[1] for t in tokens[pos:end1+1]))
+        if tokens[end][1] == '}':
+            break
+        pos = end+1
+    return name, fields
+
+# List of type slots as of Python 3.2, omitting ob_base
+typeslots = [
+    'tp_name',
+    'tp_basicsize',
+    'tp_itemsize',
+    'tp_dealloc',
+    'tp_print',
+    'tp_getattr',
+    'tp_setattr',
+    'tp_reserved',
+    'tp_repr',
+    'tp_as_number',
+    'tp_as_sequence',
+    'tp_as_mapping',
+    'tp_hash',
+    'tp_call',
+    'tp_str',
+    'tp_getattro',
+    'tp_setattro',
+    'tp_as_buffer',
+    'tp_flags',
+    'tp_doc',
+    'tp_traverse',
+    'tp_clear',
+    'tp_richcompare',
+    'tp_weaklistoffset',
+    'tp_iter',
+    'iternextfunc',
+    'tp_methods',
+    'tp_members',
+    'tp_getset',
+    'tp_base',
+    'tp_dict',
+    'tp_descr_get',
+    'tp_descr_set',
+    'tp_dictoffset',
+    'tp_init',
+    'tp_alloc',
+    'tp_new',
+    'tp_free',
+    'tp_is_gc',
+    'tp_bases',
+    'tp_mro',
+    'tp_cache',
+    'tp_subclasses',
+    'tp_weaklist',
+    'tp_del'
+    'tp_version_tag'
+]
+
+# Generate a PyType_Spec definition
+def make_slots(name, fields):
+    res = []
+    res.append('static PyType_Slot %s_slots[] = {' % name)
+    # defaults for spec
+    spec = { 'tp_doc':'NULL', 'tp_itemsize':'0' }
+    for i, val in enumerate(fields):
+        if val.endswith('0'):
+            continue
+        if typeslots[i] in ('tp_name', 'tp_doc', 'tp_basicsize',
+                         'tp_itemsize', 'tp_flags'):
+            spec[typeslots[i]] = val
+            continue
+        res.append('    {Py_%s, %s},' % (typeslots[i], val))
+    res.append('};')
+    res.append('static PyType_Spec %s_spec = {' % name)
+    res.append('    %s,' % spec['tp_name'])
+    res.append('    %s,' % spec['tp_doc'])
+    res.append('    %s,' % spec['tp_basicsize'])
+    res.append('    %s,' % spec['tp_itemsize'])
+    res.append('    %s,' % spec['tp_flags'])
+    res.append('    %s_slots,' % name)
+    res.append('};\n')
+    return '\n'.join(res)
+
+
+# Main loop: replace all static PyTypeObjects until
+# there are none left.
+while 1:
+    c = classify()
+    m = re.search('(SW)?TWIW?=W?{.*?};', c)
+    if not m:
+        break
+    start = m.start()
+    end = m.end()
+    name, fields = get_fields(start, m)
+    tokens[start:end] = [('',make_slots(name, fields))]
+
+# Output result to stdout
+for t, v in tokens:
+    sys.stdout.write(v)
index d4e981b8fda6cbf5633de6b466bbe7d829f51a0f..6d2d3ac5df2df31df8adcbfe12d53a73bacce093 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1579,6 +1579,9 @@ class PyBuildExt(build_ext):
 ##         # Uncomment these lines if you want to play with xxmodule.c
 ##         ext = Extension('xx', ['xxmodule.c'])
 ##         self.extensions.append(ext)
+        ext = Extension('xxlimited', ['xxlimited.c'],
+                        define_macros=[('Py_LIMITED_API', 1)])
+        self.extensions.append(ext)
 
         # XXX handle these, but how to detect?
         # *** Uncomment and edit for PIL (TkImaging) extension only: