[Python-checkins] python/dist/src/Python bltinmodule.c, 2.261.2.4, 2.261.2.5 ceval.c, 2.314.2.6, 2.314.2.7 compile.c, 2.247.2.3, 2.247.2.4 errors.c, 2.70.2.3, 2.70.2.4 exceptions.c, 1.32.2.2, 1.32.2.3 future.c, 2.12.2.7, 2.12.2.8 getargs.c, 2.92.2.2, 2.92.2.3 getcopyright.c, 1.16.2.2, 1.16.2.3 graminit.c, 2.33.2.3, 2.33.2.4 import.c, 2.208.2.6, 2.208.2.7 marshal.c, 1.72.2.3, 1.72.2.4 pystate.c, 2.20.18.2, 2.20.18.3 pythonrun.c, 2.161.2.18, 2.161.2.19 structmember.c, 2.23.8.1, 2.23.8.2 sysmodule.c, 2.107.2.3, 2.107.2.4 thread.c, 2.44.2.2, 2.44.2.3 thread_nt.h, 2.22.2.1, 2.22.2.2 thread_os2.h, 2.14.2.1, 2.14.2.2 thread_pthread.h, 2.40.2.2, 2.40.2.3 thread_wince.h, 2.7, 2.7.12.1

jhylton@users.sourceforge.net jhylton at users.sourceforge.net
Sun Oct 16 07:24:12 CEST 2005


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27718/Python

Modified Files:
      Tag: ast-branch
	bltinmodule.c ceval.c compile.c errors.c exceptions.c future.c 
	getargs.c getcopyright.c graminit.c import.c marshal.c 
	pystate.c pythonrun.c structmember.c sysmodule.c thread.c 
	thread_nt.h thread_os2.h thread_pthread.h thread_wince.h 
Log Message:
Merge head to branch (for the last time)


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.261.2.4
retrieving revision 2.261.2.5
diff -u -d -r2.261.2.4 -r2.261.2.5
--- bltinmodule.c	7 Jan 2005 07:04:35 -0000	2.261.2.4
+++ bltinmodule.c	16 Oct 2005 05:24:05 -0000	2.261.2.5
@@ -68,6 +68,69 @@
 \n\
 Return the absolute value of the argument.");
 
+static PyObject *
+builtin_all(PyObject *self, PyObject *v)
+{
+	PyObject *it, *item;
+
+	it = PyObject_GetIter(v);
+	if (it == NULL)
+		return NULL;
+
+	while ((item = PyIter_Next(it)) != NULL) {
+		int cmp = PyObject_IsTrue(item);
+		Py_DECREF(item);
+		if (cmp < 0) {
+			Py_DECREF(it);
+			return NULL;
+		}
+		if (cmp == 0) {
+			Py_DECREF(it);
+			Py_RETURN_FALSE;
+		}
+	}
+	Py_DECREF(it);
+	if (PyErr_Occurred())
+		return NULL;
+	Py_RETURN_TRUE;
+}
+
+PyDoc_STRVAR(all_doc,
+"all(iterable) -> bool\n\
+\n\
+Return True if bool(x) is True for all values x in the iterable.");
+
+static PyObject *
+builtin_any(PyObject *self, PyObject *v)
+{
+	PyObject *it, *item;
+
+	it = PyObject_GetIter(v);
+	if (it == NULL)
+		return NULL;
+
+	while ((item = PyIter_Next(it)) != NULL) {
+		int cmp = PyObject_IsTrue(item);
+		Py_DECREF(item);
+		if (cmp < 0) {
+			Py_DECREF(it);
+			return NULL;
+		}
+		if (cmp == 1) {
+			Py_DECREF(it);
+			Py_RETURN_TRUE;
+		}
+	}
+	Py_DECREF(it);
+	if (PyErr_Occurred())
+		return NULL;
+	Py_RETURN_FALSE;
+}
+
+PyDoc_STRVAR(any_doc,
+"any(iterable) -> bool\n\
+\n\
+Return True if bool(x) is True for any x in the iterable.");
 
 static PyObject *
 builtin_apply(PyObject *self, PyObject *args)
@@ -147,23 +210,27 @@
 	if (PyTuple_Check(seq))
 		return filtertuple(func, seq);
 
+	/* Pre-allocate argument list tuple. */
+	arg = PyTuple_New(1);
+	if (arg == NULL)
+		return NULL;
+
 	/* Get iterator. */
 	it = PyObject_GetIter(seq);
 	if (it == NULL)
-		return NULL;
+		goto Fail_arg;
 
 	/* Guess a result list size. */
-	len = PyObject_Size(seq);
+	len = _PyObject_LengthCue(seq);
 	if (len < 0) {
+		if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+		    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+			goto Fail_it;
+		}
 		PyErr_Clear();
 		len = 8;	/* arbitrary */
 	}
 
-	/* Pre-allocate argument list tuple. */
-	arg = PyTuple_New(1);
-	if (arg == NULL)
-		goto Fail_arg;
-
 	/* Get a result list. */
 	if (PyList_Check(seq) && seq->ob_refcnt == 1) {
 		/* Eww - can modify the list in-place. */
@@ -462,7 +529,7 @@
 		return NULL;
 	}
 	if (globals != Py_None && !PyDict_Check(globals)) {
-		PyErr_SetString(PyExc_TypeError, PyMapping_Check(globals) ? 
+		PyErr_SetString(PyExc_TypeError, PyMapping_Check(globals) ?
 			"globals must be a real dict; try eval(expr, {}, mapping)"
 			: "globals must be a dict");
 		return NULL;
@@ -475,6 +542,13 @@
 	else if (locals == Py_None)
 		locals = globals;
 
+	if (globals == NULL || locals == NULL) {
+		PyErr_SetString(PyExc_TypeError, 
+			"eval must be given globals and locals "
+			"when called without a frame");
+		return NULL;
+	}
+
 	if (PyDict_GetItemString(globals, "__builtins__") == NULL) {
 		if (PyDict_SetItemString(globals, "__builtins__",
 					 PyEval_GetBuiltins()) != 0)
@@ -799,8 +873,12 @@
 		}
 
 		/* Update len. */
-		curlen = PyObject_Size(curseq);
+		curlen = _PyObject_LengthCue(curseq);
 		if (curlen < 0) {
+			if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+			    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+				goto Fail_2;
+			}
 			PyErr_Clear();
 			curlen = 8;  /* arbitrary */
 		}
@@ -1127,11 +1205,11 @@
 	if (kwds != NULL && PyDict_Check(kwds) && PyDict_Size(kwds)) {
 		keyfunc = PyDict_GetItemString(kwds, "key");
 		if (PyDict_Size(kwds)!=1  ||  keyfunc == NULL) {
-			PyErr_Format(PyExc_TypeError, 
+			PyErr_Format(PyExc_TypeError,
 				"%s() got an unexpected keyword argument", name);
 			return NULL;
 		}
-	} 
+	}
 
 	it = PyObject_GetIter(v);
 	if (it == NULL)
@@ -1830,11 +1908,9 @@
 	static char *kwlist[] = {"iterable", "cmp", "key", "reverse", 0};
 	long reverse;
 
-	if (args != NULL) {
-		if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOi:sorted",
-			kwlist, &seq, &compare, &keyfunc, &reverse))
-			return NULL;
-	}
+	if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOi:sorted",
+		kwlist, &seq, &compare, &keyfunc, &reverse))
+		return NULL;
 
 	newlist = PySequence_List(seq);
 	if (newlist == NULL)
@@ -1845,7 +1921,7 @@
 		Py_DECREF(newlist);
 		return NULL;
 	}
-	
+
 	newargs = PyTuple_GetSlice(args, 1, 4);
 	if (newargs == NULL) {
 		Py_DECREF(newlist);
@@ -2032,8 +2108,12 @@
 	len = -1;	/* unknown */
 	for (i = 0; i < itemsize; ++i) {
 		PyObject *item = PyTuple_GET_ITEM(args, i);
-		int thislen = PyObject_Size(item);
+		int thislen = _PyObject_LengthCue(item);
 		if (thislen < 0) {
+			if (!PyErr_ExceptionMatches(PyExc_TypeError)  &&
+			    !PyErr_ExceptionMatches(PyExc_AttributeError)) {
+				return NULL;
+			}
 			PyErr_Clear();
 			len = -1;
 			break;
@@ -2125,6 +2205,8 @@
 static PyMethodDef builtin_methods[] = {
  	{"__import__",	builtin___import__, METH_VARARGS, import_doc},
  	{"abs",		builtin_abs,        METH_O, abs_doc},
+ 	{"all",		builtin_all,        METH_O, all_doc},
+ 	{"any",		builtin_any,        METH_O, any_doc},
  	{"apply",	builtin_apply,      METH_VARARGS, apply_doc},
  	{"callable",	builtin_callable,   METH_O, callable_doc},
  	{"chr",		builtin_chr,        METH_VARARGS, chr_doc},
@@ -2471,21 +2553,21 @@
 		if (ok) {
 			int reslen;
 			if (!PyUnicode_Check(item)) {
-				PyErr_SetString(PyExc_TypeError, 
+				PyErr_SetString(PyExc_TypeError,
 				"can't filter unicode to unicode:"
 				" __getitem__ returned different type");
 				Py_DECREF(item);
 				goto Fail_1;
 			}
 			reslen = PyUnicode_GET_SIZE(item);
-			if (reslen == 1) 
+			if (reslen == 1)
 				PyUnicode_AS_UNICODE(result)[j++] =
 					PyUnicode_AS_UNICODE(item)[0];
 			else {
 				/* do we need more space? */
 				int need = j + reslen + len - i - 1;
 				if (need > outlen) {
-					/* overallocate, 
+					/* overallocate,
 					   to avoid reallocations */
 					if (need < 2 * outlen)
 						need = 2 * outlen;

Index: ceval.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/ceval.c,v
retrieving revision 2.314.2.6
retrieving revision 2.314.2.7
diff -u -d -r2.314.2.6 -r2.314.2.7
--- ceval.c	7 Jan 2005 07:04:36 -0000	2.314.2.6
+++ ceval.c	16 Oct 2005 05:24:05 -0000	2.314.2.7
@@ -17,8 +17,10 @@
 #include <ctype.h>
 
 #ifndef WITH_TSC 
-#define rdtscll(var)
-#else /*WITH_TSC defined*/
+
+#define READ_TIMESTAMP(var)
+
+#else
 
 typedef unsigned long long uint64;
 
@@ -26,7 +28,7 @@
 			   section should work for GCC on any PowerPC platform,
 			   irrespective of OS.  POWER?  Who knows :-) */
 
-#define rdtscll(var) ppc_getcounter(&var)
+#define READ_TIMESTAMP(var) ppc_getcounter(&var)
 
 static void
 ppc_getcounter(uint64 *v)
@@ -45,9 +47,10 @@
 	((long*)(v))[1] = tb;
 }
 
-#else /* this section is for linux/x86 */
+#else /* this is for linux/x86 (and probably any other GCC/x86 combo) */
 
-#include <asm/msr.h>
+#define READ_TIMESTAMP(val) \
+     __asm__ __volatile__("rdtsc" : "=A" (val))
 
 #endif
 
@@ -99,7 +102,7 @@
 static int call_trace(Py_tracefunc, PyObject *, PyFrameObject *,
 		      int, PyObject *);
 static void call_trace_protected(Py_tracefunc, PyObject *,
-				 PyFrameObject *, int);
+				 PyFrameObject *, int, PyObject *);
 static void call_exc_trace(Py_tracefunc, PyObject *, PyFrameObject *);
 static int maybe_call_line_trace(Py_tracefunc, PyObject *,
 				  PyFrameObject *, int *, int *, int *);
@@ -414,8 +417,11 @@
 
 /* The interpreter's recursion limit */
 
-static int recursion_limit = 1000;
-int _Py_CheckRecursionLimit = 1000;
+#ifndef Py_DEFAULT_RECURSION_LIMIT
+#define Py_DEFAULT_RECURSION_LIMIT 1000
+#endif
+static int recursion_limit = Py_DEFAULT_RECURSION_LIMIT;
+int _Py_CheckRecursionLimit = Py_DEFAULT_RECURSION_LIMIT;
 
 int
 Py_GetRecursionLimit(void)
@@ -493,7 +499,14 @@
 /* Interpreter main loop */
 
 PyObject *
-PyEval_EvalFrame(PyFrameObject *f)
+PyEval_EvalFrame(PyFrameObject *f) {
+	/* This is for backward compatibility with extension modules that
+           used this API; core interpreter code should call PyEval_EvalFrameEx() */
+	return PyEval_EvalFrameEx(f, 0);
+}
+
+PyObject *
+PyEval_EvalFrameEx(PyFrameObject *f, int throw)
 {
 #ifdef DXPAIRS
 	int lastopcode = 0;
@@ -575,10 +588,10 @@
 	uint64 inst0, inst1, loop0, loop1, intr0 = 0, intr1 = 0;
 	int ticked = 0;
 
-	rdtscll(inst0);
-	rdtscll(inst1);
-	rdtscll(loop0);
-	rdtscll(loop1);
+	READ_TIMESTAMP(inst0);
+	READ_TIMESTAMP(inst1);
+	READ_TIMESTAMP(loop0);
+	READ_TIMESTAMP(loop1);
 
 	/* shut up the compiler */
 	opcode = 0;
@@ -715,7 +728,7 @@
 	consts = co->co_consts;
 	fastlocals = f->f_localsplus;
 	freevars = f->f_localsplus + f->f_nlocals;
-	first_instr = PyString_AS_STRING(co->co_code);
+	first_instr = (unsigned char*) PyString_AS_STRING(co->co_code);
 	/* An explanation is in order for the next line.
 
 	   f->f_lasti now refers to the index of the last instruction
@@ -741,6 +754,11 @@
 	x = Py_None;	/* Not a reference, just anything non-NULL */
 	w = NULL;
 
+	if (throw) { /* support for generator.throw() */
+		why = WHY_EXCEPTION;
+		goto on_error;
+	}
+		
 	for (;;) {
 #ifdef WITH_TSC
 		if (inst1 == 0) {
@@ -748,7 +766,7 @@
 			   or a continue, preventing inst1 from being set
 			   on the way out of the loop.
 			*/
-			rdtscll(inst1);
+			READ_TIMESTAMP(inst1);
 			loop1 = inst1;
 		}
 		dump_tsc(opcode, ticked, inst0, inst1, loop0, loop1,
@@ -757,7 +775,7 @@
 		inst1 = 0;
 		intr0 = 0;
 		intr1 = 0;
-		rdtscll(loop0);
+		READ_TIMESTAMP(loop0);
 #endif
 		assert(stack_pointer >= f->f_valuestack); /* else underflow */
 		assert(STACK_LEVEL() <= f->f_stacksize);  /* else overflow */
@@ -883,7 +901,7 @@
 #endif
 
 		/* Main switch on opcode */
-		rdtscll(inst0);
+		READ_TIMESTAMP(inst0);
 
 		switch (opcode) {
 
@@ -1642,9 +1660,9 @@
 			v = SECOND();
 			u = THIRD();
 			STACKADJ(-3);
-			rdtscll(intr0);
+			READ_TIMESTAMP(intr0);
 			err = exec_statement(f, u, v, w);
-			rdtscll(intr1);
+			READ_TIMESTAMP(intr1);
 			Py_DECREF(u);
 			Py_DECREF(v);
 			Py_DECREF(w);
@@ -2020,9 +2038,9 @@
 				x = NULL;
 				break;
 			}
-			rdtscll(intr0);
+			READ_TIMESTAMP(intr0);
 			x = PyEval_CallObject(x, w);
-			rdtscll(intr1);
+			READ_TIMESTAMP(intr1);
 			Py_DECREF(w);
 			SET_TOP(x);
 			if (x != NULL) continue;
@@ -2036,9 +2054,9 @@
 					"no locals found during 'import *'");
 				break;
 			}
-			rdtscll(intr0);
+			READ_TIMESTAMP(intr0);
 			err = import_all_from(x, v);
-			rdtscll(intr1);
+			READ_TIMESTAMP(intr1);
 			PyFrame_LocalsToFast(f, 0);
 			Py_DECREF(v);
 			if (err == 0) continue;
@@ -2047,9 +2065,9 @@
 		case IMPORT_FROM:
 			w = GETITEM(names, oparg);
 			v = TOP();
-			rdtscll(intr0);
+			READ_TIMESTAMP(intr0);
 			x = import_from(v, w);
-			rdtscll(intr1);
+			READ_TIMESTAMP(intr1);
 			PUSH(x);
 			if (x != NULL) continue;
 			break;
@@ -2203,9 +2221,9 @@
 		    } else
 			    Py_INCREF(func);
 		    sp = stack_pointer;
-		    rdtscll(intr0);
+		    READ_TIMESTAMP(intr0);
 		    x = ext_do_call(func, &sp, flags, na, nk);
-		    rdtscll(intr1);
+		    READ_TIMESTAMP(intr1);
 		    stack_pointer = sp;
 		    Py_DECREF(func);
 
@@ -2306,7 +2324,7 @@
 
 	    on_error:
 
-		rdtscll(inst1);
+		READ_TIMESTAMP(inst1);
 
 		/* Quickly continue if no error occurred */
 
@@ -2319,7 +2337,7 @@
 						"XXX undetected error\n");
 				else {
 #endif
-					rdtscll(loop1);
+					READ_TIMESTAMP(loop1);
 					continue; /* Normal, fast path */
 #ifdef CHECKEXC
 				}
@@ -2438,7 +2456,7 @@
 
 		if (why != WHY_NOT)
 			break;
-		rdtscll(loop1);
+		READ_TIMESTAMP(loop1);
 
 	} /* main loop */
 
@@ -2454,21 +2472,27 @@
 
 fast_yield:
 	if (tstate->use_tracing) {
-		if (tstate->c_tracefunc
-		    && (why == WHY_RETURN || why == WHY_YIELD)) {
-			if (call_trace(tstate->c_tracefunc,
-				       tstate->c_traceobj, f,
-				       PyTrace_RETURN, retval)) {
-				Py_XDECREF(retval);
-				retval = NULL;
-				why = WHY_EXCEPTION;
+		if (tstate->c_tracefunc) {
+			if (why == WHY_RETURN || why == WHY_YIELD) {
+				if (call_trace(tstate->c_tracefunc,
+					       tstate->c_traceobj, f,
+					       PyTrace_RETURN, retval)) {
+					Py_XDECREF(retval);
+					retval = NULL;
+					why = WHY_EXCEPTION;
+				}
+			}
+			else if (why == WHY_EXCEPTION) {
+				call_trace_protected(tstate->c_tracefunc,
+						     tstate->c_traceobj, f,
+						     PyTrace_RETURN, NULL);
 			}
 		}
 		if (tstate->c_profilefunc) {
 			if (why == WHY_EXCEPTION)
 				call_trace_protected(tstate->c_profilefunc,
 						     tstate->c_profileobj, f,
-						     PyTrace_RETURN);
+						     PyTrace_RETURN, NULL);
 			else if (call_trace(tstate->c_profilefunc,
 					    tstate->c_profileobj, f,
 					    PyTrace_RETURN, retval)) {
@@ -2491,7 +2515,7 @@
 
 /* this is gonna seem *real weird*, but if you put some other code between
    PyEval_EvalFrame() and PyEval_EvalCodeEx() you will need to adjust
-	the test in the if statement in Misc/gdbinit:ppystack */
+	the test in the if statement in Misc/gdbinit:pystack* */
 
 PyObject *
 PyEval_EvalCodeEx(PyCodeObject *co, PyObject *globals, PyObject *locals,
@@ -2716,7 +2740,7 @@
 		return PyGen_New(f);
 	}
 
-        retval = PyEval_EvalFrame(f);
+        retval = PyEval_EvalFrameEx(f,0);
 
   fail: /* Jump here from prelude on failure */
 
@@ -3073,12 +3097,12 @@
 
 static void
 call_trace_protected(Py_tracefunc func, PyObject *obj, PyFrameObject *frame,
-		     int what)
+		     int what, PyObject *arg)
 {
 	PyObject *type, *value, *traceback;
 	int err;
 	PyErr_Fetch(&type, &value, &traceback);
-	err = call_trace(func, obj, frame, what, NULL);
+	err = call_trace(func, obj, frame, what, arg);
 	if (err == 0)
 		PyErr_Restore(type, value, traceback);
 	else {
@@ -3267,10 +3291,12 @@
 	Py_XINCREF(arg);
 	tstate->c_profilefunc = NULL;
 	tstate->c_profileobj = NULL;
+	/* Must make sure that tracing is not ignored if 'temp' is freed */
 	tstate->use_tracing = tstate->c_tracefunc != NULL;
 	Py_XDECREF(temp);
 	tstate->c_profilefunc = func;
 	tstate->c_profileobj = arg;
+	/* Flag that tracing or profiling is turned on */
 	tstate->use_tracing = (func != NULL) || (tstate->c_tracefunc != NULL);
 }
 
@@ -3282,10 +3308,12 @@
 	Py_XINCREF(arg);
 	tstate->c_tracefunc = NULL;
 	tstate->c_traceobj = NULL;
+	/* Must make sure that profiling is not ignored if 'temp' is freed */
 	tstate->use_tracing = tstate->c_profilefunc != NULL;
 	Py_XDECREF(temp);
 	tstate->c_tracefunc = func;
 	tstate->c_traceobj = arg;
+	/* Flag that tracing or profiling is turned on */
 	tstate->use_tracing = ((func != NULL)
 			       || (tstate->c_profilefunc != NULL));
 }
@@ -3464,31 +3492,36 @@
 			     nargs);
 }
 
-#define C_TRACE(call) \
+#define C_TRACE(x, call) \
 if (tstate->use_tracing && tstate->c_profilefunc) { \
 	if (call_trace(tstate->c_profilefunc, \
 		tstate->c_profileobj, \
 		tstate->frame, PyTrace_C_CALL, \
-		func)) \
-		{ return NULL; } \
-	call; \
-	if (tstate->c_profilefunc != NULL) { \
-		if (x == NULL) { \
-			if (call_trace (tstate->c_profilefunc, \
-				tstate->c_profileobj, \
-				tstate->frame, PyTrace_C_EXCEPTION, \
-				func)) \
-				{ return NULL; } \
-		} else { \
-			if (call_trace(tstate->c_profilefunc, \
-				tstate->c_profileobj, \
-				tstate->frame, PyTrace_C_RETURN, \
-				func)) \
-				{ return NULL; } \
+		func)) { \
+		x = NULL; \
+	} \
+	else { \
+		x = call; \
+		if (tstate->c_profilefunc != NULL) { \
+			if (x == NULL) { \
+				call_trace_protected(tstate->c_profilefunc, \
+					tstate->c_profileobj, \
+					tstate->frame, PyTrace_C_EXCEPTION, \
+					func); \
+				/* XXX should pass (type, value, tb) */ \
+			} else { \
+				if (call_trace(tstate->c_profilefunc, \
+					tstate->c_profileobj, \
+					tstate->frame, PyTrace_C_RETURN, \
+					func)) { \
+					Py_DECREF(x); \
+					x = NULL; \
+				} \
+			} \
 		} \
 	} \
 } else { \
-	call; \
+	x = call; \
 	}
 
 static PyObject *
@@ -3517,11 +3550,11 @@
 			PyCFunction meth = PyCFunction_GET_FUNCTION(func);
 			PyObject *self = PyCFunction_GET_SELF(func);
 			if (flags & METH_NOARGS && na == 0) {
-				C_TRACE(x=(*meth)(self,NULL));
+				C_TRACE(x, (*meth)(self,NULL));
 			}
 			else if (flags & METH_O && na == 1) {
 				PyObject *arg = EXT_POP(*pp_stack);
-				C_TRACE(x=(*meth)(self,arg));
+				C_TRACE(x, (*meth)(self,arg));
 				Py_DECREF(arg);
 			}
 			else {
@@ -3532,9 +3565,9 @@
 		else {
 			PyObject *callargs;
 			callargs = load_args(pp_stack, na);
-			rdtscll(*pintr0);
-			C_TRACE(x=PyCFunction_Call(func,callargs,NULL));
-			rdtscll(*pintr1);
+			READ_TIMESTAMP(*pintr0);
+			C_TRACE(x, PyCFunction_Call(func,callargs,NULL));
+			READ_TIMESTAMP(*pintr1);
 			Py_XDECREF(callargs);
 		}
 	} else {
@@ -3552,12 +3585,12 @@
 			n++;
 		} else
 			Py_INCREF(func);
-		rdtscll(*pintr0);
+		READ_TIMESTAMP(*pintr0);
 		if (PyFunction_Check(func))
 			x = fast_function(func, pp_stack, n, na, nk);
 		else
 			x = do_call(func, pp_stack, na, nk);
-		rdtscll(*pintr1);
+		READ_TIMESTAMP(*pintr1);
 		Py_DECREF(func);
 	}
 
@@ -3615,7 +3648,7 @@
 			Py_INCREF(*stack);
 			fastlocals[i] = *stack++;
 		}
-		retval = PyEval_EvalFrame(f);
+		retval = PyEval_EvalFrameEx(f,0);
 		assert(tstate != NULL);
 		++tstate->recursion_depth;
 		Py_DECREF(f);

Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.247.2.3
retrieving revision 2.247.2.4
diff -u -d -r2.247.2.3 -r2.247.2.4
--- compile.c	13 Apr 2005 19:44:38 -0000	2.247.2.3
+++ compile.c	16 Oct 2005 05:24:05 -0000	2.247.2.4
@@ -325,6 +325,598 @@
 	return 0;
 }
 
+/* Begin: Peephole optimizations ----------------------------------------- */
+
+#define GETARG(arr, i) ((int)((arr[i+2]<<8) + arr[i+1]))
+#define UNCONDITIONAL_JUMP(op)  (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
+#define ABSOLUTE_JUMP(op) (op==JUMP_ABSOLUTE || op==CONTINUE_LOOP)
+#define GETJUMPTGT(arr, i) (GETARG(arr,i) + (ABSOLUTE_JUMP(arr[i]) ? 0 : i+3))
+#define SETARG(arr, i, val) arr[i+2] = val>>8; arr[i+1] = val & 255
+#define CODESIZE(op)  (HAS_ARG(op) ? 3 : 1)
+#define ISBASICBLOCK(blocks, start, bytes) (blocks[start]==blocks[start+bytes-1])
+
+/* Replace LOAD_CONST c1. LOAD_CONST c2 ... LOAD_CONST cn BUILD_TUPLE n
+   with    LOAD_CONST (c1, c2, ... cn).
+   The consts table must still be in list form so that the
+       new constant (c1, c2, ... cn) can be appended.
+   Called with codestr pointing to the first LOAD_CONST.
+   Bails out with no change if one or more of the LOAD_CONSTs is missing. 
+   Also works for BUILD_LIST when followed by an "in" or "not in" test.
+*/
+static int
+tuple_of_constants(unsigned char *codestr, int n, PyObject *consts)
+{
+	PyObject *newconst, *constant;
+	int i, arg, len_consts;
+
+	/* Pre-conditions */
+	assert(PyList_CheckExact(consts));
+	assert(codestr[n*3] == BUILD_TUPLE || codestr[n*3] == BUILD_LIST);
+	assert(GETARG(codestr, (n*3)) == n);
+	for (i=0 ; i<n ; i++)
+		assert(codestr[i*3] == LOAD_CONST);
+
+	/* Buildup new tuple of constants */
+	newconst = PyTuple_New(n);
+	if (newconst == NULL)
+		return 0;
+	len_consts = PyList_GET_SIZE(consts);
+	for (i=0 ; i<n ; i++) {
+		arg = GETARG(codestr, (i*3));
+		assert(arg < len_consts);
+		constant = PyList_GET_ITEM(consts, arg);
+		Py_INCREF(constant);
+		PyTuple_SET_ITEM(newconst, i, constant);
+	}
+
+	/* Append folded constant onto consts */
+	if (PyList_Append(consts, newconst)) {
+		Py_DECREF(newconst);
+		return 0;
+	}
+	Py_DECREF(newconst);
+
+	/* Write NOPs over old LOAD_CONSTS and
+	   add a new LOAD_CONST newconst on top of the BUILD_TUPLE n */
+	memset(codestr, NOP, n*3);
+	codestr[n*3] = LOAD_CONST;
+	SETARG(codestr, (n*3), len_consts);
+	return 1;
+}
+
+/* Replace LOAD_CONST c1. LOAD_CONST c2 BINOP
+   with    LOAD_CONST binop(c1,c2)
+   The consts table must still be in list form so that the
+       new constant can be appended.
+   Called with codestr pointing to the first LOAD_CONST. 
+   Abandons the transformation if the folding fails (i.e.  1+'a').  
+   If the new constant is a sequence, only folds when the size
+	is below a threshold value.  That keeps pyc files from
+	becoming large in the presence of code like:  (None,)*1000.
+*/
+static int
+fold_binops_on_constants(unsigned char *codestr, PyObject *consts)
+{
+	PyObject *newconst, *v, *w;
+	int len_consts, opcode, size;
+
+	/* Pre-conditions */
+	assert(PyList_CheckExact(consts));
+	assert(codestr[0] == LOAD_CONST);
+	assert(codestr[3] == LOAD_CONST);
+
+	/* Create new constant */
+	v = PyList_GET_ITEM(consts, GETARG(codestr, 0));
+	w = PyList_GET_ITEM(consts, GETARG(codestr, 3));
+	opcode = codestr[6];
+	switch (opcode) {
+	case BINARY_POWER:
+		newconst = PyNumber_Power(v, w, Py_None);
+		break;
+	case BINARY_MULTIPLY:
+		newconst = PyNumber_Multiply(v, w);
+		break;
+	case BINARY_DIVIDE:
+		/* Cannot fold this operation statically since
+		the result can depend on the run-time presence of the -Qnew flag */
+		return 0;
+	case BINARY_TRUE_DIVIDE:
+		newconst = PyNumber_TrueDivide(v, w);
+		break;
+	case BINARY_FLOOR_DIVIDE:
+		newconst = PyNumber_FloorDivide(v, w);
+		break;
+	case BINARY_MODULO:
+		newconst = PyNumber_Remainder(v, w);
+		break;
+	case BINARY_ADD:
+		newconst = PyNumber_Add(v, w);
+		break;
+	case BINARY_SUBTRACT:
+		newconst = PyNumber_Subtract(v, w);
+		break;
+	case BINARY_SUBSCR:
+		newconst = PyObject_GetItem(v, w);
+		break;
+	case BINARY_LSHIFT:
+		newconst = PyNumber_Lshift(v, w);
+		break;
+	case BINARY_RSHIFT:
+		newconst = PyNumber_Rshift(v, w);
+		break;
+	case BINARY_AND:
+		newconst = PyNumber_And(v, w);
+		break;
+	case BINARY_XOR:
+		newconst = PyNumber_Xor(v, w);
+		break;
+	case BINARY_OR:
+		newconst = PyNumber_Or(v, w);
+		break;
+	default:
+		/* Called with an unknown opcode */
+		assert(0);
+		return 0;
+	}
+	if (newconst == NULL) {
+		PyErr_Clear();
+		return 0;
+	}
+	size = PyObject_Size(newconst);
+	if (size == -1)
+		PyErr_Clear();
+	else if (size > 20) {
+		Py_DECREF(newconst);
+		return 0;
+	}
+
+	/* Append folded constant into consts table */
+	len_consts = PyList_GET_SIZE(consts);
+	if (PyList_Append(consts, newconst)) {
+		Py_DECREF(newconst);
+		return 0;
+	}
+	Py_DECREF(newconst);
+
+	/* Write NOP NOP NOP NOP LOAD_CONST newconst */
+	memset(codestr, NOP, 4);
+	codestr[4] = LOAD_CONST;
+	SETARG(codestr, 4, len_consts);
+	return 1;
+}
+
+static int
+fold_unaryops_on_constants(unsigned char *codestr, PyObject *consts)
+{
+	PyObject *newconst=NULL, *v;
+	int len_consts, opcode;
+
+	/* Pre-conditions */
+	assert(PyList_CheckExact(consts));
+	assert(codestr[0] == LOAD_CONST);
+
+	/* Create new constant */
+	v = PyList_GET_ITEM(consts, GETARG(codestr, 0));
+	opcode = codestr[3];
+	switch (opcode) {
+	case UNARY_NEGATIVE:
+		/* Preserve the sign of -0.0 */
+		if (PyObject_IsTrue(v) == 1)
+			newconst = PyNumber_Negative(v);
+		break;
+	case UNARY_CONVERT:
+		newconst = PyObject_Repr(v);
+		break;
+	case UNARY_INVERT:
+		newconst = PyNumber_Invert(v);
+		break;
+	default:
+		/* Called with an unknown opcode */
+		assert(0);
+		return 0;
+	}
+	if (newconst == NULL) {
+		PyErr_Clear();
+		return 0;
+	}
+
+	/* Append folded constant into consts table */
+	len_consts = PyList_GET_SIZE(consts);
+	if (PyList_Append(consts, newconst)) {
+		Py_DECREF(newconst);
+		return 0;
+	}
+	Py_DECREF(newconst);
+
+	/* Write NOP LOAD_CONST newconst */
+	codestr[0] = NOP;
+	codestr[1] = LOAD_CONST;
+	SETARG(codestr, 1, len_consts);
+	return 1;
+}
+
+static unsigned int *
+markblocks(unsigned char *code, int len)
+{
+	unsigned int *blocks = PyMem_Malloc(len*sizeof(int));
+	int i,j, opcode, blockcnt = 0;
+
+	if (blocks == NULL)
+		return NULL;
+	memset(blocks, 0, len*sizeof(int));
+
+	/* Mark labels in the first pass */
+	for (i=0 ; i<len ; i+=CODESIZE(opcode)) {
+		opcode = code[i];
+		switch (opcode) {
+			case FOR_ITER:
+			case JUMP_FORWARD:
+			case JUMP_IF_FALSE:
+			case JUMP_IF_TRUE:
+			case JUMP_ABSOLUTE:
+			case CONTINUE_LOOP:
+			case SETUP_LOOP:
+			case SETUP_EXCEPT:
+			case SETUP_FINALLY:
+				j = GETJUMPTGT(code, i);
+				blocks[j] = 1;
+			break;
+		}
+	}
+	/* Build block numbers in the second pass */
+	for (i=0 ; i<len ; i++) {
+		blockcnt += blocks[i];  /* increment blockcnt over labels */
+		blocks[i] = blockcnt;
+	}
+	return blocks;
+}
+
+/* Perform basic peephole optimizations to components of a code object.
+   The consts object should still be in list form to allow new constants 
+   to be appended.
+
+   To keep the optimizer simple, it bails out (does nothing) for code
+   containing extended arguments or that has a length over 32,700.  That 
+   allows us to avoid overflow and sign issues.  Likewise, it bails when
+   the lineno table has complex encoding for gaps >= 255.
+
+   Optimizations are restricted to simple transformations occuring within a
+   single basic block.  All transformations keep the code size the same or 
+   smaller.  For those that reduce size, the gaps are initially filled with 
+   NOPs.  Later those NOPs are removed and the jump addresses retargeted in 
+   a single pass.  Line numbering is adjusted accordingly. */
+
+static PyObject *
+optimize_code(PyObject *code, PyObject* consts, PyObject *names, PyObject *lineno_obj)
+{
+	int i, j, codelen, nops, h, adj;
+	int tgt, tgttgt, opcode;
+	unsigned char *codestr = NULL;
+	unsigned char *lineno;
+	int *addrmap = NULL;
+	int new_line, cum_orig_line, last_line, tabsiz;
+	int cumlc=0, lastlc=0;	/* Count runs of consecutive LOAD_CONST codes */
+	unsigned int *blocks = NULL;
+	char *name;
+
+	/* Bail out if an exception is set */
+	if (PyErr_Occurred())
+		goto exitUnchanged;
+
+	/* Bypass optimization when the lineno table is too complex */
+	assert(PyString_Check(lineno_obj));
+	lineno = (unsigned char*)PyString_AS_STRING(lineno_obj);
+	tabsiz = PyString_GET_SIZE(lineno_obj);
+	if (memchr(lineno, 255, tabsiz) != NULL)
+		goto exitUnchanged;
+
+	/* Avoid situations where jump retargeting could overflow */
+	assert(PyString_Check(code));
+	codelen = PyString_Size(code);
+	if (codelen > 32700)
+		goto exitUnchanged;
+
+	/* Make a modifiable copy of the code string */
+	codestr = PyMem_Malloc(codelen);
+	if (codestr == NULL)
+		goto exitUnchanged;
+	codestr = memcpy(codestr, PyString_AS_STRING(code), codelen);
+
+	/* Verify that RETURN_VALUE terminates the codestring.  This allows
+	   the various transformation patterns to look ahead several
+	   instructions without additional checks to make sure they are not
+	   looking beyond the end of the code string.
+	*/
+	if (codestr[codelen-1] != RETURN_VALUE)
+		goto exitUnchanged;
+
+	/* Mapping to new jump targets after NOPs are removed */
+	addrmap = PyMem_Malloc(codelen * sizeof(int));
+	if (addrmap == NULL)
+		goto exitUnchanged;
+
+	blocks = markblocks(codestr, codelen);
+	if (blocks == NULL)
+		goto exitUnchanged;
+	assert(PyList_Check(consts));
+
+	for (i=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
+		opcode = codestr[i];
+
+		lastlc = cumlc;
+		cumlc = 0;
+
+		switch (opcode) {
+
+		/* Replace UNARY_NOT JUMP_IF_FALSE POP_TOP with 
+		   with    JUMP_IF_TRUE POP_TOP */
+		case UNARY_NOT:
+			if (codestr[i+1] != JUMP_IF_FALSE  ||
+			    codestr[i+4] != POP_TOP  ||
+			    !ISBASICBLOCK(blocks,i,5))
+				continue;
+			tgt = GETJUMPTGT(codestr, (i+1));
+			if (codestr[tgt] != POP_TOP)
+				continue;
+			j = GETARG(codestr, i+1) + 1;
+			codestr[i] = JUMP_IF_TRUE;
+			SETARG(codestr, i, j);
+			codestr[i+3] = POP_TOP;
+			codestr[i+4] = NOP;
+			break;
+
+		/* not a is b -->  a is not b
+		   not a in b -->  a not in b
+		   not a is not b -->  a is b
+		   not a not in b -->  a in b
+		*/
+		case COMPARE_OP:
+			j = GETARG(codestr, i);
+			if (j < 6  ||  j > 9  ||
+			    codestr[i+3] != UNARY_NOT  || 
+			    !ISBASICBLOCK(blocks,i,4))
+				continue;
+			SETARG(codestr, i, (j^1));
+			codestr[i+3] = NOP;
+			break;
+
+		/* Replace LOAD_GLOBAL/LOAD_NAME None with LOAD_CONST None */
+		case LOAD_NAME:
+		case LOAD_GLOBAL:
+			j = GETARG(codestr, i);
+			name = PyString_AsString(PyTuple_GET_ITEM(names, j));
+			if (name == NULL  ||  strcmp(name, "None") != 0)
+				continue;
+			for (j=0 ; j < PyList_GET_SIZE(consts) ; j++) {
+				if (PyList_GET_ITEM(consts, j) == Py_None) {
+					codestr[i] = LOAD_CONST;
+					SETARG(codestr, i, j);
+					cumlc = lastlc + 1;
+					break;
+				}
+			}
+			break;
+
+		/* Skip over LOAD_CONST trueconst  JUMP_IF_FALSE xx  POP_TOP */
+		case LOAD_CONST:
+			cumlc = lastlc + 1;
+			j = GETARG(codestr, i);
+			if (codestr[i+3] != JUMP_IF_FALSE  ||
+			    codestr[i+6] != POP_TOP  ||
+			    !ISBASICBLOCK(blocks,i,7)  ||
+			    !PyObject_IsTrue(PyList_GET_ITEM(consts, j)))
+				continue;
+			memset(codestr+i, NOP, 7);
+			cumlc = 0;
+			break;
+
+		/* Try to fold tuples of constants (includes a case for lists
+		      which are only used for "in" and "not in" tests).
+		   Skip over BUILD_SEQN 1 UNPACK_SEQN 1.
+		   Replace BUILD_SEQN 2 UNPACK_SEQN 2 with ROT2.
+		   Replace BUILD_SEQN 3 UNPACK_SEQN 3 with ROT3 ROT2. */
+		case BUILD_TUPLE:
+		case BUILD_LIST:
+			j = GETARG(codestr, i);
+			h = i - 3 * j;
+			if (h >= 0  &&
+			    j <= lastlc  &&
+			    ((opcode == BUILD_TUPLE && 
+			     ISBASICBLOCK(blocks, h, 3*(j+1))) ||
+			     (opcode == BUILD_LIST && 
+			     codestr[i+3]==COMPARE_OP && 
+			     ISBASICBLOCK(blocks, h, 3*(j+2)) &&
+			     (GETARG(codestr,i+3)==6 ||
+				      GETARG(codestr,i+3)==7))) &&
+			     tuple_of_constants(&codestr[h], j, consts)) {
+				assert(codestr[i] == LOAD_CONST);
+				cumlc = 1;
+				break;
+			}
+			if (codestr[i+3] != UNPACK_SEQUENCE  ||
+			    !ISBASICBLOCK(blocks,i,6) ||
+			    j != GETARG(codestr, i+3))
+				continue;
+			if (j == 1) {
+				memset(codestr+i, NOP, 6);
+			} else if (j == 2) {
+				codestr[i] = ROT_TWO;
+				memset(codestr+i+1, NOP, 5);
+			} else if (j == 3) {
+				codestr[i] = ROT_THREE;
+				codestr[i+1] = ROT_TWO;
+				memset(codestr+i+2, NOP, 4);
+			}
+			break;
+
+		/* Fold binary ops on constants.
+		   LOAD_CONST c1 LOAD_CONST c2 BINOP -->  LOAD_CONST binop(c1,c2) */
+		case BINARY_POWER:
+		case BINARY_MULTIPLY:
+		case BINARY_TRUE_DIVIDE:
+		case BINARY_FLOOR_DIVIDE:
+		case BINARY_MODULO:
+		case BINARY_ADD:
+		case BINARY_SUBTRACT:
+		case BINARY_SUBSCR:
+		case BINARY_LSHIFT:
+		case BINARY_RSHIFT:
+		case BINARY_AND:
+		case BINARY_XOR:
+		case BINARY_OR:
+			if (lastlc >= 2  &&
+			    ISBASICBLOCK(blocks, i-6, 7)  &&
+			    fold_binops_on_constants(&codestr[i-6], consts)) {
+				i -= 2;
+				assert(codestr[i] == LOAD_CONST);
+				cumlc = 1;
+			}
+			break;
+
+		/* Fold unary ops on constants.
+		   LOAD_CONST c1  UNARY_OP -->  LOAD_CONST unary_op(c) */
+		case UNARY_NEGATIVE:
+		case UNARY_CONVERT:
+		case UNARY_INVERT:
+			if (lastlc >= 1  &&
+			    ISBASICBLOCK(blocks, i-3, 4)  &&
+			    fold_unaryops_on_constants(&codestr[i-3], consts))  {
+				i -= 2;
+				assert(codestr[i] == LOAD_CONST);
+				cumlc = 1;
+			}
+			break;
+
+		/* Simplify conditional jump to conditional jump where the
+		   result of the first test implies the success of a similar
+		   test or the failure of the opposite test.
+		   Arises in code like:
+		        "if a and b:"
+			"if a or b:"
+		        "a and b or c"
+			"(a and b) and c"
+		   x:JUMP_IF_FALSE y   y:JUMP_IF_FALSE z  -->  x:JUMP_IF_FALSE z
+		   x:JUMP_IF_FALSE y   y:JUMP_IF_TRUE z  -->  x:JUMP_IF_FALSE y+3
+			where y+3 is the instruction following the second test.
+		*/
+		case JUMP_IF_FALSE:
+		case JUMP_IF_TRUE:
+			tgt = GETJUMPTGT(codestr, i);
+			j = codestr[tgt];
+			if (j == JUMP_IF_FALSE  ||  j == JUMP_IF_TRUE) {
+				if (j == opcode) {
+					tgttgt = GETJUMPTGT(codestr, tgt) - i - 3;
+					SETARG(codestr, i, tgttgt);
+				} else {
+					tgt -= i;
+					SETARG(codestr, i, tgt);
+				}
+				break;
+			}
+			/* Intentional fallthrough */  
+
+		/* Replace jumps to unconditional jumps */
+		case FOR_ITER:
+		case JUMP_FORWARD:
+		case JUMP_ABSOLUTE:
+		case CONTINUE_LOOP:
+		case SETUP_LOOP:
+		case SETUP_EXCEPT:
+		case SETUP_FINALLY:
+			tgt = GETJUMPTGT(codestr, i);
+			if (!UNCONDITIONAL_JUMP(codestr[tgt]))
+				continue;
+			tgttgt = GETJUMPTGT(codestr, tgt);
+			if (opcode == JUMP_FORWARD) /* JMP_ABS can go backwards */
+				opcode = JUMP_ABSOLUTE;
+			if (!ABSOLUTE_JUMP(opcode))
+				tgttgt -= i + 3;     /* Calc relative jump addr */
+			if (tgttgt < 0)           /* No backward relative jumps */
+				 continue;
+			codestr[i] = opcode;
+			SETARG(codestr, i, tgttgt);
+			break;
+
+		case EXTENDED_ARG:
+			goto exitUnchanged;
+
+		/* Replace RETURN LOAD_CONST None RETURN with just RETURN */
+		case RETURN_VALUE:
+			if (i+4 >= codelen  ||
+			   codestr[i+4] != RETURN_VALUE  ||
+			   !ISBASICBLOCK(blocks,i,5))
+			       continue;
+			memset(codestr+i+1, NOP, 4);
+			break;
+		}
+	}
+
+	/* Fixup linenotab */
+	for (i=0, nops=0 ; i<codelen ; i += CODESIZE(codestr[i])) {
+		addrmap[i] = i - nops;
+		if (codestr[i] == NOP)
+			nops++;
+	}
+	cum_orig_line = 0;
+	last_line = 0;
+	for (i=0 ; i < tabsiz ; i+=2) {
+		cum_orig_line += lineno[i];
+		new_line = addrmap[cum_orig_line];
+		assert (new_line - last_line < 255);
+		lineno[i] =((unsigned char)(new_line - last_line));
+		last_line = new_line;
+	}
+
+	/* Remove NOPs and fixup jump targets */
+	for (i=0, h=0 ; i<codelen ; ) {
+		opcode = codestr[i];
+		switch (opcode) {
+			case NOP:
+				i++;
+				continue;
+
+			case JUMP_ABSOLUTE:
+			case CONTINUE_LOOP:
+				j = addrmap[GETARG(codestr, i)];
+				SETARG(codestr, i, j);
+				break;
+
+			case FOR_ITER:
+			case JUMP_FORWARD:
+			case JUMP_IF_FALSE:
+			case JUMP_IF_TRUE:
+			case SETUP_LOOP:
+			case SETUP_EXCEPT:
+			case SETUP_FINALLY:
+				j = addrmap[GETARG(codestr, i) + i + 3] - addrmap[i] - 3;
+				SETARG(codestr, i, j);
+				break;
+		}
+		adj = CODESIZE(opcode);
+		while (adj--)
+			codestr[h++] = codestr[i++];
+	}
+	assert(h + nops == codelen);
+
+	code = PyString_FromStringAndSize((char *)codestr, h);
+	PyMem_Free(addrmap);
+	PyMem_Free(codestr);
+	PyMem_Free(blocks);
+	return code;
+
+exitUnchanged:
+	if (blocks != NULL)
+		PyMem_Free(blocks);
+	if (addrmap != NULL)
+		PyMem_Free(addrmap);
+	if (codestr != NULL)
+		PyMem_Free(codestr);
+	Py_INCREF(code);
+	return code;
+}
+
+/* End: Peephole optimizations ----------------------------------------- */
+
 PyCodeObject *
 PyCode_New(int argcount, int nlocals, int stacksize, int flags,
 	   PyObject *code, PyObject *consts, PyObject *names,
@@ -1394,6 +1986,53 @@
 }  
 
 static void
+com_gen_for(struct compiling *c, node *n, node *t, int is_outmost)
+{
+	int break_anchor = 0;
+	int anchor = 0;
+	int save_begin = c->c_begin;
+
+	REQ(n, gen_for);
+	/* gen_for: for v in test [gen_iter] */
+
+	com_addfwref(c, SETUP_LOOP, &break_anchor);
+	block_push(c, SETUP_LOOP);
+
+	if (is_outmost) {
+		com_addop_varname(c, VAR_LOAD, "[outmost-iterable]");
+		com_push(c, 1);
+	}
+	else {
+		com_node(c, CHILD(n, 3));
+		com_addbyte(c, GET_ITER); 
+	}
+
+	c->c_begin = c->c_nexti;
+	com_set_lineno(c, c->c_last_line);
+	com_addfwref(c, FOR_ITER, &anchor);
+	com_push(c, 1);
+	com_assign(c, CHILD(n, 1), OP_ASSIGN, NULL);
+
+	if (NCH(n) == 5) 
+		com_gen_iter(c, CHILD(n, 4), t);
+	else {
+		com_test(c, t);
+		com_addbyte(c, YIELD_VALUE);
+		com_addbyte(c, POP_TOP);
+		com_pop(c, 1);
+	}
+
+	com_addoparg(c, JUMP_ABSOLUTE, c->c_begin);
+	c->c_begin = save_begin;
+
+	com_backpatch(c, anchor);
+	com_pop(c, 1); /* FOR_ITER has popped this */
+	com_addbyte(c, POP_BLOCK);
+	block_pop(c, SETUP_LOOP);
+	com_backpatch(c, break_anchor);
+}
+
+static void
 com_list_if(struct compiling *c, node *n, node *e, char *t)
 {
 	int anchor = 0;
@@ -1413,6 +2052,33 @@
 }
 
 static void
+com_gen_if(struct compiling *c, node *n, node *t)
+{
+	/* gen_if: 'if' test [gen_iter] */
+	int anchor = 0;
+	int a=0;
+
+	com_node(c, CHILD(n, 1));
+	com_addfwref(c, JUMP_IF_FALSE, &a);
+	com_addbyte(c, POP_TOP);
+	com_pop(c, 1);
+
+	if (NCH(n) == 3)
+		com_gen_iter(c, CHILD(n, 2), t);
+	else {
+		com_test(c, t);
+		com_addbyte(c, YIELD_VALUE);
+		com_addbyte(c, POP_TOP);
+		com_pop(c, 1);
+	}
+	com_addfwref(c, JUMP_FORWARD, &anchor);
+	com_backpatch(c, a);
+	/* We jump here with an extra entry which we now pop */
+	com_addbyte(c, POP_TOP);
+	com_backpatch(c, anchor);
+}
+
+static void
 com_list_iter(struct compiling *c,
 	      node *p,		/* parent of list_iter node */
 	      node *e,		/* element expression node */
@@ -1495,6 +2161,10 @@
 	}
 }
 
+
+/* forward reference */
+static void com_yield_expr(struct compiling *c, node *n);
+
 static void
 com_atom(struct compiling *c, node *n)
 {
@@ -1510,7 +2180,10 @@
 			com_push(c, 1);
 		}
 		else
-			com_node(c, CHILD(n, 1));
+			if (TYPE(CHILD(n, 1)) == yield_expr)
+				com_yield_expr(c, CHILD(n, 1));
+			else
+				com_testlist_gexp(c, CHILD(n, 1));
 		break;
 	case LSQB: /* '[' [listmaker] ']' */
 		if (TYPE(CHILD(n, 1)) == RSQB) {
@@ -2562,7 +3235,11 @@
 			}
 			n = CHILD(n, 0);
 			break;
-		
+		case yield_expr:
+			com_error(c, PyExc_SyntaxError,
+			  "assignment to yield expression not possible");
+			return;
+					
 		case test:
 		case and_test:
 		case not_test:
@@ -2619,7 +3296,7 @@
 				}
 				if (assigning > OP_APPLY) {
 					com_error(c, PyExc_SyntaxError,
-				  "augmented assign to tuple not possible");
+				  "augmented assign to tuple literal, yield, or generator expression not possible");
 					return;
 				}
 				break;
@@ -2855,27 +3532,41 @@
 }
 
 static void
-com_yield_stmt(struct compiling *c, node *n)
+com_yield_expr(struct compiling *c, node *n)
 {
-	int i;
-	REQ(n, yield_stmt); /* 'yield' testlist */
+	REQ(n, yield_expr); /* 'yield' testlist */
 	if (!c->c_infunction) {
 		com_error(c, PyExc_SyntaxError, "'yield' outside function");
 	}
 	
-	for (i = 0; i < c->c_nblocks; ++i) {
+	/* for (i = 0; i < c->c_nblocks; ++i) {
 		if (c->c_block[i] == SETUP_FINALLY) {
 			com_error(c, PyExc_SyntaxError,
 				  "'yield' not allowed in a 'try' block "
 				  "with a 'finally' clause");
 			return;
 		}
+	} */
+
+	if (NCH(n) < 2) {
+		com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
+		com_push(c, 1);
 	}
-	com_node(c, CHILD(n, 1));
+	else
+		com_node(c, CHILD(n, 1));
 	com_addbyte(c, YIELD_VALUE);
+}
+
+static void
+com_yield_stmt(struct compiling *c, node *n)
+{
+	REQ(n, yield_stmt); /* yield_expr */
+	com_node(c, CHILD(n, 0));
+	com_addbyte(c, POP_TOP);
 	com_pop(c, 1);
 }
 
+
 static void
 com_raise_stmt(struct compiling *c, node *n)
 {
@@ -3639,7 +4330,7 @@
 	char *name;
 
 	REQ(n, classdef);
-	/* classdef: class NAME ['(' testlist ')'] ':' suite */
+	/* classdef: class NAME ['(' [testlist] ')'] ':' suite */
 	if ((v = PyString_InternFromString(STR(CHILD(n, 1)))) == NULL) {
 		c->c_errors++;
 		return;
@@ -3650,7 +4341,8 @@
 	com_push(c, 1);
 	Py_DECREF(v);
 	/* Push the tuple of base classes on the stack */
-	if (TYPE(CHILD(n, 2)) != LPAR) {
+	if (TYPE(CHILD(n, 2)) != LPAR ||
+			TYPE(CHILD(n, 3)) == RPAR) {
 		com_addoparg(c, BUILD_TUPLE, 0);
 		com_push(c, 1);
 	}
@@ -3782,6 +4474,10 @@
 	
 	/* Expression nodes */
 	
+	case yield_expr:
+		com_yield_expr(c, n);
+		break;
+
 	case testlist:
 	case testlist1:
 	case testlist_safe:
@@ -4029,6 +4725,25 @@
 }
 
 static void
+compile_generator_expression(struct compiling *c, node *n)
+{
+	/* testlist_gexp: test gen_for */
+	/* argument: test gen_for */
+	REQ(CHILD(n, 0), test); 
+	REQ(CHILD(n, 1), gen_for); 
+
+	c->c_name = "<generator expression>";
+	c->c_infunction = 1;
+	com_gen_for(c, CHILD(n, 1), CHILD(n, 0), 1);
+	c->c_infunction = 0;
+
+	com_addoparg(c, LOAD_CONST, com_addconst(c, Py_None));
+	com_push(c, 1);
+	com_addbyte(c, RETURN_VALUE);
+	com_pop(c, 1);
+}
+
+static void
 compile_node(struct compiling *c, node *n)
 {
 	com_addoparg(c, SET_LINENO, n->n_lineno);
@@ -4979,7 +5694,7 @@
 
 #define symtable_add_use(ST, NAME) symtable_add_def((ST), (NAME), USE)
 
-/* Look for a yield stmt under n.  Return 1 if found, else 0.
+/* Look for a yield stmt or expr under n.  Return 1 if found, else 0.
    This hack is used to look inside "if 0:" blocks (which are normally
    ignored) in case those are the only places a yield occurs (so that this
    function is a generator). */
@@ -5001,7 +5716,8 @@
 			return 0;
 
 		case yield_stmt:
-			return 1;
+		case yield_expr:
+			return GENERATOR;
 
 		default:
 			if (look_for_yield(kid))
@@ -5108,8 +5824,10 @@
 	case del_stmt:
 		symtable_assign(st, CHILD(n, 1), 0);
 		break;
-	case yield_stmt:
+	case yield_expr:
 		st->st_cur->ste_generator = 1;
+		if (NCH(n)==1) 
+			break;
 		n = CHILD(n, 1);
 		goto loop;
 	case expr_stmt:
@@ -5170,9 +5888,15 @@
 		}
 		/* fall through */
 	case atom:
-		if (TYPE(n) == atom && TYPE(CHILD(n, 0)) == NAME) {
-			symtable_add_use(st, STR(CHILD(n, 0)));
-			break;
+		if (TYPE(n) == atom) {
+			if (TYPE(CHILD(n, 0)) == NAME) {
+				symtable_add_use(st, STR(CHILD(n, 0)));
+				break;
+			}
+			else if (TYPE(CHILD(n,0)) == LPAR) {
+				n = CHILD(n,1);
+				goto loop;
+			}
 		}
 		/* fall through */
 	default:
@@ -5492,6 +6216,15 @@
 			symtable_add_def(st, STR(tmp), DEF_LOCAL | def_flag);
 		}
 		return;
+
+	case yield_expr:
+		st->st_cur->ste_generator = 1;
+		if (NCH(n)==2) {
+			n = CHILD(n, 1);
+			goto loop;
+		}
+		return;
+
 	case dotted_as_name:
 		if (NCH(n) == 3)
 			symtable_add_def(st, STR(CHILD(n, 2)),

Index: errors.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/errors.c,v
retrieving revision 2.70.2.3
retrieving revision 2.70.2.4
diff -u -d -r2.70.2.3 -r2.70.2.4
--- errors.c	7 Jan 2005 07:04:38 -0000	2.70.2.3
+++ errors.c	16 Oct 2005 05:24:05 -0000	2.70.2.4
@@ -535,10 +535,6 @@
 	}
 	if (base == NULL)
 		base = PyExc_Exception;
-	if (!PyClass_Check(base)) {
-		/* Must be using string-based standard exceptions (-X) */
-		return PyString_FromString(name);
-	}
 	if (dict == NULL) {
 		dict = mydict = PyDict_New();
 		if (dict == NULL)

Index: exceptions.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/exceptions.c,v
retrieving revision 1.32.2.2
retrieving revision 1.32.2.3
diff -u -d -r1.32.2.2 -r1.32.2.3
--- exceptions.c	7 Jan 2005 07:04:38 -0000	1.32.2.2
+++ exceptions.c	16 Oct 2005 05:24:05 -0000	1.32.2.3
@@ -57,6 +57,7 @@
  |\n\
  +-- SystemExit\n\
  +-- StopIteration\n\
+ +-- GeneratorExit\n\
  +-- StandardError\n\
  |    |\n\
  |    +-- KeyboardInterrupt\n\
@@ -394,6 +395,7 @@
 PyDoc_STRVAR(TypeError__doc__, "Inappropriate argument type.");
 
 PyDoc_STRVAR(StopIteration__doc__, "Signal the end from iterator.next().");
+PyDoc_STRVAR(GeneratorExit__doc__, "Request that a generator exit.");
 
 
 
@@ -1583,6 +1585,7 @@
 
 PyObject *PyExc_Exception;
 PyObject *PyExc_StopIteration;
+PyObject *PyExc_GeneratorExit;
 PyObject *PyExc_StandardError;
 PyObject *PyExc_ArithmeticError;
 PyObject *PyExc_LookupError;
@@ -1657,6 +1660,8 @@
  {"Exception", &PyExc_Exception},
  {"StopIteration", &PyExc_StopIteration, &PyExc_Exception,
   StopIteration__doc__},
+ {"GeneratorExit", &PyExc_GeneratorExit, &PyExc_Exception,
+  GeneratorExit__doc__},
  {"StandardError", &PyExc_StandardError, &PyExc_Exception,
   StandardError__doc__},
  {"TypeError", &PyExc_TypeError, 0, TypeError__doc__},

Index: future.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/future.c,v
retrieving revision 2.12.2.7
retrieving revision 2.12.2.8
diff -u -d -r2.12.2.7 -r2.12.2.8
--- future.c	21 Apr 2004 14:41:49 -0000	2.12.2.7
+++ future.c	16 Oct 2005 05:24:05 -0000	2.12.2.8
@@ -130,4 +130,3 @@
 	}
 	return ff;
 }
-

Index: getargs.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getargs.c,v
retrieving revision 2.92.2.2
retrieving revision 2.92.2.3
diff -u -d -r2.92.2.2 -r2.92.2.3
--- getargs.c	7 Jan 2005 07:04:39 -0000	2.92.2.2
+++ getargs.c	16 Oct 2005 05:24:05 -0000	2.92.2.3
@@ -453,7 +453,9 @@
    or a string with a message describing the failure.  The message is
    formatted as "must be <desired type>, not <actual type>".
    When failing, an exception may or may not have been raised.
-   Don't call if a tuple is expected. 
+   Don't call if a tuple is expected.
+
+   When you add new format codes, please don't forget poor skipitem() below.
 */
 
 static char *
@@ -1299,7 +1301,8 @@
 	/* make sure we got an acceptable number of arguments; the message
 	   is a little confusing with keywords since keyword arguments
 	   which are supplied, but don't match the required arguments
-	   are not included in the "%d given" part of the message */
+	   are not included in the "%d given" part of the message 
+	   XXX and this isn't a bug!? */
 	if (len < min || max < len) {
 		if (message == NULL) {
 			PyOS_snprintf(msgbuf, sizeof(msgbuf),
@@ -1405,83 +1408,52 @@
 	char c = *format++;
 	
 	switch (c) {
-	
+
+	/* simple codes
+	 * The individual types (second arg of va_arg) are irrelevant */
+
 	case 'b': /* byte -- very short int */
 	case 'B': /* byte as bitfield */
-		{
-			(void) va_arg(*p_va, char *);
-			break;
-		}
-	
 	case 'h': /* short int */
-		{
-			(void) va_arg(*p_va, short *);
-			break;
-		}
-	
 	case 'H': /* short int as bitfield */
-		{
-			(void) va_arg(*p_va, unsigned short *);
-			break;
-		}
-	
 	case 'i': /* int */
-		{
-			(void) va_arg(*p_va, int *);
-			break;
-		}
-	
+	case 'I': /* int sized bitfield */
 	case 'l': /* long int */
-		{
-			(void) va_arg(*p_va, long *);
-			break;
-		}
-	
+	case 'k': /* long int sized bitfield */
 #ifdef HAVE_LONG_LONG
-	case 'L': /* PY_LONG_LONG int */
-		{
-			(void) va_arg(*p_va, PY_LONG_LONG *);
-			break;
-		}
+	case 'L': /* PY_LONG_LONG */
+	case 'K': /* PY_LONG_LONG sized bitfield */
 #endif
-	
 	case 'f': /* float */
-		{
-			(void) va_arg(*p_va, float *);
-			break;
-		}
-	
 	case 'd': /* double */
-		{
-			(void) va_arg(*p_va, double *);
-			break;
-		}
-	
 #ifndef WITHOUT_COMPLEX
 	case 'D': /* complex double */
-		{
-			(void) va_arg(*p_va, Py_complex *);
-			break;
-		}
-#endif /* WITHOUT_COMPLEX */
-	
+#endif
 	case 'c': /* char */
 		{
-			(void) va_arg(*p_va, char *);
+			(void) va_arg(*p_va, void *);
 			break;
 		}
 	
-	case 's': /* string */
+	/* string codes */
+		
+	case 'e': /* string with encoding */
 		{
-			(void) va_arg(*p_va, char **);
-			if (*format == '#') {
-				(void) va_arg(*p_va, int *);
-				format++;
-			}
-			break;
+			(void) va_arg(*p_va, const char *);
+			if (!(*format == 's' || *format == 't'))
+				/* after 'e', only 's' and 't' is allowed */
+				goto err;
+			format++;
+			/* explicit fallthrough to string cases */
 		}
 	
-	case 'z': /* string */
+	case 's': /* string */
+	case 'z': /* string or None */
+#ifdef Py_USING_UNICODE
+	case 'u': /* unicode string */
+#endif
+	case 't': /* buffer, read-only */
+	case 'w': /* buffer, read-write */
 		{
 			(void) va_arg(*p_va, char **);
 			if (*format == '#') {
@@ -1490,8 +1462,13 @@
 			}
 			break;
 		}
-	
+
+	/* object codes */
+
 	case 'S': /* string object */
+#ifdef Py_USING_UNICODE
+	case 'U': /* unicode string object */
+#endif
 		{
 			(void) va_arg(*p_va, PyObject **);
 			break;
@@ -1527,9 +1504,13 @@
 		}
 	
 	default:
+err:
 		return "impossible<bad format char>";
 	
 	}
+
+	/* The "(...)" format code for tuples is not handled here because
+	 * it is not allowed with keyword args. */
 	
 	*p_format = format;
 	return NULL;
@@ -1594,3 +1575,29 @@
 	va_end(vargs);
 	return 1;
 }
+
+
+/* For type constructors that don't take keyword args
+ *
+ * Sets a TypeError and returns 0 if the kwds dict is 
+ * not emtpy, returns 1 otherwise
+ */
+int
+_PyArg_NoKeywords(char *funcname, PyObject *kw)
+{
+	if (kw == NULL)
+		return 1;
+	if (!PyDict_CheckExact(kw)) {
+		PyErr_BadInternalCall();
+		return 0;
+	}
+	if (PyDict_Size(kw) == 0)
+		return 1;
+	
+	PyErr_Format(PyExc_TypeError, "%s does not take keyword arguments", 
+			funcname);
+	return 0;
+}
+
+
+

Index: getcopyright.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/getcopyright.c,v
retrieving revision 1.16.2.2
retrieving revision 1.16.2.3
diff -u -d -r1.16.2.2 -r1.16.2.3
--- getcopyright.c	7 Jan 2005 07:04:39 -0000	1.16.2.2
+++ getcopyright.c	16 Oct 2005 05:24:05 -0000	1.16.2.3
@@ -4,7 +4,7 @@
 
 static char cprt[] = 
 "\
-Copyright (c) 2001-2004 Python Software Foundation.\n\
+Copyright (c) 2001-2005 Python Software Foundation.\n\
 All Rights Reserved.\n\
 \n\
 Copyright (c) 2000 BeOpen.com.\n\

Index: graminit.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/graminit.c,v
retrieving revision 2.33.2.3
retrieving revision 2.33.2.4
diff -u -d -r2.33.2.3 -r2.33.2.4
--- graminit.c	15 Apr 2005 02:18:23 -0000	2.33.2.3
+++ graminit.c	16 Oct 2005 05:24:05 -0000	2.33.2.4
@@ -279,10 +279,12 @@
 	{25, 3},
 	{0, 1},
 };
-static arc arcs_13_2[1] = {
+static arc arcs_13_2[2] = {
+	{43, 4},
 	{9, 4},
 };
-static arc arcs_13_3[1] = {
+static arc arcs_13_3[2] = {
+	{43, 5},
 	{9, 5},
 };
 static arc arcs_13_4[1] = {
@@ -295,13 +297,12 @@
 static state states_13[6] = {
 	{1, arcs_13_0},
 	{3, arcs_13_1},
-	{1, arcs_13_2},
-	{1, arcs_13_3},
+	{2, arcs_13_2},
+	{2, arcs_13_3},
 	{1, arcs_13_4},
 	{2, arcs_13_5},
 };
 static arc arcs_14_0[12] = {
-	{43, 1},
 	{44, 1},
 	{45, 1},
 	{46, 1},
@@ -313,6 +314,7 @@
 	{52, 1},
 	{53, 1},
 	{54, 1},
+	{55, 1},
 };
 static arc arcs_14_1[1] = {
 	{0, 1},
@@ -322,11 +324,11 @@
 	{1, arcs_14_1},
 };
 static arc arcs_15_0[1] = {
-	{55, 1},
+	{56, 1},
 };
 static arc arcs_15_1[3] = {
 	{26, 2},
-	{56, 3},
+	{57, 3},
 	{0, 1},
 };
 static arc arcs_15_2[2] = {
@@ -367,10 +369,10 @@
 	{2, arcs_15_8},
 };
 static arc arcs_16_0[1] = {
-	{57, 1},
+	{58, 1},
 };
 static arc arcs_16_1[1] = {
-	{58, 2},
+	{59, 2},
 };
 static arc arcs_16_2[1] = {
 	{0, 2},
@@ -381,7 +383,7 @@
 	{1, arcs_16_2},
 };
 static arc arcs_17_0[1] = {
-	{59, 1},
+	{60, 1},
 };
 static arc arcs_17_1[1] = {
 	{0, 1},
@@ -391,11 +393,11 @@
 	{1, arcs_17_1},
 };
 static arc arcs_18_0[5] = {
-	{60, 1},
 	{61, 1},
 	{62, 1},
 	{63, 1},
 	{64, 1},
+	{65, 1},
 };
 static arc arcs_18_1[1] = {
 	{0, 1},
@@ -405,7 +407,7 @@
 	{1, arcs_18_1},
 };
 static arc arcs_19_0[1] = {
-	{65, 1},
+	{66, 1},
 };
 static arc arcs_19_1[1] = {
 	{0, 1},
@@ -415,7 +417,7 @@
 	{1, arcs_19_1},
 };
 static arc arcs_20_0[1] = {
-	{66, 1},
+	{67, 1},
 };
 static arc arcs_20_1[1] = {
 	{0, 1},
@@ -425,7 +427,7 @@
 	{1, arcs_20_1},
 };
 static arc arcs_21_0[1] = {
-	{67, 1},
+	{68, 1},
 };
 static arc arcs_21_1[2] = {
 	{9, 2},
@@ -440,18 +442,14 @@
 	{1, arcs_21_2},
 };
 static arc arcs_22_0[1] = {
-	{68, 1},
+	{43, 1},
 };
 static arc arcs_22_1[1] = {
-	{9, 2},
-};
-static arc arcs_22_2[1] = {
-	{0, 2},
+	{0, 1},
 };
-static state states_22[3] = {
+static state states_22[2] = {
 	{1, arcs_22_0},
 	{1, arcs_22_1},
-	{1, arcs_22_2},
 };
 static arc arcs_23_0[1] = {
 	{69, 1},
@@ -779,7 +777,7 @@
 	{93, 1},
 };
 static arc arcs_38_1[1] = {
-	{58, 2},
+	{59, 2},
 };
 static arc arcs_38_2[1] = {
 	{82, 3},
@@ -1034,7 +1032,7 @@
 };
 static arc arcs_50_1[3] = {
 	{123, 0},
-	{56, 0},
+	{57, 0},
 	{0, 1},
 };
 static state states_50[2] = {
@@ -1113,7 +1111,8 @@
 	{144, 5},
 	{145, 6},
 };
-static arc arcs_55_1[2] = {
+static arc arcs_55_1[3] = {
+	{43, 7},
 	{135, 7},
 	{15, 5},
 };
@@ -1149,7 +1148,7 @@
 };
 static state states_55[11] = {
 	{7, arcs_55_0},
-	{2, arcs_55_1},
+	{3, arcs_55_1},
 	{2, arcs_55_2},
 	{2, arcs_55_3},
 	{1, arcs_55_4},
@@ -1533,7 +1532,7 @@
 	{93, 1},
 };
 static arc arcs_71_1[1] = {
-	{58, 2},
+	{59, 2},
 };
 static arc arcs_71_2[1] = {
 	{82, 3},
@@ -1590,7 +1589,7 @@
 	{93, 1},
 };
 static arc arcs_74_1[1] = {
-	{58, 2},
+	{59, 2},
 };
 static arc arcs_74_2[1] = {
 	{82, 3},
@@ -1653,165 +1652,182 @@
 	{1, arcs_77_0},
 	{1, arcs_77_1},
 };
-static dfa dfas[78] = {
+static arc arcs_78_0[1] = {
+	{160, 1},
+};
+static arc arcs_78_1[2] = {
+	{9, 2},
+	{0, 1},
+};
+static arc arcs_78_2[1] = {
+	{0, 2},
+};
+static state states_78[3] = {
+	{1, arcs_78_0},
+	{2, arcs_78_1},
+	{1, arcs_78_2},
+};
+static dfa dfas[79] = {
 	{256, "single_input", 0, 3, states_0,
-	 "\004\050\014\000\000\000\200\012\076\205\011\162\000\002\000\140\010\111\023\002"},
+	 "\004\050\014\000\000\000\000\025\074\205\011\162\000\002\000\140\010\111\023\002\001"},
 	{257, "file_input", 0, 2, states_1,
-	 "\204\050\014\000\000\000\200\012\076\205\011\162\000\002\000\140\010\111\023\002"},
+	 "\204\050\014\000\000\000\000\025\074\205\011\162\000\002\000\140\010\111\023\002\001"},
 	{258, "eval_input", 0, 3, states_2,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{259, "decorator", 0, 7, states_3,
-	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{260, "decorators", 0, 2, states_4,
-	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{261, "funcdef", 0, 7, states_5,
-	 "\000\010\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\010\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{262, "parameters", 0, 4, states_6,
-	 "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{263, "varargslist", 0, 10, states_7,
-	 "\000\040\010\060\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\040\010\060\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{264, "fpdef", 0, 4, states_8,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{265, "fplist", 0, 3, states_9,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{266, "stmt", 0, 2, states_10,
-	 "\000\050\014\000\000\000\200\012\076\205\011\162\000\002\000\140\010\111\023\002"},
+	 "\000\050\014\000\000\000\000\025\074\205\011\162\000\002\000\140\010\111\023\002\001"},
 	{267, "simple_stmt", 0, 4, states_11,
-	 "\000\040\010\000\000\000\200\012\076\205\011\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\025\074\205\011\000\000\002\000\140\010\111\023\000\001"},
 	{268, "small_stmt", 0, 2, states_12,
-	 "\000\040\010\000\000\000\200\012\076\205\011\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\025\074\205\011\000\000\002\000\140\010\111\023\000\001"},
 	{269, "expr_stmt", 0, 6, states_13,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{270, "augassign", 0, 2, states_14,
-	 "\000\000\000\000\000\370\177\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\360\377\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{271, "print_stmt", 0, 9, states_15,
-	 "\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{272, "del_stmt", 0, 3, states_16,
-	 "\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{273, "pass_stmt", 0, 2, states_17,
-	 "\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{274, "flow_stmt", 0, 2, states_18,
-	 "\000\000\000\000\000\000\000\000\076\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\074\000\000\000\000\000\000\000\000\000\000\000\001"},
 	{275, "break_stmt", 0, 2, states_19,
-	 "\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{276, "continue_stmt", 0, 2, states_20,
-	 "\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{277, "return_stmt", 0, 3, states_21,
-	 "\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000\000"},
-	{278, "yield_stmt", 0, 3, states_22,
-	 "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000\000\000\000"},
+	{278, "yield_stmt", 0, 2, states_22,
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
 	{279, "raise_stmt", 0, 7, states_23,
-	 "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{280, "import_stmt", 0, 2, states_24,
-	 "\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\000\000\000\000"},
 	{281, "import_name", 0, 3, states_25,
-	 "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000\000"},
 	{282, "import_from", 0, 7, states_26,
-	 "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000"},
 	{283, "import_as_name", 0, 4, states_27,
-	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{284, "dotted_as_name", 0, 4, states_28,
-	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{285, "import_as_names", 0, 3, states_29,
-	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{286, "dotted_as_names", 0, 2, states_30,
-	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{287, "dotted_name", 0, 2, states_31,
-	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{288, "global_stmt", 0, 3, states_32,
-	 "\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000"},
 	{289, "exec_stmt", 0, 7, states_33,
-	 "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\000\000\000"},
 	{290, "assert_stmt", 0, 5, states_34,
-	 "\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000\000\000"},
 	{291, "compound_stmt", 0, 2, states_35,
-	 "\000\010\004\000\000\000\000\000\000\000\000\162\000\000\000\000\000\000\000\002"},
+	 "\000\010\004\000\000\000\000\000\000\000\000\162\000\000\000\000\000\000\000\002\000"},
 	{292, "if_stmt", 0, 8, states_36,
-	 "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
 	{293, "while_stmt", 0, 8, states_37,
-	 "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\020\000\000\000\000\000\000\000\000\000"},
 	{294, "for_stmt", 0, 10, states_38,
-	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
 	{295, "try_stmt", 0, 10, states_39,
-	 "\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\000\000"},
 	{296, "except_clause", 0, 5, states_40,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
 	{297, "suite", 0, 5, states_41,
-	 "\004\040\010\000\000\000\200\012\076\205\011\000\000\002\000\140\010\111\023\000"},
+	 "\004\040\010\000\000\000\000\025\074\205\011\000\000\002\000\140\010\111\023\000\001"},
 	{298, "test", 0, 4, states_42,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{299, "and_test", 0, 2, states_43,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\003\000\000"},
 	{300, "not_test", 0, 3, states_44,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\003\000\000"},
 	{301, "comparison", 0, 2, states_45,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{302, "comp_op", 0, 4, states_46,
-	 "\000\000\000\000\000\000\000\000\000\000\004\000\000\362\017\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\004\000\000\362\017\000\000\000\000\000\000"},
 	{303, "expr", 0, 2, states_47,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{304, "xor_expr", 0, 2, states_48,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{305, "and_expr", 0, 2, states_49,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{306, "shift_expr", 0, 2, states_50,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{307, "arith_expr", 0, 2, states_51,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{308, "term", 0, 2, states_52,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{309, "factor", 0, 3, states_53,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{310, "power", 0, 4, states_54,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\111\003\000\000"},
 	{311, "atom", 0, 11, states_55,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\111\003\000\000"},
 	{312, "listmaker", 0, 5, states_56,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{313, "testlist_gexp", 0, 5, states_57,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{314, "lambdef", 0, 5, states_58,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\020\000\000"},
 	{315, "trailer", 0, 7, states_59,
-	 "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\001\000\000"},
+	 "\000\040\000\000\000\000\000\000\000\100\000\000\000\000\000\000\000\001\000\000\000"},
 	{316, "subscriptlist", 0, 3, states_60,
-	 "\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
 	{317, "subscript", 0, 7, states_61,
-	 "\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\050\000\000\000\000\000\000\100\000\000\000\002\000\140\010\111\023\000\000"},
 	{318, "sliceop", 0, 3, states_62,
-	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\040\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
 	{319, "exprlist", 0, 3, states_63,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\000\000\140\010\111\003\000\000"},
 	{320, "testlist", 0, 3, states_64,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{321, "testlist_safe", 0, 5, states_65,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{322, "dictmaker", 0, 5, states_66,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{323, "classdef", 0, 8, states_67,
-	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000"},
 	{324, "arglist", 0, 8, states_68,
-	 "\000\040\010\060\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\060\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{325, "argument", 0, 5, states_69,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{326, "list_iter", 0, 2, states_70,
-	 "\000\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"},
 	{327, "list_for", 0, 6, states_71,
-	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
 	{328, "list_if", 0, 4, states_72,
-	 "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
 	{329, "gen_iter", 0, 2, states_73,
-	 "\000\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\042\000\000\000\000\000\000\000\000\000"},
 	{330, "gen_for", 0, 6, states_74,
-	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000\000"},
 	{331, "gen_if", 0, 4, states_75,
-	 "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000"},
+	 "\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000"},
 	{332, "testlist1", 0, 2, states_76,
-	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000"},
+	 "\000\040\010\000\000\000\000\000\000\000\000\000\000\002\000\140\010\111\023\000\000"},
 	{333, "encoding_decl", 0, 2, states_77,
-	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	 "\000\000\010\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"},
+	{334, "yield_expr", 0, 3, states_78,
+	 "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\001"},
 };
-static label labels[160] = {
+static label labels[161] = {
 	{0, "EMPTY"},
 	{256, 0},
 	{4, 0},
@@ -1855,6 +1871,7 @@
 	{289, 0},
 	{290, 0},
 	{270, 0},
+	{334, 0},
 	{37, 0},
 	{38, 0},
 	{39, 0},
@@ -1880,7 +1897,6 @@
 	{1, "break"},
 	{1, "continue"},
 	{1, "return"},
-	{1, "yield"},
 	{1, "raise"},
 	{281, 0},
 	{282, 0},
@@ -1972,10 +1988,11 @@
 	{329, 0},
 	{331, 0},
 	{333, 0},
+	{1, "yield"},
 };
 grammar _PyParser_Grammar = {
-	78,
+	79,
 	dfas,
-	{160, labels},
+	{161, labels},
 	256
 };

Index: import.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/import.c,v
retrieving revision 2.208.2.6
retrieving revision 2.208.2.7
diff -u -d -r2.208.2.6 -r2.208.2.7
--- import.c	14 Oct 2005 07:21:26 -0000	2.208.2.6
+++ import.c	16 Oct 2005 05:24:05 -0000	2.208.2.7
@@ -51,8 +51,9 @@
        Python 2.4a0: 62041
        Python 2.4a3: 62051
        Python 2.4b1: 62061
+       Python 2.5a0: 62071
 */
-#define MAGIC (62061 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (62071 | ((long)'\r'<<16) | ((long)'\n'<<24))
 
 /* Magic word as global; note that _PyImport_Init() can change the
    value of this global to accommodate for alterations of how the
@@ -260,6 +261,18 @@
 	return 1;
 }
 
+/* This function is called from PyOS_AfterFork to ensure that newly
+   created child processes do not share locks with the parent. */
+
+void
+_PyImport_ReInitLock(void)
+{
+#ifdef _AIX
+	if (import_lock != NULL)
+		import_lock = PyThread_allocate_lock();
+#endif
+}
+
 #else
 
 #define lock_import()
@@ -856,8 +869,12 @@
 	PyObject *m;
 
 	mtime = PyOS_GetLastModificationTime(pathname, fp);
-	if (mtime == (time_t)(-1))
+	if (mtime == (time_t)(-1)) {
+		PyErr_Format(PyExc_RuntimeError,
+			     "unable to get modification time from '%s'",
+			     pathname);
 		return NULL;
+	}
 #if SIZEOF_TIME_T > 4
 	/* Python's .pyc timestamp handling presumes that the timestamp fits
 	   in 4 bytes. This will be fine until sometime in the year 2038,
@@ -1378,16 +1395,13 @@
 /* First we may need a pile of platform-specific header files; the sequence
  * of #if's here should match the sequence in the body of case_ok().
  */
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+#if defined(MS_WINDOWS)
 #include <windows.h>
-#ifdef __CYGWIN__
-#include <sys/cygwin.h>
-#endif
 
 #elif defined(DJGPP)
 #include <dir.h>
 
-#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H)
+#elif (defined(__MACH__) && defined(__APPLE__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H)
 #include <sys/types.h>
 #include <dirent.h>
 
@@ -1408,23 +1422,15 @@
  * match the sequence just above.
  */
 
-/* MS_WINDOWS || __CYGWIN__ */
-#if defined(MS_WINDOWS) || defined(__CYGWIN__)
+/* MS_WINDOWS */
+#if defined(MS_WINDOWS)
 	WIN32_FIND_DATA data;
 	HANDLE h;
-#ifdef __CYGWIN__
-	char tempbuf[MAX_PATH];
-#endif
 
 	if (Py_GETENV("PYTHONCASEOK") != NULL)
 		return 1;
 
-#ifdef __CYGWIN__
-	cygwin32_conv_to_win32_path(buf, tempbuf);
-	h = FindFirstFile(tempbuf, &data);
-#else
 	h = FindFirstFile(buf, &data);
-#endif
 	if (h == INVALID_HANDLE_VALUE) {
 		PyErr_Format(PyExc_NameError,
 		  "Can't find file for module %.100s\n(filename %.300s)",
@@ -1451,8 +1457,8 @@
 	}
 	return strncmp(ffblk.ff_name, name, namelen) == 0;
 
-/* new-fangled macintosh (macosx) */
-#elif defined(__MACH__) && defined(__APPLE__) && defined(HAVE_DIRENT_H)
+/* new-fangled macintosh (macosx) or Cygwin */
+#elif (defined(__MACH__) && defined(__APPLE__) || defined(__CYGWIN__)) && defined(HAVE_DIRENT_H)
 	DIR *dirp;
 	struct dirent *dp;
 	char dirname[MAXPATHLEN + 1];
@@ -2299,13 +2305,14 @@
 		if (parentname == NULL)
 			return NULL;
 		parent = PyDict_GetItem(modules, parentname);
-		Py_DECREF(parentname);
 		if (parent == NULL) {
 			PyErr_Format(PyExc_ImportError,
 			    "reload(): parent %.200s not in sys.modules",
-			    name);
+			    PyString_AS_STRING(parentname));
+			Py_DECREF(parentname);
 			return NULL;
 		}
+		Py_DECREF(parentname);
 		subname++;
 		path = PyObject_GetAttrString(parent, "__path__");
 		if (path == NULL)

Index: marshal.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/marshal.c,v
retrieving revision 1.72.2.3
retrieving revision 1.72.2.4
diff -u -d -r1.72.2.3 -r1.72.2.4
--- marshal.c	7 Jan 2005 07:04:56 -0000	1.72.2.3
+++ marshal.c	16 Oct 2005 05:24:05 -0000	1.72.2.4
@@ -16,26 +16,30 @@
  */
 #define MAX_MARSHAL_STACK_DEPTH 5000
 
-#define TYPE_NULL	'0'
-#define TYPE_NONE	'N'
-#define TYPE_FALSE	'F'
-#define TYPE_TRUE	'T'
-#define TYPE_STOPITER	'S'
-#define TYPE_ELLIPSIS   '.'
-#define TYPE_INT	'i'
-#define TYPE_INT64	'I'
-#define TYPE_FLOAT	'f'
-#define TYPE_COMPLEX	'x'
-#define TYPE_LONG	'l'
-#define TYPE_STRING	's'
-#define TYPE_INTERNED	't'
-#define TYPE_STRINGREF	'R'
-#define TYPE_TUPLE	'('
-#define TYPE_LIST	'['
-#define TYPE_DICT	'{'
-#define TYPE_CODE	'c'
-#define TYPE_UNICODE	'u'
-#define TYPE_UNKNOWN	'?'
+#define TYPE_NULL		'0'
+#define TYPE_NONE		'N'
+#define TYPE_FALSE		'F'
+#define TYPE_TRUE		'T'
+#define TYPE_STOPITER		'S'
+#define TYPE_ELLIPSIS   	'.'
+#define TYPE_INT		'i'
+#define TYPE_INT64		'I'
+#define TYPE_FLOAT		'f'
+#define TYPE_BINARY_FLOAT	'g'
+#define TYPE_COMPLEX		'x'
+#define TYPE_BINARY_COMPLEX	'y'
+#define TYPE_LONG		'l'
+#define TYPE_STRING		's'
+#define TYPE_INTERNED		't'
+#define TYPE_STRINGREF		'R'
+#define TYPE_TUPLE		'('
+#define TYPE_LIST		'['
+#define TYPE_DICT		'{'
+#define TYPE_CODE		'c'
+#define TYPE_UNICODE		'u'
+#define TYPE_UNKNOWN		'?'
+#define TYPE_SET		'<'
+#define TYPE_FROZENSET  	'>'
 
 typedef struct {
 	FILE *fp;
@@ -46,6 +50,7 @@
 	char *ptr;
 	char *end;
 	PyObject *strings; /* dict on marshal, list on unmarshal */
+	int version;
 } WFILE;
 
 #define w_byte(c, p) if (((p)->fp)) putc((c), (p)->fp); \
@@ -164,32 +169,62 @@
 			w_short(ob->ob_digit[i], p);
 	}
 	else if (PyFloat_Check(v)) {
-		char buf[256]; /* Plenty to format any double */
-		PyFloat_AsReprString(buf, (PyFloatObject *)v);
-		n = strlen(buf);
-		w_byte(TYPE_FLOAT, p);
-		w_byte(n, p);
-		w_string(buf, n, p);
+		if (p->version > 1) {
+			unsigned char buf[8];
+			if (_PyFloat_Pack8(PyFloat_AsDouble(v), 
+					   buf, 1) < 0) {
+				p->error = 1;
+				return;
+			}
+			w_byte(TYPE_BINARY_FLOAT, p);
+			w_string((char*)buf, 8, p);
+		}
+		else {
+			char buf[256]; /* Plenty to format any double */
+			PyFloat_AsReprString(buf, (PyFloatObject *)v);
+			n = strlen(buf);
+			w_byte(TYPE_FLOAT, p);
+			w_byte(n, p);
+			w_string(buf, n, p);
+		}
 	}
 #ifndef WITHOUT_COMPLEX
 	else if (PyComplex_Check(v)) {
-		char buf[256]; /* Plenty to format any double */
-		PyFloatObject *temp;
-		w_byte(TYPE_COMPLEX, p);
-		temp = (PyFloatObject*)PyFloat_FromDouble(
-			PyComplex_RealAsDouble(v));
-		PyFloat_AsReprString(buf, temp);
-		Py_DECREF(temp);
-		n = strlen(buf);
-		w_byte(n, p);
-		w_string(buf, n, p);
-		temp = (PyFloatObject*)PyFloat_FromDouble(
-			PyComplex_ImagAsDouble(v));
-		PyFloat_AsReprString(buf, temp);
-		Py_DECREF(temp);
-		n = strlen(buf);
-		w_byte(n, p);
-		w_string(buf, n, p);
+		if (p->version > 1) {
+			unsigned char buf[8];
+			if (_PyFloat_Pack8(PyComplex_RealAsDouble(v),
+					   buf, 1) < 0) {
+				p->error = 1;
+				return;
+			}
+			w_byte(TYPE_BINARY_COMPLEX, p);
+			w_string((char*)buf, 8, p);
+			if (_PyFloat_Pack8(PyComplex_ImagAsDouble(v), 
+					   buf, 1) < 0) {
+				p->error = 1;
+				return;
+			}
+			w_string((char*)buf, 8, p);
+		}
+		else {
+			char buf[256]; /* Plenty to format any double */
+			PyFloatObject *temp;
+			w_byte(TYPE_COMPLEX, p);
+			temp = (PyFloatObject*)PyFloat_FromDouble(
+				PyComplex_RealAsDouble(v));
+			PyFloat_AsReprString(buf, temp);
+			Py_DECREF(temp);
+			n = strlen(buf);
+			w_byte(n, p);
+			w_string(buf, n, p);
+			temp = (PyFloatObject*)PyFloat_FromDouble(
+				PyComplex_ImagAsDouble(v));
+			PyFloat_AsReprString(buf, temp);
+			Py_DECREF(temp);
+			n = strlen(buf);
+			w_byte(n, p);
+			w_string(buf, n, p);
+		}
 	}
 #endif
 	else if (PyString_Check(v)) {
@@ -259,6 +294,37 @@
 		}
 		w_object((PyObject *)NULL, p);
 	}
+	else if (PyAnySet_Check(v)) {
+		PyObject *value, *it;
+
+		if (PyObject_TypeCheck(v, &PySet_Type))
+			w_byte(TYPE_SET, p);
+		else
+			w_byte(TYPE_FROZENSET, p);
+		n = PyObject_Size(v);
+		if (n == -1) {
+			p->depth--;
+			p->error = 1;
+			return;
+		}
+		w_long((long)n, p);
+		it = PyObject_GetIter(v);
+		if (it == NULL) {
+			p->depth--;
+			p->error = 1;
+			return;
+		}
+		while ((value = PyIter_Next(it)) != NULL) {
+			w_object(value, p);
+			Py_DECREF(value);
+		}
+		Py_DECREF(it);
+		if (PyErr_Occurred()) {
+			p->depth--;
+			p->error = 1;
+			return;
+		}
+	}
 	else if (PyCode_Check(v)) {
 		PyCodeObject *co = (PyCodeObject *)v;
 		w_byte(TYPE_CODE, p);
@@ -303,6 +369,7 @@
 	wf.error = 0;
 	wf.depth = 0;
 	wf.strings = NULL;
+	wf.version = version;
 	w_long(x, &wf);
 }
 
@@ -314,6 +381,7 @@
 	wf.error = 0;
 	wf.depth = 0;
 	wf.strings = (version > 0) ? PyDict_New() : NULL;
+	wf.version = version;
 	w_object(x, &wf);
 	Py_XDECREF(wf.strings);
 }
@@ -407,7 +475,7 @@
 {
 	/* NULL is a valid return value, it does not necessarily means that
 	   an exception is set. */
-	PyObject *v, *v2;
+	PyObject *v, *v2, *v3;
 	long i, n;
 	int type = r_byte(p);
 
@@ -487,6 +555,22 @@
 			return PyFloat_FromDouble(dx);
 		}
 
+	case TYPE_BINARY_FLOAT:
+		{
+			unsigned char buf[8];
+			double x;
+			if (r_string((char*)buf, 8, p) != 8) {
+				PyErr_SetString(PyExc_EOFError,
+					"EOF read where object expected");
+				return NULL;
+			}
+			x = _PyFloat_Unpack8(buf, 1);
+			if (x == -1.0 && PyErr_Occurred()) {
+				return NULL;
+			}
+			return PyFloat_FromDouble(x);
+		}
+
 #ifndef WITHOUT_COMPLEX
 	case TYPE_COMPLEX:
 		{
@@ -514,6 +598,31 @@
 			PyFPE_END_PROTECT(c)
 			return PyComplex_FromCComplex(c);
 		}
+
+	case TYPE_BINARY_COMPLEX:
+		{
+			unsigned char buf[8];
+			Py_complex c;
+			if (r_string((char*)buf, 8, p) != 8) {
+				PyErr_SetString(PyExc_EOFError,
+					"EOF read where object expected");
+				return NULL;
+			}
+			c.real = _PyFloat_Unpack8(buf, 1);
+			if (c.real == -1.0 && PyErr_Occurred()) {
+				return NULL;
+			}
+			if (r_string((char*)buf, 8, p) != 8) {
+				PyErr_SetString(PyExc_EOFError,
+					"EOF read where object expected");
+				return NULL;
+			}
+			c.imag = _PyFloat_Unpack8(buf, 1);
+			if (c.imag == -1.0 && PyErr_Occurred()) {
+				return NULL;
+			}
+			return PyComplex_FromCComplex(c);
+		}
 #endif
 
 	case TYPE_INTERNED:
@@ -524,13 +633,13 @@
 			return NULL;
 		}
 		v = PyString_FromStringAndSize((char *)NULL, n);
-		if (v != NULL) {
-			if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
-				Py_DECREF(v);
-				v = NULL;
-				PyErr_SetString(PyExc_EOFError,
+		if (v == NULL)
+			return v;
+		if (r_string(PyString_AS_STRING(v), (int)n, p) != n) {
+			Py_DECREF(v);
+			PyErr_SetString(PyExc_EOFError,
 					"EOF read where object expected");
-			}
+			return NULL;
 		}
 		if (type == TYPE_INTERNED) {
 			PyString_InternInPlace(&v);
@@ -540,6 +649,10 @@
 
 	case TYPE_STRINGREF:
 		n = r_long(p);
+		if (n < 0 || n >= PyList_GET_SIZE(p->strings)) {
+			PyErr_SetString(PyExc_ValueError, "bad marshal data");
+			return NULL;
+		}
 		v = PyList_GET_ITEM(p->strings, n);
 		Py_INCREF(v);
 		return v;
@@ -636,6 +749,37 @@
 		}
 		return v;
 
+	case TYPE_SET:
+	case TYPE_FROZENSET:
+		n = r_long(p);
+		if (n < 0) {
+			PyErr_SetString(PyExc_ValueError, "bad marshal data");
+			return NULL;
+		}
+		v = PyTuple_New((int)n);
+		if (v == NULL)
+			return v;
+		for (i = 0; i < n; i++) {
+			v2 = r_object(p);
+			if ( v2 == NULL ) {
+				if (!PyErr_Occurred())
+					PyErr_SetString(PyExc_TypeError,
+						"NULL object in marshal data");
+				Py_DECREF(v);
+				v = NULL;
+				break;
+			}
+			PyTuple_SET_ITEM(v, (int)i, v2);
+		}
+		if (v == NULL)
+			return v;
+		if (type == TYPE_SET)
+			v3 = PySet_New(v);
+		else
+			v3 = PyFrozenSet_New(v);
+		Py_DECREF(v);
+		return v3;
+
 	case TYPE_CODE:
 		if (PyEval_GetRestricted()) {
 			PyErr_SetString(PyExc_RuntimeError,
@@ -644,30 +788,63 @@
 			return NULL;
 		}
 		else {
-			int argcount = r_long(p);
-			int nlocals = r_long(p);
-			int stacksize = r_long(p);
-			int flags = r_long(p);
-			PyObject *code = r_object(p);
-			PyObject *consts = r_object(p);
-			PyObject *names = r_object(p);
-			PyObject *varnames = r_object(p);
-			PyObject *freevars = r_object(p);
-			PyObject *cellvars = r_object(p);
-			PyObject *filename = r_object(p);
-			PyObject *name = r_object(p);
-			int firstlineno = r_long(p);
-			PyObject *lnotab = r_object(p);
+			int argcount;
+			int nlocals;
+			int stacksize;
+			int flags;
+			PyObject *code = NULL;
+			PyObject *consts = NULL;
+			PyObject *names = NULL;
+			PyObject *varnames = NULL;
+			PyObject *freevars = NULL;
+			PyObject *cellvars = NULL;
+			PyObject *filename = NULL;
+			PyObject *name = NULL;
+			int firstlineno;
+			PyObject *lnotab = NULL;
+			
+			v = NULL;
 
-			if (!PyErr_Occurred()) {
-				v = (PyObject *) PyCode_New(
+			argcount = r_long(p);
+			nlocals = r_long(p);
+			stacksize = r_long(p);
+			flags = r_long(p);
+			code = r_object(p);
+			if (code == NULL)
+				goto code_error;
+			consts = r_object(p);
+			if (consts == NULL)
+				goto code_error;
+			names = r_object(p);
+			if (names == NULL)
+				goto code_error;
+			varnames = r_object(p);
+			if (varnames == NULL)
+				goto code_error;
+			freevars = r_object(p);
+			if (freevars == NULL)
+				goto code_error;
+			cellvars = r_object(p);
+			if (cellvars == NULL)
+				goto code_error;
+			filename = r_object(p);
+			if (filename == NULL)
+				goto code_error;
+			name = r_object(p);
+			if (name == NULL)
+				goto code_error;
+			firstlineno = r_long(p);
+			lnotab = r_object(p);
+			if (lnotab == NULL)
+				goto code_error;
+
+			v = (PyObject *) PyCode_New(
 					argcount, nlocals, stacksize, flags,
 					code, consts, names, varnames,
 					freevars, cellvars, filename, name,
 					firstlineno, lnotab);
-			}
-			else
-				v = NULL;
+
+		  code_error:
 			Py_XDECREF(code);
 			Py_XDECREF(consts);
 			Py_XDECREF(names);
@@ -819,6 +996,7 @@
 	wf.end = wf.ptr + PyString_Size(wf.str);
 	wf.error = 0;
 	wf.depth = 0;
+	wf.version = version;
 	wf.strings = (version > 0) ? PyDict_New() : NULL;
 	w_object(x, &wf);
 	Py_XDECREF(wf.strings);
@@ -906,7 +1084,7 @@
 	char *s;
 	int n;
 	PyObject* result;
-	if (!PyArg_ParseTuple(args, "s#|i:loads", &s, &n))
+	if (!PyArg_ParseTuple(args, "s#:loads", &s, &n))
 		return NULL;
 	rf.fp = NULL;
 	rf.ptr = s;

Index: pystate.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pystate.c,v
retrieving revision 2.20.18.2
retrieving revision 2.20.18.3
diff -u -d -r2.20.18.2 -r2.20.18.3
--- pystate.c	7 Jan 2005 07:04:57 -0000	2.20.18.2
+++ pystate.c	16 Oct 2005 05:24:05 -0000	2.20.18.3
@@ -36,6 +36,12 @@
 #define HEAD_INIT() (void)(head_mutex || (head_mutex = PyThread_allocate_lock()))
 #define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK)
 #define HEAD_UNLOCK() PyThread_release_lock(head_mutex)
+
+/* The single PyInterpreterState used by this process'
+   GILState implementation
+*/
+static PyInterpreterState *autoInterpreterState = NULL;
+static int autoTLSkey = 0;
 #else
 #define HEAD_INIT() /* Nothing */
 #define HEAD_LOCK() /* Nothing */
@@ -47,6 +53,10 @@
 PyThreadState *_PyThreadState_Current = NULL;
 PyThreadFrameGetter _PyThreadState_GetFrame = NULL;
 
+#ifdef WITH_THREAD
+static void _PyGILState_NoteThreadState(PyThreadState* tstate);
+#endif
+
 
 PyInterpreterState *
 PyInterpreterState_New(void)
@@ -180,6 +190,10 @@
 		tstate->c_profileobj = NULL;
 		tstate->c_traceobj = NULL;
 
+#ifdef WITH_THREAD
+		_PyGILState_NoteThreadState(tstate);
+#endif
+
 		HEAD_LOCK();
 		tstate->next = interp->tstate_head;
 		interp->tstate_head = tstate;
@@ -261,6 +275,8 @@
 			"PyThreadState_DeleteCurrent: no current tstate");
 	_PyThreadState_Current = NULL;
 	tstate_delete_common(tstate);
+	if (autoTLSkey && PyThread_get_key_value(autoTLSkey) == tstate)
+		PyThread_delete_key_value(autoTLSkey);
 	PyEval_ReleaseLock();
 }
 #endif /* WITH_THREAD */
@@ -289,7 +305,7 @@
 #if defined(Py_DEBUG) && defined(WITH_THREAD)
 	if (new) {
 		PyThreadState *check = PyGILState_GetThisThreadState();
-		if (check && check != new)
+		if (check && check->interp == new->interp && check != new)
 			Py_FatalError("Invalid thread state for this thread");
 	}
 #endif
@@ -320,7 +336,7 @@
 
 /* Asynchronously raise an exception in a thread.
    Requested by Just van Rossum and Alex Martelli.
-   To prevent naive misuse, you must write your own exception
+   To prevent naive misuse, you must write your own extension
    to call this.  Must be called with the GIL held.
    Returns the number of tstates modified; if it returns a number
    greater than one, you're in trouble, and you should call it again
@@ -332,6 +348,7 @@
 	PyInterpreterState *interp = tstate->interp;
 	PyThreadState *p;
 	int count = 0;
+	HEAD_LOCK();
 	for (p = interp->tstate_head; p != NULL; p = p->next) {
 		if (p->thread_id != id)
 			continue;
@@ -340,6 +357,7 @@
 		p->async_exc = exc;
 		count += 1;
 	}
+	HEAD_UNLOCK();
 	return count;
 }
 
@@ -391,12 +409,6 @@
 	return tstate == _PyThreadState_Current;
 }
 
-/* The single PyInterpreterState used by this process'
-   GILState implementation
-*/
-static PyInterpreterState *autoInterpreterState = NULL;
-static int autoTLSkey = 0;
-
 /* Internal initialization/finalization functions called by
    Py_Initialize/Py_Finalize
 */
@@ -406,12 +418,10 @@
 	assert(i && t); /* must init with valid states */
 	autoTLSkey = PyThread_create_key();
 	autoInterpreterState = i;
-	/* Now stash the thread state for this thread in TLS */
 	assert(PyThread_get_key_value(autoTLSkey) == NULL);
-	if (PyThread_set_key_value(autoTLSkey, (void *)t) < 0)
-		Py_FatalError("Couldn't create autoTLSkey mapping");
-	assert(t->gilstate_counter == 0); /* must be a new thread state */
-	t->gilstate_counter = 1;
+	assert(t->gilstate_counter == 0);
+
+	_PyGILState_NoteThreadState(t);
 }
 
 void
@@ -422,6 +432,41 @@
 	autoInterpreterState = NULL;;
 }
 
+/* When a thread state is created for a thread by some mechanism other than
+   PyGILState_Ensure, it's important that the GILState machinery knows about
+   it so it doesn't try to create another thread state for the thread (this is
+   a better fix for SF bug #1010677 than the first one attempted).
+*/
+void
+_PyGILState_NoteThreadState(PyThreadState* tstate)
+{
+	/* If autoTLSkey is 0, this must be the very first threadstate created
+	   in Py_Initialize().  Don't do anything for now (we'll be back here
+	   when _PyGILState_Init is called). */
+	if (!autoTLSkey) 
+		return;
+	
+	/* Stick the thread state for this thread in thread local storage.
+
+	   The only situation where you can legitimately have more than one
+	   thread state for an OS level thread is when there are multiple
+	   interpreters, when:
+	       
+	       a) You shouldn't really be using the PyGILState_ APIs anyway,
+	          and:
+
+	       b) The slightly odd way PyThread_set_key_value works (see
+	          comments by its implementation) means that the first thread
+	          state created for that given OS level thread will "win",
+	          which seems reasonable behaviour.
+	*/
+	if (PyThread_set_key_value(autoTLSkey, (void *)tstate) < 0)
+		Py_FatalError("Couldn't create autoTLSkey mapping");
+
+	/* PyGILState_Release must not try to delete this thread state. */
+	tstate->gilstate_counter = 1;
+}
+
 /* The public functions */
 PyThreadState *
 PyGILState_GetThisThreadState(void)
@@ -448,8 +493,9 @@
 		tcur = PyThreadState_New(autoInterpreterState);
 		if (tcur == NULL)
 			Py_FatalError("Couldn't create thread-state for new thread");
-		if (PyThread_set_key_value(autoTLSkey, (void *)tcur) < 0)
-			Py_FatalError("Couldn't create autoTLSkey mapping");
+		/* This is our thread state!  We'll need to delete it in the
+		   matching call to PyGILState_Release(). */
+		tcur->gilstate_counter = 0;
 		current = 0; /* new thread state is never current */
 	}
 	else
@@ -496,11 +542,9 @@
 		 * habit of coming back).
 		 */
 		PyThreadState_DeleteCurrent();
-		/* Delete this thread from our TLS. */
-		PyThread_delete_key_value(autoTLSkey);
 	}
 	/* Release the lock if necessary */
 	else if (oldstate == PyGILState_UNLOCKED)
-		PyEval_ReleaseThread(tcur);
+		PyEval_SaveThread();
 }
 #endif /* WITH_THREAD */

Index: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.161.2.18
retrieving revision 2.161.2.19
diff -u -d -r2.161.2.18 -r2.161.2.19
--- pythonrun.c	14 Oct 2005 07:21:27 -0000	2.161.2.18
+++ pythonrun.c	16 Oct 2005 05:24:05 -0000	2.161.2.19
@@ -175,6 +175,8 @@
 	if (!_PyInt_Init())
 		Py_FatalError("Py_Initialize: can't init ints");
 
+	_PyFloat_Init();
+
 	interp->modules = PyDict_New();
 	if (interp->modules == NULL)
 		Py_FatalError("Py_Initialize: can't make modules dictionary");
@@ -395,13 +397,6 @@
 		_Py_PrintReferences(stderr);
 #endif /* Py_TRACE_REFS */
 
-	/* Now we decref the exception classes.  After this point nothing
-	   can raise an exception.  That's okay, because each Fini() method
-	   below has been checked to make sure no exceptions are ever
-	   raised.
-	*/
-	_PyExc_Fini();
-
 	/* Cleanup auto-thread-state */
 #ifdef WITH_THREAD
 	_PyGILState_Fini();
@@ -410,6 +405,14 @@
 	/* Clear interpreter state */
 	PyInterpreterState_Clear(interp);
 
+	/* Now we decref the exception classes.  After this point nothing
+	   can raise an exception.  That's okay, because each Fini() method
+	   below has been checked to make sure no exceptions are ever
+	   raised.
+	*/
+
+	_PyExc_Fini();
+
 	/* Delete current thread */
 	PyThreadState_Swap(NULL);
 	PyInterpreterState_Delete(interp);
@@ -420,6 +423,7 @@
 	PyCFunction_Fini();
 	PyTuple_Fini();
 	PyList_Fini();
+	PySet_Fini();
 	PyString_Fini();
 	PyInt_Fini();
 	PyFloat_Fini();
@@ -1417,20 +1421,25 @@
 		errtype = PyExc_IndentationError;
 		msg = "too many levels of indentation";
 		break;
-	case E_DECODE: {	/* XXX */
-		PyThreadState* tstate = PyThreadState_GET();
-		PyObject* value = tstate->curexc_value;
+	case E_DECODE: {
+		PyObject *type, *value, *tb;
+		PyErr_Fetch(&type, &value, &tb);
 		if (value != NULL) {
-			u = PyObject_Repr(value);
+			u = PyObject_Str(value);
 			if (u != NULL) {
 				msg = PyString_AsString(u);
-				break;
 			}
 		}
 		if (msg == NULL)
 			msg = "unknown decode error";
+		Py_DECREF(type);
+		Py_DECREF(value);
+		Py_XDECREF(tb);
 		break;
 	}
+	case E_LINECONT:
+		msg = "unexpected character after line continuation character";
+		break;
 	default:
 		fprintf(stderr, "error=%d\n", err->error);
 		msg = "unknown parsing error";

Index: structmember.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/structmember.c,v
retrieving revision 2.23.8.1
retrieving revision 2.23.8.2
diff -u -d -r2.23.8.1 -r2.23.8.2
--- structmember.c	7 Jan 2005 07:04:58 -0000	2.23.8.1
+++ structmember.c	16 Oct 2005 05:24:06 -0000	2.23.8.2
@@ -118,6 +118,14 @@
 			PyErr_SetString(PyExc_AttributeError, l->name);
 		Py_XINCREF(v);
 		break;
+#ifdef HAVE_LONG_LONG
+	case T_LONGLONG:
+		v = PyLong_FromLongLong(*(PY_LONG_LONG *)addr);
+		break;
+	case T_ULONGLONG:
+		v = PyLong_FromUnsignedLongLong(*(unsigned PY_LONG_LONG *)addr);
+		break;
+#endif /* HAVE_LONG_LONG */
 	default:
 		PyErr_SetString(PyExc_SystemError, "bad memberdescr type");
 		v = NULL;
@@ -246,6 +254,30 @@
 			return -1;
 		}
 		break;
+#ifdef HAVE_LONG_LONG
+	case T_LONGLONG:
+		if (!PyLong_Check(v)) {
+			PyErr_BadArgument();
+			return -1;
+		} else {
+                        *(PY_LONG_LONG*)addr = PyLong_AsLongLong(v);
+                        if ((*addr == -1) && PyErr_Occurred()) {
+                                return -1;
+                        }
+                }
+                break;
+	case T_ULONGLONG:
+                if (!PyLong_Check(v)) {
+                        PyErr_BadArgument();
+                        return -1;
+                } else {
+                        *(unsigned PY_LONG_LONG*)addr = PyLong_AsUnsignedLongLong(v);
+                        if ((*addr == -1) && PyErr_Occurred()) {
+                                return -1;
+                        }
+                }
+                break;
+#endif /* HAVE_LONG_LONG */
 	default:
 		PyErr_Format(PyExc_SystemError,
 			     "bad memberdescr type for %s", l->name);

Index: sysmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/sysmodule.c,v
retrieving revision 2.107.2.3
retrieving revision 2.107.2.4
diff -u -d -r2.107.2.3 -r2.107.2.4
--- sysmodule.c	7 Jan 2005 07:04:59 -0000	2.107.2.3
+++ sysmodule.c	16 Oct 2005 05:24:06 -0000	2.107.2.4
@@ -927,6 +927,13 @@
 )
 /* end of sys_doc */ ;
 
+static int
+_check_and_flush (FILE *stream)
+{
+  int prev_fail = ferror (stream);
+  return fflush (stream) || prev_fail ? EOF : 0;
+}
+
 PyObject *
 _PySys_Init(void)
 {
@@ -940,9 +947,27 @@
 	m = Py_InitModule3("sys", sys_methods, sys_doc);
 	sysdict = PyModule_GetDict(m);
 
+	{
+		/* XXX: does this work on Win/Win64? (see posix_fstat) */
+		struct stat sb;
+		if (fstat(fileno(stdin), &sb) == 0 &&
+		    S_ISDIR(sb.st_mode)) {
+			Py_FatalError("<stdin> is a directory");
+		}
+	}
+
+	/* Closing the standard FILE* if sys.std* goes aways causes problems
+	 * for embedded Python usages. Closing them when somebody explicitly
+	 * invokes .close() might be possible, but the FAQ promises they get
+	 * never closed. However, we still need to get write errors when
+	 * writing fails (e.g. because stdout is redirected), so we flush the
+	 * streams and check for errors before the file objects are deleted.
+	 * On OS X, fflush()ing stdin causes an error, so we exempt stdin
+	 * from that procedure.
+	 */
 	sysin = PyFile_FromFile(stdin, "<stdin>", "r", NULL);
-	sysout = PyFile_FromFile(stdout, "<stdout>", "w", NULL);
-	syserr = PyFile_FromFile(stderr, "<stderr>", "w", NULL);
+	sysout = PyFile_FromFile(stdout, "<stdout>", "w", _check_and_flush);
+	syserr = PyFile_FromFile(stderr, "<stderr>", "w", _check_and_flush);
 	if (PyErr_Occurred())
 		return NULL;
 #ifdef MS_WINDOWS
@@ -1172,7 +1197,7 @@
 		char link[MAXPATHLEN+1];
 		char argv0copy[2*MAXPATHLEN+1];
 		int nr = 0;
-		if (argc > 0 && argv0 != NULL)
+		if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0)
 			nr = readlink(argv0, link, MAXPATHLEN);
 		if (nr > 0) {
 			/* It's a symlink */
@@ -1197,7 +1222,7 @@
 		}
 #endif /* HAVE_READLINK */
 #if SEP == '\\' /* Special case for MS filename syntax */
-		if (argc > 0 && argv0 != NULL) {
+		if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0) {
 			char *q;
 #ifdef MS_WINDOWS
 			char *ptemp;
@@ -1220,7 +1245,7 @@
 			}
 		}
 #else /* All other filename syntaxes */
-		if (argc > 0 && argv0 != NULL) {
+		if (argc > 0 && argv0 != NULL && strcmp(argv0, "-c") != 0) {
 #if defined(HAVE_REALPATH)
 			if (realpath(argv0, fullpath)) {
 				argv0 = fullpath;

Index: thread.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread.c,v
retrieving revision 2.44.2.2
retrieving revision 2.44.2.3
diff -u -d -r2.44.2.2 -r2.44.2.3
--- thread.c	7 Jan 2005 07:04:59 -0000	2.44.2.2
+++ thread.c	16 Oct 2005 05:24:06 -0000	2.44.2.3
@@ -45,6 +45,20 @@
 #define SUN_LWP
 #endif
 
+/* Check if we're running on HP-UX and _SC_THREADS is defined. If so, then
+   enough of the Posix threads package is implimented to support python 
+   threads.
+
+   This is valid for HP-UX 11.23 running on an ia64 system. If needed, add
+   a check of __ia64 to verify that we're running on a ia64 system instead
+   of a pa-risc system.
+*/
+#ifdef __hpux
+#ifdef _SC_THREADS
+#define _POSIX_THREADS
+#endif
+#endif
+
 #endif /* _POSIX_THREADS */
 
 

Index: thread_nt.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_nt.h,v
retrieving revision 2.22.2.1
retrieving revision 2.22.2.2
diff -u -d -r2.22.2.1 -r2.22.2.2
--- thread_nt.h	7 Jan 2005 07:05:00 -0000	2.22.2.1
+++ thread_nt.h	16 Oct 2005 05:24:06 -0000	2.22.2.2
@@ -299,7 +299,7 @@
 
 	dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag));
 
-	success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag == 1 ? INFINITE : 0)) == WAIT_OBJECT_0 ;
+	success = aLock && EnterNonRecursiveMutex((PNRMUTEX) aLock, (waitflag ? INFINITE : 0)) == WAIT_OBJECT_0 ;
 
 	dprintf(("%ld: PyThread_acquire_lock(%p, %d) -> %d\n", PyThread_get_thread_ident(),aLock, waitflag, success));
 

Index: thread_os2.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_os2.h,v
retrieving revision 2.14.2.1
retrieving revision 2.14.2.2
diff -u -d -r2.14.2.1 -r2.14.2.2
--- thread_os2.h	28 Apr 2003 17:16:44 -0000	2.14.2.1
+++ thread_os2.h	16 Oct 2005 05:24:06 -0000	2.14.2.2
@@ -14,6 +14,10 @@
 long PyThread_get_thread_ident(void);
 #endif
 
+#if !defined(THREAD_STACK_SIZE)
+#define	THREAD_STACK_SIZE	0x10000
+#endif
+
 /*
  * Initialization of the C package, should not be needed.
  */
@@ -31,7 +35,7 @@
 	int aThread;
 	int success = 0;
 
-	aThread = _beginthread(func,NULL,65536,arg);
+	aThread = _beginthread(func, NULL, THREAD_STACK_SIZE, arg);
 
 	if (aThread == -1) {
 		success = -1;

Index: thread_pthread.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_pthread.h,v
retrieving revision 2.40.2.2
retrieving revision 2.40.2.3
diff -u -d -r2.40.2.2 -r2.40.2.3
--- thread_pthread.h	7 Jan 2005 07:05:00 -0000	2.40.2.2
+++ thread_pthread.h	16 Oct 2005 05:24:06 -0000	2.40.2.3
@@ -16,9 +16,15 @@
    family of functions must indicate this by defining
    _POSIX_SEMAPHORES. */   
 #ifdef _POSIX_SEMAPHORES
+/* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so 
+   we need to add 0 to make it work there as well. */
+#if (_POSIX_SEMAPHORES+0) == -1
+#define HAVE_BROKEN_POSIX_SEMAPHORES
+#else
 #include <semaphore.h>
 #include <errno.h>
 #endif
+#endif
 
 #if !defined(pthread_attr_default)
 #  define pthread_attr_default ((pthread_attr_t *)NULL)
@@ -349,8 +355,8 @@
 		PyThread_init_thread();
 
 	lock = (pthread_lock *) malloc(sizeof(pthread_lock));
-	memset((void *)lock, '\0', sizeof(pthread_lock));
 	if (lock) {
+		memset((void *)lock, '\0', sizeof(pthread_lock));
 		lock->locked = 0;
 
 		status = pthread_mutex_init(&lock->mut,

Index: thread_wince.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/thread_wince.h,v
retrieving revision 2.7
retrieving revision 2.7.12.1
diff -u -d -r2.7 -r2.7.12.1
--- thread_wince.h	16 Oct 2001 21:13:49 -0000	2.7
+++ thread_wince.h	16 Oct 2005 05:24:06 -0000	2.7.12.1
@@ -140,13 +140,13 @@
     dprintf(("%ld: PyThread_acquire_lock(%p, %d) called\n", PyThread_get_thread_ident(),aLock, waitflag));
 
 #ifndef DEBUG
-    waitResult = WaitForSingleObject(aLock, (waitflag == 1 ? INFINITE : 0));
+    waitResult = WaitForSingleObject(aLock, (waitflag ? INFINITE : 0));
 #else
 	/* To aid in debugging, we regularly wake up.  This allows us to
 	break into the debugger */
 	while (TRUE) {
 		waitResult = WaitForSingleObject(aLock, waitflag ? 3000 : 0);
-		if (waitflag==0 || (waitflag==1 && waitResult == WAIT_OBJECT_0))
+		if (waitflag==0 || (waitflag && waitResult == WAIT_OBJECT_0))
 			break;
 	}
 #endif



More information about the Python-checkins mailing list