summaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-04-21 10:40:58 +0000
committerThomas Wouters <thomas@python.org>2006-04-21 10:40:58 +0000
commit66cac891ab67e9460620df27246918805f291990 (patch)
tree63521472f86287a79d85cfad1b44c4e97eb91c93 /Include
parent3e3958e8e08cb62877e8aac097ce9a95ae682124 (diff)
downloadcpython-66cac891ab67e9460620df27246918805f291990.tar.gz
Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
number of tests, all because of the codecs/_multibytecodecs issue described here (it's not a Py3K issue, just something Py3K discovers): http://mail.python.org/pipermail/python-dev/2006-April/064051.html Hye-Shik Chang promised to look for a fix, so no need to fix it here. The tests that are expected to break are: test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecs test_multibytecodec This merge fixes an actual test failure (test_weakref) in this branch, though, so I believe merging is the right thing to do anyway.
Diffstat (limited to 'Include')
-rw-r--r--Include/Python-ast.h46
-rw-r--r--Include/abstract.h10
-rw-r--r--Include/asdl.h8
-rw-r--r--Include/code.h17
-rw-r--r--Include/compile.h2
-rw-r--r--Include/genobject.h2
-rw-r--r--Include/modsupport.h7
-rw-r--r--Include/object.h41
-rw-r--r--Include/objimpl.h22
-rw-r--r--Include/pymem.h17
-rw-r--r--Include/pyport.h60
-rw-r--r--Include/setobject.h3
-rw-r--r--Include/sliceobject.h1
13 files changed, 179 insertions, 57 deletions
diff --git a/Include/Python-ast.h b/Include/Python-ast.h
index b3bc06372d..3e2103097b 100644
--- a/Include/Python-ast.h
+++ b/Include/Python-ast.h
@@ -35,9 +35,10 @@ typedef struct _keyword *keyword_ty;
typedef struct _alias *alias_ty;
+enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
+ Suite_kind=4};
struct _mod {
- enum { Module_kind=1, Interactive_kind=2, Expression_kind=3,
- Suite_kind=4 } kind;
+ enum _mod_kind kind;
union {
struct {
asdl_seq *body;
@@ -58,14 +59,15 @@ struct _mod {
} v;
};
+enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
+ Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
+ For_kind=8, While_kind=9, If_kind=10, With_kind=11,
+ Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
+ Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
+ Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
+ Break_kind=22, Continue_kind=23};
struct _stmt {
- enum { FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3,
- Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7,
- For_kind=8, While_kind=9, If_kind=10, With_kind=11,
- Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14,
- Assert_kind=15, Import_kind=16, ImportFrom_kind=17,
- Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21,
- Break_kind=22, Continue_kind=23 } kind;
+ enum _stmt_kind kind;
union {
struct {
identifier name;
@@ -181,12 +183,14 @@ struct _stmt {
int col_offset;
};
+enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
+ IfExp_kind=5, Dict_kind=6, ListComp_kind=7,
+ GeneratorExp_kind=8, Yield_kind=9, Compare_kind=10,
+ Call_kind=11, Repr_kind=12, Num_kind=13, Str_kind=14,
+ Attribute_kind=15, Subscript_kind=16, Name_kind=17,
+ List_kind=18, Tuple_kind=19};
struct _expr {
- enum { BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4,
- IfExp_kind=5, Dict_kind=6, ListComp_kind=7, GeneratorExp_kind=8,
- Yield_kind=9, Compare_kind=10, Call_kind=11, Repr_kind=12,
- Num_kind=13, Str_kind=14, Attribute_kind=15, Subscript_kind=16,
- Name_kind=17, List_kind=18, Tuple_kind=19 } kind;
+ enum _expr_kind kind;
union {
struct {
boolop_ty op;
@@ -236,7 +240,7 @@ struct _expr {
struct {
expr_ty left;
- asdl_seq *ops;
+ asdl_int_seq *ops;
asdl_seq *comparators;
} Compare;
@@ -292,9 +296,9 @@ struct _expr {
int col_offset;
};
+enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4};
struct _slice {
- enum { Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4 }
- kind;
+ enum _slice_kind kind;
union {
struct {
expr_ty lower;
@@ -323,6 +327,8 @@ struct _excepthandler {
expr_ty type;
expr_ty name;
asdl_seq *body;
+ int lineno;
+ int col_offset;
};
struct _arguments {
@@ -403,7 +409,7 @@ expr_ty ListComp(expr_ty elt, asdl_seq * generators, int lineno, int
expr_ty GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int
col_offset, PyArena *arena);
expr_ty Yield(expr_ty value, int lineno, int col_offset, PyArena *arena);
-expr_ty Compare(expr_ty left, asdl_seq * ops, asdl_seq * comparators, int
+expr_ty Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, int
lineno, int col_offset, PyArena *arena);
expr_ty Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty
starargs, expr_ty kwargs, int lineno, int col_offset, PyArena
@@ -427,8 +433,8 @@ slice_ty ExtSlice(asdl_seq * dims, PyArena *arena);
slice_ty Index(expr_ty value, PyArena *arena);
comprehension_ty comprehension(expr_ty target, expr_ty iter, asdl_seq * ifs,
PyArena *arena);
-excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body,
- PyArena *arena);
+excepthandler_ty excepthandler(expr_ty type, expr_ty name, asdl_seq * body, int
+ lineno, int col_offset, PyArena *arena);
arguments_ty arguments(asdl_seq * args, identifier vararg, identifier kwarg,
asdl_seq * defaults, PyArena *arena);
keyword_ty keyword(identifier arg, expr_ty value, PyArena *arena);
diff --git a/Include/abstract.h b/Include/abstract.h
index b76f2573c9..d4bd5884ad 100644
--- a/Include/abstract.h
+++ b/Include/abstract.h
@@ -4,6 +4,11 @@
extern "C" {
#endif
+#ifdef PY_SSIZE_T_CLEAN
+#define PyObject_CallFunction _PyObject_CallFunction_SizeT
+#define PyObject_CallMethod _PyObject_CallMethod_SizeT
+#endif
+
/* Abstract Object Interface (many thanks to Jim Fulton) */
/*
@@ -337,6 +342,11 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/
Python expression: o.method(args).
*/
+ PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
+ char *format, ...);
+ PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o,
+ char *name,
+ char *format, ...);
PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
...);
diff --git a/Include/asdl.h b/Include/asdl.h
index c1c5603e8b..84e837e752 100644
--- a/Include/asdl.h
+++ b/Include/asdl.h
@@ -5,7 +5,9 @@ typedef PyObject * identifier;
typedef PyObject * string;
typedef PyObject * object;
+#ifndef __cplusplus
typedef enum {false, true} bool;
+#endif
/* It would be nice if the code generated by asdl_c.py was completely
independent of Python, but it is a goal the requires too much work
@@ -20,7 +22,13 @@ typedef struct {
void *elements[1];
} asdl_seq;
+typedef struct {
+ int size;
+ int elements[1];
+} asdl_int_seq;
+
asdl_seq *asdl_seq_new(int size, PyArena *arena);
+asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena);
#define asdl_seq_GET(S, I) (S)->elements[(I)]
#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
diff --git a/Include/code.h b/Include/code.h
index a4509e3329..23d9e175fc 100644
--- a/Include/code.h
+++ b/Include/code.h
@@ -44,7 +44,7 @@ typedef struct {
/* These are no longer used. */
#define CO_GENERATOR_ALLOWED 0x1000
#define CO_FUTURE_DIVISION 0x2000
-#define CO_FUTURE_ABSIMPORT 0x4000 /* absolute import by default */
+#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
#define CO_FUTURE_WITH_STATEMENT 0x8000
#endif
@@ -72,6 +72,21 @@ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
((*(co)->co_code->ob_type->tp_as_buffer->bf_getreadbuffer) \
((co)->co_code, 0, (void **)(pp)))
+typedef struct _addr_pair {
+ int ap_lower;
+ int ap_upper;
+} PyAddrPair;
+
+/* Check whether lasti (an instruction offset) falls outside bounds
+ and whether it is a line number that should be traced. Returns
+ a line number if it should be traced or -1 if the line should not.
+
+ If lasti is not within bounds, updates bounds.
+*/
+
+PyAPI_FUNC(int) PyCode_CheckLineNumber(PyCodeObject* co,
+ int lasti, PyAddrPair *bounds);
+
#ifdef __cplusplus
}
#endif
diff --git a/Include/compile.h b/Include/compile.h
index 4ac69822a0..2bde6fb56f 100644
--- a/Include/compile.h
+++ b/Include/compile.h
@@ -22,7 +22,7 @@ typedef struct {
#define FUTURE_NESTED_SCOPES "nested_scopes"
#define FUTURE_GENERATORS "generators"
#define FUTURE_DIVISION "division"
-#define FUTURE_ABSIMPORT "absolute_import"
+#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
#define FUTURE_WITH_STATEMENT "with_statement"
struct _mod; /* Declare the existence of this type */
diff --git a/Include/genobject.h b/Include/genobject.h
index f4226ede42..ca8443203c 100644
--- a/Include/genobject.h
+++ b/Include/genobject.h
@@ -13,6 +13,7 @@ typedef struct {
PyObject_HEAD
/* The gi_ prefix is intended to remind of generator-iterator. */
+ /* Note: gi_frame can be NULL if the generator is "finished" */
struct _frame *gi_frame;
/* True if generator is being executed. */
@@ -28,6 +29,7 @@ PyAPI_DATA(PyTypeObject) PyGen_Type;
#define PyGen_CheckExact(op) ((op)->ob_type == &PyGen_Type)
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
+PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
#ifdef __cplusplus
}
diff --git a/Include/modsupport.h b/Include/modsupport.h
index c356f03e50..23d5d3a093 100644
--- a/Include/modsupport.h
+++ b/Include/modsupport.h
@@ -17,8 +17,10 @@ extern "C" {
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
#define PyArg_VaParse _PyArg_VaParse_SizeT
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
-#define PyArg_BuildValue _PyArg_BuildValue_SizeT
-#define PyArg_VaBuildValue _PyArg_VaBuildValue_SizeT
+#define Py_BuildValue _Py_BuildValue_SizeT
+#define Py_VaBuildValue _Py_VaBuildValue_SizeT
+#else
+PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
#endif
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
@@ -27,6 +29,7 @@ PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
const char *, char **, ...);
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 *, ...);
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
diff --git a/Include/object.h b/Include/object.h
index 9198007a06..cdbddfed85 100644
--- a/Include/object.h
+++ b/Include/object.h
@@ -327,6 +327,7 @@ typedef struct _typeobject {
Py_ssize_t tp_allocs;
Py_ssize_t tp_frees;
Py_ssize_t tp_maxalloc;
+ struct _typeobject *tp_prev;
struct _typeobject *tp_next;
#endif
} PyTypeObject;
@@ -566,6 +567,9 @@ environment the global variable trick is not safe.)
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
int lineno, PyObject *op);
+PyAPI_FUNC(PyObject *) _PyDict_Dummy(void);
+PyAPI_FUNC(PyObject *) _PySet_Dummy(void);
+PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
#define _Py_INC_REFTOTAL _Py_RefTotal++
#define _Py_DEC_REFTOTAL _Py_RefTotal--
#define _Py_REF_DEBUG_COMMA ,
@@ -583,8 +587,9 @@ PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
#ifdef COUNT_ALLOCS
PyAPI_FUNC(void) inc_count(PyTypeObject *);
+PyAPI_FUNC(void) dec_count(PyTypeObject *);
#define _Py_INC_TPALLOCS(OP) inc_count((OP)->ob_type)
-#define _Py_INC_TPFREES(OP) (OP)->ob_type->tp_frees++
+#define _Py_INC_TPFREES(OP) dec_count((OP)->ob_type)
#define _Py_DEC_TPFREES(OP) (OP)->ob_type->tp_frees--
#define _Py_COUNT_ALLOCS_COMMA ,
#else
@@ -630,6 +635,40 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
else \
_Py_Dealloc((PyObject *)(op))
+/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
+ * and tp_dealloc implementatons.
+ *
+ * Note that "the obvious" code can be deadly:
+ *
+ * Py_XDECREF(op);
+ * op = NULL;
+ *
+ * Typically, `op` is something like self->containee, and `self` is done
+ * using its `containee` member. In the code sequence above, suppose
+ * `containee` is non-NULL with a refcount of 1. Its refcount falls to
+ * 0 on the first line, which can trigger an arbitrary amount of code,
+ * possibly including finalizers (like __del__ methods or weakref callbacks)
+ * coded in Python, which in turn can release the GIL and allow other threads
+ * to run, etc. Such code may even invoke methods of `self` again, or cause
+ * cyclic gc to trigger, but-- oops! --self->containee still points to the
+ * object being torn down, and it may be in an insane state while being torn
+ * down. This has in fact been a rich historic source of miserable (rare &
+ * hard-to-diagnose) segfaulting (and other) bugs.
+ *
+ * The safe way is:
+ *
+ * Py_CLEAR(op);
+ *
+ * That arranges to set `op` to NULL _before_ decref'ing, so that any code
+ * triggered as a side-effect of `op` getting torn down no longer believes
+ * `op` points to a valid object.
+ *
+ * There are cases where it's safe to use the naive code, but they're brittle.
+ * For example, if `op` points to a Python integer, you know that destroying
+ * one of those can't cause problems -- but in part that relies on that
+ * Python integers aren't currently weakly referencable. Best practice is
+ * to use Py_CLEAR() even if you can't think of a reason for why you need to.
+ */
#define Py_CLEAR(op) \
do { \
if (op) { \
diff --git a/Include/objimpl.h b/Include/objimpl.h
index 7c6819442d..03b6a8d49d 100644
--- a/Include/objimpl.h
+++ b/Include/objimpl.h
@@ -101,7 +101,7 @@ PyAPI_FUNC(void) PyObject_Free(void *);
/* Macros */
#ifdef WITH_PYMALLOC
-#ifdef PYMALLOC_DEBUG
+#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */
PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes);
PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes);
PyAPI_FUNC(void) _PyObject_DebugFree(void *p);
@@ -124,11 +124,7 @@ PyAPI_FUNC(void) _PyObject_DebugMallocStats(void);
#else /* ! WITH_PYMALLOC */
#define PyObject_MALLOC PyMem_MALLOC
#define PyObject_REALLOC PyMem_REALLOC
-/* This is an odd one! For backward compatibility with old extensions, the
- PyMem "release memory" functions have to invoke the object allocator's
- free() function. When pymalloc isn't enabled, that leaves us using
- the platform free(). */
-#define PyObject_FREE free
+#define PyObject_FREE PyMem_FREE
#endif /* WITH_PYMALLOC */
@@ -307,13 +303,13 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
* "visit" and "arg". This is intended to keep tp_traverse functions
* looking as much alike as possible.
*/
-#define Py_VISIT(op) \
- do { \
- if (op) { \
- int vret = visit((op), arg); \
- if (vret) \
- return vret; \
- } \
+#define Py_VISIT(op) \
+ do { \
+ if (op) { \
+ int vret = visit((PyObject *)(op), arg); \
+ if (vret) \
+ return vret; \
+ } \
} while (0)
/* This is here for the sake of backwards compatibility. Extensions that
diff --git a/Include/pymem.h b/Include/pymem.h
index f8aef2991b..671f967c89 100644
--- a/Include/pymem.h
+++ b/Include/pymem.h
@@ -59,6 +59,7 @@ PyAPI_FUNC(void) PyMem_Free(void *);
/* Redirect all memory operations to Python's debugging allocator. */
#define PyMem_MALLOC PyObject_MALLOC
#define PyMem_REALLOC PyObject_REALLOC
+#define PyMem_FREE PyObject_FREE
#else /* ! PYMALLOC_DEBUG */
@@ -68,14 +69,10 @@ PyAPI_FUNC(void) PyMem_Free(void *);
pymalloc. To solve these problems, allocate an extra byte. */
#define PyMem_MALLOC(n) malloc((n) ? (n) : 1)
#define PyMem_REALLOC(p, n) realloc((p), (n) ? (n) : 1)
+#define PyMem_FREE free
#endif /* PYMALLOC_DEBUG */
-/* In order to avoid breaking old code mixing PyObject_{New, NEW} with
- PyMem_{Del, DEL} and PyMem_{Free, FREE}, the PyMem "release memory"
- functions have to be redirected to the object deallocator. */
-#define PyMem_FREE PyObject_FREE
-
/*
* Type-oriented memory interface
* ==============================
@@ -95,11 +92,11 @@ PyAPI_FUNC(void) PyMem_Free(void *);
#define PyMem_RESIZE(p, type, n) \
( (p) = (type *) PyMem_REALLOC((p), (n) * sizeof(type)) )
-/* In order to avoid breaking old code mixing PyObject_{New, NEW} with
- PyMem_{Del, DEL} and PyMem_{Free, FREE}, the PyMem "release memory"
- functions have to be redirected to the object deallocator. */
-#define PyMem_Del PyObject_Free
-#define PyMem_DEL PyObject_FREE
+/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used
+ * anymore. They're just confusing aliases for PyMem_{Free,FREE} now.
+ */
+#define PyMem_Del PyMem_Free
+#define PyMem_DEL PyMem_FREE
#ifdef __cplusplus
}
diff --git a/Include/pyport.h b/Include/pyport.h
index 9111d86228..2bce415c5c 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -85,6 +85,10 @@ typedef PY_LONG_LONG Py_intptr_t;
# error "Python needs a typedef for Py_uintptr_t in pyport.h."
#endif /* HAVE_UINTPTR_T */
+/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) ==
+ * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an
+ * unsigned integral type). See PEP 353 for details.
+ */
#ifdef HAVE_SSIZE_T
typedef ssize_t Py_ssize_t;
#elif SIZEOF_VOID_P == SIZEOF_SIZE_T
@@ -92,7 +96,46 @@ typedef Py_intptr_t Py_ssize_t;
#else
# error "Python needs a typedef for Py_ssize_t in pyport.h."
#endif
+
+/* Largest positive value of type Py_ssize_t. */
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
+/* Smallest negative value of type Py_ssize_t. */
+#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
+
+/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
+ * format to convert an argument with the width of a size_t or Py_ssize_t.
+ * C99 introduced "z" for this purpose, but not all platforms support that;
+ * e.g., MS compilers use "I" instead.
+ *
+ * These "high level" Python format functions interpret "z" correctly on
+ * all platforms (Python interprets the format string itself, and does whatever
+ * the platform C requires to convert a size_t/Py_ssize_t argument):
+ *
+ * PyString_FromFormat
+ * PyErr_Format
+ * PyString_FromFormatV
+ *
+ * Lower-level uses require that you interpolate the correct format modifier
+ * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
+ * example,
+ *
+ * Py_ssize_t index;
+ * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
+ *
+ * That will expand to %ld, or %Id, or to something else correct for a
+ * Py_ssize_t on the platform.
+ */
+#ifndef PY_FORMAT_SIZE_T
+# if SIZEOF_SIZE_T == SIZEOF_INT
+# define PY_FORMAT_SIZE_T ""
+# elif SIZEOF_SIZE_T == SIZEOF_LONG
+# define PY_FORMAT_SIZE_T "l"
+# elif defined(MS_WINDOWS)
+# define PY_FORMAT_SIZE_T "I"
+# else
+# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
+# endif
+#endif
#include <stdlib.h>
@@ -367,7 +410,8 @@ extern "C" {
* typedef int T1 Py_DEPRECATED(2.4);
* extern int x() Py_DEPRECATED(2.5);
*/
-#if defined(__GNUC__) && (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)
+#if defined(__GNUC__) && ((__GNUC__ >= 4) || \
+ (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
#else
#define Py_DEPRECATED(VERSION_UNUSED)
@@ -436,14 +480,12 @@ extern double hypot(double, double);
#endif
-/*******************************************************************
-On 4.4BSD-descendants, ctype functions serves the whole range of
-wchar_t character set rather than single byte code points only.
-This characteristic can break some operations of string object
-including str.upper() and str.split() on UTF-8 locales. This
-workaround was provided by Tim Robbins of FreeBSD project. He said
-the incompatibility will be fixed in FreeBSD 6.
-********************************************************************/
+/* On 4.4BSD-descendants, ctype functions serves the whole range of
+ * wchar_t character set rather than single byte code points only.
+ * This characteristic can break some operations of string object
+ * including str.upper() and str.split() on UTF-8 locales. This
+ * workaround was provided by Tim Robbins of FreeBSD project.
+ */
#ifdef __FreeBSD__
#include <osreldate.h>
diff --git a/Include/setobject.h b/Include/setobject.h
index cea95cc29e..cc939687a8 100644
--- a/Include/setobject.h
+++ b/Include/setobject.h
@@ -78,10 +78,13 @@ PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used)
+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);
+PyAPI_FUNC(int) _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **entry);
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
+PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
#ifdef __cplusplus
}
diff --git a/Include/sliceobject.h b/Include/sliceobject.h
index 17f36dc1ff..dbc34b2aea 100644
--- a/Include/sliceobject.h
+++ b/Include/sliceobject.h
@@ -30,6 +30,7 @@ PyAPI_DATA(PyTypeObject) PySlice_Type;
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
PyObject* step);
+PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *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,