Skip to content

Commit 4d0d471

Browse files
committed
Merge branches/pep-0384.
1 parent c4df784 commit 4d0d471

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+2835
-75
lines changed

Doc/c-api/veryhigh.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,14 @@ the same library that the Python runtime is using.
239239
be parsed or compiled.
240240
241241
242-
.. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals)
242+
.. c:function:: PyObject* PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals)
243243
244244
This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just
245245
the code object, and the dictionaries of global and local variables.
246246
The other arguments are set to *NULL*.
247247
248248
249-
.. 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)
249+
.. 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)
250250
251251
Evaluate a precompiled code object, given a particular environment for its
252252
evaluation. This environment consists of dictionaries of global and local

Doc/faq/extending.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ complete example using the GNU readline library (you may want to ignore
379379
if (ps1 == prompt || /* ">>> " or */
380380
'\n' == code[i + j - 1]) /* "... " and double '\n' */
381381
{ /* so execute it */
382-
dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc);
382+
dum = PyEval_EvalCode (src, glb, loc);
383383
Py_XDECREF (dum);
384384
Py_XDECREF (src);
385385
free (code);

Doc/whatsnew/3.2.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@
4949
5050
This article explains the new features in Python 3.2, compared to 3.1.
5151

52+
PEP 382: Defining a Stable ABI
53+
==============================
54+
55+
In the past, extension modules built for one Python version were often
56+
not usable with other Python versions. Particularly on Windows, every
57+
feature release of Python required rebuilding all extension modules that
58+
one wanted to use. This requirement was the result of the free access to
59+
Python interpreter internals that extension modules could use.
60+
61+
With Python 3.2, an alternative approach becomes available: extension
62+
modules with restrict themselves to a limited API (by defining
63+
Py_LIMITED_API) cannot use many of the internals, but are constrained
64+
to a set of API functions that are promised to be stable for several
65+
releases. As a consequence, extension modules built for 3.2 in that
66+
mode will also work with 3.3, 3.4, and so on. Extension modules that
67+
make use of details of memory structures can still be built, but will
68+
need to be recompiled for every feature release.
69+
5270

5371
PEP 391: Dictionary Based Configuration for Logging
5472
====================================================

Include/Python.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666

6767
#include "object.h"
6868
#include "objimpl.h"
69+
#include "typeslots.h"
6970

7071
#include "pydebug.h"
7172

@@ -100,6 +101,7 @@
100101
#include "weakrefobject.h"
101102
#include "structseq.h"
102103

104+
103105
#include "codecs.h"
104106
#include "pyerrors.h"
105107

@@ -130,7 +132,9 @@ extern "C" {
130132
#endif
131133

132134
/* _Py_Mangle is defined in compile.c */
135+
#ifndef Py_LIMITED_API
133136
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
137+
#endif
134138

135139
#ifdef __cplusplus
136140
}

Include/abstract.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
387387
PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
388388
#define PyObject_Length PyObject_Size
389389

390+
#ifndef Py_LIMITED_API
390391
PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t);
392+
#endif
391393

392394
/*
393395
Guess the size of object o using len(o) or o.__length_hint__().
@@ -765,9 +767,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
765767
that can accept a char* naming integral's type.
766768
*/
767769

770+
#ifndef Py_LIMITED_API
768771
PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt(
769772
PyObject *integral,
770773
const char* error_format);
774+
#endif
771775

772776
/*
773777
Returns the object converted to Py_ssize_t by going through
@@ -1057,11 +1061,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
10571061
Use __contains__ if possible, else _PySequence_IterSearch().
10581062
*/
10591063

1064+
#ifndef Py_LIMITED_API
10601065
#define PY_ITERSEARCH_COUNT 1
10611066
#define PY_ITERSEARCH_INDEX 2
10621067
#define PY_ITERSEARCH_CONTAINS 3
10631068
PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
10641069
PyObject *obj, int operation);
1070+
#endif
10651071
/*
10661072
Iterate over seq. Result depends on the operation:
10671073
PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
@@ -1228,13 +1234,15 @@ PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
12281234
/* issubclass(object, typeorclass) */
12291235

12301236

1237+
#ifndef Py_LIMITED_API
12311238
PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
12321239

12331240
PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
12341241

12351242
PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self);
12361243

12371244
PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]);
1245+
#endif
12381246

12391247
/* For internal use by buffer API functions */
12401248
PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,

Include/bytearrayobject.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ extern "C" {
1919
*/
2020

2121
/* Object layout */
22+
#ifndef Py_LIMITED_API
2223
typedef struct {
2324
PyObject_VAR_HEAD
2425
/* XXX(nnorwitz): should ob_exports be Py_ssize_t? */
2526
int ob_exports; /* how many buffer exports */
2627
Py_ssize_t ob_alloc; /* How many bytes allocated */
2728
char *ob_bytes;
2829
} PyByteArrayObject;
30+
#endif
2931

3032
/* Type object */
3133
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
@@ -44,12 +46,14 @@ PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
4446
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
4547

4648
/* Macros, trading safety for speed */
49+
#ifndef Py_LIMITED_API
4750
#define PyByteArray_AS_STRING(self) \
4851
(assert(PyByteArray_Check(self)), \
4952
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string)
5053
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self))
5154

5255
PyAPI_DATA(char) _PyByteArray_empty_string[];
56+
#endif
5357

5458
#ifdef __cplusplus
5559
}

Include/bytes_methods.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#ifndef Py_LIMITED_API
12
#ifndef Py_BYTES_CTYPE_H
23
#define Py_BYTES_CTYPE_H
34

@@ -42,3 +43,4 @@ extern const char _Py_maketrans__doc__[];
4243
#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
4344

4445
#endif /* !Py_BYTES_CTYPE_H */
46+
#endif /* !Py_LIMITED_API */

Include/bytesobject.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ functions should be applied to nil objects.
2727
/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
2828
This significantly speeds up dict lookups. */
2929

30+
#ifndef Py_LIMITED_API
3031
typedef struct {
3132
PyObject_VAR_HEAD
3233
Py_hash_t ob_shash;
@@ -38,6 +39,7 @@ typedef struct {
3839
* ob_shash is the hash of the string or -1 if not computed yet.
3940
*/
4041
} PyBytesObject;
42+
#endif
4143

4244
PyAPI_DATA(PyTypeObject) PyBytes_Type;
4345
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
@@ -58,21 +60,27 @@ PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
5860
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
5961
PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
6062
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
63+
#ifndef Py_LIMITED_API
6164
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
6265
PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int,
6366
int, char**, int*);
67+
#endif
6468
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
6569
const char *, Py_ssize_t,
6670
const char *);
6771

6872
/* Macro, trading safety for speed */
73+
#ifndef Py_LIMITED_API
6974
#define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
7075
(((PyBytesObject *)(op))->ob_sval))
7176
#define PyBytes_GET_SIZE(op) (assert(PyBytes_Check(op)),Py_SIZE(op))
77+
#endif
7278

7379
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
7480
x must be an iterable object. */
81+
#ifndef Py_LIMITED_API
7582
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
83+
#endif
7684

7785
/* Provides access to the internal data buffer and size of a string
7886
object or the default encoded version of an Unicode object. Passing
@@ -90,7 +98,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
9098
/* Using the current locale, insert the thousands grouping
9199
into the string pointed to by buffer. For the argument descriptions,
92100
see Objects/stringlib/localeutil.h */
93-
101+
#ifndef Py_LIMITED_API
94102
PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer,
95103
Py_ssize_t n_buffer,
96104
char *digits,
@@ -107,6 +115,7 @@ PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer,
107115
Py_ssize_t min_width,
108116
const char *grouping,
109117
const char *thousands_sep);
118+
#endif
110119

111120
/* Flags used by string formatting */
112121
#define F_LJUST (1<<0)

Include/cellobject.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* Cell object interface */
2-
2+
#ifndef Py_LIMITED_API
33
#ifndef Py_CELLOBJECT_H
44
#define Py_CELLOBJECT_H
55
#ifdef __cplusplus
@@ -26,3 +26,4 @@ PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
2626
}
2727
#endif
2828
#endif /* !Py_TUPLEOBJECT_H */
29+
#endif /* Py_LIMITED_API */

Include/ceval.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
2020
const char *methodname,
2121
const char *format, ...);
2222

23+
#ifndef Py_LIMITED_API
2324
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
2425
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
26+
#endif
2527

2628
struct _frame; /* Avoid including frameobject.h */
2729

@@ -33,7 +35,9 @@ PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
3335
/* Look at the current frame's (if any) code's co_flags, and turn on
3436
the corresponding compiler flags in cf->cf_flags. Return 1 if any
3537
flag was set, else return 0. */
38+
#ifndef Py_LIMITED_API
3639
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
40+
#endif
3741

3842
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
3943
PyAPI_FUNC(int) Py_MakePendingCalls(void);
@@ -167,8 +171,10 @@ PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
167171
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
168172
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
169173

174+
#ifndef Py_LIMITED_API
170175
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
171176
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
177+
#endif
172178

173179
#define Py_BEGIN_ALLOW_THREADS { \
174180
PyThreadState *_save; \
@@ -187,8 +193,10 @@ PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
187193

188194
#endif /* !WITH_THREAD */
189195

196+
#ifndef Py_LIMITED_API
190197
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
191198
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
199+
#endif
192200

193201

194202
#ifdef __cplusplus

0 commit comments

Comments
 (0)