| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -239,14 +239,14 @@ the same library that the Python runtime is using. | |||
| 239 | 239 | be parsed or compiled. | |
| 240 | 240 | ||
| 241 | 241 | ||
| 242 | - .. c:function:: PyObject* PyEval_EvalCode(PyCodeObject *co, PyObject *globals, PyObject *locals) | ||
| 242 | + .. c:function:: PyObject* PyEval_EvalCode(PyObject *co, PyObject *globals, PyObject *locals) | ||
| 243 | 243 | ||
| 244 | 244 | This is a simplified interface to :c:func:`PyEval_EvalCodeEx`, with just | |
| 245 | 245 | the code object, and the dictionaries of global and local variables. | |
| 246 | 246 | The other arguments are set to *NULL*. | |
| 247 | 247 | ||
| 248 | 248 | ||
| 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) | ||
| 250 | 250 | ||
| 251 | 251 | Evaluate a precompiled code object, given a particular environment for its | |
| 252 | 252 | evaluation. This environment consists of dictionaries of global and local | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -379,7 +379,7 @@ complete example using the GNU readline library (you may want to ignore | |||
| 379 | 379 | if (ps1 == prompt || /* ">>> " or */ | |
| 380 | 380 | '\n' == code[i + j - 1]) /* "... " and double '\n' */ | |
| 381 | 381 | { /* so execute it */ | |
| 382 | - dum = PyEval_EvalCode ((PyCodeObject *)src, glb, loc); | ||
| 382 | + dum = PyEval_EvalCode (src, glb, loc); | ||
| 383 | 383 | Py_XDECREF (dum); | |
| 384 | 384 | Py_XDECREF (src); | |
| 385 | 385 | free (code); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -49,6 +49,24 @@ | |||
| 49 | 49 | ||
| 50 | 50 | This article explains the new features in Python 3.2, compared to 3.1. | |
| 51 | 51 | ||
| 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 | + | ||
| 52 | 70 | ||
| 53 | 71 | PEP 391: Dictionary Based Configuration for Logging | |
| 54 | 72 | ==================================================== | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,6 +66,7 @@ | |||
| 66 | 66 | ||
| 67 | 67 | #include "object.h" | |
| 68 | 68 | #include "objimpl.h" | |
| 69 | + #include "typeslots.h" | ||
| 69 | 70 | ||
| 70 | 71 | #include "pydebug.h" | |
| 71 | 72 | ||
@@ -100,6 +101,7 @@ | |||
| 100 | 101 | #include "weakrefobject.h" | |
| 101 | 102 | #include "structseq.h" | |
| 102 | 103 | ||
| 104 | + | ||
| 103 | 105 | #include "codecs.h" | |
| 104 | 106 | #include "pyerrors.h" | |
| 105 | 107 | ||
@@ -130,7 +132,9 @@ extern "C" { | |||
| 130 | 132 | #endif | |
| 131 | 133 | ||
| 132 | 134 | /* _Py_Mangle is defined in compile.c */ | |
| 135 | + #ifndef Py_LIMITED_API | ||
| 133 | 136 | PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); | |
| 137 | + #endif | ||
| 134 | 138 | ||
| 135 | 139 | #ifdef __cplusplus | |
| 136 | 140 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -387,7 +387,9 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ | |||
| 387 | 387 | PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o); | |
| 388 | 388 | #define PyObject_Length PyObject_Size | |
| 389 | 389 | ||
| 390 | + #ifndef Py_LIMITED_API | ||
| 390 | 391 | PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t); | |
| 392 | + #endif | ||
| 391 | 393 | ||
| 392 | 394 | /* | |
| 393 | 395 | Guess the size of object o using len(o) or o.__length_hint__(). | |
@@ -765,9 +767,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ | |||
| 765 | 767 | that can accept a char* naming integral's type. | |
| 766 | 768 | */ | |
| 767 | 769 | ||
| 770 | + #ifndef Py_LIMITED_API | ||
| 768 | 771 | PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt( | |
| 769 | 772 | PyObject *integral, | |
| 770 | 773 | const char* error_format); | |
| 774 | + #endif | ||
| 771 | 775 | ||
| 772 | 776 | /* | |
| 773 | 777 | Returns the object converted to Py_ssize_t by going through | |
@@ -1057,11 +1061,13 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ | |||
| 1057 | 1061 | Use __contains__ if possible, else _PySequence_IterSearch(). | |
| 1058 | 1062 | */ | |
| 1059 | 1063 | ||
| 1064 | + #ifndef Py_LIMITED_API | ||
| 1060 | 1065 | #define PY_ITERSEARCH_COUNT 1 | |
| 1061 | 1066 | #define PY_ITERSEARCH_INDEX 2 | |
| 1062 | 1067 | #define PY_ITERSEARCH_CONTAINS 3 | |
| 1063 | 1068 | PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, | |
| 1064 | 1069 | PyObject *obj, int operation); | |
| 1070 | + #endif | ||
| 1065 | 1071 | /* | |
| 1066 | 1072 | Iterate over seq. Result depends on the operation: | |
| 1067 | 1073 | 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); | |||
| 1228 | 1234 | /* issubclass(object, typeorclass) */ | |
| 1229 | 1235 | ||
| 1230 | 1236 | ||
| 1237 | + #ifndef Py_LIMITED_API | ||
| 1231 | 1238 | PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); | |
| 1232 | 1239 | ||
| 1233 | 1240 | PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); | |
| 1234 | 1241 | ||
| 1235 | 1242 | PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self); | |
| 1236 | 1243 | ||
| 1237 | 1244 | PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]); | |
| 1245 | + #endif | ||
| 1238 | 1246 | ||
| 1239 | 1247 | /* For internal use by buffer API functions */ | |
| 1240 | 1248 | PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,13 +19,15 @@ extern "C" { | |||
| 19 | 19 | */ | |
| 20 | 20 | ||
| 21 | 21 | /* Object layout */ | |
| 22 | + #ifndef Py_LIMITED_API | ||
| 22 | 23 | typedef struct { | |
| 23 | 24 | PyObject_VAR_HEAD | |
| 24 | 25 | /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ | |
| 25 | 26 | int ob_exports; /* how many buffer exports */ | |
| 26 | 27 | Py_ssize_t ob_alloc; /* How many bytes allocated */ | |
| 27 | 28 | char *ob_bytes; | |
| 28 | 29 | } PyByteArrayObject; | |
| 30 | + #endif | ||
| 29 | 31 | ||
| 30 | 32 | /* Type object */ | |
| 31 | 33 | PyAPI_DATA(PyTypeObject) PyByteArray_Type; | |
@@ -44,12 +46,14 @@ PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); | |||
| 44 | 46 | PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); | |
| 45 | 47 | ||
| 46 | 48 | /* Macros, trading safety for speed */ | |
| 49 | + #ifndef Py_LIMITED_API | ||
| 47 | 50 | #define PyByteArray_AS_STRING(self) \ | |
| 48 | 51 | (assert(PyByteArray_Check(self)), \ | |
| 49 | 52 | Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string) | |
| 50 | 53 | #define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self)) | |
| 51 | 54 | ||
| 52 | 55 | PyAPI_DATA(char) _PyByteArray_empty_string[]; | |
| 56 | + #endif | ||
| 53 | 57 | ||
| 54 | 58 | #ifdef __cplusplus | |
| 55 | 59 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,4 @@ | |||
| 1 | + #ifndef Py_LIMITED_API | ||
| 1 | 2 | #ifndef Py_BYTES_CTYPE_H | |
| 2 | 3 | #define Py_BYTES_CTYPE_H | |
| 3 | 4 | ||
@@ -42,3 +43,4 @@ extern const char _Py_maketrans__doc__[]; | |||
| 42 | 43 | #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) | |
| 43 | 44 | ||
| 44 | 45 | #endif /* !Py_BYTES_CTYPE_H */ | |
| 46 | + #endif /* !Py_LIMITED_API */ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -27,6 +27,7 @@ functions should be applied to nil objects. | |||
| 27 | 27 | /* Caching the hash (ob_shash) saves recalculation of a string's hash value. | |
| 28 | 28 | This significantly speeds up dict lookups. */ | |
| 29 | 29 | ||
| 30 | + #ifndef Py_LIMITED_API | ||
| 30 | 31 | typedef struct { | |
| 31 | 32 | PyObject_VAR_HEAD | |
| 32 | 33 | Py_hash_t ob_shash; | |
@@ -38,6 +39,7 @@ typedef struct { | |||
| 38 | 39 | * ob_shash is the hash of the string or -1 if not computed yet. | |
| 39 | 40 | */ | |
| 40 | 41 | } PyBytesObject; | |
| 42 | + #endif | ||
| 41 | 43 | ||
| 42 | 44 | PyAPI_DATA(PyTypeObject) PyBytes_Type; | |
| 43 | 45 | PyAPI_DATA(PyTypeObject) PyBytesIter_Type; | |
@@ -58,21 +60,27 @@ PyAPI_FUNC(char *) PyBytes_AsString(PyObject *); | |||
| 58 | 60 | PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int); | |
| 59 | 61 | PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *); | |
| 60 | 62 | PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *); | |
| 63 | + #ifndef Py_LIMITED_API | ||
| 61 | 64 | PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); | |
| 62 | 65 | PyAPI_FUNC(PyObject *) _PyBytes_FormatLong(PyObject*, int, int, | |
| 63 | 66 | int, char**, int*); | |
| 67 | + #endif | ||
| 64 | 68 | PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t, | |
| 65 | 69 | const char *, Py_ssize_t, | |
| 66 | 70 | const char *); | |
| 67 | 71 | ||
| 68 | 72 | /* Macro, trading safety for speed */ | |
| 73 | + #ifndef Py_LIMITED_API | ||
| 69 | 74 | #define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \ | |
| 70 | 75 | (((PyBytesObject *)(op))->ob_sval)) | |
| 71 | 76 | #define PyBytes_GET_SIZE(op) (assert(PyBytes_Check(op)),Py_SIZE(op)) | |
| 77 | + #endif | ||
| 72 | 78 | ||
| 73 | 79 | /* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*, | |
| 74 | 80 | x must be an iterable object. */ | |
| 81 | + #ifndef Py_LIMITED_API | ||
| 75 | 82 | PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x); | |
| 83 | + #endif | ||
| 76 | 84 | ||
| 77 | 85 | /* Provides access to the internal data buffer and size of a string | |
| 78 | 86 | object or the default encoded version of an Unicode object. Passing | |
@@ -90,7 +98,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize( | |||
| 90 | 98 | /* Using the current locale, insert the thousands grouping | |
| 91 | 99 | into the string pointed to by buffer. For the argument descriptions, | |
| 92 | 100 | see Objects/stringlib/localeutil.h */ | |
| 93 | - | ||
| 101 | + #ifndef Py_LIMITED_API | ||
| 94 | 102 | PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer, | |
| 95 | 103 | Py_ssize_t n_buffer, | |
| 96 | 104 | char *digits, | |
@@ -107,6 +115,7 @@ PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer, | |||
| 107 | 115 | Py_ssize_t min_width, | |
| 108 | 116 | const char *grouping, | |
| 109 | 117 | const char *thousands_sep); | |
| 118 | + #endif | ||
| 110 | 119 | ||
| 111 | 120 | /* Flags used by string formatting */ | |
| 112 | 121 | #define F_LJUST (1<<0) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | /* Cell object interface */ | |
| 2 | - | ||
| 2 | + #ifndef Py_LIMITED_API | ||
| 3 | 3 | #ifndef Py_CELLOBJECT_H | |
| 4 | 4 | #define Py_CELLOBJECT_H | |
| 5 | 5 | #ifdef __cplusplus | |
@@ -26,3 +26,4 @@ PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); | |||
| 26 | 26 | } | |
| 27 | 27 | #endif | |
| 28 | 28 | #endif /* !Py_TUPLEOBJECT_H */ | |
| 29 | + #endif /* Py_LIMITED_API */ | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,8 +20,10 @@ PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, | |||
| 20 | 20 | const char *methodname, | |
| 21 | 21 | const char *format, ...); | |
| 22 | 22 | ||
| 23 | + #ifndef Py_LIMITED_API | ||
| 23 | 24 | PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); | |
| 24 | 25 | PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); | |
| 26 | + #endif | ||
| 25 | 27 | ||
| 26 | 28 | struct _frame; /* Avoid including frameobject.h */ | |
| 27 | 29 | ||
@@ -33,7 +35,9 @@ PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); | |||
| 33 | 35 | /* Look at the current frame's (if any) code's co_flags, and turn on | |
| 34 | 36 | the corresponding compiler flags in cf->cf_flags. Return 1 if any | |
| 35 | 37 | flag was set, else return 0. */ | |
| 38 | + #ifndef Py_LIMITED_API | ||
| 36 | 39 | PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); | |
| 40 | + #endif | ||
| 37 | 41 | ||
| 38 | 42 | PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); | |
| 39 | 43 | PyAPI_FUNC(int) Py_MakePendingCalls(void); | |
@@ -167,8 +171,10 @@ PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); | |||
| 167 | 171 | PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); | |
| 168 | 172 | PyAPI_FUNC(void) PyEval_ReInitThreads(void); | |
| 169 | 173 | ||
| 174 | + #ifndef Py_LIMITED_API | ||
| 170 | 175 | PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds); | |
| 171 | 176 | PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void); | |
| 177 | + #endif | ||
| 172 | 178 | ||
| 173 | 179 | #define Py_BEGIN_ALLOW_THREADS { \ | |
| 174 | 180 | PyThreadState *_save; \ | |
@@ -187,8 +193,10 @@ PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void); | |||
| 187 | 193 | ||
| 188 | 194 | #endif /* !WITH_THREAD */ | |
| 189 | 195 | ||
| 196 | + #ifndef Py_LIMITED_API | ||
| 190 | 197 | PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); | |
| 191 | 198 | PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void); | |
| 199 | + #endif | ||
| 192 | 200 | ||
| 193 | 201 | ||
| 194 | 202 | #ifdef __cplusplus | |
| Back | FazBrowse Home | New Git URL |
0 commit comments