+ I'm not sure what to do about configure.in. Left it alone.
+ Ditto pyexpat.c. Fred or Martin will know what to do.
#include "patchlevel.h"
#include "pyconfig.h"
+/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the
+ * old symbol for the benefit of extension modules written before then
+ * that may be conditionalizing on it. The core doesn't use it anymore.
+ */
+#ifndef WITH_CYCLE_GC
+#define WITH_CYCLE_GC 1
+#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
#define Py_TPFLAGS_READYING (1L<<13)
/* Objects support garbage collection (see objimp.h) */
-#ifdef WITH_CYCLE_GC
#define Py_TPFLAGS_HAVE_GC (1L<<14)
-#else
-#define Py_TPFLAGS_HAVE_GC 0
-#endif
#define Py_TPFLAGS_DEFAULT ( \
Py_TPFLAGS_HAVE_GETCHARBUFFER | \
/*
* Garbage Collection Support
* ==========================
- *
- * Some of the functions and macros below are always defined; when
- * WITH_CYCLE_GC is undefined, they simply don't do anything different
- * than their non-GC counterparts.
*/
/* Test if a type has a GC head */
/* for source compatibility with 2.2 */
#define _PyObject_GC_Del PyObject_GC_Del
-#ifdef WITH_CYCLE_GC
-
/* GC information is stored BEFORE the object structure. */
typedef union _gc_head {
struct {
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
-#else /* !WITH_CYCLE_GC */
-
-#define _PyObject_GC_Malloc PyObject_Malloc
-#define PyObject_GC_New PyObject_New
-#define PyObject_GC_NewVar PyObject_NewVar
-#define PyObject_GC_Del PyObject_Del
-#define _PyObject_GC_TRACK(op)
-#define _PyObject_GC_UNTRACK(op)
-#define PyObject_GC_Track(op)
-#define PyObject_GC_UnTrack(op)
-
-#endif
-
/* This is here for the sake of backwards compatibility. Extensions that
* use the old GC API will still compile but the objects will not be
* tracked by the GC. */
Library
+- binascii.crc32() and the zipfile module had problems on some 64-bit
+ platforms. These have been fixed. On a platform with 8-byte C longs,
+ crc32() now returns a signed-extended 4-byte result, so that its value
+ as a Python int is equal to the value computed a 32-bit platform.
+
- xml.dom.minidom.toxml and toprettyxml now take an optional encoding
argument.
Build
+- Compiling out the cyclic garbage collector is no longer an option.
+ The old symbol WITH_CYCLE_GC is now ignored, and Python.h arranges
+ that it's always defined (for the benefit of any extension modules
+ that may be conditionalizing on it). A bonus is that any extension
+ type participating in cyclic gc can choose to participate in the
+ Py_TRASHCAN mechanism now too; in the absence of cyclic gc, this used
+ to require editing the core to teach the trashcan mechanism about the
+ new type.
+
- Accoring to Annex F of the current C standard,
The Standard C macro HUGE_VAL and its float and long double analogs,
{"sys", NULL},
{"exceptions", NULL},
-#ifdef WITH_CYCLE_GC
/* This lives in gcmodule.c */
{"gc", initgc},
-#endif
/* Sentinel */
{0, 0}
#include "Python.h"
-#ifdef WITH_CYCLE_GC
-
/* Get an object's GC head */
#define AS_GC(o) ((PyGC_Head *)(o)-1)
_PyObject_Dump(FROM_GC(g));
}
-#endif /* WITH_CYCLE_GC */
-
/* extension modules might be compiled with GC support so these
functions must always be available */
void
PyObject_GC_UnTrack(void *op)
{
-#ifdef WITH_CYCLE_GC
if (IS_TRACKED(op))
_PyObject_GC_UNTRACK(op);
-#endif
}
/* for binary compatibility with 2.2 */
_PyObject_GC_Malloc(size_t basicsize)
{
PyObject *op;
-#ifdef WITH_CYCLE_GC
PyGC_Head *g = PyObject_MALLOC(sizeof(PyGC_Head) + basicsize);
if (g == NULL)
return PyErr_NoMemory();
collecting = 0;
}
op = FROM_GC(g);
-#else
- op = PyObject_MALLOC(basicsize);
- if (op == NULL)
- return PyErr_NoMemory();
-
-#endif
return op;
}
_PyObject_GC_Resize(PyVarObject *op, int nitems)
{
const size_t basicsize = _PyObject_VAR_SIZE(op->ob_type, nitems);
-#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
g = PyObject_REALLOC(g, sizeof(PyGC_Head) + basicsize);
if (g == NULL)
return (PyVarObject *)PyErr_NoMemory();
op = (PyVarObject *) FROM_GC(g);
-#else
- op = PyObject_REALLOC(op, basicsize);
- if (op == NULL)
- return (PyVarObject *)PyErr_NoMemory();
-#endif
op->ob_size = nitems;
return op;
}
void
PyObject_GC_Del(void *op)
{
-#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
if (IS_TRACKED(op))
gc_list_remove(g);
generations[0].count--;
}
PyObject_FREE(g);
-#else
- PyObject_FREE(op);
-#endif
}
/* for binary compatibility with 2.2 */
/* compensate for increment in _Py_ForgetReference */
inst->ob_type->tp_frees--;
#endif
-#ifndef WITH_CYCLE_GC
- inst->ob_type = NULL;
-#endif
#endif
Py_DECREF(inst->in_class);
Py_XDECREF(inst->in_dict);
void
_PyTrash_deposit_object(PyObject *op)
{
-#ifndef WITH_CYCLE_GC
- int typecode;
-
- if (PyTuple_Check(op))
- typecode = Py_TRASHCAN_TUPLE;
- else if (PyList_Check(op))
- typecode = Py_TRASHCAN_LIST;
- else if (PyDict_Check(op))
- typecode = Py_TRASHCAN_DICT;
- else if (PyFrame_Check(op))
- typecode = Py_TRASHCAN_FRAME;
- else if (PyTraceBack_Check(op))
- typecode = Py_TRASHCAN_TRACEBACK;
- else /* We have a bug here -- those are the only types in GC */ {
- Py_FatalError("Type not supported in GC -- internal bug");
- return; /* pacify compiler -- execution never here */
- }
- op->ob_refcnt = typecode;
- op->ob_type = (PyTypeObject*)_PyTrash_delete_later;
-#else
assert (_Py_AS_GC(op)->gc.gc_next == NULL);
_Py_AS_GC(op)->gc.gc_prev = (PyGC_Head *)_PyTrash_delete_later;
-#endif
_PyTrash_delete_later = op;
}
while (_PyTrash_delete_later) {
PyObject *shredder = _PyTrash_delete_later;
-#ifndef WITH_CYCLE_GC
- _PyTrash_delete_later = (PyObject*) shredder->ob_type;
-
- switch (shredder->ob_refcnt) {
- case Py_TRASHCAN_TUPLE:
- shredder->ob_type = &PyTuple_Type;
- break;
- case Py_TRASHCAN_LIST:
- shredder->ob_type = &PyList_Type;
- break;
- case Py_TRASHCAN_DICT:
- shredder->ob_type = &PyDict_Type;
- break;
- case Py_TRASHCAN_FRAME:
- shredder->ob_type = &PyFrame_Type;
- break;
- case Py_TRASHCAN_TRACEBACK:
- shredder->ob_type = &PyTraceBack_Type;
- break;
- }
-#else
_PyTrash_delete_later =
(PyObject*) _Py_AS_GC(shredder)->gc.gc_prev;
-#endif
_Py_NewReference(shredder);
extern void initbinascii(void);
extern void initcmath(void);
extern void initerrno(void);
-#ifdef WITH_CYCLE_GC
extern void initgc(void);
-#endif
#ifndef MS_WIN64
extern void initimageop(void);
#endif
{"binascii", initbinascii},
{"cmath", initcmath},
{"errno", initerrno},
-#ifdef WITH_CYCLE_GC
{"gc", initgc},
-#endif
#ifndef MS_WIN64
{"imageop", initimageop},
#endif
#define HAVE_USABLE_WCHAR_T
#endif
-/* Define if you want cycle garbage collection */
-#define WITH_CYCLE_GC 1
-
/* Use Python's own small-block memory-allocator. */
#define WITH_PYMALLOC 1
{"sys", NULL},
{"exceptions", NULL},
-#ifdef WITH_CYCLE_GC
/* This lives in gcmodule.c */
{"gc", initgc},
-#endif
/* Sentinel */
{0, 0}
one supplied by Python itself. (see Include/unicodectype.h). */
#undef WANT_WCTYPE_FUNCTIONS
-/* Define if you want to compile in cycle garbage collection */
-#define WITH_CYCLE_GC 1
-
/* Define if you want to emulate SGI (IRIX 4) dynamic linking.
This is rumoured to work on VAX (Ultrix), Sun3 (SunOS 3.4),
Sequent Symmetry (Dynix), and Atari ST.