From python-checkins at python.org Fri Sep 1 00:32:44 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 1 Sep 2006 00:32:44 +0200 (CEST) Subject: [Python-checkins] r51672 - in python/branches/bcannon-objcap: Include/fileobject.h Lib/test/test_descr.py Lib/test/test_objcap.py Modules/bz2module.c Modules/objcapmodule.c Objects/fileobject.c Python/bltinmodule.c securing_python.txt Message-ID: <20060831223244.189071E4009@bag.python.org> Author: brett.cannon Date: Fri Sep 1 00:32:42 2006 New Revision: 51672 Modified: python/branches/bcannon-objcap/Include/fileobject.h python/branches/bcannon-objcap/Lib/test/test_descr.py python/branches/bcannon-objcap/Lib/test/test_objcap.py python/branches/bcannon-objcap/Modules/bz2module.c python/branches/bcannon-objcap/Modules/objcapmodule.c python/branches/bcannon-objcap/Objects/fileobject.c python/branches/bcannon-objcap/Python/bltinmodule.c python/branches/bcannon-objcap/securing_python.txt Log: Re-implement the removal of the 'file' type's initializer. file_init() was renamed _PyFile_Init() and made non-static. At the C level, a simulation of calling open() is now done with calling PyFile_Type.tp_new() and passing the result to _PyFile_Init() with the tuple and dict arguments. Exposed _PyFile_Init() as the file_init() function in the objcap module. Takes in an instance of the 'file' type and the typical arguments to open() and initializes the instance as needed to refer to a file. This allows subclasses of 'file' to work with some changes. __new__() will now need to be overridden to make sure to not call file.__new__() with any arguments. Then, in __init__(), just pass 'self' to file_init() with the needed arguments to get the open file bound to the instance (see Lib/test/test_descr.py for an example). Doing this allows (eventual) import blocking of objcap and thus make open() the only way to open new files if desired but still provide subclassing 'file' to be functional if so desired. Modified: python/branches/bcannon-objcap/Include/fileobject.h ============================================================================== --- python/branches/bcannon-objcap/Include/fileobject.h (original) +++ python/branches/bcannon-objcap/Include/fileobject.h Fri Sep 1 00:32:42 2006 @@ -44,6 +44,7 @@ PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); +PyAPI_FUNC(int) _PyFile_Init(PyObject *, PyObject *, PyObject *); /* The default encoding used by the platform file system APIs If non-NULL, this is different than the default encoding for strings Modified: python/branches/bcannon-objcap/Lib/test/test_descr.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_descr.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_descr.py Fri Sep 1 00:32:42 2006 @@ -3,6 +3,7 @@ from test.test_support import verify, vereq, verbose, TestFailed, TESTFN, get_original_stdout from copy import deepcopy import warnings +import objcap warnings.filterwarnings("ignore", r'complex divmod\(\), // and % are deprecated$', @@ -2452,6 +2453,13 @@ lineno = 0 ateof = 0 + + def __new__(self, *args, **kwargs): + return file.__new__(self) + + def __init__(self, *args, **kwargs): + objcap.file_init(self, *args, **kwargs) + def readline(self): if self.ateof: return "" Modified: python/branches/bcannon-objcap/Lib/test/test_objcap.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_objcap.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_objcap.py Fri Sep 1 00:32:42 2006 @@ -23,9 +23,47 @@ self.failUnless(objcap.subclasses(object)) +class FileInitTests(unittest.TestCase): + + """Test removal of file type initializer and addition of file_init().""" + + def test_removal(self): + # Calling constructor with any arguments should fail. + self.failUnlessRaises(TypeError, file, test_support.TESTFN, 'w') + + def test_file_subclassing(self): + # Should still be possible to subclass 'file'. + + class FileSubclass(file): + pass + + self.failUnless(FileSubclass()) + + def test_file_init(self): + # Should be able to use file_init() to initialize instances of 'file'. + ins = file() + try: + objcap.file_init(ins, test_support.TESTFN, 'w') + finally: + ins.close() + + ins = file() + try: + objcap.file_init(ins, test_support.TESTFN) + finally: + ins.close() + + ins = file() + try: + objcap.file_init(ins, test_support.TESTFN, 'r', 0) + finally: + ins.close() + + def test_main(): test_support.run_unittest( - ObjectSubclasses + ObjectSubclasses, + FileInitTests, ) Modified: python/branches/bcannon-objcap/Modules/bz2module.c ============================================================================== --- python/branches/bcannon-objcap/Modules/bz2module.c (original) +++ python/branches/bcannon-objcap/Modules/bz2module.c Fri Sep 1 00:32:42 2006 @@ -1298,6 +1298,7 @@ int compresslevel = 9; int bzerror; int mode_char = 0; + PyObject *file_ins_args = NULL; self->size = -1; @@ -1353,10 +1354,22 @@ mode = (mode_char == 'r') ? "rb" : "wb"; - self->file = PyObject_CallFunction((PyObject*)&PyFile_Type, "(Osi)", - name, mode, buffering); - if (self->file == NULL) + file_ins_args = Py_BuildValue("Osi", name, mode, buffering); + if (!file_ins_args) + return -1; + + self->file = PyFile_Type.tp_new(&PyFile_Type, NULL, NULL); + if (self->file == NULL) { + Py_DECREF(file_ins_args); return -1; + } + + + if (_PyFile_Init(self->file, file_ins_args, NULL) < 0) { + Py_DECREF(file_ins_args); + return -1; + } + Py_DECREF(file_ins_args); /* From now on, we have stuff to dealloc, so jump to error label * instead of returning */ Modified: python/branches/bcannon-objcap/Modules/objcapmodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/objcapmodule.c (original) +++ python/branches/bcannon-objcap/Modules/objcapmodule.c Fri Sep 1 00:32:42 2006 @@ -53,9 +53,90 @@ "subclasses(object) -> return a list of subclasses.\n\ Originally object.__subclasses__()."); +/* + Initialize a file object. + + Need to strip out file instance and then pass remaining arguments to + _PyFile_Init(). +*/ +static PyObject * +file_init(PyObject *self, PyObject *args, PyObject *kwds) +{ + PyObject *file_ins = NULL; + static char *kwlist[] = {"file_instance", "name", "mode", "buffering", 0}; + PyObject *name = NULL; + PyObject *mode = NULL; + PyObject *buffering = NULL; + PyObject *init_args = NULL; + Py_ssize_t arg_count = 1; + Py_ssize_t arg_pos = 0; + int ret; + + /* Unpack all arguments. */ + if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|OO:file_init", kwlist, + &file_ins, &name, &mode, &buffering)) + return NULL; + + /* Figure out how many arguments to _PyFile_Init() we have. */ + if (mode) + arg_count += 1; + if (buffering) + arg_count += 1; + + /* Construct a new argument tuple for _PyFile_Init() sans file instance. */ + init_args = PyTuple_New(arg_count); + PyTuple_SET_ITEM(init_args, arg_pos++, name); + Py_INCREF(name); + if (mode) { + Py_INCREF(mode); + PyTuple_SET_ITEM(init_args, arg_pos++, mode); + } + if (buffering) { + Py_INCREF(buffering); + PyTuple_SET_ITEM(init_args, arg_pos++, buffering); + } + + /* Initialize file instance. */ + Py_INCREF(file_ins); + ret = _PyFile_Init(file_ins, init_args, NULL); + Py_DECREF(file_ins); + Py_DECREF(init_args); + + if (ret < 0) + return NULL; + + Py_RETURN_NONE; +} + + +PyDoc_VAR(file_init_doc) = +PyDoc_STR( +"file_init(file_instance, name[, mode[, buffering]]) -> None\n" +"\n" +"Initialize a file object. The mode can be 'r', 'w' or 'a' for reading (default),\n" +"writing or appending. The file itself will be created if it doesn't exist\n" +"when opened for writing or appending; it will be truncated when\n" +"opened for writing. Add a 'b' to the mode for binary files.\n" +"Add a '+' to the mode to allow simultaneous reading and writing.\n" +"If the buffering argument is given, 0 means unbuffered, 1 means line\n" +"buffered, and larger numbers specify the buffer size.\n" +) +PyDoc_STR( +"Add a 'U' to mode to open the file for input with universal newline\n" +"support. Any line ending in the input file will be seen as a '\\n'\n" +"in Python. Also, a file so opened gains the attribute 'newlines';\n" +"the value for this attribute is one of None (no newline read yet),\n" +"'\\r', '\\n', '\\r\\n' or a tuple containing all the newline types seen.\n" +"\n" +"'U' cannot be combined with 'w' or '+' mode.\n" +); + + static PyMethodDef module_methods[] = { - {"subclasses", (PyCFunction)object_subclasses, METH_O, "XXX"}, + {"subclasses", (PyCFunction)object_subclasses, METH_O, object_subclass_doc}, + {"file_init", (PyCFunction)file_init, METH_VARARGS | METH_KEYWORDS, + file_init_doc}, {NULL, NULL} }; Modified: python/branches/bcannon-objcap/Objects/fileobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/fileobject.c (original) +++ python/branches/bcannon-objcap/Objects/fileobject.c Fri Sep 1 00:32:42 2006 @@ -1945,6 +1945,13 @@ assert(type != NULL && type->tp_alloc != NULL); + if ((args && PyTuple_GET_SIZE(args)) || + (kwds && PyDict_Check(kwds) && PyDict_Size(kwds))) { + PyErr_SetString(PyExc_TypeError, + "file type's __new__ takes no parameters"); + return NULL; + } + if (not_yet_string == NULL) { not_yet_string = PyString_FromString(""); if (not_yet_string == NULL) @@ -1966,8 +1973,12 @@ return self; } -static int -file_init(PyObject *self, PyObject *args, PyObject *kwds) +/* + Initialize a 'file' instance based on the arguments that would normally be + passed to the open() built-in. +*/ +int +_PyFile_Init(PyObject *self, PyObject *args, PyObject *kwds) { PyFileObject *foself = (PyFileObject *)self; int ret = 0; @@ -1977,7 +1988,11 @@ int bufsize = -1; int wideargument = 0; - assert(PyFile_Check(self)); + if (!PyFile_Check(self)) { + PyErr_SetString(PyExc_TypeError, + "can only initialize instances of the 'file' type"); + return -1; + } if (foself->f_fp != NULL) { /* Have to close the existing file first. */ PyObject *closeresult = file_close(foself); @@ -2016,7 +2031,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist, &o_name, &mode, &bufsize)) - return -1; + goto Error; if (fill_file_fields(foself, NULL, o_name, mode, fclose) == NULL) @@ -2038,24 +2053,11 @@ PyDoc_VAR(file_doc) = PyDoc_STR( -"file(name[, mode[, buffering]]) -> file object\n" -"\n" -"Open a file. The mode can be 'r', 'w' or 'a' for reading (default),\n" -"writing or appending. The file will be created if it doesn't exist\n" -"when opened for writing or appending; it will be truncated when\n" -"opened for writing. Add a 'b' to the mode for binary files.\n" -"Add a '+' to the mode to allow simultaneous reading and writing.\n" -"If the buffering argument is given, 0 means unbuffered, 1 means line\n" -"buffered, and larger numbers specify the buffer size.\n" -) -PyDoc_STR( -"Add a 'U' to mode to open the file for input with universal newline\n" -"support. Any line ending in the input file will be seen as a '\\n'\n" -"in Python. Also, a file so opened gains the attribute 'newlines';\n" -"the value for this attribute is one of None (no newline read yet),\n" -"'\\r', '\\n', '\\r\\n' or a tuple containing all the newline types seen.\n" +"file() -> uninitialized file object\n" "\n" -"'U' cannot be combined with 'w' or '+' mode.\n" +"To initialize a file object instance, pass it to\n\ +objcap.file_init() with the proper arguments. Otherwise open a file\n\ +using the built-in open() function." ); PyTypeObject PyFile_Type = { @@ -2096,7 +2098,7 @@ 0, /* tp_descr_get */ 0, /* tp_descr_set */ 0, /* tp_dictoffset */ - file_init, /* tp_init */ + 0, /* tp_init */ PyType_GenericAlloc, /* tp_alloc */ file_new, /* tp_new */ PyObject_Del, /* tp_free */ Modified: python/branches/bcannon-objcap/Python/bltinmodule.c ============================================================================== --- python/branches/bcannon-objcap/Python/bltinmodule.c (original) +++ python/branches/bcannon-objcap/Python/bltinmodule.c Fri Sep 1 00:32:42 2006 @@ -1344,7 +1344,14 @@ static PyObject * builtin_open(PyObject *self, PyObject *args, PyObject *kwds) { - return PyObject_Call((PyObject*)&PyFile_Type, args, kwds); + PyObject *file_ins = PyFile_Type.tp_new(&PyFile_Type, NULL, NULL); + if (!file_ins) + return NULL; + + if (_PyFile_Init(file_ins, args, kwds) < 0) + return NULL; + + return file_ins; } PyDoc_STRVAR(open_doc, Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Fri Sep 1 00:32:42 2006 @@ -7,13 +7,13 @@ + Remove object.__subclasses__ (`Mutable Shared State`_) [done] + Dangerous constructors (`Constructors`_) - file - * Create PyFile_Init() from file_init() + * Create PyFile_Init() from file_init() [done] * Switch current C-level uses of 'file' constructor to - use PyFile_Type.tp_new() and PyFile_Init(). - + built-in open() - + bz2 module + use PyFile_Type.tp_new() and PyFile_Init(). [done] + + built-in open() [done] + + bz2 module [done] * Expose PyFile_Init() in objcap module so that file - subclasses are actually worth something. + subclasses are actually worth something. [done] * Create PyFile_Safe*() version of C API that goes through open() built-in. + Convert C strings to Python objects and do a direct From python-checkins at python.org Fri Sep 1 00:36:42 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 1 Sep 2006 00:36:42 +0200 (CEST) Subject: [Python-checkins] r51673 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060831223642.6D6A11E4002@bag.python.org> Author: brett.cannon Date: Fri Sep 1 00:36:41 2006 New Revision: 51673 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Add entry on removing 'file' type's initializer. Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Fri Sep 1 00:36:41 2006 @@ -5,5 +5,14 @@ Core and builtins ----------------- +* rev. 51672: Remove the initializer from the 'file' type. Constructing an + isntance now takes no arguments and makes it an empty instance. To attach a + file to a 'file' instance, use objcap.file_init(). + + This changes how subclassing 'file' needs to be handled. First, + file.__new__() must be called with no arguments. Second, in the subclass' + __init__(), call objcap.file_init() with 'self' as the first argument and + then the usual arguments for opening a file. + * rev. 51392: Introduce objcap module to hold removed functions/methods. Begin with moving object.__subclasses__(). From python-checkins at python.org Fri Sep 1 00:42:37 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 1 Sep 2006 00:42:37 +0200 (CEST) Subject: [Python-checkins] r51674 - python/trunk/Misc/Vim/vimrc Message-ID: <20060831224237.B872C1E4002@bag.python.org> Author: brett.cannon Date: Fri Sep 1 00:42:37 2006 New Revision: 51674 Modified: python/trunk/Misc/Vim/vimrc Log: Have pre-existing C files use 8 spaces indents (to match old PEP 7 style), but have all new files use 4 spaces (to match current PEP 7 style). Modified: python/trunk/Misc/Vim/vimrc ============================================================================== --- python/trunk/Misc/Vim/vimrc (original) +++ python/trunk/Misc/Vim/vimrc Fri Sep 1 00:42:37 2006 @@ -19,9 +19,10 @@ " Number of spaces to use for an indent. " This will affect Ctrl-T and 'autoindent'. " Python: 4 spaces -" C: 4 spaces +" C: 8 spaces (pre-existing files) or 4 spaces (new files) au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 -au BufRead,BufNewFile *.c,*.h set shiftwidth=4 +au BufRead *.c,*.h set shiftwidth=8 +au BufNewFile *.c,*.h set shiftwidth=4 " Number of spaces that a pre-existing tab is equal to. " For the amount of space used for a new tab use shiftwidth. From python-checkins at python.org Fri Sep 1 05:56:23 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 1 Sep 2006 05:56:23 +0200 (CEST) Subject: [Python-checkins] r51675 - python/branches/release25-maint/Doc/lib/libunittest.tex Message-ID: <20060901035623.3B1121E400B@bag.python.org> Author: fred.drake Date: Fri Sep 1 05:56:22 2006 New Revision: 51675 Modified: python/branches/release25-maint/Doc/lib/libunittest.tex Log: - SF patch #1550263: Enhance and correct unittest docs - various minor cleanups for improved consistency Modified: python/branches/release25-maint/Doc/lib/libunittest.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libunittest.tex (original) +++ python/branches/release25-maint/Doc/lib/libunittest.tex Fri Sep 1 05:56:22 2006 @@ -212,8 +212,8 @@ class DefaultWidgetSizeTestCase(unittest.TestCase): def runTest(self): - widget = Widget("The widget") - self.failUnless(widget.size() == (50,50), 'incorrect default size') + widget = Widget('The widget') + self.assertEqual(widget.size(), (50, 50), 'incorrect default size') \end{verbatim} Note that in order to test something, we use the one of the @@ -247,7 +247,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): @@ -273,7 +273,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -298,7 +298,7 @@ class WidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -322,8 +322,8 @@ passing the method name in the constructor: \begin{verbatim} -defaultSizeTestCase = WidgetTestCase("testDefaultSize") -resizeTestCase = WidgetTestCase("testResize") +defaultSizeTestCase = WidgetTestCase('testDefaultSize') +resizeTestCase = WidgetTestCase('testResize') \end{verbatim} Test case instances are grouped together according to the features @@ -333,8 +333,8 @@ \begin{verbatim} widgetTestSuite = unittest.TestSuite() -widgetTestSuite.addTest(WidgetTestCase("testDefaultSize")) -widgetTestSuite.addTest(WidgetTestCase("testResize")) +widgetTestSuite.addTest(WidgetTestCase('testDefaultSize')) +widgetTestSuite.addTest(WidgetTestCase('testResize')) \end{verbatim} For the ease of running tests, as we will see later, it is a good @@ -344,8 +344,8 @@ \begin{verbatim} def suite(): suite = unittest.TestSuite() - suite.addTest(WidgetTestCase("testDefaultSize")) - suite.addTest(WidgetTestCase("testResize")) + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) return suite \end{verbatim} @@ -353,7 +353,7 @@ \begin{verbatim} def suite(): - tests = ["testDefaultSize", "testResize"] + tests = ['testDefaultSize', 'testResize'] return unittest.TestSuite(map(WidgetTestCase, tests)) \end{verbatim} @@ -462,7 +462,7 @@ \subsection{Classes and functions \label{unittest-contents}} -\begin{classdesc}{TestCase}{} +\begin{classdesc}{TestCase}{\optional{methodName}} Instances of the \class{TestCase} class represent the smallest testable units in the \module{unittest} universe. This class is intended to be used as a base class, with specific tests being @@ -470,6 +470,23 @@ interface needed by the test runner to allow it to drive the test, and methods that the test code can use to check for and report various kinds of failure. + + Each instance of \class{TestCase} will run a single test method: + the method named \var{methodName}. If you remember, we had an + earlier example that went something like this: + + \begin{verbatim} + def suite(): + suite = unittest.TestSuite() + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) + return suite + \end{verbatim} + + Here, we create two instances of \class{WidgetTestCase}, each of + which runs a single test. + + \var{methodName} defaults to \code{'runTest'}. \end{classdesc} \begin{classdesc}{FunctionTestCase}{testFunc\optional{, @@ -502,6 +519,11 @@ subclass. \end{classdesc} +\begin{classdesc}{TestResult}{} + This class is used to compile information about which tests have succeeded + and which have failed. +\end{classdesc} + \begin{datadesc}{defaultTestLoader} Instance of the \class{TestLoader} class intended to be shared. If no customization of the \class{TestLoader} is needed, this instance can @@ -574,8 +596,9 @@ \begin{methoddesc}[TestCase]{run}{\optional{result}} Run the test, collecting the result into the test result object passed as \var{result}. If \var{result} is omitted or \constant{None}, - a temporary result object is created and used, but is not made - available to the caller. + a temporary result object is created (by calling the + \method{defaultTestCase()} method) and used; this result object is not + returned to \method{run()}'s caller. The same effect may be had by simply calling the \class{TestCase} instance. @@ -684,8 +707,13 @@ \end{methoddesc} \begin{methoddesc}[TestCase]{defaultTestResult}{} - Return the default type of test result object to be used to run this - test. + Return an instance of the test result class that should be used + for this test case class (if no other result instance is provided + to the \method{run()} method). + + For \class{TestCase} instances, this will always be an instance of + \class{TestResult}; subclasses of \class{TestCase} should + override this as necessary. \end{methoddesc} \begin{methoddesc}[TestCase]{id}{} @@ -761,26 +789,20 @@ tests for reporting purposes; a \class{TestResult} instance is returned by the \method{TestRunner.run()} method for this purpose. -Each instance holds the total number of tests run, and collections of -failures and errors that occurred among those test runs. The -collections contain tuples of \code{(\var{testcase}, -\var{traceback})}, where \var{traceback} is a string containing a -formatted version of the traceback for the exception. - \class{TestResult} instances have the following attributes that will be of interest when inspecting the results of running a set of tests: \begin{memberdesc}[TestResult]{errors} A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test which raised an - unexpected exception. + strings holding formatted tracebacks. Each tuple represents a test which + raised an unexpected exception. \versionchanged[Contains formatted tracebacks instead of \function{sys.exc_info()} results]{2.2} \end{memberdesc} \begin{memberdesc}[TestResult]{failures} - A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test where a failure + A list containing 2-tuples of \class{TestCase} instances and strings + holding formatted tracebacks. Each tuple represents a test where a failure was explicitly signalled using the \method{TestCase.fail*()} or \method{TestCase.assert*()} methods. \versionchanged[Contains formatted tracebacks instead of @@ -817,17 +839,25 @@ \begin{methoddesc}[TestResult]{startTest}{test} Called when the test case \var{test} is about to be run. + + The default implementation simply increments the instance's + \code{testsRun} counter. \end{methoddesc} \begin{methoddesc}[TestResult]{stopTest}{test} - Called when the test case \var{test} has been executed, regardless + Called after the test case \var{test} has been executed, regardless of the outcome. + + The default implementation does nothing. \end{methoddesc} \begin{methoddesc}[TestResult]{addError}{test, err} Called when the test case \var{test} raises an unexpected exception \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{errors} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addFailure}{test, err} @@ -835,10 +865,15 @@ \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{failures} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addSuccess}{test} Called when the test case \var{test} succeeds. + + The default implementation does nothing. \end{methoddesc} @@ -878,9 +913,12 @@ Return a suite of all tests cases given a string specifier. The specifier \var{name} is a ``dotted name'' that may resolve - either to a module, a test case class, a \class{TestSuite} instance, - a test method within a test case class, or a callable object which - returns a \class{TestCase} or \class{TestSuite} instance. + either to a module, a test case class, a test method within a test + case class, a \class{TestSuite} instance, or a callable object which + returns a \class{TestCase} or \class{TestSuite} instance. These checks + are applied in the order listed here; that is, a method on a possible + test case class will be picked up as ``a test method within a test + case class'', rather than ``a callable object''. For example, if you have a module \module{SampleTests} containing a \class{TestCase}-derived class \class{SampleTestCase} with three test @@ -905,7 +943,7 @@ \begin{methoddesc}[TestLoader]{getTestCaseNames}{testCaseClass} Return a sorted sequence of method names found within - \var{testCaseClass}. + \var{testCaseClass}; this should be a subclass of \class{TestCase}. \end{methoddesc} From python-checkins at python.org Fri Sep 1 05:57:19 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 1 Sep 2006 05:57:19 +0200 (CEST) Subject: [Python-checkins] r51676 - python/trunk/Doc/lib/libunittest.tex Message-ID: <20060901035719.BB0041E400B@bag.python.org> Author: fred.drake Date: Fri Sep 1 05:57:19 2006 New Revision: 51676 Modified: python/trunk/Doc/lib/libunittest.tex Log: - SF patch #1550263: Enhance and correct unittest docs - various minor cleanups for improved consistency Modified: python/trunk/Doc/lib/libunittest.tex ============================================================================== --- python/trunk/Doc/lib/libunittest.tex (original) +++ python/trunk/Doc/lib/libunittest.tex Fri Sep 1 05:57:19 2006 @@ -212,8 +212,8 @@ class DefaultWidgetSizeTestCase(unittest.TestCase): def runTest(self): - widget = Widget("The widget") - self.failUnless(widget.size() == (50,50), 'incorrect default size') + widget = Widget('The widget') + self.assertEqual(widget.size(), (50, 50), 'incorrect default size') \end{verbatim} Note that in order to test something, we use the one of the @@ -247,7 +247,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): @@ -273,7 +273,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -298,7 +298,7 @@ class WidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -322,8 +322,8 @@ passing the method name in the constructor: \begin{verbatim} -defaultSizeTestCase = WidgetTestCase("testDefaultSize") -resizeTestCase = WidgetTestCase("testResize") +defaultSizeTestCase = WidgetTestCase('testDefaultSize') +resizeTestCase = WidgetTestCase('testResize') \end{verbatim} Test case instances are grouped together according to the features @@ -333,8 +333,8 @@ \begin{verbatim} widgetTestSuite = unittest.TestSuite() -widgetTestSuite.addTest(WidgetTestCase("testDefaultSize")) -widgetTestSuite.addTest(WidgetTestCase("testResize")) +widgetTestSuite.addTest(WidgetTestCase('testDefaultSize')) +widgetTestSuite.addTest(WidgetTestCase('testResize')) \end{verbatim} For the ease of running tests, as we will see later, it is a good @@ -344,8 +344,8 @@ \begin{verbatim} def suite(): suite = unittest.TestSuite() - suite.addTest(WidgetTestCase("testDefaultSize")) - suite.addTest(WidgetTestCase("testResize")) + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) return suite \end{verbatim} @@ -353,7 +353,7 @@ \begin{verbatim} def suite(): - tests = ["testDefaultSize", "testResize"] + tests = ['testDefaultSize', 'testResize'] return unittest.TestSuite(map(WidgetTestCase, tests)) \end{verbatim} @@ -462,7 +462,7 @@ \subsection{Classes and functions \label{unittest-contents}} -\begin{classdesc}{TestCase}{} +\begin{classdesc}{TestCase}{\optional{methodName}} Instances of the \class{TestCase} class represent the smallest testable units in the \module{unittest} universe. This class is intended to be used as a base class, with specific tests being @@ -470,6 +470,23 @@ interface needed by the test runner to allow it to drive the test, and methods that the test code can use to check for and report various kinds of failure. + + Each instance of \class{TestCase} will run a single test method: + the method named \var{methodName}. If you remember, we had an + earlier example that went something like this: + + \begin{verbatim} + def suite(): + suite = unittest.TestSuite() + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) + return suite + \end{verbatim} + + Here, we create two instances of \class{WidgetTestCase}, each of + which runs a single test. + + \var{methodName} defaults to \code{'runTest'}. \end{classdesc} \begin{classdesc}{FunctionTestCase}{testFunc\optional{, @@ -502,6 +519,11 @@ subclass. \end{classdesc} +\begin{classdesc}{TestResult}{} + This class is used to compile information about which tests have succeeded + and which have failed. +\end{classdesc} + \begin{datadesc}{defaultTestLoader} Instance of the \class{TestLoader} class intended to be shared. If no customization of the \class{TestLoader} is needed, this instance can @@ -574,8 +596,9 @@ \begin{methoddesc}[TestCase]{run}{\optional{result}} Run the test, collecting the result into the test result object passed as \var{result}. If \var{result} is omitted or \constant{None}, - a temporary result object is created and used, but is not made - available to the caller. + a temporary result object is created (by calling the + \method{defaultTestCase()} method) and used; this result object is not + returned to \method{run()}'s caller. The same effect may be had by simply calling the \class{TestCase} instance. @@ -684,8 +707,13 @@ \end{methoddesc} \begin{methoddesc}[TestCase]{defaultTestResult}{} - Return the default type of test result object to be used to run this - test. + Return an instance of the test result class that should be used + for this test case class (if no other result instance is provided + to the \method{run()} method). + + For \class{TestCase} instances, this will always be an instance of + \class{TestResult}; subclasses of \class{TestCase} should + override this as necessary. \end{methoddesc} \begin{methoddesc}[TestCase]{id}{} @@ -761,26 +789,20 @@ tests for reporting purposes; a \class{TestResult} instance is returned by the \method{TestRunner.run()} method for this purpose. -Each instance holds the total number of tests run, and collections of -failures and errors that occurred among those test runs. The -collections contain tuples of \code{(\var{testcase}, -\var{traceback})}, where \var{traceback} is a string containing a -formatted version of the traceback for the exception. - \class{TestResult} instances have the following attributes that will be of interest when inspecting the results of running a set of tests: \begin{memberdesc}[TestResult]{errors} A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test which raised an - unexpected exception. + strings holding formatted tracebacks. Each tuple represents a test which + raised an unexpected exception. \versionchanged[Contains formatted tracebacks instead of \function{sys.exc_info()} results]{2.2} \end{memberdesc} \begin{memberdesc}[TestResult]{failures} - A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test where a failure + A list containing 2-tuples of \class{TestCase} instances and strings + holding formatted tracebacks. Each tuple represents a test where a failure was explicitly signalled using the \method{TestCase.fail*()} or \method{TestCase.assert*()} methods. \versionchanged[Contains formatted tracebacks instead of @@ -817,17 +839,25 @@ \begin{methoddesc}[TestResult]{startTest}{test} Called when the test case \var{test} is about to be run. + + The default implementation simply increments the instance's + \code{testsRun} counter. \end{methoddesc} \begin{methoddesc}[TestResult]{stopTest}{test} - Called when the test case \var{test} has been executed, regardless + Called after the test case \var{test} has been executed, regardless of the outcome. + + The default implementation does nothing. \end{methoddesc} \begin{methoddesc}[TestResult]{addError}{test, err} Called when the test case \var{test} raises an unexpected exception \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{errors} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addFailure}{test, err} @@ -835,10 +865,15 @@ \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{failures} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addSuccess}{test} Called when the test case \var{test} succeeds. + + The default implementation does nothing. \end{methoddesc} @@ -878,9 +913,12 @@ Return a suite of all tests cases given a string specifier. The specifier \var{name} is a ``dotted name'' that may resolve - either to a module, a test case class, a \class{TestSuite} instance, - a test method within a test case class, or a callable object which - returns a \class{TestCase} or \class{TestSuite} instance. + either to a module, a test case class, a test method within a test + case class, a \class{TestSuite} instance, or a callable object which + returns a \class{TestCase} or \class{TestSuite} instance. These checks + are applied in the order listed here; that is, a method on a possible + test case class will be picked up as ``a test method within a test + case class'', rather than ``a callable object''. For example, if you have a module \module{SampleTests} containing a \class{TestCase}-derived class \class{SampleTestCase} with three test @@ -905,7 +943,7 @@ \begin{methoddesc}[TestLoader]{getTestCaseNames}{testCaseClass} Return a sorted sequence of method names found within - \var{testCaseClass}. + \var{testCaseClass}; this should be a subclass of \class{TestCase}. \end{methoddesc} From noreply at python.org Fri Sep 1 23:37:09 2006 From: noreply at python.org (Automatic Email Delivery Software) Date: Fri, 1 Sep 2006 16:37:09 -0500 Subject: [Python-checkins] PYTHON-CHECKINS@PYTHON.ORG Message-ID: -------------- next part -------------- A non-text attachment was scrubbed... Name: Deleted0.txt Type: application/octet-stream Size: 145 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20060901/6e4280c2/attachment.obj From python-checkins at python.org Sat Sep 2 00:30:53 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 2 Sep 2006 00:30:53 +0200 (CEST) Subject: [Python-checkins] r51677 - python/trunk/Doc/tut/tut.tex Message-ID: <20060901223053.212E71E4010@bag.python.org> Author: georg.brandl Date: Sat Sep 2 00:30:52 2006 New Revision: 51677 Modified: python/trunk/Doc/tut/tut.tex Log: evalfile() should be execfile(). Modified: python/trunk/Doc/tut/tut.tex ============================================================================== --- python/trunk/Doc/tut/tut.tex (original) +++ python/trunk/Doc/tut/tut.tex Sat Sep 2 00:30:52 2006 @@ -4381,7 +4381,7 @@ makes use of private variables of the base class possible.) Notice that code passed to \code{exec}, \code{eval()} or -\code{evalfile()} does not consider the classname of the invoking +\code{execfile()} does not consider the classname of the invoking class to be the current class; this is similar to the effect of the \code{global} statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to From python-checkins at python.org Sat Sep 2 00:30:57 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 2 Sep 2006 00:30:57 +0200 (CEST) Subject: [Python-checkins] r51678 - python/branches/release25-maint/Doc/tut/tut.tex Message-ID: <20060901223057.43C621E401A@bag.python.org> Author: georg.brandl Date: Sat Sep 2 00:30:56 2006 New Revision: 51678 Modified: python/branches/release25-maint/Doc/tut/tut.tex Log: evalfile() should be execfile(). (backport from rev. 51677) Modified: python/branches/release25-maint/Doc/tut/tut.tex ============================================================================== --- python/branches/release25-maint/Doc/tut/tut.tex (original) +++ python/branches/release25-maint/Doc/tut/tut.tex Sat Sep 2 00:30:56 2006 @@ -4381,7 +4381,7 @@ makes use of private variables of the base class possible.) Notice that code passed to \code{exec}, \code{eval()} or -\code{evalfile()} does not consider the classname of the invoking +\code{execfile()} does not consider the classname of the invoking class to be the current class; this is similar to the effect of the \code{global} statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to From python-checkins at python.org Sat Sep 2 00:42:52 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 2 Sep 2006 00:42:52 +0200 (CEST) Subject: [Python-checkins] r51679 - in python/branches/bcannon-objcap: Lib/compiler/pyassem.py Lib/test/output/test_new Lib/test/test_new.py Lib/test/test_objcap.py Modules/objcapmodule.c Objects/codeobject.c securing_python.txt Message-ID: <20060901224252.9B55A1E400C@bag.python.org> Author: brett.cannon Date: Sat Sep 2 00:42:51 2006 New Revision: 51679 Modified: python/branches/bcannon-objcap/Lib/compiler/pyassem.py python/branches/bcannon-objcap/Lib/test/output/test_new python/branches/bcannon-objcap/Lib/test/test_new.py python/branches/bcannon-objcap/Lib/test/test_objcap.py python/branches/bcannon-objcap/Modules/objcapmodule.c python/branches/bcannon-objcap/Objects/codeobject.c python/branches/bcannon-objcap/securing_python.txt Log: Remove the code type's constructor. Now the only way to create a code instance in Python code is through the factory function objcap.code_new(). Modified: python/branches/bcannon-objcap/Lib/compiler/pyassem.py ============================================================================== --- python/branches/bcannon-objcap/Lib/compiler/pyassem.py (original) +++ python/branches/bcannon-objcap/Lib/compiler/pyassem.py Sat Sep 2 00:42:51 2006 @@ -1,8 +1,8 @@ """A flow graph representation for Python bytecode""" import dis -import new import sys +import objcap from compiler import misc from compiler.consts \ @@ -595,7 +595,7 @@ argcount = self.argcount if self.flags & CO_VARKEYWORDS: argcount = argcount - 1 - return new.code(argcount, nlocals, self.stacksize, self.flags, + return objcap.code_new(argcount, nlocals, self.stacksize, self.flags, self.lnotab.getCode(), self.getConsts(), tuple(self.names), tuple(self.varnames), self.filename, self.name, self.lnotab.firstline, Modified: python/branches/bcannon-objcap/Lib/test/output/test_new ============================================================================== --- python/branches/bcannon-objcap/Lib/test/output/test_new (original) +++ python/branches/bcannon-objcap/Lib/test/output/test_new Sat Sep 2 00:42:51 2006 @@ -4,4 +4,3 @@ new.instance() new.instancemethod() new.function() -new.code() Modified: python/branches/bcannon-objcap/Lib/test/test_new.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_new.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_new.py Sat Sep 2 00:42:51 2006 @@ -105,71 +105,3 @@ test_closure(g, (1, 1), ValueError) # closure is wrong size test_closure(f, g.func_closure, ValueError) # no closure needed -print 'new.code()' -# bogus test of new.code() -# Note: Jython will never have new.code() -if hasattr(new, 'code'): - def f(a): pass - - c = f.func_code - argcount = c.co_argcount - nlocals = c.co_nlocals - stacksize = c.co_stacksize - flags = c.co_flags - codestring = c.co_code - constants = c.co_consts - names = c.co_names - varnames = c.co_varnames - filename = c.co_filename - name = c.co_name - firstlineno = c.co_firstlineno - lnotab = c.co_lnotab - freevars = c.co_freevars - cellvars = c.co_cellvars - - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab, freevars, cellvars) - - # test backwards-compatibility version with no freevars or cellvars - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab) - - try: # this used to trigger a SystemError - d = new.code(-argcount, nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab) - except ValueError: - pass - else: - raise TestFailed, "negative co_argcount didn't trigger an exception" - - try: # this used to trigger a SystemError - d = new.code(argcount, -nlocals, stacksize, flags, codestring, - constants, names, varnames, filename, name, - firstlineno, lnotab) - except ValueError: - pass - else: - raise TestFailed, "negative co_nlocals didn't trigger an exception" - - try: # this used to trigger a Py_FatalError! - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, (5,), varnames, filename, name, - firstlineno, lnotab) - except TypeError: - pass - else: - raise TestFailed, "non-string co_name didn't trigger an exception" - - # new.code used to be a way to mutate a tuple... - class S(str): pass - t = (S("ab"),) - d = new.code(argcount, nlocals, stacksize, flags, codestring, - constants, t, varnames, filename, name, - firstlineno, lnotab) - verify(type(t[0]) is S, "eek, tuple changed under us!") - - if verbose: - print d Modified: python/branches/bcannon-objcap/Lib/test/test_objcap.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_objcap.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_objcap.py Sat Sep 2 00:42:51 2006 @@ -60,10 +60,84 @@ ins.close() +class CodeNewTests(unittest.TestCase): + + """Test code_new().""" + + def test_all(self): + # Originally taken from test_new.py . + + def f(a): pass + + c = f.func_code + argcount = c.co_argcount + nlocals = c.co_nlocals + stacksize = c.co_stacksize + flags = c.co_flags + codestring = c.co_code + constants = c.co_consts + names = c.co_names + varnames = c.co_varnames + filename = c.co_filename + name = c.co_name + firstlineno = c.co_firstlineno + lnotab = c.co_lnotab + freevars = c.co_freevars + cellvars = c.co_cellvars + + d = objcap.code_new(argcount, nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, + firstlineno, lnotab, freevars, cellvars) + + # test backwards-compatibility version with no freevars or cellvars + d = objcap.code_new(argcount, nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, + firstlineno, lnotab) + + try: # this used to trigger a SystemError + d = objcap.code_new(-argcount, nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, + firstlineno, lnotab) + except ValueError: + pass + else: + raise test_support.TestFailed( + "negative co_argcount didn't trigger an exception") + + try: # this used to trigger a SystemError + d = objcap.code_new(argcount, -nlocals, stacksize, flags, codestring, + constants, names, varnames, filename, name, + firstlineno, lnotab) + except ValueError: + pass + else: + raise test_support.TestFailed( + "negative co_nlocals didn't trigger an exception") + + try: # this used to trigger a Py_FatalError! + d = objcap.code_new(argcount, nlocals, stacksize, flags, codestring, + constants, (5,), varnames, filename, name, + firstlineno, lnotab) + except TypeError: + pass + else: + raise TestFailed, "non-string co_name didn't trigger an exception" + + # new.code used to be a way to mutate a tuple... + class S(str): pass + t = (S("ab"),) + d = objcap.code_new(argcount, nlocals, stacksize, flags, codestring, + constants, t, varnames, filename, name, + firstlineno, lnotab) + self.failUnless(type(t[0]) is S, "eek, tuple changed under us!") + + + def test_main(): test_support.run_unittest( ObjectSubclasses, FileInitTests, + CodeNewTests, ) Modified: python/branches/bcannon-objcap/Modules/objcapmodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/objcapmodule.c (original) +++ python/branches/bcannon-objcap/Modules/objcapmodule.c Sat Sep 2 00:42:51 2006 @@ -132,11 +132,139 @@ ); +/* Helper for code_new: return a shallow copy of a tuple that is + guaranteed to contain exact strings, by converting string subclasses + to exact strings and complaining if a non-string is found. */ +static PyObject* +validate_and_copy_tuple(PyObject *tup) +{ + PyObject *newtuple; + PyObject *item; + Py_ssize_t i, len; + + len = PyTuple_GET_SIZE(tup); + newtuple = PyTuple_New(len); + if (newtuple == NULL) + return NULL; + + for (i = 0; i < len; i++) { + item = PyTuple_GET_ITEM(tup, i); + if (PyString_CheckExact(item)) { + Py_INCREF(item); + } + else if (!PyString_Check(item)) { + PyErr_Format( + PyExc_TypeError, + "name tuples must contain only " + "strings, not '%.500s'", + item->ob_type->tp_name); + Py_DECREF(newtuple); + return NULL; + } + else { + item = PyString_FromStringAndSize( + PyString_AS_STRING(item), + PyString_GET_SIZE(item)); + if (item == NULL) { + Py_DECREF(newtuple); + return NULL; + } + } + PyTuple_SET_ITEM(newtuple, i, item); + } + + return newtuple; +} + +PyDoc_STRVAR(code_doc, +"code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n\ + varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n\ +\n\ +Create a code object. Not for the faint of heart."); + +static PyObject * +code_new(PyTypeObject *type, PyObject *args, PyObject *kw) +{ + int argcount; + int nlocals; + int stacksize; + int flags; + PyObject *co = NULL; + PyObject *code; + PyObject *consts; + PyObject *names, *ournames = NULL; + PyObject *varnames, *ourvarnames = NULL; + PyObject *freevars = NULL, *ourfreevars = NULL; + PyObject *cellvars = NULL, *ourcellvars = NULL; + PyObject *filename; + PyObject *name; + int firstlineno; + PyObject *lnotab; + + if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code", + &argcount, &nlocals, &stacksize, &flags, + &code, + &PyTuple_Type, &consts, + &PyTuple_Type, &names, + &PyTuple_Type, &varnames, + &filename, &name, + &firstlineno, &lnotab, + &PyTuple_Type, &freevars, + &PyTuple_Type, &cellvars)) + return NULL; + + if (argcount < 0) { + PyErr_SetString( + PyExc_ValueError, + "code: argcount must not be negative"); + goto cleanup; + } + + if (nlocals < 0) { + PyErr_SetString( + PyExc_ValueError, + "code: nlocals must not be negative"); + goto cleanup; + } + + ournames = validate_and_copy_tuple(names); + if (ournames == NULL) + goto cleanup; + ourvarnames = validate_and_copy_tuple(varnames); + if (ourvarnames == NULL) + goto cleanup; + if (freevars) + ourfreevars = validate_and_copy_tuple(freevars); + else + ourfreevars = PyTuple_New(0); + if (ourfreevars == NULL) + goto cleanup; + if (cellvars) + ourcellvars = validate_and_copy_tuple(cellvars); + else + ourcellvars = PyTuple_New(0); + if (ourcellvars == NULL) + goto cleanup; + + co = (PyObject *)PyCode_New(argcount, nlocals, stacksize, flags, + code, consts, ournames, ourvarnames, + ourfreevars, ourcellvars, filename, + name, firstlineno, lnotab); + cleanup: + Py_XDECREF(ournames); + Py_XDECREF(ourvarnames); + Py_XDECREF(ourfreevars); + Py_XDECREF(ourcellvars); + return co; +} + + static PyMethodDef module_methods[] = { {"subclasses", (PyCFunction)object_subclasses, METH_O, object_subclass_doc}, {"file_init", (PyCFunction)file_init, METH_VARARGS | METH_KEYWORDS, file_init_doc}, + {"code_new", (PyCFunction)code_new, METH_VARARGS, code_doc}, {NULL, NULL} }; Modified: python/branches/bcannon-objcap/Objects/codeobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/codeobject.c (original) +++ python/branches/bcannon-objcap/Objects/codeobject.c Sat Sep 2 00:42:51 2006 @@ -128,131 +128,10 @@ {NULL} /* Sentinel */ }; -/* Helper for code_new: return a shallow copy of a tuple that is - guaranteed to contain exact strings, by converting string subclasses - to exact strings and complaining if a non-string is found. */ -static PyObject* -validate_and_copy_tuple(PyObject *tup) -{ - PyObject *newtuple; - PyObject *item; - Py_ssize_t i, len; - - len = PyTuple_GET_SIZE(tup); - newtuple = PyTuple_New(len); - if (newtuple == NULL) - return NULL; - - for (i = 0; i < len; i++) { - item = PyTuple_GET_ITEM(tup, i); - if (PyString_CheckExact(item)) { - Py_INCREF(item); - } - else if (!PyString_Check(item)) { - PyErr_Format( - PyExc_TypeError, - "name tuples must contain only " - "strings, not '%.500s'", - item->ob_type->tp_name); - Py_DECREF(newtuple); - return NULL; - } - else { - item = PyString_FromStringAndSize( - PyString_AS_STRING(item), - PyString_GET_SIZE(item)); - if (item == NULL) { - Py_DECREF(newtuple); - return NULL; - } - } - PyTuple_SET_ITEM(newtuple, i, item); - } - - return newtuple; -} PyDoc_STRVAR(code_doc, -"code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n\ - varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n\ -\n\ -Create a code object. Not for the faint of heart."); +"Code type."); -static PyObject * -code_new(PyTypeObject *type, PyObject *args, PyObject *kw) -{ - int argcount; - int nlocals; - int stacksize; - int flags; - PyObject *co = NULL; - PyObject *code; - PyObject *consts; - PyObject *names, *ournames = NULL; - PyObject *varnames, *ourvarnames = NULL; - PyObject *freevars = NULL, *ourfreevars = NULL; - PyObject *cellvars = NULL, *ourcellvars = NULL; - PyObject *filename; - PyObject *name; - int firstlineno; - PyObject *lnotab; - - if (!PyArg_ParseTuple(args, "iiiiSO!O!O!SSiS|O!O!:code", - &argcount, &nlocals, &stacksize, &flags, - &code, - &PyTuple_Type, &consts, - &PyTuple_Type, &names, - &PyTuple_Type, &varnames, - &filename, &name, - &firstlineno, &lnotab, - &PyTuple_Type, &freevars, - &PyTuple_Type, &cellvars)) - return NULL; - - if (argcount < 0) { - PyErr_SetString( - PyExc_ValueError, - "code: argcount must not be negative"); - goto cleanup; - } - - if (nlocals < 0) { - PyErr_SetString( - PyExc_ValueError, - "code: nlocals must not be negative"); - goto cleanup; - } - - ournames = validate_and_copy_tuple(names); - if (ournames == NULL) - goto cleanup; - ourvarnames = validate_and_copy_tuple(varnames); - if (ourvarnames == NULL) - goto cleanup; - if (freevars) - ourfreevars = validate_and_copy_tuple(freevars); - else - ourfreevars = PyTuple_New(0); - if (ourfreevars == NULL) - goto cleanup; - if (cellvars) - ourcellvars = validate_and_copy_tuple(cellvars); - else - ourcellvars = PyTuple_New(0); - if (ourcellvars == NULL) - goto cleanup; - - co = (PyObject *)PyCode_New(argcount, nlocals, stacksize, flags, - code, consts, ournames, ourvarnames, - ourfreevars, ourcellvars, filename, - name, firstlineno, lnotab); - cleanup: - Py_XDECREF(ournames); - Py_XDECREF(ourvarnames); - Py_XDECREF(ourfreevars); - Py_XDECREF(ourcellvars); - return co; -} static void code_dealloc(PyCodeObject *co) @@ -392,7 +271,7 @@ 0, /* tp_dictoffset */ 0, /* tp_init */ 0, /* tp_alloc */ - code_new, /* tp_new */ + 0, /* tp_new */ }; /* All about c_lnotab. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Sat Sep 2 00:42:51 2006 @@ -24,7 +24,8 @@ makes less of a performance-critical operation. + Might need to add some C code for easily accessing built-in objects. - - code + - code [done] + * Add objcap.code_new() function [done] - ??? + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) - open() From python-checkins at python.org Sat Sep 2 00:44:12 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 2 Sep 2006 00:44:12 +0200 (CEST) Subject: [Python-checkins] r51680 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060901224412.E41EF1E400C@bag.python.org> Author: brett.cannon Date: Sat Sep 2 00:44:12 2006 New Revision: 51680 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Add entry about removing the 'code' type's constructor. Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Sat Sep 2 00:44:12 2006 @@ -5,6 +5,10 @@ Core and builtins ----------------- +* rev. 51679: Remove the constructor for the 'code' type. This means instances + of the 'code' type cannot be created directly. You must use the new + objcap.code_new() factory function to create instances. + * rev. 51672: Remove the initializer from the 'file' type. Constructing an isntance now takes no arguments and makes it an empty instance. To attach a file to a 'file' instance, use objcap.file_init(). From python-checkins at python.org Sat Sep 2 04:43:19 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 2 Sep 2006 04:43:19 +0200 (CEST) Subject: [Python-checkins] r51681 - python/trunk/Doc/ref/ref3.tex Message-ID: <20060902024319.03C461E400D@bag.python.org> Author: neal.norwitz Date: Sat Sep 2 04:43:17 2006 New Revision: 51681 Modified: python/trunk/Doc/ref/ref3.tex Log: SF #1547931, fix typo (missing and). Will backport to 2.5 Modified: python/trunk/Doc/ref/ref3.tex ============================================================================== --- python/trunk/Doc/ref/ref3.tex (original) +++ python/trunk/Doc/ref/ref3.tex Sat Sep 2 04:43:17 2006 @@ -762,7 +762,7 @@ (call it~\class{C}) of the instance for which the attribute reference was initiated or one of its bases, it is transformed into a bound user-defined method object whose -\member{im_class} attribute is~\class{C} whose \member{im_self} attribute +\member{im_class} attribute is~\class{C} and whose \member{im_self} attribute is the instance. Static method and class method objects are also transformed, as if they had been retrieved from class~\class{C}; see above under ``Classes''. See section~\ref{descriptors} for From python-checkins at python.org Sat Sep 2 04:45:43 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 2 Sep 2006 04:45:43 +0200 (CEST) Subject: [Python-checkins] r51682 - python/branches/release25-maint/Doc/ref/ref3.tex Message-ID: <20060902024543.D23791E400D@bag.python.org> Author: neal.norwitz Date: Sat Sep 2 04:45:43 2006 New Revision: 51682 Modified: python/branches/release25-maint/Doc/ref/ref3.tex Log: SF #1547931, fix typo (missing and). Backport candidate for 2.3/2.4 too Modified: python/branches/release25-maint/Doc/ref/ref3.tex ============================================================================== --- python/branches/release25-maint/Doc/ref/ref3.tex (original) +++ python/branches/release25-maint/Doc/ref/ref3.tex Sat Sep 2 04:45:43 2006 @@ -762,7 +762,7 @@ (call it~\class{C}) of the instance for which the attribute reference was initiated or one of its bases, it is transformed into a bound user-defined method object whose -\member{im_class} attribute is~\class{C} whose \member{im_self} attribute +\member{im_class} attribute is~\class{C} and whose \member{im_self} attribute is the instance. Static method and class method objects are also transformed, as if they had been retrieved from class~\class{C}; see above under ``Classes''. See section~\ref{descriptors} for From python-checkins at python.org Sat Sep 2 04:50:36 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 2 Sep 2006 04:50:36 +0200 (CEST) Subject: [Python-checkins] r51683 - in python/trunk: Misc/NEWS Modules/_cursesmodule.c Message-ID: <20060902025036.8CC0F1E4017@bag.python.org> Author: neal.norwitz Date: Sat Sep 2 04:50:35 2006 New Revision: 51683 Modified: python/trunk/Misc/NEWS python/trunk/Modules/_cursesmodule.c Log: Bug #1548092: fix curses.tparm seg fault on invalid input. Needs backport to 2.5.1 and earlier. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 2 04:50:35 2006 @@ -25,6 +25,8 @@ Extension Modules ----------------- +- Bug #1548092: fix curses.tparm seg fault on invalid input. + Tests ----- Modified: python/trunk/Modules/_cursesmodule.c ============================================================================== --- python/trunk/Modules/_cursesmodule.c (original) +++ python/trunk/Modules/_cursesmodule.c Sat Sep 2 04:50:35 2006 @@ -2334,6 +2334,10 @@ } result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); + if (!result) { + PyErr_SetString(PyCursesError, "tparm() returned NULL"); + return NULL; + } return PyString_FromString(result); } From nnorwitz at gmail.com Sat Sep 2 04:55:24 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Fri, 1 Sep 2006 19:55:24 -0700 Subject: [Python-checkins] r51683 - in python/trunk: Misc/NEWS Modules/_cursesmodule.c In-Reply-To: <20060902025036.8CC0F1E4017@bag.python.org> References: <20060902025036.8CC0F1E4017@bag.python.org> Message-ID: I should note that I couldn't get a test for this to work. That's why there's no automated test. Tested manually. n -- On 9/1/06, neal.norwitz wrote: > Author: neal.norwitz > Date: Sat Sep 2 04:50:35 2006 > New Revision: 51683 > > Modified: > python/trunk/Misc/NEWS > python/trunk/Modules/_cursesmodule.c > Log: > Bug #1548092: fix curses.tparm seg fault on invalid input. Needs backport to 2.5.1 and earlier. > > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS (original) > +++ python/trunk/Misc/NEWS Sat Sep 2 04:50:35 2006 > @@ -25,6 +25,8 @@ > Extension Modules > ----------------- > > +- Bug #1548092: fix curses.tparm seg fault on invalid input. > + > > Tests > ----- > > Modified: python/trunk/Modules/_cursesmodule.c > ============================================================================== > --- python/trunk/Modules/_cursesmodule.c (original) > +++ python/trunk/Modules/_cursesmodule.c Sat Sep 2 04:50:35 2006 > @@ -2334,6 +2334,10 @@ > } > > result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); > + if (!result) { > + PyErr_SetString(PyCursesError, "tparm() returned NULL"); > + return NULL; > + } > > return PyString_FromString(result); > } > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Sat Sep 2 04:58:14 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 2 Sep 2006 04:58:14 +0200 (CEST) Subject: [Python-checkins] r51684 - in python/trunk: Lib/test/test_itertools.py Misc/NEWS Modules/itertoolsmodule.c Message-ID: <20060902025814.14BB41E400D@bag.python.org> Author: neal.norwitz Date: Sat Sep 2 04:58:13 2006 New Revision: 51684 Modified: python/trunk/Lib/test/test_itertools.py python/trunk/Misc/NEWS python/trunk/Modules/itertoolsmodule.c Log: Bug #1550714: fix SystemError from itertools.tee on negative value for n. Needs backport to 2.5.1 and earlier. Modified: python/trunk/Lib/test/test_itertools.py ============================================================================== --- python/trunk/Lib/test/test_itertools.py (original) +++ python/trunk/Lib/test/test_itertools.py Sat Sep 2 04:58:13 2006 @@ -371,6 +371,7 @@ # test values of n self.assertRaises(TypeError, tee, 'abc', 'invalid') + self.assertRaises(ValueError, tee, [], -1) for n in xrange(5): result = tee('abc', n) self.assertEqual(type(result), tuple) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 2 04:58:13 2006 @@ -27,6 +27,8 @@ - Bug #1548092: fix curses.tparm seg fault on invalid input. +- Bug #1550714: fix SystemError from itertools.tee on negative value for n. + Tests ----- Modified: python/trunk/Modules/itertoolsmodule.c ============================================================================== --- python/trunk/Modules/itertoolsmodule.c (original) +++ python/trunk/Modules/itertoolsmodule.c Sat Sep 2 04:58:13 2006 @@ -618,11 +618,15 @@ static PyObject * tee(PyObject *self, PyObject *args) { - int i, n=2; + Py_ssize_t i, n=2; PyObject *it, *iterable, *copyable, *result; - if (!PyArg_ParseTuple(args, "O|i", &iterable, &n)) + if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "n must be >= 0"); + return NULL; + } result = PyTuple_New(n); if (result == NULL) return NULL; From buildbot at python.org Sat Sep 2 05:28:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 03:28:07 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060902032807.E56F51E400D@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/1155 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,fred.drake,georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 2 05:42:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 03:42:50 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060902034250.764E81E4017@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1138 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,fred.drake,georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat Sep 2 05:54:19 2006 From: python-checkins at python.org (nick.coghlan) Date: Sat, 2 Sep 2006 05:54:19 +0200 (CEST) Subject: [Python-checkins] r51685 - in python/trunk/Lib: decimal.py test/test_decimal.py Message-ID: <20060902035419.A7F7E1E400D@bag.python.org> Author: nick.coghlan Date: Sat Sep 2 05:54:17 2006 New Revision: 51685 Modified: python/trunk/Lib/decimal.py python/trunk/Lib/test/test_decimal.py Log: Make decimal.ContextManager a private implementation detail of decimal.localcontext() Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Sat Sep 2 05:54:17 2006 @@ -130,9 +130,6 @@ 'ROUND_DOWN', 'ROUND_HALF_UP', 'ROUND_HALF_EVEN', 'ROUND_CEILING', 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', - # helper for context management - 'ContextManager', - # Functions for manipulating contexts 'setcontext', 'getcontext', 'localcontext' ] @@ -501,8 +498,8 @@ >>> print getcontext().prec 28 """ - if ctx is None: ctx = getcontext().copy() - return ContextManager(ctx.copy()) + if ctx is None: ctx = getcontext() + return _ContextManager(ctx) ##### Decimal class ########################################### @@ -2219,30 +2216,14 @@ del name, val, globalname, rounding_functions -class ContextManager(object): +class _ContextManager(object): """Context manager class to support localcontext(). - Sets the supplied context in __enter__() and restores + Sets a copy of the supplied context in __enter__() and restores the previous decimal context in __exit__() - - """ - # The below can't be included in the docstring until Python 2.6 - # as the doctest module doesn't understand __future__ statements - """ - Sample usage: - >>> from __future__ import with_statement - >>> print getcontext().prec - 28 - >>> ctx = Context(prec=15) - >>> with ContextManager(ctx): - ... print getcontext().prec - ... - 15 - >>> print getcontext().prec - 28 """ def __init__(self, new_context): - self.new_context = new_context + self.new_context = new_context.copy() def __enter__(self): self.saved_context = getcontext() setcontext(self.new_context) Modified: python/trunk/Lib/test/test_decimal.py ============================================================================== --- python/trunk/Lib/test/test_decimal.py (original) +++ python/trunk/Lib/test/test_decimal.py Sat Sep 2 05:54:17 2006 @@ -1068,20 +1068,9 @@ class WithStatementTest(unittest.TestCase): # Can't do these as docstrings until Python 2.6 # as doctest can't handle __future__ statements - def test_ContextManager(self): - # The basic context manager uses the supplied context - # without making a copy of it - orig_ctx = getcontext() - new_ctx = Context() - with ContextManager(new_ctx) as enter_ctx: - set_ctx = getcontext() - final_ctx = getcontext() - self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') - self.assert_(new_ctx is set_ctx, 'did not set correct context') - self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') def test_localcontext(self): - # The helper function makes a copy of the supplied context + # Use a copy of the current context in the block orig_ctx = getcontext() with localcontext() as enter_ctx: set_ctx = getcontext() @@ -1091,7 +1080,7 @@ self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') def test_localcontextarg(self): - # The helper function makes a copy of the supplied context + # Use a copy of the supplied context in the block orig_ctx = getcontext() new_ctx = Context(prec=42) with localcontext(new_ctx) as enter_ctx: From python-checkins at python.org Sat Sep 2 06:04:18 2006 From: python-checkins at python.org (nick.coghlan) Date: Sat, 2 Sep 2006 06:04:18 +0200 (CEST) Subject: [Python-checkins] r51686 - python/trunk/Doc/lib/libdecimal.tex Message-ID: <20060902040418.E82411E400D@bag.python.org> Author: nick.coghlan Date: Sat Sep 2 06:04:18 2006 New Revision: 51686 Modified: python/trunk/Doc/lib/libdecimal.tex Log: Further corrections to the decimal module context management documentation Modified: python/trunk/Doc/lib/libdecimal.tex ============================================================================== --- python/trunk/Doc/lib/libdecimal.tex (original) +++ python/trunk/Doc/lib/libdecimal.tex Sat Sep 2 06:04:18 2006 @@ -443,36 +443,33 @@ \end{funcdesc} Beginning with Python 2.5, you can also use the \keyword{with} statement -to temporarily change the active context. +and the \function{localcontext()} function to temporarily change the +active context. \begin{funcdesc}{localcontext}{\optional{c}} Return a context manager that will set the current context for the active thread to a copy of \var{c} on entry to the with statement - and restore the previous context when exiting the with statement. + and restore the previous context when exiting the with statement. If + no context is specified, a copy of the current context is used. For example the following code increases the current decimal precision - by 2 places, performs a calculation, and then automatically restores + by 42 places, performs a calculation, and then automatically restores the previous context: \begin{verbatim} from __future__ import with_statement import decimal with decimal.localcontext() as ctx: - ctx.prec += 2 # add 2 more digits of precision + ctx.prec = 42 # Perform a high precision calculation s = calculate_something() s = +s # Round the final result back to the default precision \end{verbatim} -\end{funcdesc} -The context that's active in the body of the \keyword{with} statement is -a \emph{copy} of the context you provided to the \keyword{with} -statement, so modifying its attributes doesn't affect anything except -that temporary copy. - -You can use any decimal context in a \keyword{with} statement, but if -you just want to make a temporary change to some aspect of the current -context, it's easiest to just use \function{getcontext()} as shown -above. + The context that is held by the context manager and made active in the + body of the \keyword{with} statement is a \emph{copy} of the context + you provide to this function, so modifying its attributes doesn't + affect anything except that temporary copy. +\end{funcdesc} New contexts can also be created using the \class{Context} constructor described below. In addition, the module provides three pre-made From buildbot at python.org Sat Sep 2 06:12:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 04:12:27 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060902041227.9DBF61E400D@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1249 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 2 06:33:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 04:33:19 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian trunk Message-ID: <20060902043319.3906A1E400D@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%2520trunk/builds/454 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 2 07:01:40 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 05:01:40 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060902050140.403A21E400D@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/533 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,fred.drake,georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 2 07:17:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 05:17:09 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060902051709.B6CDC1E400D@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1140 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 2 13:36:53 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 11:36:53 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060902113653.5F9E41E400D@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/679 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,fred.drake,georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat Sep 2 19:07:24 2006 From: python-checkins at python.org (raymond.hettinger) Date: Sat, 2 Sep 2006 19:07:24 +0200 (CEST) Subject: [Python-checkins] r51688 - in python/trunk/Doc: lib/libdecimal.tex whatsnew/whatsnew25.tex Message-ID: <20060902170724.19F971E4003@bag.python.org> Author: raymond.hettinger Date: Sat Sep 2 19:07:23 2006 New Revision: 51688 Modified: python/trunk/Doc/lib/libdecimal.tex python/trunk/Doc/whatsnew/whatsnew25.tex Log: Fix documentation nits for decimal context managers. Modified: python/trunk/Doc/lib/libdecimal.tex ============================================================================== --- python/trunk/Doc/lib/libdecimal.tex (original) +++ python/trunk/Doc/lib/libdecimal.tex Sat Sep 2 19:07:23 2006 @@ -448,27 +448,23 @@ \begin{funcdesc}{localcontext}{\optional{c}} Return a context manager that will set the current context for - the active thread to a copy of \var{c} on entry to the with statement - and restore the previous context when exiting the with statement. If + the active thread to a copy of \var{c} on entry to the with-statement + and restore the previous context when exiting the with-statement. If no context is specified, a copy of the current context is used. + \versionadded{2.5} - For example the following code increases the current decimal precision + For example, the following code increases the current decimal precision by 42 places, performs a calculation, and then automatically restores the previous context: \begin{verbatim} from __future__ import with_statement import decimal - with decimal.localcontext() as ctx: + with localcontext() as ctx: ctx.prec = 42 # Perform a high precision calculation s = calculate_something() s = +s # Round the final result back to the default precision \end{verbatim} - - The context that is held by the context manager and made active in the - body of the \keyword{with} statement is a \emph{copy} of the context - you provide to this function, so modifying its attributes doesn't - affect anything except that temporary copy. \end{funcdesc} New contexts can also be created using the \class{Context} constructor Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat Sep 2 19:07:23 2006 @@ -685,20 +685,19 @@ The \module{decimal} module's contexts, which encapsulate the desired precision and rounding characteristics for computations, provide a -\method{context_manager()} method for getting a context manager: +\function{localcontext()} function for getting a context manager: \begin{verbatim} -import decimal +from decimal import Decimal, Context, localcontext # Displays with default precision of 28 digits -v1 = decimal.Decimal('578') -print v1.sqrt() +v = Decimal('578') +print v.sqrt() -ctx = decimal.Context(prec=16) -with ctx.context_manager(): +with localcontext(Context(prec=16)): # All code in this block uses a precision of 16 digits. # The original context is restored on exiting the block. - print v1.sqrt() + print v.sqrt() \end{verbatim} \subsection{Writing Context Managers\label{context-managers}} From python-checkins at python.org Sat Sep 2 19:21:40 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 2 Sep 2006 19:21:40 +0200 (CEST) Subject: [Python-checkins] r51689 - peps/trunk/pep-0362.txt Message-ID: <20060902172140.7A1C01E4003@bag.python.org> Author: george.yoshida Date: Sat Sep 2 19:21:40 2006 New Revision: 51689 Modified: peps/trunk/pep-0362.txt Log: Typo fix Modified: peps/trunk/pep-0362.txt ============================================================================== --- peps/trunk/pep-0362.txt (original) +++ peps/trunk/pep-0362.txt Sat Sep 2 19:21:40 2006 @@ -45,7 +45,7 @@ function objects for methods do not know the class they are contained within. This makes functions and methods indistinguishable from one another when passed to decorators, - prevventing proper creation of a fully qualified name. + preventing proper creation of a fully qualified name. indistinguishable from * var_args:str Name of the ``*args`` parameter, if present, else the empty From python-checkins at python.org Sat Sep 2 20:51:35 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 2 Sep 2006 20:51:35 +0200 (CEST) Subject: [Python-checkins] r51690 - python/trunk/Lib/decimal.py Message-ID: <20060902185135.7D75D1E4010@bag.python.org> Author: neal.norwitz Date: Sat Sep 2 20:51:34 2006 New Revision: 51690 Modified: python/trunk/Lib/decimal.py Log: Add missing word in comment Modified: python/trunk/Lib/decimal.py ============================================================================== --- python/trunk/Lib/decimal.py (original) +++ python/trunk/Lib/decimal.py Sat Sep 2 20:51:34 2006 @@ -479,7 +479,7 @@ return +s # Convert result to normal context """ - # The below can't be included in the docstring until Python 2.6 + # The string below can't be included in the docstring until Python 2.6 # as the doctest module doesn't understand __future__ statements """ >>> from __future__ import with_statement From buildbot at python.org Sat Sep 2 21:33:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 19:33:44 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060902193344.3D45F1E4003@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1251 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz,nick.coghlan,raymond.hettinger Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat Sep 2 21:40:19 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 2 Sep 2006 21:40:19 +0200 (CEST) Subject: [Python-checkins] r51691 - python/trunk/Lib/test/test_tokenize.py Message-ID: <20060902194019.BE6171E4003@bag.python.org> Author: neal.norwitz Date: Sat Sep 2 21:40:19 2006 New Revision: 51691 Modified: python/trunk/Lib/test/test_tokenize.py Log: Hmm, this test has failed at least twice recently on the OpenBSD and Debian sparc buildbots. Since this goes through a lot of tests and hits the disk a lot it could be slow (especially if NFS is involved). I'm not sure if that's the problem, but printing periodic msgs shouldn't hurt. The code was stolen from test_compiler. Modified: python/trunk/Lib/test/test_tokenize.py ============================================================================== --- python/trunk/Lib/test/test_tokenize.py (original) +++ python/trunk/Lib/test/test_tokenize.py Sat Sep 2 21:40:19 2006 @@ -79,13 +79,16 @@ """ -import os, glob, random +import os, glob, random, time, sys from cStringIO import StringIO from test.test_support import (verbose, findfile, is_resource_enabled, TestFailed) from tokenize import (tokenize, generate_tokens, untokenize, tok_name, ENDMARKER, NUMBER, NAME, OP, STRING, COMMENT) +# How much time in seconds can pass before we print a 'Still working' message. +_PRINT_WORKING_MSG_INTERVAL = 5 * 60 + # Test roundtrip for `untokenize`. `f` is a file path. The source code in f # is tokenized, converted back to source code via tokenize.untokenize(), # and tokenized again from the latter. The test fails if the second @@ -164,6 +167,8 @@ if verbose: print 'starting...' + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + # This displays the tokenization of tokenize_tests.py to stdout, and # regrtest.py checks that this equals the expected output (in the # test/output/ directory). @@ -183,6 +188,12 @@ testfiles = random.sample(testfiles, 10) for f in testfiles: + # Print still working message since this test can be really slow + if next_time <= time.time(): + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + print >>sys.__stdout__, ' test_main still working, be patient...' + sys.__stdout__.flush() + test_roundtrip(f) # Test detecton of IndentationError. From buildbot at python.org Sun Sep 3 00:58:13 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 02 Sep 2006 22:58:13 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian trunk Message-ID: <20060902225813.DE5451E4003@bag.python.org> The Buildbot has detected a new failure of MIPS Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/MIPS%2520Debian%2520trunk/builds/397 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: armin.rigo,brett.cannon,marc-andre.lemburg,neal.norwitz,nick.coghlan Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Sun Sep 3 02:04:27 2006 From: python-checkins at python.org (neal.norwitz) Date: Sun, 3 Sep 2006 02:04:27 +0200 (CEST) Subject: [Python-checkins] r51692 - python/branches/release25-maint/Doc/lib/libhashlib.tex Message-ID: <20060903000427.2308C1E4003@bag.python.org> Author: neal.norwitz Date: Sun Sep 3 02:04:26 2006 New Revision: 51692 Modified: python/branches/release25-maint/Doc/lib/libhashlib.tex Log: Backport 51663: Doc fix: hashlib objects don't always return a digest of 16 bytes. Modified: python/branches/release25-maint/Doc/lib/libhashlib.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libhashlib.tex (original) +++ python/branches/release25-maint/Doc/lib/libhashlib.tex Sun Sep 3 02:04:26 2006 @@ -86,8 +86,8 @@ \begin{methoddesc}[hash]{digest}{} Return the digest of the strings passed to the \method{update()} -method so far. This is a 16-byte string which may contain -non-\ASCII{} characters, including null bytes. +method so far. This is a string of \member{digest_size} bytes which may +contain non-\ASCII{} characters, including null bytes. \end{methoddesc} \begin{methoddesc}[hash]{hexdigest}{} From python-checkins at python.org Sun Sep 3 03:02:03 2006 From: python-checkins at python.org (nick.coghlan) Date: Sun, 3 Sep 2006 03:02:03 +0200 (CEST) Subject: [Python-checkins] r51693 - in python/trunk/Doc: lib/libdecimal.tex whatsnew/whatsnew25.tex Message-ID: <20060903010203.4491F1E4003@bag.python.org> Author: nick.coghlan Date: Sun Sep 3 03:02:00 2006 New Revision: 51693 Modified: python/trunk/Doc/lib/libdecimal.tex python/trunk/Doc/whatsnew/whatsnew25.tex Log: Fix final documentation nits before backporting decimal module fixes to 2.5 Modified: python/trunk/Doc/lib/libdecimal.tex ============================================================================== --- python/trunk/Doc/lib/libdecimal.tex (original) +++ python/trunk/Doc/lib/libdecimal.tex Sun Sep 3 03:02:00 2006 @@ -453,12 +453,12 @@ no context is specified, a copy of the current context is used. \versionadded{2.5} - For example, the following code increases the current decimal precision - by 42 places, performs a calculation, and then automatically restores + For example, the following code set the current decimal precision + to 42 places, performs a calculation, and then automatically restores the previous context: \begin{verbatim} from __future__ import with_statement - import decimal + from decimal import localcontext with localcontext() as ctx: ctx.prec = 42 # Perform a high precision calculation Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sun Sep 3 03:02:00 2006 @@ -683,9 +683,10 @@ The lock is acquired before the block is executed and always released once the block is complete. -The \module{decimal} module's contexts, which encapsulate the desired -precision and rounding characteristics for computations, provide a -\function{localcontext()} function for getting a context manager: +The new \function{localcontext()} function in the \module{decimal} module +makes it easy to save and restore the current decimal context, which +encapsulates the desired precision and rounding characteristics for +computations: \begin{verbatim} from decimal import Decimal, Context, localcontext From python-checkins at python.org Sun Sep 3 03:06:08 2006 From: python-checkins at python.org (nick.coghlan) Date: Sun, 3 Sep 2006 03:06:08 +0200 (CEST) Subject: [Python-checkins] r51694 - python/trunk/Doc/lib/libdecimal.tex Message-ID: <20060903010608.AAFF41E4003@bag.python.org> Author: nick.coghlan Date: Sun Sep 3 03:06:07 2006 New Revision: 51694 Modified: python/trunk/Doc/lib/libdecimal.tex Log: Typo fix for decimal docs Modified: python/trunk/Doc/lib/libdecimal.tex ============================================================================== --- python/trunk/Doc/lib/libdecimal.tex (original) +++ python/trunk/Doc/lib/libdecimal.tex Sun Sep 3 03:06:07 2006 @@ -453,7 +453,7 @@ no context is specified, a copy of the current context is used. \versionadded{2.5} - For example, the following code set the current decimal precision + For example, the following code sets the current decimal precision to 42 places, performs a calculation, and then automatically restores the previous context: \begin{verbatim} From python-checkins at python.org Sun Sep 3 03:08:31 2006 From: python-checkins at python.org (nick.coghlan) Date: Sun, 3 Sep 2006 03:08:31 +0200 (CEST) Subject: [Python-checkins] r51695 - in python/branches/release25-maint: Doc/lib/libdecimal.tex Doc/whatsnew/whatsnew25.tex Lib/decimal.py Lib/test/test_contextlib.py Lib/test/test_decimal.py Message-ID: <20060903010831.A73B81E4003@bag.python.org> Author: nick.coghlan Date: Sun Sep 3 03:08:30 2006 New Revision: 51695 Modified: python/branches/release25-maint/Doc/lib/libdecimal.tex python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex python/branches/release25-maint/Lib/decimal.py python/branches/release25-maint/Lib/test/test_contextlib.py python/branches/release25-maint/Lib/test/test_decimal.py Log: Backport of decimal module context management updates from rev 51694 to 2.5 release branch Modified: python/branches/release25-maint/Doc/lib/libdecimal.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libdecimal.tex (original) +++ python/branches/release25-maint/Doc/lib/libdecimal.tex Sun Sep 3 03:08:30 2006 @@ -435,36 +435,37 @@ the \function{getcontext()} and \function{setcontext()} functions: \begin{funcdesc}{getcontext}{} - Return the current context for the active thread. + Return the current context for the active thread. \end{funcdesc} \begin{funcdesc}{setcontext}{c} - Set the current context for the active thread to \var{c}. + Set the current context for the active thread to \var{c}. \end{funcdesc} Beginning with Python 2.5, you can also use the \keyword{with} statement -to temporarily change the active context. For example the following code -increases the current decimal precision by 2 places, performs a -calculation, and then automatically restores the previous context: +and the \function{localcontext()} function to temporarily change the +active context. -\begin{verbatim} -from __future__ import with_statement -import decimal - -with decimal.getcontext() as ctx: - ctx.prec += 2 # add 2 more digits of precision - calculate_something() +\begin{funcdesc}{localcontext}{\optional{c}} + Return a context manager that will set the current context for + the active thread to a copy of \var{c} on entry to the with-statement + and restore the previous context when exiting the with-statement. If + no context is specified, a copy of the current context is used. + \versionadded{2.5} + + For example, the following code sets the current decimal precision + to 42 places, performs a calculation, and then automatically restores + the previous context: +\begin{verbatim} + from __future__ import with_statement + from decimal import localcontext + + with localcontext() as ctx: + ctx.prec = 42 # Perform a high precision calculation + s = calculate_something() + s = +s # Round the final result back to the default precision \end{verbatim} - -The context that's active in the body of the \keyword{with} statement is -a \emph{copy} of the context you provided to the \keyword{with} -statement, so modifying its attributes doesn't affect anything except -that temporary copy. - -You can use any decimal context in a \keyword{with} statement, but if -you just want to make a temporary change to some aspect of the current -context, it's easiest to just use \function{getcontext()} as shown -above. +\end{funcdesc} New contexts can also be created using the \class{Context} constructor described below. In addition, the module provides three pre-made Modified: python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex Sun Sep 3 03:08:30 2006 @@ -683,22 +683,22 @@ The lock is acquired before the block is executed and always released once the block is complete. -The \module{decimal} module's contexts, which encapsulate the desired -precision and rounding characteristics for computations, provide a -\method{context_manager()} method for getting a context manager: +The new \function{localcontext()} function in the \module{decimal} module +makes it easy to save and restore the current decimal context, which +encapsulates the desired precision and rounding characteristics for +computations: \begin{verbatim} -import decimal +from decimal import Decimal, Context, localcontext # Displays with default precision of 28 digits -v1 = decimal.Decimal('578') -print v1.sqrt() +v = Decimal('578') +print v.sqrt() -ctx = decimal.Context(prec=16) -with ctx.context_manager(): +with localcontext(Context(prec=16)): # All code in this block uses a precision of 16 digits. # The original context is restored on exiting the block. - print v1.sqrt() + print v.sqrt() \end{verbatim} \subsection{Writing Context Managers\label{context-managers}} Modified: python/branches/release25-maint/Lib/decimal.py ============================================================================== --- python/branches/release25-maint/Lib/decimal.py (original) +++ python/branches/release25-maint/Lib/decimal.py Sun Sep 3 03:08:30 2006 @@ -131,7 +131,7 @@ 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', # Functions for manipulating contexts - 'setcontext', 'getcontext' + 'setcontext', 'getcontext', 'localcontext' ] import copy as _copy @@ -458,6 +458,49 @@ del threading, local # Don't contaminate the namespace +def localcontext(ctx=None): + """Return a context manager for a copy of the supplied context + + Uses a copy of the current context if no context is specified + The returned context manager creates a local decimal context + in a with statement: + def sin(x): + with localcontext() as ctx: + ctx.prec += 2 + # Rest of sin calculation algorithm + # uses a precision 2 greater than normal + return +s # Convert result to normal precision + + def sin(x): + with localcontext(ExtendedContext): + # Rest of sin calculation algorithm + # uses the Extended Context from the + # General Decimal Arithmetic Specification + return +s # Convert result to normal context + + """ + # The below can't be included in the docstring until Python 2.6 + # as the doctest module doesn't understand __future__ statements + """ + >>> from __future__ import with_statement + >>> print getcontext().prec + 28 + >>> with localcontext(): + ... ctx = getcontext() + ... ctx.prec() += 2 + ... print ctx.prec + ... + 30 + >>> with localcontext(ExtendedContext): + ... print getcontext().prec + ... + 9 + >>> print getcontext().prec + 28 + """ + if ctx is None: ctx = getcontext() + return _ContextManager(ctx) + ##### Decimal class ########################################### @@ -2173,23 +2216,14 @@ del name, val, globalname, rounding_functions -class ContextManager(object): - """Helper class to simplify Context management. - - Sample usage: - - with decimal.ExtendedContext: - s = ... - return +s # Convert result to normal precision - - with decimal.getcontext() as ctx: - ctx.prec += 2 - s = ... - return +s +class _ContextManager(object): + """Context manager class to support localcontext(). + Sets a copy of the supplied context in __enter__() and restores + the previous decimal context in __exit__() """ def __init__(self, new_context): - self.new_context = new_context + self.new_context = new_context.copy() def __enter__(self): self.saved_context = getcontext() setcontext(self.new_context) @@ -2248,9 +2282,6 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' - def get_manager(self): - return ContextManager(self.copy()) - def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: Modified: python/branches/release25-maint/Lib/test/test_contextlib.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_contextlib.py (original) +++ python/branches/release25-maint/Lib/test/test_contextlib.py Sun Sep 3 03:08:30 2006 @@ -330,32 +330,6 @@ return True self.boilerPlate(lock, locked) -class DecimalContextTestCase(unittest.TestCase): - - # XXX Somebody should write more thorough tests for this - - def testBasic(self): - ctx = decimal.getcontext() - orig_context = ctx.copy() - try: - ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - self.assertEqual(decimal.getcontext().prec, save_prec) - try: - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - 1/0 - except ZeroDivisionError: - self.assertEqual(decimal.getcontext().prec, save_prec) - else: - self.fail("Didn't raise ZeroDivisionError") - finally: - decimal.setcontext(orig_context) - - # This is needed to make the test actually run under regrtest.py! def test_main(): run_suite( Modified: python/branches/release25-maint/Lib/test/test_decimal.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_decimal.py (original) +++ python/branches/release25-maint/Lib/test/test_decimal.py Sun Sep 3 03:08:30 2006 @@ -23,6 +23,7 @@ you're working through IDLE, you can import this test module and call test_main() with the corresponding argument. """ +from __future__ import with_statement import unittest import glob @@ -1064,6 +1065,32 @@ self.assertNotEqual(id(c.flags), id(d.flags)) self.assertNotEqual(id(c.traps), id(d.traps)) +class WithStatementTest(unittest.TestCase): + # Can't do these as docstrings until Python 2.6 + # as doctest can't handle __future__ statements + + def test_localcontext(self): + # Use a copy of the current context in the block + orig_ctx = getcontext() + with localcontext() as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(orig_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + + def test_localcontextarg(self): + # Use a copy of the supplied context in the block + orig_ctx = getcontext() + new_ctx = Context(prec=42) + with localcontext(new_ctx) as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context') + self.assert_(new_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + def test_main(arith=False, verbose=None): """ Execute the tests. @@ -1084,6 +1111,7 @@ DecimalPythonAPItests, ContextAPItests, DecimalTest, + WithStatementTest, ] try: From python-checkins at python.org Sun Sep 3 03:13:07 2006 From: python-checkins at python.org (nick.coghlan) Date: Sun, 3 Sep 2006 03:13:07 +0200 (CEST) Subject: [Python-checkins] r51696 - python/branches/release25-maint/Misc/NEWS Message-ID: <20060903011307.569671E4003@bag.python.org> Author: nick.coghlan Date: Sun Sep 3 03:13:06 2006 New Revision: 51696 Modified: python/branches/release25-maint/Misc/NEWS Log: NEWS entry for decimal module changes Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sun Sep 3 03:13:06 2006 @@ -19,6 +19,9 @@ Library ------- +- Patch #1550886: Fix decimal module context management implementation + to match the localcontext() example from PEP 343 + - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. From python-checkins at python.org Sun Sep 3 03:20:47 2006 From: python-checkins at python.org (nick.coghlan) Date: Sun, 3 Sep 2006 03:20:47 +0200 (CEST) Subject: [Python-checkins] r51697 - python/trunk/Misc/NEWS Message-ID: <20060903012047.14BD21E4003@bag.python.org> Author: nick.coghlan Date: Sun Sep 3 03:20:46 2006 New Revision: 51697 Modified: python/trunk/Misc/NEWS Log: NEWS entry on trunk for decimal module changes Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Sep 3 03:20:46 2006 @@ -4,8 +4,8 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.6? -========================= +What's New in Python 2.6 alpha 1? +================================= *Release date: XX-XXX-200X* @@ -18,6 +18,9 @@ Library ------- +- Patch #1550886: Fix decimal module context management implementation + to match the localcontext() example from PEP 343 + - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. From buildbot at python.org Sun Sep 3 05:10:56 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 03 Sep 2006 03:10:56 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060903031056.991981E4003@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.5/builds/10 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: fred.drake,georg.brandl,neal.norwitz,nick.coghlan Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sun Sep 3 18:22:29 2006 From: python-checkins at python.org (jackilyn.hoxworth) Date: Sun, 3 Sep 2006 18:22:29 +0200 (CEST) Subject: [Python-checkins] r51698 - python/branches/hoxworth-stdlib_logging-soc/new_soc_logging_test.py python/branches/hoxworth-stdlib_logging-soc/pep_update.txt python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py python/branches/hoxworth-stdlib_logging-soc/test_stmpd_logging.py python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py Message-ID: <20060903162229.535B21E4003@bag.python.org> Author: jackilyn.hoxworth Date: Sun Sep 3 18:22:27 2006 New Revision: 51698 Added: python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py Removed: python/branches/hoxworth-stdlib_logging-soc/new_soc_logging_test.py python/branches/hoxworth-stdlib_logging-soc/test_stmpd_logging.py Modified: python/branches/hoxworth-stdlib_logging-soc/pep_update.txt Log: created tests for the logging Deleted: /python/branches/hoxworth-stdlib_logging-soc/new_soc_logging_test.py ============================================================================== --- /python/branches/hoxworth-stdlib_logging-soc/new_soc_logging_test.py Sun Sep 3 18:22:27 2006 +++ (empty file) @@ -1,42 +0,0 @@ -import httplib -reload(httplib) -import fakesocket -import logging -from cStringIO import StringIO - -origsocket=httplib.socket -# monkeypatch -- replace httplib.socket with our own fake module -httplib.socket=fakesocket - -# ... run the tests ... -log=logging.getLogger("py.httplib") -stringLog = StringIO() - -# define the handler and level -handler = logging.StreamHandler(stringLog) -log.setLevel(logging.INFO) - -# add the handler to the logger -log.addHandler(handler) - -httplib._log.info("message 1") # 1st test - -myconn = httplib.HTTPConnection('www.google.com') -myconn.set_debuglevel(43) -if myconn.debuglevel > 0: - print "Debug level is > 0" - -#myconn.connect() -httplib.HTTPConnection('MOCK') -myconn.putrequest("GET", "/search?q=python") -#myconn.getresponse() - -print stringLog.getvalue() # For testing purposes - -if stringLog.getvalue() != "Error: It worked": - print "it worked" -else: - print "it didn't work" - -# restore it to working order, so other tests won't fail -httplib.socket=origsocket \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/pep_update.txt ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/pep_update.txt (original) +++ python/branches/hoxworth-stdlib_logging-soc/pep_update.txt Sun Sep 3 18:22:27 2006 @@ -5,17 +5,17 @@ BaseHTTPServer.py - done but no test case created SocketServer.py - done but no test case created asyncore.py - done -gopherlib.py - done but no test case created -httplib - done with a test case almost completed -ihooks.py - done but no test case created -imaplib.py - done but no test case created -mhlib.py - done but no test case created -nntplib.py - done but no test case created -pipes.py - done but no test case created -pkgutil.py - done but no test case created +gopherlib.py - done +httplib - done +ihooks.py - done +imaplib.py - done +mhlib.py - done +nntplib.py - done +pipes.py - done +pkgutil.py - done robotparser.py - done shlex.py - done smtpd.py - done -threading.py - done but no test case created -timeit.py - done but no test case created +threading.py - done and test case really close to completion, small problem +timeit.py - done trace.py - done but no test case created \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import gopherlib +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.gopherlib") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +gopherlib._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,42 @@ +import httplib +reload(httplib) +import fakesocket +import logging +from cStringIO import StringIO + +origsocket=httplib.socket +# monkeypatch -- replace httplib.socket with our own fake module +httplib.socket=fakesocket + +# ... run the tests ... +log=logging.getLogger("py.httplib") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +httplib._log.info("message 1") # 1st test + +myconn = httplib.HTTPConnection('www.google.com') +myconn.set_debuglevel(43) +if myconn.debuglevel > 0: + print "Debug level is > 0" + +#myconn.connect() +httplib.HTTPConnection('MOCK') +myconn.putrequest("GET", "/search?q=python") +#myconn.getresponse() + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" + +# restore it to working order, so other tests won't fail +httplib.socket=origsocket \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import shlex +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.shlex") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +shlex._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import imaplib +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.imaplib") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +imaplib._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import mhlib +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.mhlib") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +mhlib._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import nntplib +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.nntplib") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +nntplib._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import pipes +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.pipes") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +pipes._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Deleted: /python/branches/hoxworth-stdlib_logging-soc/test_stmpd_logging.py ============================================================================== --- /python/branches/hoxworth-stdlib_logging-soc/test_stmpd_logging.py Sun Sep 3 18:22:27 2006 +++ (empty file) @@ -1,23 +0,0 @@ -import smtpd -import logging -from cStringIO import StringIO - -# ... run the tests ... -log=logging.getLogger("py.smtpd") -stringLog = StringIO() - -# define the handler and level -handler = logging.StreamHandler(stringLog) -log.setLevel(logging.INFO) - -# add the handler to the logger -log.addHandler(handler) - -smtpd._log.info("message 1") - -print stringLog.getvalue() # For testing purposes - -if stringLog.getvalue() != "Error: It worked": - print "it worked" -else: - print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import threading +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.threading") # says there isn't a _log attribute ??? +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +threading._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file Added: python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py Sun Sep 3 18:22:27 2006 @@ -0,0 +1,23 @@ +import timeit +import logging +from cStringIO import StringIO + +# ... run the tests ... +log=logging.getLogger("py.timeit") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# add the handler to the logger +log.addHandler(handler) + +timeit._log.info("message 1") + +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() != "Error: It worked": + print "it worked" +else: + print "it didn't work" \ No newline at end of file From python-checkins at python.org Sun Sep 3 22:00:40 2006 From: python-checkins at python.org (neal.norwitz) Date: Sun, 3 Sep 2006 22:00:40 +0200 (CEST) Subject: [Python-checkins] r51702 - python/branches/release25-maint/Lib/decimal.py Message-ID: <20060903200040.C1ACE1E4003@bag.python.org> Author: neal.norwitz Date: Sun Sep 3 22:00:39 2006 New Revision: 51702 Modified: python/branches/release25-maint/Lib/decimal.py Log: Backport doco Modified: python/branches/release25-maint/Lib/decimal.py ============================================================================== --- python/branches/release25-maint/Lib/decimal.py (original) +++ python/branches/release25-maint/Lib/decimal.py Sun Sep 3 22:00:39 2006 @@ -479,7 +479,7 @@ return +s # Convert result to normal context """ - # The below can't be included in the docstring until Python 2.6 + # The string below can't be included in the docstring until Python 2.6 # as the doctest module doesn't understand __future__ statements """ >>> from __future__ import with_statement From python-checkins at python.org Sun Sep 3 22:01:06 2006 From: python-checkins at python.org (neal.norwitz) Date: Sun, 3 Sep 2006 22:01:06 +0200 (CEST) Subject: [Python-checkins] r51703 - python/branches/release25-maint/Lib/doctest.py Message-ID: <20060903200106.5777C1E4003@bag.python.org> Author: neal.norwitz Date: Sun Sep 3 22:01:05 2006 New Revision: 51703 Modified: python/branches/release25-maint/Lib/doctest.py Log: Backport docos Modified: python/branches/release25-maint/Lib/doctest.py ============================================================================== --- python/branches/release25-maint/Lib/doctest.py (original) +++ python/branches/release25-maint/Lib/doctest.py Sun Sep 3 22:01:05 2006 @@ -1561,7 +1561,7 @@ - test: the DocTest object being run - - excample: the Example object that failed + - example: the Example object that failed - got: the actual output """ @@ -1580,7 +1580,7 @@ - test: the DocTest object being run - - excample: the Example object that failed + - example: the Example object that failed - exc_info: the exception info """ From python-checkins at python.org Mon Sep 4 17:32:50 2006 From: python-checkins at python.org (raymond.hettinger) Date: Mon, 4 Sep 2006 17:32:50 +0200 (CEST) Subject: [Python-checkins] r51704 - in python/trunk: Doc/lib/libstdtypes.tex Lib/test/string_tests.py Objects/stringlib/partition.h Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060904153250.4A03A1E400C@bag.python.org> Author: raymond.hettinger Date: Mon Sep 4 17:32:48 2006 New Revision: 51704 Modified: python/trunk/Doc/lib/libstdtypes.tex python/trunk/Lib/test/string_tests.py python/trunk/Objects/stringlib/partition.h python/trunk/Objects/stringobject.c python/trunk/Objects/unicodeobject.c Log: Fix endcase for str.rpartition() Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Mon Sep 4 17:32:48 2006 @@ -771,8 +771,8 @@ Split the string at the last occurrence of \var{sep}, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not -found, return a 3-tuple containing the string itself, followed by -two empty strings. +found, return a 3-tuple containing two empty strings, followed by +the string itself. \versionadded{2.5} \end{methoddesc} Modified: python/trunk/Lib/test/string_tests.py ============================================================================== --- python/trunk/Lib/test/string_tests.py (original) +++ python/trunk/Lib/test/string_tests.py Mon Sep 4 17:32:48 2006 @@ -1069,7 +1069,7 @@ # from raymond's original specification S = 'http://www.python.org' self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') - self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') + self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') Modified: python/trunk/Objects/stringlib/partition.h ============================================================================== --- python/trunk/Objects/stringlib/partition.h (original) +++ python/trunk/Objects/stringlib/partition.h Mon Sep 4 17:32:48 2006 @@ -78,12 +78,12 @@ } if (pos < 0) { - Py_INCREF(str_obj); - PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); return out; } Modified: python/trunk/Objects/stringobject.c ============================================================================== --- python/trunk/Objects/stringobject.c (original) +++ python/trunk/Objects/stringobject.c Mon Sep 4 17:32:48 2006 @@ -1543,11 +1543,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject * string_rpartition(PyStringObject *self, PyObject *sep_obj) Modified: python/trunk/Objects/unicodeobject.c ============================================================================== --- python/trunk/Objects/unicodeobject.c (original) +++ python/trunk/Objects/unicodeobject.c Mon Sep 4 17:32:48 2006 @@ -6712,11 +6712,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject* unicode_rpartition(PyUnicodeObject *self, PyObject *separator) From buildbot at python.org Mon Sep 4 19:37:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 04 Sep 2006 17:37:05 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060904173705.A514F1E4005@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/537 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan,raymond.hettinger Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon Sep 4 22:50:35 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 4 Sep 2006 22:50:35 +0200 (CEST) Subject: [Python-checkins] r51705 - sandbox/trunk/trackers/trackers.txt Message-ID: <20060904205035.EE2CD1E4019@bag.python.org> Author: brett.cannon Date: Mon Sep 4 22:50:35 2006 New Revision: 51705 Modified: sandbox/trunk/trackers/trackers.txt Log: Added how to get password info for the Trac install. Modified: sandbox/trunk/trackers/trackers.txt ============================================================================== --- sandbox/trunk/trackers/trackers.txt (original) +++ sandbox/trunk/trackers/trackers.txt Mon Sep 4 22:50:35 2006 @@ -63,3 +63,11 @@ Cannon should enter brett at python.org to get a password reset mail sent to him). + +Trac +============================= + +Your username is the name of your python.org email address. For the +password, email either Alec Thomas (alec at swapoff.org) or Noah +Kantrowitz (kantrn at rpi.edu). + From python-checkins at python.org Tue Sep 5 03:36:43 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 03:36:43 +0200 (CEST) Subject: [Python-checkins] r51710 - python/branches/release25-maint/Misc/RPM/python-2.5.spec Message-ID: <20060905013643.A232A1E4011@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 03:36:43 2006 New Revision: 51710 Modified: python/branches/release25-maint/Misc/RPM/python-2.5.spec Log: SF patch #1551340 ] Updated spec file for 2.5 release (c2) Modified: python/branches/release25-maint/Misc/RPM/python-2.5.spec ============================================================================== --- python/branches/release25-maint/Misc/RPM/python-2.5.spec (original) +++ python/branches/release25-maint/Misc/RPM/python-2.5.spec Tue Sep 5 03:36:43 2006 @@ -33,7 +33,7 @@ ################################# %define name python -%define version 2.5c1 +%define version 2.5c2 %define libvers 2.5 %define release 1pydotorg %define __prefix /usr @@ -52,7 +52,7 @@ Name: %{name}%{binsuffix} Version: %{version} Release: %{release} -Copyright: Modified CNRI Open Source License +License: Python Software Foundation Group: Development/Languages Source: Python-%{version}.tar.bz2 %if %{include_docs} @@ -239,14 +239,16 @@ # REPLACE PATH IN PYDOC if [ ! -z "%{binsuffix}" ] then - ( - cd $RPM_BUILD_ROOT%{__prefix}/bin - mv pydoc pydoc.old - sed 's|#!.*|#!%{__prefix}/bin/env python'%{binsuffix}'|' \ - pydoc.old >pydoc - chmod 755 pydoc - rm -f pydoc.old - ) + for file in pydoc python-config; do + ( + cd $RPM_BUILD_ROOT%{__prefix}/bin + mv "$file" "$file".old + sed 's|#!.*|#!%{__prefix}/bin/env python'%{binsuffix}'|' \ + "$file".old >"$file" + chmod 755 "$file" + rm -f "$file".old + ) + done fi # add the binsuffix @@ -255,8 +257,10 @@ ( cd $RPM_BUILD_ROOT%{__prefix}/bin; rm -f python[0-9a-zA-Z]*; mv -f python python"%{binsuffix}" ) ( cd $RPM_BUILD_ROOT%{__prefix}/man/man1; mv python.1 python%{binsuffix}.1 ) - ( cd $RPM_BUILD_ROOT%{__prefix}/bin; mv -f pydoc pydoc"%{binsuffix}" ) - ( cd $RPM_BUILD_ROOT%{__prefix}/bin; mv -f idle idle"%{binsuffix}" ) + ( cd $RPM_BUILD_ROOT%{__prefix}/bin; mv -f smtpd.py python-smtpd ) + for file in pydoc idle python-config python-smtpd; do + ( cd $RPM_BUILD_ROOT%{__prefix}/bin; mv -f "$file" "$file""%{binsuffix}" ) + done fi ######## @@ -276,13 +280,19 @@ grep -v -e '_tkinter.so$' >mainpkg.files find "$RPM_BUILD_ROOT""%{__prefix}"/bin -type f | sed "s|^${RPM_BUILD_ROOT}|/|" | + grep -v -e '/bin/setup-config%{binsuffix}$' | grep -v -e '/bin/idle%{binsuffix}$' >>mainpkg.files rm -f tools.files find "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/idlelib \ "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/Tools -type f | + grep -v -e '\\.pyc$' -e '\\.pyo$' | sed "s|^${RPM_BUILD_ROOT}|/|" >tools.files echo "%{__prefix}"/bin/idle%{binsuffix} >>tools.files +grep '\.py$' tools.files | sed 's/$/c/' | grep -v /idlelib/ >tools.files.tmp +grep '\.py$' tools.files | sed 's/$/o/' | grep -v /idlelib/ >>tools.files.tmp +cat tools.files.tmp >>tools.files +rm tools.files.tmp ###### # Docs @@ -346,7 +356,6 @@ %{__prefix}/%{libdirname}/python%{libvers}/*.txt %{__prefix}/%{libdirname}/python%{libvers}/*.py* %{__prefix}/%{libdirname}/python%{libvers}/pdb.doc -%{__prefix}/%{libdirname}/python%{libvers}/profile.doc %{__prefix}/%{libdirname}/python%{libvers}/curses %{__prefix}/%{libdirname}/python%{libvers}/distutils %{__prefix}/%{libdirname}/python%{libvers}/encodings @@ -355,13 +364,14 @@ %{__prefix}/%{libdirname}/python%{libvers}/test %{__prefix}/%{libdirname}/python%{libvers}/xml %{__prefix}/%{libdirname}/python%{libvers}/email -%{__prefix}/%{libdirname}/python%{libvers}/email/mime %{__prefix}/%{libdirname}/python%{libvers}/sqlite3 %{__prefix}/%{libdirname}/python%{libvers}/compiler %{__prefix}/%{libdirname}/python%{libvers}/bsddb %{__prefix}/%{libdirname}/python%{libvers}/hotshot %{__prefix}/%{libdirname}/python%{libvers}/logging -%{__prefix}/%{libdirname}/python%{libvers}/lib-old +%{__prefix}/%{libdirname}/python%{libvers}/wsgiref +%{__prefix}/%{libdirname}/python%{libvers}/ctypes +%{__prefix}/%{libdirname}/python%{libvers}/wsgiref.egg-info %files devel %defattr(-,root,root) From python-checkins at python.org Tue Sep 5 03:47:54 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 5 Sep 2006 03:47:54 +0200 (CEST) Subject: [Python-checkins] r51711 - in python/branches/release25-maint: Misc/NEWS Objects/intobject.c Message-ID: <20060905014754.265B11E4004@bag.python.org> Author: tim.peters Date: Tue Sep 5 03:47:53 2006 New Revision: 51711 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/intobject.c Log: i_divmod(): As discussed on Python-Dev, changed the overflow checking to live happily with recent gcc optimizations that assume signed integer arithmetic never overflows. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 03:47:53 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Overflow checking code in integer division ran afoul of new gcc + optimizations. Changed to be more standard-conforming. + - Patch #1541585: fix buffer overrun when performing repr() on a unicode string in a build with wide unicode (UCS-4) support. @@ -127,7 +130,7 @@ - The __repr__ method of a NULL ctypes.py_object() no longer raises an exception. -- uuid.UUID now has a bytes_le attribute. This returns the UUID in +- uuid.UUID now has a bytes_le attribute. This returns the UUID in little-endian byte order for Windows. In addition, uuid.py gained some workarounds for clocks with low resolution, to stop the code yielding duplicate UUIDs. @@ -286,7 +289,7 @@ - Bug #1002398: The documentation for os.path.sameopenfile now correctly refers to file descriptors, not file objects. -- The renaming of the xml package to xmlcore, and the import hackery done +- The renaming of the xml package to xmlcore, and the import hackery done to make it appear at both names, has been removed. Bug #1511497, #1513611, and probably others. Modified: python/branches/release25-maint/Objects/intobject.c ============================================================================== --- python/branches/release25-maint/Objects/intobject.c (original) +++ python/branches/release25-maint/Objects/intobject.c Tue Sep 5 03:47:53 2006 @@ -564,8 +564,14 @@ "integer division or modulo by zero"); return DIVMOD_ERROR; } - /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) + /* (-sys.maxint-1)/-1 is the only overflow case. x is the most + * negative long iff x < 0 and, on a 2's-complement box, x == -x. + * However, -x is undefined (by C) if x /is/ the most negative long + * (it's a signed overflow case), and some compilers care. So we cast + * x to unsigned long first. However, then other compilers warn about + * applying unary minus to an unsigned operand. Hence the weird "0-". + */ + if (y == -1 && x < 0 && (unsigned long)x == 0-(unsigned long)x) return DIVMOD_OVERFLOW; xdivy = x / y; xmody = x - xdivy * y; From python-checkins at python.org Tue Sep 5 03:52:01 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 03:52:01 +0200 (CEST) Subject: [Python-checkins] r51712 - python/branches/release25-maint/Python/bltinmodule.c Message-ID: <20060905015201.497531E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 03:52:00 2006 New Revision: 51712 Modified: python/branches/release25-maint/Python/bltinmodule.c Log: Fix SF #1552093, eval docstring typo (3 ps in mapping) Modified: python/branches/release25-maint/Python/bltinmodule.c ============================================================================== --- python/branches/release25-maint/Python/bltinmodule.c (original) +++ python/branches/release25-maint/Python/bltinmodule.c Tue Sep 5 03:52:00 2006 @@ -607,7 +607,7 @@ Evaluate the source in the context of globals and locals.\n\ The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ -The globals must be a dictionary and locals can be any mappping,\n\ +The globals must be a dictionary and locals can be any mapping,\n\ defaulting to the current globals and locals.\n\ If only globals is given, locals defaults to it.\n"); From python-checkins at python.org Tue Sep 5 03:54:06 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 03:54:06 +0200 (CEST) Subject: [Python-checkins] r51713 - in python/branches/release25-maint: Lib/test/test_mutants.py Misc/NEWS Objects/dictobject.c Message-ID: <20060905015406.DACFA1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 03:54:06 2006 New Revision: 51713 Modified: python/branches/release25-maint/Lib/test/test_mutants.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/dictobject.c Log: Fix SF bug #1546288, crash in dict_equal Modified: python/branches/release25-maint/Lib/test/test_mutants.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_mutants.py (original) +++ python/branches/release25-maint/Lib/test/test_mutants.py Tue Sep 5 03:54:06 2006 @@ -91,12 +91,17 @@ self.hashcode = random.randrange(1000000000) def __hash__(self): + return 42 return self.hashcode def __cmp__(self, other): maybe_mutate() # The point of the test. return cmp(self.i, other.i) + def __eq__(self, other): + maybe_mutate() # The point of the test. + return self.i == other.i + def __repr__(self): return "Horrid(%d)" % self.i @@ -132,7 +137,10 @@ while dict1 and len(dict1) == len(dict2): if verbose: print ".", - c = cmp(dict1, dict2) + if random.random() < 0.5: + c = cmp(dict1, dict2) + else: + c = dict1 == dict2 if verbose: print Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 03:54:06 2006 @@ -9,6 +9,13 @@ *Release date: XX-SEP-2006* +(Hopefully nothing.) + +What's New in Python 2.5 release candidate 2? +============================================= + +*Release date: XX-SEP-2006* + Core and builtins ----------------- @@ -18,12 +25,14 @@ - Patch #1541585: fix buffer overrun when performing repr() on a unicode string in a build with wide unicode (UCS-4) support. +- Patch #1546288: fix seg fault in dict_equal due to ref counting bug. + Library ------- - Patch #1550886: Fix decimal module context management implementation - to match the localcontext() example from PEP 343 + to match the localcontext() example from PEP 343. - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. Modified: python/branches/release25-maint/Objects/dictobject.c ============================================================================== --- python/branches/release25-maint/Objects/dictobject.c (original) +++ python/branches/release25-maint/Objects/dictobject.c Tue Sep 5 03:54:06 2006 @@ -1585,7 +1585,10 @@ /* temporarily bump aval's refcount to ensure it stays alive until we're done with it */ Py_INCREF(aval); + /* ditto for key */ + Py_INCREF(key); bval = PyDict_GetItem((PyObject *)b, key); + Py_DECREF(key); if (bval == NULL) { Py_DECREF(aval); return 0; From python-checkins at python.org Tue Sep 5 04:00:23 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:00:23 +0200 (CEST) Subject: [Python-checkins] r51714 - in python/branches/release25-maint: Lib/bsddb/test/test_basics.py Misc/NEWS Message-ID: <20060905020023.2D5071E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:00:21 2006 New Revision: 51714 Modified: python/branches/release25-maint/Lib/bsddb/test/test_basics.py python/branches/release25-maint/Misc/NEWS Log: This was found by Guido AFAIK on p3yk (sic) branch. Modified: python/branches/release25-maint/Lib/bsddb/test/test_basics.py ============================================================================== --- python/branches/release25-maint/Lib/bsddb/test/test_basics.py (original) +++ python/branches/release25-maint/Lib/bsddb/test/test_basics.py Tue Sep 5 04:00:21 2006 @@ -697,7 +697,7 @@ for log in logs: if verbose: print 'log file: ' + log - if db.version >= (4,2): + if db.version() >= (4,2): logs = self.env.log_archive(db.DB_ARCH_REMOVE) assert not logs Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 04:00:21 2006 @@ -40,6 +40,13 @@ - Bug #1543303, patch #1543897: remove NUL padding from tarfiles. +Tests +----- + +- Fix bsddb test_basics.test06_Transactions to check the version + number properly. + + Documentation ------------- From python-checkins at python.org Tue Sep 5 04:00:52 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 5 Sep 2006 04:00:52 +0200 (CEST) Subject: [Python-checkins] r51715 - in python/branches/release24-maint: Misc/NEWS Objects/intobject.c Message-ID: <20060905020052.DE5511E4004@bag.python.org> Author: tim.peters Date: Tue Sep 5 04:00:47 2006 New Revision: 51715 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Objects/intobject.c Log: Merge rev 51711 from the 2.5 branch. i_divmod(): As discussed on Python-Dev, changed the overflow checking to live happily with recent gcc optimizations that assume signed integer arithmetic never overflows. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Tue Sep 5 04:00:47 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Overflow checking code in integer division ran afoul of new gcc + optimizations. Changed to be more standard-conforming. + - Patch #1541585: fix buffer overrun when performing repr() on a unicode string in a build with wide unicode (UCS-4) support. Modified: python/branches/release24-maint/Objects/intobject.c ============================================================================== --- python/branches/release24-maint/Objects/intobject.c (original) +++ python/branches/release24-maint/Objects/intobject.c Tue Sep 5 04:00:47 2006 @@ -478,8 +478,14 @@ "integer division or modulo by zero"); return DIVMOD_ERROR; } - /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) + /* (-sys.maxint-1)/-1 is the only overflow case. x is the most + * negative long iff x < 0 and, on a 2's-complement box, x == -x. + * However, -x is undefined (by C) if x /is/ the most negative long + * (it's a signed overflow case), and some compilers care. So we cast + * x to unsigned long first. However, then other compilers warn about + * applying unary minus to an unsigned operand. Hence the weird "0-". + */ + if (y == -1 && x < 0 && (unsigned long)x == 0-(unsigned long)x) return DIVMOD_OVERFLOW; xdivy = x / y; xmody = x - xdivy * y; From python-checkins at python.org Tue Sep 5 04:18:10 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 5 Sep 2006 04:18:10 +0200 (CEST) Subject: [Python-checkins] r51716 - in python/trunk: Misc/NEWS Objects/intobject.c Message-ID: <20060905021810.D3F6D1E400E@bag.python.org> Author: tim.peters Date: Tue Sep 5 04:18:09 2006 New Revision: 51716 Modified: python/trunk/Misc/NEWS python/trunk/Objects/intobject.c Log: "Conceptual" merge of rev 51711 from the 2.5 branch. i_divmod(): As discussed on Python-Dev, changed the overflow checking to live happily with recent gcc optimizations that assume signed integer arithmetic never overflows. This differs from the corresponding change on the 2.5 and 2.4 branches, using a less obscure approach, but one that /may/ tickle platform idiocies in their definitions of LONG_MIN. The 2.4 + 2.5 change avoided introducing a dependence on LONG_MIN, at the cost of substantially goofier code. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 04:18:09 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Overflow checking code in integer division ran afoul of new gcc + optimizations. Changed to be more standard-conforming. + - Patch #1542451: disallow continue anywhere under a finally. @@ -136,7 +139,7 @@ - The __repr__ method of a NULL ctypes.py_object() no longer raises an exception. -- uuid.UUID now has a bytes_le attribute. This returns the UUID in +- uuid.UUID now has a bytes_le attribute. This returns the UUID in little-endian byte order for Windows. In addition, uuid.py gained some workarounds for clocks with low resolution, to stop the code yielding duplicate UUIDs. @@ -295,7 +298,7 @@ - Bug #1002398: The documentation for os.path.sameopenfile now correctly refers to file descriptors, not file objects. -- The renaming of the xml package to xmlcore, and the import hackery done +- The renaming of the xml package to xmlcore, and the import hackery done to make it appear at both names, has been removed. Bug #1511497, #1513611, and probably others. Modified: python/trunk/Objects/intobject.c ============================================================================== --- python/trunk/Objects/intobject.c (original) +++ python/trunk/Objects/intobject.c Tue Sep 5 04:18:09 2006 @@ -565,7 +565,7 @@ return DIVMOD_ERROR; } /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) + if (y == -1 && x == LONG_MIN) return DIVMOD_OVERFLOW; xdivy = x / y; xmody = x - xdivy * y; From python-checkins at python.org Tue Sep 5 04:21:19 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 5 Sep 2006 04:21:19 +0200 (CEST) Subject: [Python-checkins] r51717 - python/trunk/Lib/genericpath.py Message-ID: <20060905022119.F2ECB1E4009@bag.python.org> Author: tim.peters Date: Tue Sep 5 04:21:19 2006 New Revision: 51717 Modified: python/trunk/Lib/genericpath.py Log: Whitespace normalization. Modified: python/trunk/Lib/genericpath.py ============================================================================== --- python/trunk/Lib/genericpath.py (original) +++ python/trunk/Lib/genericpath.py Tue Sep 5 04:21:19 2006 @@ -1,78 +1,77 @@ -""" -Path operations common to more than one OS -Do not use directly. The OS specific modules import the appropriate -functions from this module themselves. -""" -import os -import stat - -__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime', - 'getsize', 'isdir', 'isfile'] - - -# Does a path exist? -# This is false for dangling symbolic links on systems that support them. -def exists(path): - """Test whether a path exists. Returns False for broken symbolic links""" - try: - st = os.stat(path) - except os.error: - return False - return True - - -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path ono systems that support symlinks -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISREG(st.st_mode) - - -# Is a path a directory? -# This follows symbolic links, so both islink() and isdir() -# can be true for the same path on systems that support symlinks -def isdir(s): - """Return true if the pathname refers to an existing directory.""" - try: - st = os.stat(s) - except os.error: - return False - return stat.S_ISDIR(st.st_mode) - - -def getsize(filename): - """Return the size of a file, reported by os.stat().""" - return os.stat(filename).st_size - - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat().""" - return os.stat(filename).st_mtime - - -def getatime(filename): - """Return the last access time of a file, reported by os.stat().""" - return os.stat(filename).st_atime - - -def getctime(filename): - """Return the metadata change time of a file, reported by os.stat().""" - return os.stat(filename).st_ctime - - -# Return the longest prefix of all list elements. -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - s1 = min(m) - s2 = max(m) - n = min(len(s1), len(s2)) - for i in xrange(n): - if s1[i] != s2[i]: - return s1[:i] - return s1[:n] - +""" +Path operations common to more than one OS +Do not use directly. The OS specific modules import the appropriate +functions from this module themselves. +""" +import os +import stat + +__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime', + 'getsize', 'isdir', 'isfile'] + + +# Does a path exist? +# This is false for dangling symbolic links on systems that support them. +def exists(path): + """Test whether a path exists. Returns False for broken symbolic links""" + try: + st = os.stat(path) + except os.error: + return False + return True + + +# This follows symbolic links, so both islink() and isdir() can be true +# for the same path ono systems that support symlinks +def isfile(path): + """Test whether a path is a regular file""" + try: + st = os.stat(path) + except os.error: + return False + return stat.S_ISREG(st.st_mode) + + +# Is a path a directory? +# This follows symbolic links, so both islink() and isdir() +# can be true for the same path on systems that support symlinks +def isdir(s): + """Return true if the pathname refers to an existing directory.""" + try: + st = os.stat(s) + except os.error: + return False + return stat.S_ISDIR(st.st_mode) + + +def getsize(filename): + """Return the size of a file, reported by os.stat().""" + return os.stat(filename).st_size + + +def getmtime(filename): + """Return the last modification time of a file, reported by os.stat().""" + return os.stat(filename).st_mtime + + +def getatime(filename): + """Return the last access time of a file, reported by os.stat().""" + return os.stat(filename).st_atime + + +def getctime(filename): + """Return the metadata change time of a file, reported by os.stat().""" + return os.stat(filename).st_ctime + + +# Return the longest prefix of all list elements. +def commonprefix(m): + "Given a list of pathnames, returns the longest common leading component" + if not m: return '' + s1 = min(m) + s2 = max(m) + n = min(len(s1), len(s2)) + for i in xrange(n): + if s1[i] != s2[i]: + return s1[:i] + return s1[:n] From python-checkins at python.org Tue Sep 5 04:21:40 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:21:40 +0200 (CEST) Subject: [Python-checkins] r51718 - in python/branches/release25-maint: Doc/lib/libstdtypes.tex Lib/test/string_tests.py Misc/NEWS Objects/stringlib/partition.h Objects/stringobject.c Objects/unicodeobject.c Message-ID: <20060905022140.C211C1E4015@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:21:38 2006 New Revision: 51718 Modified: python/branches/release25-maint/Doc/lib/libstdtypes.tex python/branches/release25-maint/Lib/test/string_tests.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/stringlib/partition.h python/branches/release25-maint/Objects/stringobject.c python/branches/release25-maint/Objects/unicodeobject.c Log: Fix str.rpartition(sep) when sep is not found in str. Partially from SF patch #1551339, but also taken from head. Modified: python/branches/release25-maint/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libstdtypes.tex (original) +++ python/branches/release25-maint/Doc/lib/libstdtypes.tex Tue Sep 5 04:21:38 2006 @@ -771,8 +771,8 @@ Split the string at the last occurrence of \var{sep}, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not -found, return a 3-tuple containing the string itself, followed by -two empty strings. +found, return a 3-tuple containing two empty strings, followed by +the string itself. \versionadded{2.5} \end{methoddesc} Modified: python/branches/release25-maint/Lib/test/string_tests.py ============================================================================== --- python/branches/release25-maint/Lib/test/string_tests.py (original) +++ python/branches/release25-maint/Lib/test/string_tests.py Tue Sep 5 04:21:38 2006 @@ -1069,7 +1069,7 @@ # from raymond's original specification S = 'http://www.python.org' self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') - self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') + self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 04:21:38 2006 @@ -27,6 +27,9 @@ - Patch #1546288: fix seg fault in dict_equal due to ref counting bug. +- The return tuple from str.rpartition(sep) is (tail, sep, head) where + head is the original string if sep was not found. + Library ------- Modified: python/branches/release25-maint/Objects/stringlib/partition.h ============================================================================== --- python/branches/release25-maint/Objects/stringlib/partition.h (original) +++ python/branches/release25-maint/Objects/stringlib/partition.h Tue Sep 5 04:21:38 2006 @@ -78,12 +78,12 @@ } if (pos < 0) { - Py_INCREF(str_obj); - PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); return out; } Modified: python/branches/release25-maint/Objects/stringobject.c ============================================================================== --- python/branches/release25-maint/Objects/stringobject.c (original) +++ python/branches/release25-maint/Objects/stringobject.c Tue Sep 5 04:21:38 2006 @@ -1543,11 +1543,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject * string_rpartition(PyStringObject *self, PyObject *sep_obj) Modified: python/branches/release25-maint/Objects/unicodeobject.c ============================================================================== --- python/branches/release25-maint/Objects/unicodeobject.c (original) +++ python/branches/release25-maint/Objects/unicodeobject.c Tue Sep 5 04:21:38 2006 @@ -6708,11 +6708,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject* unicode_rpartition(PyUnicodeObject *self, PyObject *separator) From python-checkins at python.org Tue Sep 5 04:22:17 2006 From: python-checkins at python.org (tim.peters) Date: Tue, 5 Sep 2006 04:22:17 +0200 (CEST) Subject: [Python-checkins] r51719 - in python/trunk/Lib: genericpath.py test/test_genericpath.py Message-ID: <20060905022217.75A961E4004@bag.python.org> Author: tim.peters Date: Tue Sep 5 04:22:17 2006 New Revision: 51719 Modified: python/trunk/Lib/genericpath.py (contents, props changed) python/trunk/Lib/test/test_genericpath.py (props changed) Log: Add missing svn:eol-style property to text files. Modified: python/trunk/Lib/genericpath.py ============================================================================== --- python/trunk/Lib/genericpath.py (original) +++ python/trunk/Lib/genericpath.py Tue Sep 5 04:22:17 2006 @@ -1,77 +1,77 @@ -""" -Path operations common to more than one OS -Do not use directly. The OS specific modules import the appropriate -functions from this module themselves. -""" -import os -import stat - -__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime', - 'getsize', 'isdir', 'isfile'] - - -# Does a path exist? -# This is false for dangling symbolic links on systems that support them. -def exists(path): - """Test whether a path exists. Returns False for broken symbolic links""" - try: - st = os.stat(path) - except os.error: - return False - return True - - -# This follows symbolic links, so both islink() and isdir() can be true -# for the same path ono systems that support symlinks -def isfile(path): - """Test whether a path is a regular file""" - try: - st = os.stat(path) - except os.error: - return False - return stat.S_ISREG(st.st_mode) - - -# Is a path a directory? -# This follows symbolic links, so both islink() and isdir() -# can be true for the same path on systems that support symlinks -def isdir(s): - """Return true if the pathname refers to an existing directory.""" - try: - st = os.stat(s) - except os.error: - return False - return stat.S_ISDIR(st.st_mode) - - -def getsize(filename): - """Return the size of a file, reported by os.stat().""" - return os.stat(filename).st_size - - -def getmtime(filename): - """Return the last modification time of a file, reported by os.stat().""" - return os.stat(filename).st_mtime - - -def getatime(filename): - """Return the last access time of a file, reported by os.stat().""" - return os.stat(filename).st_atime - - -def getctime(filename): - """Return the metadata change time of a file, reported by os.stat().""" - return os.stat(filename).st_ctime - - -# Return the longest prefix of all list elements. -def commonprefix(m): - "Given a list of pathnames, returns the longest common leading component" - if not m: return '' - s1 = min(m) - s2 = max(m) - n = min(len(s1), len(s2)) - for i in xrange(n): - if s1[i] != s2[i]: - return s1[:i] - return s1[:n] +""" +Path operations common to more than one OS +Do not use directly. The OS specific modules import the appropriate +functions from this module themselves. +""" +import os +import stat + +__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime', + 'getsize', 'isdir', 'isfile'] + + +# Does a path exist? +# This is false for dangling symbolic links on systems that support them. +def exists(path): + """Test whether a path exists. Returns False for broken symbolic links""" + try: + st = os.stat(path) + except os.error: + return False + return True + + +# This follows symbolic links, so both islink() and isdir() can be true +# for the same path ono systems that support symlinks +def isfile(path): + """Test whether a path is a regular file""" + try: + st = os.stat(path) + except os.error: + return False + return stat.S_ISREG(st.st_mode) + + +# Is a path a directory? +# This follows symbolic links, so both islink() and isdir() +# can be true for the same path on systems that support symlinks +def isdir(s): + """Return true if the pathname refers to an existing directory.""" + try: + st = os.stat(s) + except os.error: + return False + return stat.S_ISDIR(st.st_mode) + + +def getsize(filename): + """Return the size of a file, reported by os.stat().""" + return os.stat(filename).st_size + + +def getmtime(filename): + """Return the last modification time of a file, reported by os.stat().""" + return os.stat(filename).st_mtime + + +def getatime(filename): + """Return the last access time of a file, reported by os.stat().""" + return os.stat(filename).st_atime + + +def getctime(filename): + """Return the metadata change time of a file, reported by os.stat().""" + return os.stat(filename).st_ctime + + +# Return the longest prefix of all list elements. +def commonprefix(m): + "Given a list of pathnames, returns the longest common leading component" + if not m: return '' + s1 = min(m) + s2 = max(m) + n = min(len(s1), len(s2)) + for i in xrange(n): + if s1[i] != s2[i]: + return s1[:i] + return s1[:n] From python-checkins at python.org Tue Sep 5 04:24:04 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:24:04 +0200 (CEST) Subject: [Python-checkins] r51720 - in python/trunk: Lib/test/test_mutants.py Misc/NEWS Objects/dictobject.c Message-ID: <20060905022404.410E31E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:24:03 2006 New Revision: 51720 Modified: python/trunk/Lib/test/test_mutants.py python/trunk/Misc/NEWS python/trunk/Objects/dictobject.c Log: Fix SF bug #1546288, crash in dict_equal. Modified: python/trunk/Lib/test/test_mutants.py ============================================================================== --- python/trunk/Lib/test/test_mutants.py (original) +++ python/trunk/Lib/test/test_mutants.py Tue Sep 5 04:24:03 2006 @@ -91,12 +91,17 @@ self.hashcode = random.randrange(1000000000) def __hash__(self): + return 42 return self.hashcode def __cmp__(self, other): maybe_mutate() # The point of the test. return cmp(self.i, other.i) + def __eq__(self, other): + maybe_mutate() # The point of the test. + return self.i == other.i + def __repr__(self): return "Horrid(%d)" % self.i @@ -132,7 +137,10 @@ while dict1 and len(dict1) == len(dict2): if verbose: print ".", - c = cmp(dict1, dict2) + if random.random() < 0.5: + c = cmp(dict1, dict2) + else: + c = dict1 == dict2 if verbose: print Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 04:24:03 2006 @@ -17,12 +17,14 @@ - Patch #1542451: disallow continue anywhere under a finally. +- Patch #1546288: fix seg fault in dict_equal due to ref counting bug. + Library ------- - Patch #1550886: Fix decimal module context management implementation - to match the localcontext() example from PEP 343 + to match the localcontext() example from PEP 343. - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. Modified: python/trunk/Objects/dictobject.c ============================================================================== --- python/trunk/Objects/dictobject.c (original) +++ python/trunk/Objects/dictobject.c Tue Sep 5 04:24:03 2006 @@ -1585,7 +1585,10 @@ /* temporarily bump aval's refcount to ensure it stays alive until we're done with it */ Py_INCREF(aval); + /* ditto for key */ + Py_INCREF(key); bval = PyDict_GetItem((PyObject *)b, key); + Py_DECREF(key); if (bval == NULL) { Py_DECREF(aval); return 0; From python-checkins at python.org Tue Sep 5 04:25:41 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:25:41 +0200 (CEST) Subject: [Python-checkins] r51721 - python/trunk/Python/bltinmodule.c Message-ID: <20060905022541.ADA5B1E400C@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:25:41 2006 New Revision: 51721 Modified: python/trunk/Python/bltinmodule.c Log: Fix SF #1552093, eval docstring typo (3 ps in mapping) Modified: python/trunk/Python/bltinmodule.c ============================================================================== --- python/trunk/Python/bltinmodule.c (original) +++ python/trunk/Python/bltinmodule.c Tue Sep 5 04:25:41 2006 @@ -607,7 +607,7 @@ Evaluate the source in the context of globals and locals.\n\ The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ -The globals must be a dictionary and locals can be any mappping,\n\ +The globals must be a dictionary and locals can be any mapping,\n\ defaulting to the current globals and locals.\n\ If only globals is given, locals defaults to it.\n"); From python-checkins at python.org Tue Sep 5 04:30:10 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:30:10 +0200 (CEST) Subject: [Python-checkins] r51722 - in python/branches/release25-maint: Lib/test/test_itertools.py Misc/NEWS Modules/itertoolsmodule.c Message-ID: <20060905023010.D2A3A1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:30:10 2006 New Revision: 51722 Modified: python/branches/release25-maint/Lib/test/test_itertools.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/itertoolsmodule.c Log: Backport fix for SF bug #1550714, itertools.tee raises SystemError Modified: python/branches/release25-maint/Lib/test/test_itertools.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_itertools.py (original) +++ python/branches/release25-maint/Lib/test/test_itertools.py Tue Sep 5 04:30:10 2006 @@ -371,6 +371,7 @@ # test values of n self.assertRaises(TypeError, tee, 'abc', 'invalid') + self.assertRaises(ValueError, tee, [], -1) for n in xrange(5): result = tee('abc', n) self.assertEqual(type(result), tuple) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 04:30:10 2006 @@ -43,6 +43,12 @@ - Bug #1543303, patch #1543897: remove NUL padding from tarfiles. +Extension Modules +----------------- + +- Bug #1550714: fix SystemError from itertools.tee on negative value for n. + + Tests ----- Modified: python/branches/release25-maint/Modules/itertoolsmodule.c ============================================================================== --- python/branches/release25-maint/Modules/itertoolsmodule.c (original) +++ python/branches/release25-maint/Modules/itertoolsmodule.c Tue Sep 5 04:30:10 2006 @@ -618,11 +618,15 @@ static PyObject * tee(PyObject *self, PyObject *args) { - int i, n=2; + Py_ssize_t i, n=2; PyObject *it, *iterable, *copyable, *result; - if (!PyArg_ParseTuple(args, "O|i", &iterable, &n)) + if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "n must be >= 0"); + return NULL; + } result = PyTuple_New(n); if (result == NULL) return NULL; From python-checkins at python.org Tue Sep 5 04:33:46 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:33:46 +0200 (CEST) Subject: [Python-checkins] r51723 - in python/branches/release25-maint: Misc/NEWS Modules/_cursesmodule.c Message-ID: <20060905023346.C3F0A1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:33:44 2006 New Revision: 51723 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/_cursesmodule.c Log: Backport fix from 51683. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 04:33:44 2006 @@ -46,6 +46,8 @@ Extension Modules ----------------- +- Bug #1548092: fix curses.tparm seg fault on invalid input. + - Bug #1550714: fix SystemError from itertools.tee on negative value for n. Modified: python/branches/release25-maint/Modules/_cursesmodule.c ============================================================================== --- python/branches/release25-maint/Modules/_cursesmodule.c (original) +++ python/branches/release25-maint/Modules/_cursesmodule.c Tue Sep 5 04:33:44 2006 @@ -2334,6 +2334,10 @@ } result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); + if (!result) { + PyErr_SetString(PyCursesError, "tparm() returned NULL"); + return NULL; + } return PyString_FromString(result); } From python-checkins at python.org Tue Sep 5 04:35:08 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:35:08 +0200 (CEST) Subject: [Python-checkins] r51724 - in python/trunk: Lib/bsddb/test/test_basics.py Misc/NEWS Message-ID: <20060905023508.EF86C1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:35:08 2006 New Revision: 51724 Modified: python/trunk/Lib/bsddb/test/test_basics.py python/trunk/Misc/NEWS Log: This was found by Guido AFAIK on p3yk (sic) branch. Modified: python/trunk/Lib/bsddb/test/test_basics.py ============================================================================== --- python/trunk/Lib/bsddb/test/test_basics.py (original) +++ python/trunk/Lib/bsddb/test/test_basics.py Tue Sep 5 04:35:08 2006 @@ -697,7 +697,7 @@ for log in logs: if verbose: print 'log file: ' + log - if db.version >= (4,2): + if db.version() >= (4,2): logs = self.env.log_archive(db.DB_ARCH_REMOVE) assert not logs Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 04:35:08 2006 @@ -41,6 +41,9 @@ Tests ----- +- Fix bsddb test_basics.test06_Transactions to check the version + number properly. + Documentation ------------- From python-checkins at python.org Tue Sep 5 04:36:20 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:36:20 +0200 (CEST) Subject: [Python-checkins] r51725 - python/trunk/Misc/NEWS Message-ID: <20060905023620.E0D211E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:36:20 2006 New Revision: 51725 Modified: python/trunk/Misc/NEWS Log: Add a NEWS entry for str.rpartition() change Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 04:36:20 2006 @@ -19,6 +19,9 @@ - Patch #1546288: fix seg fault in dict_equal due to ref counting bug. +- The return tuple from str.rpartition(sep) is (tail, sep, head) where + head is the original string if sep was not found. + Library ------- From python-checkins at python.org Tue Sep 5 04:40:18 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:40:18 +0200 (CEST) Subject: [Python-checkins] r51726 - peps/trunk/pep-0356.txt Message-ID: <20060905024018.33EC81E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:40:16 2006 New Revision: 51726 Modified: peps/trunk/pep-0356.txt Log: update for rc2 Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Tue Sep 5 04:40:16 2006 @@ -39,7 +39,8 @@ beta 2: July 11, 2006 [completed] beta 3: August 3, 2006 [completed] rc 1: August 17, 2006 [completed] - final: September 12, 2006 [planned] + rc 2: September 12, 2006 [planned] + final: September 19, 2006 [planned] Completed features for 2.5 @@ -150,12 +151,12 @@ - Bugs that need resolving before release, ie, they block release: http://python.org/sf/1541697 - sgmllib regexp bug causes hang - http://python.org/sf/1541420 - tools and demo missing from windows - Bugs deferred until 2.5.1 (or later) - http://python.org/sf/1446043 - unicode() does not raise LookupError + http://python.org/sf/1541420 - tools and demo missing from windows http://python.org/sf/1475523 - gettext.py bug (owner: Martin v. Loewis) http://python.org/sf/1467929 - %-formatting and dicts + http://python.org/sf/1446043 - unicode() does not raise LookupError - The PEP 302 changes to (at least) pkgutil, runpy and pydoc must be documented. From buildbot at python.org Tue Sep 5 04:52:26 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 02:52:26 +0000 Subject: [Python-checkins] buildbot warnings in S-390 Debian 2.5 Message-ID: <20060905025226.81C5F1E4004@bag.python.org> The Buildbot has detected a new failure of S-390 Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/S-390%2520Debian%25202.5/builds/9 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: neal.norwitz,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 5 04:54:43 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:54:43 +0200 (CEST) Subject: [Python-checkins] r51727 - in python/branches/release25-maint: Lib/test/test_fcntl.py Lib/test/test_tempfile.py Misc/NEWS configure configure.in Message-ID: <20060905025443.EDF841E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:54:42 2006 New Revision: 51727 Modified: python/branches/release25-maint/Lib/test/test_fcntl.py python/branches/release25-maint/Lib/test/test_tempfile.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/configure python/branches/release25-maint/configure.in Log: Patch #1540470, for OpenBSD 4.0. Backport candidate for 2.[34]. Modified: python/branches/release25-maint/Lib/test/test_fcntl.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_fcntl.py (original) +++ python/branches/release25-maint/Lib/test/test_fcntl.py Tue Sep 5 04:54:42 2006 @@ -25,7 +25,7 @@ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'bsdos2', 'bsdos3', 'bsdos4', - 'openbsd', 'openbsd2', 'openbsd3'): + 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' Modified: python/branches/release25-maint/Lib/test/test_tempfile.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_tempfile.py (original) +++ python/branches/release25-maint/Lib/test/test_tempfile.py Tue Sep 5 04:54:42 2006 @@ -27,7 +27,7 @@ # number of files that can be opened at one time (see ulimit -n) if sys.platform == 'mac': TEST_FILES = 32 -elif sys.platform == 'openbsd3': +elif sys.platform in ('openbsd3', 'openbsd4'): TEST_FILES = 48 else: TEST_FILES = 100 Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 04:54:42 2006 @@ -69,6 +69,8 @@ Build ----- +- Patch #1540470, for OpenBSD 4.0. + - Patch #1545507: Exclude ctypes package in Win64 MSI file. - Fix OpenSSL debug build process. Modified: python/branches/release25-maint/configure ============================================================================== --- python/branches/release25-maint/configure (original) +++ python/branches/release25-maint/configure Tue Sep 5 04:54:42 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 47267 . +# From configure.in Revision: 51173 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -1553,7 +1553,7 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.[0123456789]) + OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0]) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. Modified: python/branches/release25-maint/configure.in ============================================================================== --- python/branches/release25-maint/configure.in (original) +++ python/branches/release25-maint/configure.in Tue Sep 5 04:54:42 2006 @@ -201,7 +201,7 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@) + OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. From python-checkins at python.org Tue Sep 5 04:57:02 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 04:57:02 +0200 (CEST) Subject: [Python-checkins] r51728 - in python/trunk: Lib/test/test_fcntl.py Lib/test/test_tempfile.py Misc/NEWS configure configure.in Message-ID: <20060905025702.EAC051E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 04:57:01 2006 New Revision: 51728 Modified: python/trunk/Lib/test/test_fcntl.py python/trunk/Lib/test/test_tempfile.py python/trunk/Misc/NEWS python/trunk/configure python/trunk/configure.in Log: Patch #1540470, for OpenBSD 4.0. Backport candidate for 2.[34]. Modified: python/trunk/Lib/test/test_fcntl.py ============================================================================== --- python/trunk/Lib/test/test_fcntl.py (original) +++ python/trunk/Lib/test/test_fcntl.py Tue Sep 5 04:57:01 2006 @@ -25,7 +25,7 @@ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'bsdos2', 'bsdos3', 'bsdos4', - 'openbsd', 'openbsd2', 'openbsd3'): + 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' Modified: python/trunk/Lib/test/test_tempfile.py ============================================================================== --- python/trunk/Lib/test/test_tempfile.py (original) +++ python/trunk/Lib/test/test_tempfile.py Tue Sep 5 04:57:01 2006 @@ -27,7 +27,7 @@ # number of files that can be opened at one time (see ulimit -n) if sys.platform == 'mac': TEST_FILES = 32 -elif sys.platform == 'openbsd3': +elif sys.platform in ('openbsd3', 'openbsd4'): TEST_FILES = 48 else: TEST_FILES = 100 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 04:57:01 2006 @@ -59,6 +59,8 @@ Build ----- +- Patch #1540470, for OpenBSD 4.0. + C API ----- Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Tue Sep 5 04:57:01 2006 @@ -1553,7 +1553,7 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.[0123456789]) + OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0]) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Tue Sep 5 04:57:01 2006 @@ -201,7 +201,7 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@) + OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. From python-checkins at python.org Tue Sep 5 05:53:09 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 05:53:09 +0200 (CEST) Subject: [Python-checkins] r51729 - in python/trunk: Lib/test/test_grammar.py Misc/NEWS Python/ast.c Python/import.c Message-ID: <20060905035309.F04B31E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 05:53:08 2006 New Revision: 51729 Modified: python/trunk/Lib/test/test_grammar.py python/trunk/Misc/NEWS python/trunk/Python/ast.c python/trunk/Python/import.c Log: Bug #1520864 (again): unpacking singleton tuples in list comprehensions and generator expressions (x for x, in ... ) works again. Sigh, I only fixed for loops the first time, not list comps and genexprs too. I couldn't find any more unpacking cases where there is a similar bug lurking. This code should be refactored to eliminate the duplication. I'm sure the listcomp/genexpr code can be refactored. I'm not sure if the for loop can re-use any of the same code though. Will backport to 2.5 (the only place it matters). Modified: python/trunk/Lib/test/test_grammar.py ============================================================================== --- python/trunk/Lib/test/test_grammar.py (original) +++ python/trunk/Lib/test/test_grammar.py Tue Sep 5 05:53:08 2006 @@ -825,6 +825,10 @@ verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) +# Verify unpacking single element tuples in listcomp/genexp. +vereq([x for x, in [(4,), (5,), (6,)]], [4, 5, 6]) +vereq(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9]) + # Test ifelse expressions in various cases def _checkeval(msg, ret): "helper to check that evaluation of expressions is done correctly" Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 05:53:08 2006 @@ -22,6 +22,11 @@ - The return tuple from str.rpartition(sep) is (tail, sep, head) where head is the original string if sep was not found. +- Bug #1520864: unpacking singleton tuples in list comprehensions and + generator expressions (x for x, in ... ) works again. Fixing this problem + required changing the .pyc magic number. This means that .pyc files + generated before 2.5c2 will be regenerated. + Library ------- Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Tue Sep 5 05:53:08 2006 @@ -983,17 +983,21 @@ comprehension_ty lc; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, list_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_testlist(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + [x for x, in ... ] has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else @@ -1129,17 +1133,21 @@ comprehension_ty ge; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, gen_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_expr(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + (x for x, in ...) has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Tue Sep 5 05:53:08 2006 @@ -64,9 +64,10 @@ Python 2.5b3: 62111 (fix wrong code: x += yield) Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) + Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) . */ -#define MAGIC (62121 | ((long)'\r'<<16) | ((long)'\n'<<24)) +#define MAGIC (62131 | ((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 From python-checkins at python.org Tue Sep 5 05:56:02 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 05:56:02 +0200 (CEST) Subject: [Python-checkins] r51730 - in python/branches/release25-maint: Lib/test/test_grammar.py Misc/NEWS Python/ast.c Python/import.c Message-ID: <20060905035602.9F55F1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 05:56:01 2006 New Revision: 51730 Modified: python/branches/release25-maint/Lib/test/test_grammar.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Python/ast.c python/branches/release25-maint/Python/import.c Log: Bug #1520864 (again): unpacking singleton tuples in list comprehensions and generator expressions (x for x, in ... ) works again. Sigh, I only fixed for loops the first time, not list comps and genexprs too. I couldn't find any more unpacking cases where there is a similar bug lurking. Modified: python/branches/release25-maint/Lib/test/test_grammar.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_grammar.py (original) +++ python/branches/release25-maint/Lib/test/test_grammar.py Tue Sep 5 05:56:01 2006 @@ -825,6 +825,10 @@ verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) +# Verify unpacking single element tuples in listcomp/genexp. +vereq([x for x, in [(4,), (5,), (6,)]], [4, 5, 6]) +vereq(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9]) + # Test ifelse expressions in various cases def _checkeval(msg, ret): "helper to check that evaluation of expressions is done correctly" Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 05:56:01 2006 @@ -30,6 +30,11 @@ - The return tuple from str.rpartition(sep) is (tail, sep, head) where head is the original string if sep was not found. +- Bug #1520864: unpacking singleton tuples in list comprehensions and + generator expressions (x for x, in ... ) works again. Fixing this problem + required changing the .pyc magic number. This means that .pyc files + generated before 2.5c2 will be regenerated. + Library ------- Modified: python/branches/release25-maint/Python/ast.c ============================================================================== --- python/branches/release25-maint/Python/ast.c (original) +++ python/branches/release25-maint/Python/ast.c Tue Sep 5 05:56:01 2006 @@ -983,17 +983,21 @@ comprehension_ty lc; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, list_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_testlist(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + [x for x, in ... ] has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else @@ -1129,17 +1133,21 @@ comprehension_ty ge; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, gen_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_expr(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + (x for x, in ...) has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else Modified: python/branches/release25-maint/Python/import.c ============================================================================== --- python/branches/release25-maint/Python/import.c (original) +++ python/branches/release25-maint/Python/import.c Tue Sep 5 05:56:01 2006 @@ -64,9 +64,10 @@ Python 2.5b3: 62111 (fix wrong code: x += yield) Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) + Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) . */ -#define MAGIC (62121 | ((long)'\r'<<16) | ((long)'\n'<<24)) +#define MAGIC (62131 | ((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 From python-checkins at python.org Tue Sep 5 05:58:27 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 05:58:27 +0200 (CEST) Subject: [Python-checkins] r51731 - python/trunk/Python/ast.c Message-ID: <20060905035827.07C471E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 05:58:26 2006 New Revision: 51731 Modified: python/trunk/Python/ast.c Log: Add a comment about some refactoring. (There's probably more that should be done.) I will reformat this file in the next checkin due to the inconsistent tabs/spaces. Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Tue Sep 5 05:58:26 2006 @@ -15,12 +15,6 @@ #include -/* XXX TO DO - - re-indent this file (should be done) - - internal error checking (freeing memory, etc.) - - syntax errors -*/ - /* Data structure used internally */ struct compiling { char *c_encoding; /* source encoding */ @@ -889,6 +883,11 @@ c->c_arena); } +/* XXX(nnorwitz): the listcomp and genexpr code should be refactored + so there is only a single version. Possibly for loops can also re-use + the code. +*/ + /* Count the number of 'for' loop in a list comprehension. Helper for ast_for_listcomp(). From python-checkins at python.org Tue Sep 5 06:00:13 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 06:00:13 +0200 (CEST) Subject: [Python-checkins] r51732 - python/trunk/Python/ast.c Message-ID: <20060905040013.6A7071E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 06:00:12 2006 New Revision: 51732 Modified: python/trunk/Python/ast.c Log: M-x untabify Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Tue Sep 5 06:00:12 2006 @@ -37,7 +37,7 @@ static PyObject *parsestrplus(struct compiling *, const node *n); #ifndef LINENO -#define LINENO(n) ((n)->n_lineno) +#define LINENO(n) ((n)->n_lineno) #endif static identifier @@ -62,7 +62,7 @@ { PyObject *u = Py_BuildValue("zi", errstr, LINENO(n)); if (!u) - return 0; + return 0; PyErr_SetObject(PyExc_SyntaxError, u); Py_DECREF(u); return 0; @@ -76,36 +76,36 @@ assert(PyErr_Occurred()); if (!PyErr_ExceptionMatches(PyExc_SyntaxError)) - return; + return; PyErr_Fetch(&type, &value, &tback); errstr = PyTuple_GetItem(value, 0); if (!errstr) - return; + return; Py_INCREF(errstr); lineno = PyInt_AsLong(PyTuple_GetItem(value, 1)); if (lineno == -1) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } Py_DECREF(value); loc = PyErr_ProgramText(filename, lineno); if (!loc) { - Py_INCREF(Py_None); - loc = Py_None; + Py_INCREF(Py_None); + loc = Py_None; } tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc); Py_DECREF(loc); if (!tmp) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } value = PyTuple_Pack(2, errstr, tmp); Py_DECREF(errstr); Py_DECREF(tmp); if (!value) - return; + return; PyErr_Restore(type, value, tback); } @@ -240,7 +240,7 @@ if (TYPE(CHILD(n, 0)) == NEWLINE) { stmts = asdl_seq_new(1, arena); if (!stmts) - goto error; + goto error; asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset, arena)); return Interactive(stmts, arena); @@ -250,11 +250,11 @@ num = num_stmts(n); stmts = asdl_seq_new(num, arena); if (!stmts) - goto error; + goto error; if (num == 1) { - s = ast_for_stmt(&c, n); - if (!s) - goto error; + s = ast_for_stmt(&c, n); + if (!s) + goto error; asdl_seq_SET(stmts, 0, s); } else { @@ -341,38 +341,38 @@ switch (e->kind) { case Attribute_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Attribute.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Attribute.ctx = ctx; + break; case Subscript_kind: - e->v.Subscript.ctx = ctx; - break; + e->v.Subscript.ctx = ctx; + break; case Name_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Name.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Name.ctx = ctx; + break; case List_kind: - e->v.List.ctx = ctx; - s = e->v.List.elts; - break; + e->v.List.ctx = ctx; + s = e->v.List.elts; + break; case Tuple_kind: if (asdl_seq_LEN(e->v.Tuple.elts) == 0) return ast_error(n, "can't assign to ()"); - e->v.Tuple.ctx = ctx; - s = e->v.Tuple.elts; - break; + e->v.Tuple.ctx = ctx; + s = e->v.Tuple.elts; + break; case Lambda_kind: expr_name = "lambda"; break; case Call_kind: expr_name = "function call"; - break; + break; case BoolOp_kind: case BinOp_kind: case UnaryOp_kind: @@ -421,12 +421,12 @@ context for all the contained elements. */ if (s) { - int i; + int i; - for (i = 0; i < asdl_seq_LEN(s); i++) { - if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) - return 0; - } + for (i = 0; i < asdl_seq_LEN(s); i++) { + if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) + return 0; + } } return 1; } @@ -477,13 +477,13 @@ */ REQ(n, comp_op); if (NCH(n) == 1) { - n = CHILD(n, 0); - switch (TYPE(n)) { + n = CHILD(n, 0); + switch (TYPE(n)) { case LESS: return Lt; case GREATER: return Gt; - case EQEQUAL: /* == */ + case EQEQUAL: /* == */ return Eq; case LESSEQUAL: return LtE; @@ -500,11 +500,11 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s", STR(n)); return (cmpop_ty)0; - } + } } else if (NCH(n) == 2) { - /* handle "not in" and "is not" */ - switch (TYPE(CHILD(n, 0))) { + /* handle "not in" and "is not" */ + switch (TYPE(CHILD(n, 0))) { case NAME: if (strcmp(STR(CHILD(n, 1)), "in") == 0) return NotIn; @@ -514,7 +514,7 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s", STR(CHILD(n, 0)), STR(CHILD(n, 1))); return (cmpop_ty)0; - } + } } PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children", NCH(n)); @@ -529,10 +529,10 @@ expr_ty expression; int i; assert(TYPE(n) == testlist - || TYPE(n) == listmaker - || TYPE(n) == testlist_gexp - || TYPE(n) == testlist_safe - ); + || TYPE(n) == listmaker + || TYPE(n) == testlist_gexp + || TYPE(n) == testlist_safe + ); seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) @@ -565,13 +565,13 @@ const node *child = CHILD(CHILD(n, 2*i), 0); expr_ty arg; if (TYPE(child) == NAME) { - if (!strcmp(STR(child), "None")) { - ast_error(child, "assignment to None"); - return NULL; - } + if (!strcmp(STR(child), "None")) { + ast_error(child, "assignment to None"); + return NULL; + } arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child), child->n_col_offset, c->c_arena); - } + } else { arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); } @@ -600,26 +600,26 @@ node *ch; if (TYPE(n) == parameters) { - if (NCH(n) == 2) /* () as argument list */ - return arguments(NULL, NULL, NULL, NULL, c->c_arena); - n = CHILD(n, 1); + if (NCH(n) == 2) /* () as argument list */ + return arguments(NULL, NULL, NULL, NULL, c->c_arena); + n = CHILD(n, 1); } REQ(n, varargslist); /* first count the number of normal args & defaults */ for (i = 0; i < NCH(n); i++) { - ch = CHILD(n, i); - if (TYPE(ch) == fpdef) - n_args++; - if (TYPE(ch) == EQUAL) - n_defaults++; + ch = CHILD(n, i); + if (TYPE(ch) == fpdef) + n_args++; + if (TYPE(ch) == EQUAL) + n_defaults++; } args = (n_args ? asdl_seq_new(n_args, c->c_arena) : NULL); if (!args && n_args) - return NULL; /* Don't need to goto error; no objects allocated */ + return NULL; /* Don't need to goto error; no objects allocated */ defaults = (n_defaults ? asdl_seq_new(n_defaults, c->c_arena) : NULL); if (!defaults && n_defaults) - return NULL; /* Don't need to goto error; no objects allocated */ + return NULL; /* Don't need to goto error; no objects allocated */ /* fpdef: NAME | '(' fplist ')' fplist: fpdef (',' fpdef)* [','] @@ -628,8 +628,8 @@ j = 0; /* index for defaults */ k = 0; /* index for args */ while (i < NCH(n)) { - ch = CHILD(n, i); - switch (TYPE(ch)) { + ch = CHILD(n, i); + switch (TYPE(ch)) { case fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ @@ -641,53 +641,53 @@ assert(defaults != NULL); asdl_seq_SET(defaults, j++, expression); i += 2; - found_default = 1; + found_default = 1; + } + else if (found_default) { + ast_error(n, + "non-default argument follows default argument"); + goto error; } - else if (found_default) { - ast_error(n, - "non-default argument follows default argument"); - goto error; - } if (NCH(ch) == 3) { - ch = CHILD(ch, 1); - /* def foo((x)): is not complex, special case. */ - if (NCH(ch) != 1) { - /* We have complex arguments, setup for unpacking. */ - asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); - } else { - /* def foo((x)): setup for checking NAME below. */ - ch = CHILD(ch, 0); - } + ch = CHILD(ch, 1); + /* def foo((x)): is not complex, special case. */ + if (NCH(ch) != 1) { + /* We have complex arguments, setup for unpacking. */ + asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); + } else { + /* def foo((x)): setup for checking NAME below. */ + ch = CHILD(ch, 0); + } } if (TYPE(CHILD(ch, 0)) == NAME) { - expr_ty name; - if (!strcmp(STR(CHILD(ch, 0)), "None")) { - ast_error(CHILD(ch, 0), "assignment to None"); - goto error; - } + expr_ty name; + if (!strcmp(STR(CHILD(ch, 0)), "None")) { + ast_error(CHILD(ch, 0), "assignment to None"); + goto error; + } name = Name(NEW_IDENTIFIER(CHILD(ch, 0)), Param, LINENO(ch), ch->n_col_offset, c->c_arena); if (!name) goto error; asdl_seq_SET(args, k++, name); - - } + + } i += 2; /* the name and the comma */ break; case STAR: - if (!strcmp(STR(CHILD(n, i+1)), "None")) { - ast_error(CHILD(n, i+1), "assignment to None"); - goto error; - } + if (!strcmp(STR(CHILD(n, i+1)), "None")) { + ast_error(CHILD(n, i+1), "assignment to None"); + goto error; + } vararg = NEW_IDENTIFIER(CHILD(n, i+1)); i += 3; break; case DOUBLESTAR: - if (!strcmp(STR(CHILD(n, i+1)), "None")) { - ast_error(CHILD(n, i+1), "assignment to None"); - goto error; - } + if (!strcmp(STR(CHILD(n, i+1)), "None")) { + ast_error(CHILD(n, i+1), "assignment to None"); + goto error; + } kwarg = NEW_IDENTIFIER(CHILD(n, i+1)); i += 3; break; @@ -696,7 +696,7 @@ "unexpected node in varargslist: %d @ %d", TYPE(ch), i); goto error; - } + } } return arguments(args, vararg, kwarg, defaults, c->c_arena); @@ -725,15 +725,15 @@ return NULL; e = Name(id, Load, lineno, col_offset, c->c_arena); if (!e) - return NULL; + return NULL; for (i = 2; i < NCH(n); i+=2) { id = NEW_IDENTIFIER(CHILD(n, i)); - if (!id) - return NULL; - e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); - if (!e) - return NULL; + if (!id) + return NULL; + e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); + if (!e) + return NULL; } return e; @@ -752,24 +752,24 @@ name_expr = ast_for_dotted_name(c, CHILD(n, 1)); if (!name_expr) - return NULL; - + return NULL; + if (NCH(n) == 3) { /* No arguments */ - d = name_expr; - name_expr = NULL; + d = name_expr; + name_expr = NULL; } else if (NCH(n) == 5) { /* Call with no arguments */ - d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), + d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); - if (!d) - return NULL; - name_expr = NULL; + if (!d) + return NULL; + name_expr = NULL; } else { - d = ast_for_call(c, CHILD(n, 3), name_expr); - if (!d) - return NULL; - name_expr = NULL; + d = ast_for_call(c, CHILD(n, 3), name_expr); + if (!d) + return NULL; + name_expr = NULL; } return d; @@ -786,12 +786,12 @@ decorator_seq = asdl_seq_new(NCH(n), c->c_arena); if (!decorator_seq) return NULL; - + for (i = 0; i < NCH(n); i++) { d = ast_for_decorator(c, CHILD(n, i)); - if (!d) - return NULL; - asdl_seq_SET(decorator_seq, i, d); + if (!d) + return NULL; + asdl_seq_SET(decorator_seq, i, d); } return decorator_seq; } @@ -809,28 +809,28 @@ REQ(n, funcdef); if (NCH(n) == 6) { /* decorators are present */ - decorator_seq = ast_for_decorators(c, CHILD(n, 0)); - if (!decorator_seq) - return NULL; - name_i = 2; + decorator_seq = ast_for_decorators(c, CHILD(n, 0)); + if (!decorator_seq) + return NULL; + name_i = 2; } else { - name_i = 1; + name_i = 1; } name = NEW_IDENTIFIER(CHILD(n, name_i)); if (!name) - return NULL; + return NULL; else if (!strcmp(STR(CHILD(n, name_i)), "None")) { - ast_error(CHILD(n, name_i), "assignment to None"); - return NULL; + ast_error(CHILD(n, name_i), "assignment to None"); + return NULL; } args = ast_for_arguments(c, CHILD(n, name_i + 1)); if (!args) - return NULL; + return NULL; body = ast_for_suite(c, CHILD(n, name_i + 3)); if (!body) - return NULL; + return NULL; return FunctionDef(name, args, body, decorator_seq, LINENO(n), n->n_col_offset, c->c_arena); @@ -872,13 +872,13 @@ assert(NCH(n) == 5); body = ast_for_expr(c, CHILD(n, 0)); if (!body) - return NULL; + return NULL; expression = ast_for_expr(c, CHILD(n, 2)); if (!expression) - return NULL; + return NULL; orelse = ast_for_expr(c, CHILD(n, 4)); if (!orelse) - return NULL; + return NULL; return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset, c->c_arena); } @@ -903,14 +903,14 @@ n_fors++; REQ(ch, list_for); if (NCH(ch) == 5) - ch = CHILD(ch, 4); + ch = CHILD(ch, 4); else - return n_fors; + return n_fors; count_list_iter: REQ(ch, list_iter); ch = CHILD(ch, 0); if (TYPE(ch) == list_for) - goto count_list_for; + goto count_list_for; else if (TYPE(ch) == list_if) { if (NCH(ch) == 3) { ch = CHILD(ch, 2); @@ -938,12 +938,12 @@ count_list_iter: REQ(n, list_iter); if (TYPE(CHILD(n, 0)) == list_for) - return n_ifs; + return n_ifs; n = CHILD(n, 0); REQ(n, list_if); n_ifs++; if (NCH(n) == 2) - return n_ifs; + return n_ifs; n = CHILD(n, 2); goto count_list_iter; } @@ -975,16 +975,16 @@ listcomps = asdl_seq_new(n_fors, c->c_arena); if (!listcomps) - return NULL; + return NULL; ch = CHILD(n, 1); for (i = 0; i < n_fors; i++) { - comprehension_ty lc; - asdl_seq *t; + comprehension_ty lc; + asdl_seq *t; expr_ty expression; node *for_ch; - REQ(ch, list_for); + REQ(ch, list_for); for_ch = CHILD(ch, 1); t = ast_for_exprlist(c, for_ch, Store); @@ -996,44 +996,44 @@ /* Check the # of children rather than the length of t, since [x for x, in ... ] has 1 element in t, but still requires a Tuple. */ - if (NCH(for_ch) == 1) - lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, + if (NCH(for_ch) == 1) + lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); - else - lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, + else + lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, c->c_arena), expression, NULL, c->c_arena); if (!lc) return NULL; - if (NCH(ch) == 5) { - int j, n_ifs; - asdl_seq *ifs; + if (NCH(ch) == 5) { + int j, n_ifs; + asdl_seq *ifs; - ch = CHILD(ch, 4); - n_ifs = count_list_ifs(ch); + ch = CHILD(ch, 4); + n_ifs = count_list_ifs(ch); if (n_ifs == -1) return NULL; - ifs = asdl_seq_new(n_ifs, c->c_arena); - if (!ifs) - return NULL; + ifs = asdl_seq_new(n_ifs, c->c_arena); + if (!ifs) + return NULL; - for (j = 0; j < n_ifs; j++) { + for (j = 0; j < n_ifs; j++) { REQ(ch, list_iter); - ch = CHILD(ch, 0); - REQ(ch, list_if); + ch = CHILD(ch, 0); + REQ(ch, list_if); - asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); - if (NCH(ch) == 3) - ch = CHILD(ch, 2); - } - /* on exit, must guarantee that ch is a list_for */ - if (TYPE(ch) == list_iter) - ch = CHILD(ch, 0); + asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); + if (NCH(ch) == 3) + ch = CHILD(ch, 2); + } + /* on exit, must guarantee that ch is a list_for */ + if (TYPE(ch) == list_iter) + ch = CHILD(ch, 0); lc->ifs = ifs; - } - asdl_seq_SET(listcomps, i, lc); + } + asdl_seq_SET(listcomps, i, lc); } return ListComp(elt, listcomps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1048,34 +1048,34 @@ static int count_gen_fors(const node *n) { - int n_fors = 0; - node *ch = CHILD(n, 1); + int n_fors = 0; + node *ch = CHILD(n, 1); count_gen_for: - n_fors++; - REQ(ch, gen_for); - if (NCH(ch) == 5) - ch = CHILD(ch, 4); - else - return n_fors; + n_fors++; + REQ(ch, gen_for); + if (NCH(ch) == 5) + ch = CHILD(ch, 4); + else + return n_fors; count_gen_iter: - REQ(ch, gen_iter); - ch = CHILD(ch, 0); - if (TYPE(ch) == gen_for) - goto count_gen_for; - else if (TYPE(ch) == gen_if) { - if (NCH(ch) == 3) { - ch = CHILD(ch, 2); - goto count_gen_iter; - } - else - return n_fors; - } - - /* Should never be reached */ - PyErr_SetString(PyExc_SystemError, - "logic error in count_gen_fors"); - return -1; + REQ(ch, gen_iter); + ch = CHILD(ch, 0); + if (TYPE(ch) == gen_for) + goto count_gen_for; + else if (TYPE(ch) == gen_if) { + if (NCH(ch) == 3) { + ch = CHILD(ch, 2); + goto count_gen_iter; + } + else + return n_fors; + } + + /* Should never be reached */ + PyErr_SetString(PyExc_SystemError, + "logic error in count_gen_fors"); + return -1; } /* Count the number of 'if' statements in a generator expression. @@ -1086,19 +1086,19 @@ static int count_gen_ifs(const node *n) { - int n_ifs = 0; + int n_ifs = 0; - while (1) { - REQ(n, gen_iter); - if (TYPE(CHILD(n, 0)) == gen_for) - return n_ifs; - n = CHILD(n, 0); - REQ(n, gen_if); - n_ifs++; - if (NCH(n) == 2) - return n_ifs; - n = CHILD(n, 2); - } + while (1) { + REQ(n, gen_iter); + if (TYPE(CHILD(n, 0)) == gen_for) + return n_ifs; + n = CHILD(n, 0); + REQ(n, gen_if); + n_ifs++; + if (NCH(n) == 2) + return n_ifs; + n = CHILD(n, 2); + } } /* TODO(jhylton): Combine with list comprehension code? */ @@ -1106,7 +1106,7 @@ ast_for_genexp(struct compiling *c, const node *n) { /* testlist_gexp: test ( gen_for | (',' test)* [','] ) - argument: [test '='] test [gen_for] # Really [keyword '='] test */ + argument: [test '='] test [gen_for] # Really [keyword '='] test */ expr_ty elt; asdl_seq *genexps; int i, n_fors; @@ -1203,96 +1203,96 @@ switch (TYPE(ch)) { case NAME: - /* All names start in Load context, but may later be - changed. */ - return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); + /* All names start in Load context, but may later be + changed. */ + return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); case STRING: { - PyObject *str = parsestrplus(c, n); - if (!str) - return NULL; + PyObject *str = parsestrplus(c, n); + if (!str) + return NULL; - PyArena_AddPyObject(c->c_arena, str); - return Str(str, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, str); + return Str(str, LINENO(n), n->n_col_offset, c->c_arena); } case NUMBER: { - PyObject *pynum = parsenumber(STR(ch)); - if (!pynum) - return NULL; + PyObject *pynum = parsenumber(STR(ch)); + if (!pynum) + return NULL; - PyArena_AddPyObject(c->c_arena, pynum); - return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, pynum); + return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); } case LPAR: /* some parenthesized expressions */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RPAR) - return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - if (TYPE(ch) == yield_expr) - return ast_for_expr(c, ch); - - if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) - return ast_for_genexp(c, ch); - - return ast_for_testlist_gexp(c, ch); + ch = CHILD(n, 1); + + if (TYPE(ch) == RPAR) + return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + if (TYPE(ch) == yield_expr) + return ast_for_expr(c, ch); + + if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) + return ast_for_genexp(c, ch); + + return ast_for_testlist_gexp(c, ch); case LSQB: /* list (or list comprehension) */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RSQB) - return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - REQ(ch, listmaker); - if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { - asdl_seq *elts = seq_for_testlist(c, ch); - if (!elts) - return NULL; - - return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); - } - else - return ast_for_listcomp(c, ch); + ch = CHILD(n, 1); + + if (TYPE(ch) == RSQB) + return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + REQ(ch, listmaker); + if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { + asdl_seq *elts = seq_for_testlist(c, ch); + if (!elts) + return NULL; + + return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); + } + else + return ast_for_listcomp(c, ch); case LBRACE: { - /* dictmaker: test ':' test (',' test ':' test)* [','] */ - int i, size; - asdl_seq *keys, *values; - - ch = CHILD(n, 1); - size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ - keys = asdl_seq_new(size, c->c_arena); - if (!keys) - return NULL; - - values = asdl_seq_new(size, c->c_arena); - if (!values) - return NULL; - - for (i = 0; i < NCH(ch); i += 4) { - expr_ty expression; - - expression = ast_for_expr(c, CHILD(ch, i)); - if (!expression) - return NULL; - - asdl_seq_SET(keys, i / 4, expression); - - expression = ast_for_expr(c, CHILD(ch, i + 2)); - if (!expression) - return NULL; - - asdl_seq_SET(values, i / 4, expression); - } - return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); + /* dictmaker: test ':' test (',' test ':' test)* [','] */ + int i, size; + asdl_seq *keys, *values; + + ch = CHILD(n, 1); + size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ + keys = asdl_seq_new(size, c->c_arena); + if (!keys) + return NULL; + + values = asdl_seq_new(size, c->c_arena); + if (!values) + return NULL; + + for (i = 0; i < NCH(ch); i += 4) { + expr_ty expression; + + expression = ast_for_expr(c, CHILD(ch, i)); + if (!expression) + return NULL; + + asdl_seq_SET(keys, i / 4, expression); + + expression = ast_for_expr(c, CHILD(ch, i + 2)); + if (!expression) + return NULL; + + asdl_seq_SET(values, i / 4, expression); + } + return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); } case BACKQUOTE: { /* repr */ - expr_ty expression = ast_for_testlist(c, CHILD(n, 1)); - if (!expression) - return NULL; + expr_ty expression = ast_for_testlist(c, CHILD(n, 1)); + if (!expression) + return NULL; - return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena); + return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena); } default: - PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); - return NULL; + PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); + return NULL; } } @@ -1310,7 +1310,7 @@ */ ch = CHILD(n, 0); if (TYPE(ch) == DOT) - return Ellipsis(c->c_arena); + return Ellipsis(c->c_arena); if (NCH(n) == 1 && TYPE(ch) == test) { /* 'step' variable hold no significance in terms of being used over @@ -1319,31 +1319,31 @@ if (!step) return NULL; - return Index(step, c->c_arena); + return Index(step, c->c_arena); } if (TYPE(ch) == test) { - lower = ast_for_expr(c, ch); + lower = ast_for_expr(c, ch); if (!lower) return NULL; } /* If there's an upper bound it's in the second or third position. */ if (TYPE(ch) == COLON) { - if (NCH(n) > 1) { - node *n2 = CHILD(n, 1); + if (NCH(n) > 1) { + node *n2 = CHILD(n, 1); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } - } + } } else if (NCH(n) > 2) { - node *n2 = CHILD(n, 2); + node *n2 = CHILD(n, 2); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } @@ -1374,13 +1374,13 @@ static expr_ty ast_for_binop(struct compiling *c, const node *n) { - /* Must account for a sequence of expressions. - How should A op B op C by represented? - BinOp(BinOp(A, op, B), op, C). - */ + /* Must account for a sequence of expressions. + How should A op B op C by represented? + BinOp(BinOp(A, op, B), op, C). + */ - int i, nops; - expr_ty expr1, expr2, result; + int i, nops; + expr_ty expr1, expr2, result; operator_ty newoperator; expr1 = ast_for_expr(c, CHILD(n, 0)); @@ -1395,17 +1395,17 @@ if (!newoperator) return NULL; - result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, + result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); - if (!result) + if (!result) return NULL; - nops = (NCH(n) - 1) / 2; - for (i = 1; i < nops; i++) { - expr_ty tmp_result, tmp; - const node* next_oper = CHILD(n, i * 2 + 1); + nops = (NCH(n) - 1) / 2; + for (i = 1; i < nops; i++) { + expr_ty tmp_result, tmp; + const node* next_oper = CHILD(n, i * 2 + 1); - newoperator = get_operator(next_oper); + newoperator = get_operator(next_oper); if (!newoperator) return NULL; @@ -1414,13 +1414,13 @@ return NULL; tmp_result = BinOp(result, newoperator, tmp, - LINENO(next_oper), next_oper->n_col_offset, + LINENO(next_oper), next_oper->n_col_offset, c->c_arena); - if (!tmp) - return NULL; - result = tmp_result; - } - return result; + if (!tmp) + return NULL; + result = tmp_result; + } + return result; } static expr_ty @@ -1567,8 +1567,8 @@ tmp = ast_for_trailer(c, ch, e); if (!tmp) return NULL; - tmp->lineno = e->lineno; - tmp->col_offset = e->col_offset; + tmp->lineno = e->lineno; + tmp->col_offset = e->col_offset; e = tmp; } if (TYPE(CHILD(n, NCH(n) - 1)) == factor) { @@ -1626,8 +1626,8 @@ return ast_for_lambdef(c, CHILD(n, 0)); else if (NCH(n) > 1) return ast_for_ifexpr(c, n); - /* Fallthrough */ - case or_test: + /* Fallthrough */ + case or_test: case and_test: if (NCH(n) == 1) { n = CHILD(n, 0); @@ -1668,7 +1668,7 @@ else { expr_ty expression; asdl_int_seq *ops; - asdl_seq *cmps; + asdl_seq *cmps; ops = asdl_int_seq_new(NCH(n) / 2, c->c_arena); if (!ops) return NULL; @@ -1682,12 +1682,12 @@ newoperator = ast_for_comp_op(CHILD(n, i)); if (!newoperator) { return NULL; - } + } expression = ast_for_expr(c, CHILD(n, i + 1)); if (!expression) { return NULL; - } + } asdl_seq_SET(ops, i / 2, newoperator); asdl_seq_SET(cmps, i / 2, expression); @@ -1695,7 +1695,7 @@ expression = ast_for_expr(c, CHILD(n, 0)); if (!expression) { return NULL; - } + } return Compare(expression, ops, cmps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1718,20 +1718,20 @@ } return ast_for_binop(c, n); case yield_expr: { - expr_ty exp = NULL; - if (NCH(n) == 2) { - exp = ast_for_testlist(c, CHILD(n, 1)); - if (!exp) - return NULL; - } - return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); - } + expr_ty exp = NULL; + if (NCH(n) == 2) { + exp = ast_for_testlist(c, CHILD(n, 1)); + if (!exp) + return NULL; + } + return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); + } case factor: if (NCH(n) == 1) { n = CHILD(n, 0); goto loop; } - return ast_for_factor(c, n); + return ast_for_factor(c, n); case power: return ast_for_power(c, n); default: @@ -1748,7 +1748,7 @@ /* arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) - argument: [test '='] test [gen_for] # Really [keyword '='] test + argument: [test '='] test [gen_for] # Really [keyword '='] test */ int i, nargs, nkeywords, ngens; @@ -1762,20 +1762,20 @@ nkeywords = 0; ngens = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - if (NCH(ch) == 1) - nargs++; - else if (TYPE(CHILD(ch, 1)) == gen_for) - ngens++; + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + if (NCH(ch) == 1) + nargs++; + else if (TYPE(CHILD(ch, 1)) == gen_for) + ngens++; else - nkeywords++; - } + nkeywords++; + } } if (ngens > 1 || (ngens && (nargs || nkeywords))) { ast_error(n, "Generator expression must be parenthesized " - "if not sole argument"); - return NULL; + "if not sole argument"); + return NULL; } if (nargs + nkeywords + ngens > 255) { @@ -1792,32 +1792,32 @@ nargs = 0; nkeywords = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - expr_ty e; - if (NCH(ch) == 1) { - if (nkeywords) { - ast_error(CHILD(ch, 0), - "non-keyword arg after keyword arg"); - return NULL; - } - e = ast_for_expr(c, CHILD(ch, 0)); + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + expr_ty e; + if (NCH(ch) == 1) { + if (nkeywords) { + ast_error(CHILD(ch, 0), + "non-keyword arg after keyword arg"); + return NULL; + } + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); - } - else if (TYPE(CHILD(ch, 1)) == gen_for) { - e = ast_for_genexp(c, ch); + asdl_seq_SET(args, nargs++, e); + } + else if (TYPE(CHILD(ch, 1)) == gen_for) { + e = ast_for_genexp(c, ch); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); + asdl_seq_SET(args, nargs++, e); } - else { - keyword_ty kw; - identifier key; + else { + keyword_ty kw; + identifier key; - /* CHILD(ch, 0) is test, but must be an identifier? */ - e = ast_for_expr(c, CHILD(ch, 0)); + /* CHILD(ch, 0) is test, but must be an identifier? */ + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; /* f(lambda x: x[0] = 3) ends up getting parsed with @@ -1832,24 +1832,24 @@ ast_error(CHILD(ch, 0), "keyword can't be an expression"); return NULL; } - key = e->v.Name.id; - e = ast_for_expr(c, CHILD(ch, 2)); + key = e->v.Name.id; + e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL; - kw = keyword(key, e, c->c_arena); + kw = keyword(key, e, c->c_arena); if (!kw) return NULL; - asdl_seq_SET(keywords, nkeywords++, kw); - } - } - else if (TYPE(ch) == STAR) { - vararg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } - else if (TYPE(ch) == DOUBLESTAR) { - kwarg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } + asdl_seq_SET(keywords, nkeywords++, kw); + } + } + else if (TYPE(ch) == STAR) { + vararg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } + else if (TYPE(ch) == DOUBLESTAR) { + kwarg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } } return Call(func, args, keywords, vararg, kwarg, func->lineno, func->col_offset, c->c_arena); @@ -1873,12 +1873,12 @@ TYPE(n) == testlist1); } if (NCH(n) == 1) - return ast_for_expr(c, CHILD(n, 0)); + return ast_for_expr(c, CHILD(n, 0)); else { asdl_seq *tmp = seq_for_testlist(c, n); if (!tmp) return NULL; - return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); + return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -1889,7 +1889,7 @@ /* argument: test [ gen_for ] */ assert(TYPE(n) == testlist_gexp || TYPE(n) == argument); if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == gen_for) - return ast_for_genexp(c, n); + return ast_for_genexp(c, n); return ast_for_testlist(c, n); } @@ -1923,23 +1923,23 @@ | ('=' (yield_expr|testlist))*) testlist: test (',' test)* [','] augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' - | '<<=' | '>>=' | '**=' | '//=' + | '<<=' | '>>=' | '**=' | '//=' test: ... here starts the operator precendence dance */ if (NCH(n) == 1) { - expr_ty e = ast_for_testlist(c, CHILD(n, 0)); + expr_ty e = ast_for_testlist(c, CHILD(n, 0)); if (!e) return NULL; - return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); + return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); } else if (TYPE(CHILD(n, 1)) == augassign) { expr_ty expr1, expr2; operator_ty newoperator; - node *ch = CHILD(n, 0); + node *ch = CHILD(n, 0); - expr1 = ast_for_testlist(c, ch); + expr1 = ast_for_testlist(c, ch); if (!expr1) return NULL; /* TODO(nas): Remove duplicated error checks (set_context does it) */ @@ -1968,13 +1968,13 @@ "assignment"); return NULL; } - set_context(expr1, Store, ch); + set_context(expr1, Store, ch); - ch = CHILD(n, 2); - if (TYPE(ch) == testlist) - expr2 = ast_for_testlist(c, ch); - else - expr2 = ast_for_expr(c, ch); + ch = CHILD(n, 2); + if (TYPE(ch) == testlist) + expr2 = ast_for_testlist(c, ch); + else + expr2 = ast_for_expr(c, ch); if (!expr2) return NULL; @@ -1982,45 +1982,45 @@ if (!newoperator) return NULL; - return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); } else { - int i; - asdl_seq *targets; - node *value; + int i; + asdl_seq *targets; + node *value; expr_ty expression; - /* a normal assignment */ - REQ(CHILD(n, 1), EQUAL); - targets = asdl_seq_new(NCH(n) / 2, c->c_arena); - if (!targets) - return NULL; - for (i = 0; i < NCH(n) - 2; i += 2) { - expr_ty e; - node *ch = CHILD(n, i); - if (TYPE(ch) == yield_expr) { - ast_error(ch, "assignment to yield expression not possible"); - return NULL; - } - e = ast_for_testlist(c, ch); - - /* set context to assign */ - if (!e) - return NULL; - - if (!set_context(e, Store, CHILD(n, i))) - return NULL; - - asdl_seq_SET(targets, i / 2, e); - } - value = CHILD(n, NCH(n) - 1); - if (TYPE(value) == testlist) - expression = ast_for_testlist(c, value); - else - expression = ast_for_expr(c, value); - if (!expression) - return NULL; - return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); + /* a normal assignment */ + REQ(CHILD(n, 1), EQUAL); + targets = asdl_seq_new(NCH(n) / 2, c->c_arena); + if (!targets) + return NULL; + for (i = 0; i < NCH(n) - 2; i += 2) { + expr_ty e; + node *ch = CHILD(n, i); + if (TYPE(ch) == yield_expr) { + ast_error(ch, "assignment to yield expression not possible"); + return NULL; + } + e = ast_for_testlist(c, ch); + + /* set context to assign */ + if (!e) + return NULL; + + if (!set_context(e, Store, CHILD(n, i))) + return NULL; + + asdl_seq_SET(targets, i / 2, e); + } + value = CHILD(n, NCH(n) - 1); + if (TYPE(value) == testlist) + expression = ast_for_testlist(c, value); + else + expression = ast_for_expr(c, value); + if (!expression) + return NULL; + return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -2037,19 +2037,19 @@ REQ(n, print_stmt); if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) { - dest = ast_for_expr(c, CHILD(n, 2)); + dest = ast_for_expr(c, CHILD(n, 2)); if (!dest) return NULL; - start = 4; + start = 4; } seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = start, j = 0; i < NCH(n); i += 2, ++j) { expression = ast_for_expr(c, CHILD(n, i)); if (!expression) return NULL; - asdl_seq_SET(seq, j, expression); + asdl_seq_SET(seq, j, expression); } nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true; return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena); @@ -2066,14 +2066,14 @@ seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = 0; i < NCH(n); i += 2) { - e = ast_for_expr(c, CHILD(n, i)); - if (!e) - return NULL; - asdl_seq_SET(seq, i / 2, e); - if (context && !set_context(e, context, CHILD(n, i))) - return NULL; + e = ast_for_expr(c, CHILD(n, i)); + if (!e) + return NULL; + asdl_seq_SET(seq, i / 2, e); + if (context && !set_context(e, context, CHILD(n, i))) + return NULL; } return seq; } @@ -2115,9 +2115,9 @@ case continue_stmt: return Continue(LINENO(n), n->n_col_offset, c->c_arena); case yield_stmt: { /* will reduce to yield_expr */ - expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); - if (!exp) - return NULL; + expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); + if (!exp) + return NULL; return Expr(exp, LINENO(n), n->n_col_offset, c->c_arena); } case return_stmt: @@ -2244,13 +2244,13 @@ --s; *s = '\0'; PyString_InternInPlace(&str); - PyArena_AddPyObject(c->c_arena, str); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); } break; case STAR: - str = PyString_InternFromString("*"); - PyArena_AddPyObject(c->c_arena, str); + str = PyString_InternFromString("*"); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); default: PyErr_Format(PyExc_SystemError, @@ -2282,69 +2282,69 @@ n = CHILD(n, 0); if (TYPE(n) == import_name) { n = CHILD(n, 1); - REQ(n, dotted_as_names); - aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); - if (!aliases) - return NULL; - for (i = 0; i < NCH(n); i += 2) { + REQ(n, dotted_as_names); + aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); + if (!aliases) + return NULL; + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } - return Import(aliases, lineno, col_offset, c->c_arena); + return Import(aliases, lineno, col_offset, c->c_arena); } else if (TYPE(n) == import_from) { int n_children; - int idx, ndots = 0; - alias_ty mod = NULL; - identifier modname; - + int idx, ndots = 0; + alias_ty mod = NULL; + identifier modname; + /* Count the number of dots (for relative imports) and check for the optional module name */ - for (idx = 1; idx < NCH(n); idx++) { - if (TYPE(CHILD(n, idx)) == dotted_name) { - mod = alias_for_import_name(c, CHILD(n, idx)); - idx++; - break; - } else if (TYPE(CHILD(n, idx)) != DOT) { - break; - } - ndots++; - } - idx++; /* skip over the 'import' keyword */ + for (idx = 1; idx < NCH(n); idx++) { + if (TYPE(CHILD(n, idx)) == dotted_name) { + mod = alias_for_import_name(c, CHILD(n, idx)); + idx++; + break; + } else if (TYPE(CHILD(n, idx)) != DOT) { + break; + } + ndots++; + } + idx++; /* skip over the 'import' keyword */ switch (TYPE(CHILD(n, idx))) { case STAR: /* from ... import * */ - n = CHILD(n, idx); - n_children = 1; - if (ndots) { - ast_error(n, "'import *' not allowed with 'from .'"); - return NULL; - } - break; - case LPAR: - /* from ... import (x, y, z) */ - n = CHILD(n, idx + 1); - n_children = NCH(n); - break; - case import_as_names: - /* from ... import x, y, z */ - n = CHILD(n, idx); - n_children = NCH(n); + n = CHILD(n, idx); + n_children = 1; + if (ndots) { + ast_error(n, "'import *' not allowed with 'from .'"); + return NULL; + } + break; + case LPAR: + /* from ... import (x, y, z) */ + n = CHILD(n, idx + 1); + n_children = NCH(n); + break; + case import_as_names: + /* from ... import x, y, z */ + n = CHILD(n, idx); + n_children = NCH(n); if (n_children % 2 == 0) { ast_error(n, "trailing comma not allowed without" " surrounding parentheses"); return NULL; } - break; - default: - ast_error(n, "Unexpected node-type in from-import"); - return NULL; - } + break; + default: + ast_error(n, "Unexpected node-type in from-import"); + return NULL; + } - aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); - if (!aliases) + aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); + if (!aliases) return NULL; /* handle "from ... import *" special b/c there's no children */ @@ -2352,14 +2352,14 @@ alias_ty import_alias = alias_for_import_name(c, n); if (!import_alias) return NULL; - asdl_seq_SET(aliases, 0, import_alias); + asdl_seq_SET(aliases, 0, import_alias); } else { - for (i = 0; i < NCH(n); i += 2) { + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } } if (mod != NULL) @@ -2386,12 +2386,12 @@ REQ(n, global_stmt); s = asdl_seq_new(NCH(n) / 2, c->c_arena); if (!s) - return NULL; + return NULL; for (i = 1; i < NCH(n); i += 2) { - name = NEW_IDENTIFIER(CHILD(n, i)); - if (!name) - return NULL; - asdl_seq_SET(s, i / 2, name); + name = NEW_IDENTIFIER(CHILD(n, i)); + if (!name) + return NULL; + asdl_seq_SET(s, i / 2, name); } return Global(s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -2436,7 +2436,7 @@ expr_ty expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; - return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 4) { expr_ty expr1, expr2; @@ -2448,7 +2448,7 @@ if (!expr2) return NULL; - return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, "improper number of parts to 'assert' statement: %d", @@ -2470,53 +2470,53 @@ total = num_stmts(n); seq = asdl_seq_new(total, c->c_arena); if (!seq) - return NULL; + return NULL; if (TYPE(CHILD(n, 0)) == simple_stmt) { - n = CHILD(n, 0); - /* simple_stmt always ends with a NEWLINE, - and may have a trailing SEMI - */ - end = NCH(n) - 1; - if (TYPE(CHILD(n, end - 1)) == SEMI) - end--; + n = CHILD(n, 0); + /* simple_stmt always ends with a NEWLINE, + and may have a trailing SEMI + */ + end = NCH(n) - 1; + if (TYPE(CHILD(n, end - 1)) == SEMI) + end--; /* loop by 2 to skip semi-colons */ - for (i = 0; i < end; i += 2) { - ch = CHILD(n, i); - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } + for (i = 0; i < end; i += 2) { + ch = CHILD(n, i); + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } } else { - for (i = 2; i < (NCH(n) - 1); i++) { - ch = CHILD(n, i); - REQ(ch, stmt); - num = num_stmts(ch); - if (num == 1) { - /* small_stmt or compound_stmt with only one child */ - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - else { - int j; - ch = CHILD(ch, 0); - REQ(ch, simple_stmt); - for (j = 0; j < NCH(ch); j += 2) { - /* statement terminates with a semi-colon ';' */ - if (NCH(CHILD(ch, j)) == 0) { - assert((j + 1) == NCH(ch)); - break; - } - s = ast_for_stmt(c, CHILD(ch, j)); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - } - } + for (i = 2; i < (NCH(n) - 1); i++) { + ch = CHILD(n, i); + REQ(ch, stmt); + num = num_stmts(ch); + if (num == 1) { + /* small_stmt or compound_stmt with only one child */ + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + else { + int j; + ch = CHILD(ch, 0); + REQ(ch, simple_stmt); + for (j = 0; j < NCH(ch); j += 2) { + /* statement terminates with a semi-colon ';' */ + if (NCH(CHILD(ch, j)) == 0) { + assert((j + 1) == NCH(ch)); + break; + } + s = ast_for_stmt(c, CHILD(ch, j)); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + } + } } assert(pos == seq->size); return seq; @@ -2543,7 +2543,7 @@ if (!suite_seq) return NULL; - return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } s = STR(CHILD(n, 4)); @@ -2565,28 +2565,28 @@ if (!seq2) return NULL; - return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } else if (s[2] == 'i') { - int i, n_elif, has_else = 0; - asdl_seq *orelse = NULL; - n_elif = NCH(n) - 4; + int i, n_elif, has_else = 0; + asdl_seq *orelse = NULL; + n_elif = NCH(n) - 4; /* must reference the child n_elif+1 since 'else' token is third, not fourth, child from the end. */ - if (TYPE(CHILD(n, (n_elif + 1))) == NAME - && STR(CHILD(n, (n_elif + 1)))[2] == 's') { - has_else = 1; - n_elif -= 3; - } - n_elif /= 4; + if (TYPE(CHILD(n, (n_elif + 1))) == NAME + && STR(CHILD(n, (n_elif + 1)))[2] == 's') { + has_else = 1; + n_elif -= 3; + } + n_elif /= 4; - if (has_else) { + if (has_else) { expr_ty expression; asdl_seq *seq1, *seq2; - orelse = asdl_seq_new(1, c->c_arena); - if (!orelse) - return NULL; + orelse = asdl_seq_new(1, c->c_arena); + if (!orelse) + return NULL; expression = ast_for_expr(c, CHILD(n, NCH(n) - 6)); if (!expression) return NULL; @@ -2597,20 +2597,20 @@ if (!seq2) return NULL; - asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, - LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, + asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, + LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, c->c_arena)); - /* the just-created orelse handled the last elif */ - n_elif--; - } + /* the just-created orelse handled the last elif */ + n_elif--; + } - for (i = 0; i < n_elif; i++) { - int off = 5 + (n_elif - i - 1) * 4; + for (i = 0; i < n_elif; i++) { + int off = 5 + (n_elif - i - 1) * 4; expr_ty expression; asdl_seq *suite_seq; - asdl_seq *newobj = asdl_seq_new(1, c->c_arena); - if (!newobj) - return NULL; + asdl_seq *newobj = asdl_seq_new(1, c->c_arena); + if (!newobj) + return NULL; expression = ast_for_expr(c, CHILD(n, off)); if (!expression) return NULL; @@ -2618,14 +2618,14 @@ if (!suite_seq) return NULL; - asdl_seq_SET(newobj, 0, - If(expression, suite_seq, orelse, - LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); - orelse = newobj; - } - return If(ast_for_expr(c, CHILD(n, 1)), - ast_for_suite(c, CHILD(n, 3)), - orelse, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(newobj, 0, + If(expression, suite_seq, orelse, + LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); + orelse = newobj; + } + return If(ast_for_expr(c, CHILD(n, 1)), + ast_for_suite(c, CHILD(n, 3)), + orelse, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2649,7 +2649,7 @@ suite_seq = ast_for_suite(c, CHILD(n, 3)); if (!suite_seq) return NULL; - return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 7) { expr_ty expression; @@ -2665,7 +2665,7 @@ if (!seq2) return NULL; - return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2685,7 +2685,7 @@ REQ(n, for_stmt); if (NCH(n) == 9) { - seq = ast_for_suite(c, CHILD(n, 8)); + seq = ast_for_suite(c, CHILD(n, 8)); if (!seq) return NULL; } @@ -2697,9 +2697,9 @@ /* Check the # of children rather than the length of _target, since for x, in ... has 1 element in _target, but still requires a Tuple. */ if (NCH(node_target) == 1) - target = (expr_ty)asdl_seq_GET(_target, 0); + target = (expr_ty)asdl_seq_GET(_target, 0); else - target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); + target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); expression = ast_for_testlist(c, CHILD(n, 3)); if (!expression) @@ -2724,7 +2724,7 @@ if (!suite_seq) return NULL; - return excepthandler(NULL, NULL, suite_seq, LINENO(exc), + return excepthandler(NULL, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 2) { @@ -2738,16 +2738,16 @@ if (!suite_seq) return NULL; - return excepthandler(expression, NULL, suite_seq, LINENO(exc), + return excepthandler(expression, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 4) { asdl_seq *suite_seq; expr_ty expression; - expr_ty e = ast_for_expr(c, CHILD(exc, 3)); - if (!e) + expr_ty e = ast_for_expr(c, CHILD(exc, 3)); + if (!e) return NULL; - if (!set_context(e, Store, CHILD(exc, 3))) + if (!set_context(e, Store, CHILD(exc, 3))) return NULL; expression = ast_for_expr(c, CHILD(exc, 1)); if (!expression) @@ -2756,7 +2756,7 @@ if (!suite_seq) return NULL; - return excepthandler(expression, e, suite_seq, LINENO(exc), + return excepthandler(expression, e, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } @@ -2811,8 +2811,8 @@ } if (n_except > 0) { - int i; - stmt_ty except_st; + int i; + stmt_ty except_st; /* process except statements to create a try ... except */ asdl_seq *handlers = asdl_seq_new(n_except, c->c_arena); if (handlers == NULL) @@ -2826,17 +2826,17 @@ asdl_seq_SET(handlers, i, e); } - except_st = TryExcept(body, handlers, orelse, LINENO(n), + except_st = TryExcept(body, handlers, orelse, LINENO(n), n->n_col_offset, c->c_arena); if (!finally) - return except_st; + return except_st; /* if a 'finally' is present too, we nest the TryExcept within a TryFinally to emulate try ... except ... finally */ - body = asdl_seq_new(1, c->c_arena); - if (body == NULL) - return NULL; - asdl_seq_SET(body, 0, except_st); + body = asdl_seq_new(1, c->c_arena); + if (body == NULL) + return NULL; + asdl_seq_SET(body, 0, except_st); } /* must be a try ... finally (except clauses are in body, if any exist) */ @@ -2871,9 +2871,9 @@ if (!optional_vars) { return NULL; } - if (!set_context(optional_vars, Store, n)) { - return NULL; - } + if (!set_context(optional_vars, Store, n)) { + return NULL; + } suite_index = 4; } @@ -2882,7 +2882,7 @@ return NULL; } return With(context_expr, optional_vars, suite_seq, LINENO(n), - n->n_col_offset, c->c_arena); + n->n_col_offset, c->c_arena); } static stmt_ty @@ -2894,23 +2894,23 @@ REQ(n, classdef); if (!strcmp(STR(CHILD(n, 1)), "None")) { - ast_error(n, "assignment to None"); - return NULL; + ast_error(n, "assignment to None"); + return NULL; } if (NCH(n) == 4) { s = ast_for_suite(c, CHILD(n, 3)); if (!s) return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } /* check for empty base list */ if (TYPE(CHILD(n,3)) == RPAR) { - s = ast_for_suite(c, CHILD(n,5)); - if (!s) - return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + s = ast_for_suite(c, CHILD(n,5)); + if (!s) + return NULL; + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -2930,21 +2930,21 @@ ast_for_stmt(struct compiling *c, const node *n) { if (TYPE(n) == stmt) { - assert(NCH(n) == 1); - n = CHILD(n, 0); + assert(NCH(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == simple_stmt) { - assert(num_stmts(n) == 1); - n = CHILD(n, 0); + assert(num_stmts(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == small_stmt) { - REQ(n, small_stmt); - n = CHILD(n, 0); - /* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt - | flow_stmt | import_stmt | global_stmt | exec_stmt + REQ(n, small_stmt); + n = CHILD(n, 0); + /* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt + | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt - */ - switch (TYPE(n)) { + */ + switch (TYPE(n)) { case expr_stmt: return ast_for_expr_stmt(c, n); case print_stmt: @@ -2972,11 +2972,11 @@ } else { /* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt - | funcdef | classdef - */ - node *ch = CHILD(n, 0); - REQ(n, compound_stmt); - switch (TYPE(ch)) { + | funcdef | classdef + */ + node *ch = CHILD(n, 0); + REQ(n, compound_stmt); + switch (TYPE(ch)) { case if_stmt: return ast_for_if_stmt(c, ch); case while_stmt: @@ -2996,144 +2996,144 @@ "unhandled small_stmt: TYPE=%d NCH=%d\n", TYPE(n), NCH(n)); return NULL; - } + } } } static PyObject * parsenumber(const char *s) { - const char *end; - long x; - double dx; + const char *end; + long x; + double dx; #ifndef WITHOUT_COMPLEX - Py_complex c; - int imflag; + Py_complex c; + int imflag; #endif - errno = 0; - end = s + strlen(s) - 1; + errno = 0; + end = s + strlen(s) - 1; #ifndef WITHOUT_COMPLEX - imflag = *end == 'j' || *end == 'J'; + imflag = *end == 'j' || *end == 'J'; #endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString((char *)s, (char **)0, 0); - if (s[0] == '0') { - x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); - if (x < 0 && errno == 0) { - return PyLong_FromString((char *)s, - (char **)0, - 0); - } - } - else - x = PyOS_strtol((char *)s, (char **)&end, 0); - if (*end == '\0') { - if (errno != 0) - return PyLong_FromString((char *)s, (char **)0, 0); - return PyInt_FromLong(x); - } - /* XXX Huge floats may silently fail */ + if (*end == 'l' || *end == 'L') + return PyLong_FromString((char *)s, (char **)0, 0); + if (s[0] == '0') { + x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); + if (x < 0 && errno == 0) { + return PyLong_FromString((char *)s, + (char **)0, + 0); + } + } + else + x = PyOS_strtol((char *)s, (char **)&end, 0); + if (*end == '\0') { + if (errno != 0) + return PyLong_FromString((char *)s, (char **)0, 0); + return PyInt_FromLong(x); + } + /* XXX Huge floats may silently fail */ #ifndef WITHOUT_COMPLEX - if (imflag) { - c.real = 0.; - PyFPE_START_PROTECT("atof", return 0) - c.imag = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(c) - return PyComplex_FromCComplex(c); - } - else + if (imflag) { + c.real = 0.; + PyFPE_START_PROTECT("atof", return 0) + c.imag = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(c) + return PyComplex_FromCComplex(c); + } + else #endif - { - PyFPE_START_PROTECT("atof", return 0) - dx = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(dx) - return PyFloat_FromDouble(dx); - } + { + PyFPE_START_PROTECT("atof", return 0) + dx = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(dx) + return PyFloat_FromDouble(dx); + } } static PyObject * decode_utf8(const char **sPtr, const char *end, char* encoding) { #ifndef Py_USING_UNICODE - Py_FatalError("decode_utf8 should not be called in this build."); + Py_FatalError("decode_utf8 should not be called in this build."); return NULL; #else - PyObject *u, *v; - char *s, *t; - t = s = (char *)*sPtr; - /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ - while (s < end && (*s & 0x80)) s++; - *sPtr = s; - u = PyUnicode_DecodeUTF8(t, s - t, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *u, *v; + char *s, *t; + t = s = (char *)*sPtr; + /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ + while (s < end && (*s & 0x80)) s++; + *sPtr = s; + u = PyUnicode_DecodeUTF8(t, s - t, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif } static PyObject * decode_unicode(const char *s, size_t len, int rawmode, const char *encoding) { - PyObject *v, *u; - char *buf; - char *p; - const char *end; - if (encoding == NULL) { - buf = (char *)s; - u = NULL; - } else if (strcmp(encoding, "iso-8859-1") == 0) { - buf = (char *)s; - u = NULL; - } else { - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); - if (u == NULL) - return NULL; - p = buf = PyString_AsString(u); - end = s + len; - while (s < end) { - if (*s == '\\') { - *p++ = *s++; - if (*s & 0x80) { - strcpy(p, "u005c"); - p += 5; - } - } - if (*s & 0x80) { /* XXX inefficient */ - PyObject *w; - char *r; - Py_ssize_t rn, i; - w = decode_utf8(&s, end, "utf-16-be"); - if (w == NULL) { - Py_DECREF(u); - return NULL; - } - r = PyString_AsString(w); - rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", - r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; - } - Py_DECREF(w); - } else { - *p++ = *s++; - } - } - len = p - buf; - s = buf; - } - if (rawmode) - v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); - else - v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); - Py_XDECREF(u); - return v; + PyObject *v, *u; + char *buf; + char *p; + const char *end; + if (encoding == NULL) { + buf = (char *)s; + u = NULL; + } else if (strcmp(encoding, "iso-8859-1") == 0) { + buf = (char *)s; + u = NULL; + } else { + /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ + u = PyString_FromStringAndSize((char *)NULL, len * 4); + if (u == NULL) + return NULL; + p = buf = PyString_AsString(u); + end = s + len; + while (s < end) { + if (*s == '\\') { + *p++ = *s++; + if (*s & 0x80) { + strcpy(p, "u005c"); + p += 5; + } + } + if (*s & 0x80) { /* XXX inefficient */ + PyObject *w; + char *r; + Py_ssize_t rn, i; + w = decode_utf8(&s, end, "utf-16-be"); + if (w == NULL) { + Py_DECREF(u); + return NULL; + } + r = PyString_AsString(w); + rn = PyString_Size(w); + assert(rn % 2 == 0); + for (i = 0; i < rn; i += 2) { + sprintf(p, "\\u%02x%02x", + r[i + 0] & 0xFF, + r[i + 1] & 0xFF); + p += 6; + } + Py_DECREF(w); + } else { + *p++ = *s++; + } + } + len = p - buf; + s = buf; + } + if (rawmode) + v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); + else + v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); + Py_XDECREF(u); + return v; } /* s is a Python string literal, including the bracketing quote characters, @@ -3143,75 +3143,75 @@ static PyObject * parsestr(const char *s, const char *encoding) { - size_t len; - int quote = Py_CHARMASK(*s); - int rawmode = 0; - int need_encoding; - int unicode = 0; - - if (isalpha(quote) || quote == '_') { - if (quote == 'u' || quote == 'U') { - quote = *++s; - unicode = 1; - } - if (quote == 'r' || quote == 'R') { - quote = *++s; - rawmode = 1; - } - } - if (quote != '\'' && quote != '\"') { - PyErr_BadInternalCall(); - return NULL; - } - s++; - len = strlen(s); - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string to parse is too long"); - return NULL; - } - if (s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - if (len >= 4 && s[0] == quote && s[1] == quote) { - s += 2; - len -= 2; - if (s[--len] != quote || s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - } + size_t len; + int quote = Py_CHARMASK(*s); + int rawmode = 0; + int need_encoding; + int unicode = 0; + + if (isalpha(quote) || quote == '_') { + if (quote == 'u' || quote == 'U') { + quote = *++s; + unicode = 1; + } + if (quote == 'r' || quote == 'R') { + quote = *++s; + rawmode = 1; + } + } + if (quote != '\'' && quote != '\"') { + PyErr_BadInternalCall(); + return NULL; + } + s++; + len = strlen(s); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "string to parse is too long"); + return NULL; + } + if (s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + if (len >= 4 && s[0] == quote && s[1] == quote) { + s += 2; + len -= 2; + if (s[--len] != quote || s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + } #ifdef Py_USING_UNICODE - if (unicode || Py_UnicodeFlag) { - return decode_unicode(s, len, rawmode, encoding); - } + if (unicode || Py_UnicodeFlag) { + return decode_unicode(s, len, rawmode, encoding); + } #endif - need_encoding = (encoding != NULL && - strcmp(encoding, "utf-8") != 0 && - strcmp(encoding, "iso-8859-1") != 0); - if (rawmode || strchr(s, '\\') == NULL) { - if (need_encoding) { + need_encoding = (encoding != NULL && + strcmp(encoding, "utf-8") != 0 && + strcmp(encoding, "iso-8859-1") != 0); + if (rawmode || strchr(s, '\\') == NULL) { + if (need_encoding) { #ifndef Py_USING_UNICODE - /* This should not happen - we never see any other - encoding. */ - Py_FatalError( + /* This should not happen - we never see any other + encoding. */ + Py_FatalError( "cannot deal with encodings in this build."); #else - PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif - } else { - return PyString_FromStringAndSize(s, len); - } - } + } else { + return PyString_FromStringAndSize(s, len); + } + } - return PyString_DecodeEscape(s, len, NULL, unicode, - need_encoding ? encoding : NULL); + return PyString_DecodeEscape(s, len, NULL, unicode, + need_encoding ? encoding : NULL); } /* Build a Python string object out of a STRING atom. This takes care of @@ -3221,36 +3221,36 @@ static PyObject * parsestrplus(struct compiling *c, const node *n) { - PyObject *v; - int i; - REQ(CHILD(n, 0), STRING); - if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { - /* String literal concatenation */ - for (i = 1; i < NCH(n); i++) { - PyObject *s; - s = parsestr(STR(CHILD(n, i)), c->c_encoding); - if (s == NULL) - goto onError; - if (PyString_Check(v) && PyString_Check(s)) { - PyString_ConcatAndDel(&v, s); - if (v == NULL) - goto onError; - } + PyObject *v; + int i; + REQ(CHILD(n, 0), STRING); + if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { + /* String literal concatenation */ + for (i = 1; i < NCH(n); i++) { + PyObject *s; + s = parsestr(STR(CHILD(n, i)), c->c_encoding); + if (s == NULL) + goto onError; + if (PyString_Check(v) && PyString_Check(s)) { + PyString_ConcatAndDel(&v, s); + if (v == NULL) + goto onError; + } #ifdef Py_USING_UNICODE - else { - PyObject *temp = PyUnicode_Concat(v, s); - Py_DECREF(s); - Py_DECREF(v); - v = temp; - if (v == NULL) - goto onError; - } + else { + PyObject *temp = PyUnicode_Concat(v, s); + Py_DECREF(s); + Py_DECREF(v); + v = temp; + if (v == NULL) + goto onError; + } #endif - } - } - return v; + } + } + return v; onError: - Py_XDECREF(v); - return NULL; + Py_XDECREF(v); + return NULL; } From python-checkins at python.org Tue Sep 5 06:09:42 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 06:09:42 +0200 (CEST) Subject: [Python-checkins] r51733 - peps/trunk/pep-0356.txt Message-ID: <20060905040942.CF1021E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 06:09:41 2006 New Revision: 51733 Modified: peps/trunk/pep-0356.txt Log: update status of more bugs Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Tue Sep 5 06:09:41 2006 @@ -150,10 +150,14 @@ - Bugs that need resolving before release, ie, they block release: + http://python.org/sf/1551432 - __unicode__ breaks on exception classes + http://python.org/sf/1550938 - improper exception w/relative import http://python.org/sf/1541697 - sgmllib regexp bug causes hang - Bugs deferred until 2.5.1 (or later) + http://python.org/sf/1544279 - Socket module is not thread-safe http://python.org/sf/1541420 - tools and demo missing from windows + http://python.org/sf/1542451 - crash with continue in nested try/finally http://python.org/sf/1475523 - gettext.py bug (owner: Martin v. Loewis) http://python.org/sf/1467929 - %-formatting and dicts http://python.org/sf/1446043 - unicode() does not raise LookupError From nnorwitz at gmail.com Tue Sep 5 06:12:43 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Mon, 4 Sep 2006 21:12:43 -0700 Subject: [Python-checkins] TRUNK IS UNFROZEN, available for 2.6 work if you are so inclined In-Reply-To: References: <200608180023.14037.anthony@interlink.com.au> Message-ID: On 8/18/06, Georg Brandl wrote: > > I'd like to commit this. It fixes bug 1542051. > > Index: Objects/exceptions.c ... Georg, Did you still want to fix this? I don't remember anything happening with it. I don't see where _PyObject_GC_TRACK is called, so I'm not sure why _PyObject_GC_UNTRACK is necessary. You should probably add the patch to the bug report and we can discuss there. n From python-checkins at python.org Tue Sep 5 06:32:07 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 06:32:07 +0200 (CEST) Subject: [Python-checkins] r51734 - python/branches/release25-maint/Objects/fileobject.c Message-ID: <20060905043207.7882A1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 06:32:06 2006 New Revision: 51734 Modified: python/branches/release25-maint/Objects/fileobject.c Log: Backport 51669: Make sure memory is properly cleaned up in file_init (even though this should not be able to happen since we already parsed the args) Modified: python/branches/release25-maint/Objects/fileobject.c ============================================================================== --- python/branches/release25-maint/Objects/fileobject.c (original) +++ python/branches/release25-maint/Objects/fileobject.c Tue Sep 5 06:32:06 2006 @@ -2016,7 +2016,7 @@ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|si:file", kwlist, &o_name, &mode, &bufsize)) - return -1; + goto Error; if (fill_file_fields(foself, NULL, o_name, mode, fclose) == NULL) From buildbot at python.org Tue Sep 5 06:33:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 04:33:58 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20060905043358.B5B431E4004@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.5/builds/16 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: neal.norwitz,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 5 06:43:57 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 06:43:57 +0200 (CEST) Subject: [Python-checkins] r51735 - python/branches/release25-maint/Misc/NEWS Message-ID: <20060905044357.80BD91E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 06:43:56 2006 New Revision: 51735 Modified: python/branches/release25-maint/Misc/NEWS Log: Add some NEWS for fixes already in 2.5c1 Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 06:43:56 2006 @@ -96,6 +96,10 @@ Core and builtins ----------------- +- Fix infinite recursion when subclassing long and overriding __hash__. + +- Fix concatenation (+=) of long strings. + - Unicode objects will no longer raise an exception when being compared equal or unequal to a string and a UnicodeDecodeError exception occurs, e.g. as result of a decoding failure. From python-checkins at python.org Tue Sep 5 06:49:46 2006 From: python-checkins at python.org (neal.norwitz) Date: Tue, 5 Sep 2006 06:49:46 +0200 (CEST) Subject: [Python-checkins] r51736 - python/branches/release25-maint/Misc/NEWS Message-ID: <20060905044946.6B35A1E4004@bag.python.org> Author: neal.norwitz Date: Tue Sep 5 06:49:45 2006 New Revision: 51736 Modified: python/branches/release25-maint/Misc/NEWS Log: Add another NEWS entry for a fix already in 2.5c1 Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Tue Sep 5 06:49:45 2006 @@ -196,6 +196,8 @@ Extension Modules ----------------- +- Ignore data that arrives before the opening start tag in C etree. + - Patch #1511317: don't crash on invalid hostname (alias) info. - Patch #1535500: fix segfault in BZ2File.writelines and make sure it From buildbot at python.org Tue Sep 5 08:27:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 06:27:02 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.4 Message-ID: <20060905062702.CC4921E4004@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.4/builds/6 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue Sep 5 11:50:07 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 09:50:07 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060905095007.7728D1E4004@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/82 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz,tim.peters Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 5 14:07:11 2006 From: python-checkins at python.org (hyeshik.chang) Date: Tue, 5 Sep 2006 14:07:11 +0200 (CEST) Subject: [Python-checkins] r51737 - in python/trunk: Lib/test/test_codecencodings_cn.py Lib/test/test_multibytecodec.py Misc/NEWS Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h Message-ID: <20060905120711.469251E4004@bag.python.org> Author: hyeshik.chang Date: Tue Sep 5 14:07:09 2006 New Revision: 51737 Modified: python/trunk/Lib/test/test_codecencodings_cn.py python/trunk/Lib/test/test_multibytecodec.py python/trunk/Misc/NEWS python/trunk/Modules/cjkcodecs/_codecs_cn.c python/trunk/Modules/cjkcodecs/_codecs_iso2022.c python/trunk/Modules/cjkcodecs/cjkcodecs.h Log: Fix a few bugs on cjkcodecs found by Oren Tirosh: - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 codepoints to conform the standard. - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 codepoints now. Modified: python/trunk/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/trunk/Lib/test/test_codecencodings_cn.py (original) +++ python/trunk/Lib/test/test_codecencodings_cn.py Tue Sep 5 14:07:09 2006 @@ -32,6 +32,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("\x83\x34\x83\x31", "strict", None), + (u"\u30fb", "strict", None), ) class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): @@ -45,6 +46,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"), + (u"\u30fb", "strict", "\x819\xa79"), ) has_iso10646 = True Modified: python/trunk/Lib/test/test_multibytecodec.py ============================================================================== --- python/trunk/Lib/test/test_multibytecodec.py (original) +++ python/trunk/Lib/test/test_multibytecodec.py Tue Sep 5 14:07:09 2006 @@ -202,6 +202,12 @@ uni = u':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) + def test_iso2022_jp_g0(self): + self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) + for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): + e = u'\u3406'.encode(encoding) + self.failIf(filter(lambda x: x >= '\x80', e)) + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_MultibyteCodec)) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 14:07:09 2006 @@ -45,6 +45,12 @@ - Bug #1550714: fix SystemError from itertools.tee on negative value for n. +- Fixed a few bugs on cjkcodecs: + - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. + - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 + codepoints to conform the standard. + - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 + codepoints now. Tests ----- Modified: python/trunk/Modules/cjkcodecs/_codecs_cn.c ============================================================================== --- python/trunk/Modules/cjkcodecs/_codecs_cn.c (original) +++ python/trunk/Modules/cjkcodecs/_codecs_cn.c Tue Sep 5 14:07:09 2006 @@ -15,14 +15,26 @@ #undef hz #endif -#define GBK_PREDECODE(dc1, dc2, assi) \ +/* GBK and GB2312 map differently in few codepoints that are listed below: + * + * gb2312 gbk + * A1A4 U+30FB KATAKANA MIDDLE DOT U+00B7 MIDDLE DOT + * A1AA U+2015 HORIZONTAL BAR U+2014 EM DASH + * A844 undefined U+2015 HORIZONTAL BAR + */ + +#define GBK_DECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ - else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; -#define GBK_PREENCODE(code, assi) \ + else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \ + else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \ + else TRYMAP_DEC(gbkext, assi, dc1, dc2); + +#define GBK_ENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ - else if ((code) == 0x00b7) (assi) = 0xa1a4; + else if ((code) == 0x00b7) (assi) = 0xa1a4; \ + else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code)); /* * GB2312 codec @@ -99,8 +111,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); + GBK_ENCODE(c, code) else return 1; OUT1((code >> 8) | 0x80) @@ -129,9 +140,7 @@ REQUIRE_INBUF(2) - GBK_PREDECODE(c, IN2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, IN2); + GBK_DECODE(c, IN2, **outbuf) else return 2; NEXT(2, 1) @@ -187,9 +196,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); - else TRYMAP_ENC(gb18030ext, code, c); + GBK_ENCODE(c, code) else { const struct _gb18030_to_unibmp_ranges *utrrange; @@ -287,9 +294,7 @@ return 4; } - GBK_PREDECODE(c, c2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, c2); + GBK_DECODE(c, c2, **outbuf) else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; Modified: python/trunk/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/trunk/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/trunk/Modules/cjkcodecs/_codecs_iso2022.c Tue Sep 5 14:07:09 2006 @@ -854,7 +854,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -901,7 +901,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -992,7 +992,10 @@ /*-*- registry tables -*-*/ -#define REGISTRY_KSX1001 { CHARSET_KSX1001, 1, 2, \ +#define REGISTRY_KSX1001_G0 { CHARSET_KSX1001, 0, 2, \ + ksx1001_init, \ + ksx1001_decoder, ksx1001_encoder } +#define REGISTRY_KSX1001_G1 { CHARSET_KSX1001, 1, 2, \ ksx1001_init, \ ksx1001_decoder, ksx1001_encoder } #define REGISTRY_JISX0201_R { CHARSET_JISX0201_R, 0, 1, \ @@ -1034,7 +1037,7 @@ jisx0213_init, \ jisx0213_2004_2_decoder, \ jisx0213_2004_2_encoder } -#define REGISTRY_GB2312 { CHARSET_GB2312, 1, 2, \ +#define REGISTRY_GB2312 { CHARSET_GB2312, 0, 2, \ gb2312_init, \ gb2312_decoder, gb2312_encoder } #define REGISTRY_CNS11643_1 { CHARSET_CNS11643_1, 1, 2, \ @@ -1054,7 +1057,7 @@ }; static const struct iso2022_designation iso2022_kr_designations[] = { - REGISTRY_KSX1001, REGISTRY_SENTINEL + REGISTRY_KSX1001_G1, REGISTRY_SENTINEL }; CONFIGDEF(kr, 0) @@ -1071,7 +1074,7 @@ CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) static const struct iso2022_designation iso2022_jp_2_designations[] = { - REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; Modified: python/trunk/Modules/cjkcodecs/cjkcodecs.h ============================================================================== --- python/trunk/Modules/cjkcodecs/cjkcodecs.h (original) +++ python/trunk/Modules/cjkcodecs/cjkcodecs.h Tue Sep 5 14:07:09 2006 @@ -159,29 +159,32 @@ #endif #define _TRYMAP_ENC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) -#define TRYMAP_ENC(charset, assi, uni) \ +#define TRYMAP_ENC_COND(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) +#define TRYMAP_ENC(charset, assi, uni) \ + if TRYMAP_ENC_COND(charset, assi, uni) + #define _TRYMAP_DEC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ - _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ + if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ From python-checkins at python.org Tue Sep 5 14:14:58 2006 From: python-checkins at python.org (hyeshik.chang) Date: Tue, 5 Sep 2006 14:14:58 +0200 (CEST) Subject: [Python-checkins] r51738 - python/trunk/Misc/NEWS Message-ID: <20060905121458.26BC81E4004@bag.python.org> Author: hyeshik.chang Date: Tue Sep 5 14:14:57 2006 New Revision: 51738 Modified: python/trunk/Misc/NEWS Log: Fix a typo: 2013 -> 0213 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 5 14:14:57 2006 @@ -49,7 +49,7 @@ - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 codepoints to conform the standard. - - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 + - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 codepoints now. Tests From ncoghlan at gmail.com Tue Sep 5 14:30:05 2006 From: ncoghlan at gmail.com (Nick Coghlan) Date: Tue, 05 Sep 2006 22:30:05 +1000 Subject: [Python-checkins] r51731 - python/trunk/Python/ast.c In-Reply-To: <20060905035827.07C471E4004@bag.python.org> References: <20060905035827.07C471E4004@bag.python.org> Message-ID: <44FD6DCD.6010902@gmail.com> neal.norwitz wrote: > +/* XXX(nnorwitz): the listcomp and genexpr code should be refactored > + so there is only a single version. Possibly for loops can also re-use > + the code. > +*/ I believe I tried to do exactly that back before the AST compiler landed on the trunk. As I recall, the code generated turned out to be sufficiently different in structure (a for loop instead of an anonymous generator function) that it didn't seem practical to combine them. Then again, I wasn't that familiar with the AST code at the time, so maybe someone else will have more luck :) Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From python-checkins at python.org Tue Sep 5 14:44:58 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 5 Sep 2006 14:44:58 +0200 (CEST) Subject: [Python-checkins] r51740 - python/trunk/Doc/lib/libstdtypes.tex Message-ID: <20060905124458.7D13D1E4005@bag.python.org> Author: georg.brandl Date: Tue Sep 5 14:44:58 2006 New Revision: 51740 Modified: python/trunk/Doc/lib/libstdtypes.tex Log: Bug #1552618: change docs of dict.has_key() to reflect recommendation to use "in". Modified: python/trunk/Doc/lib/libstdtypes.tex ============================================================================== --- python/trunk/Doc/lib/libstdtypes.tex (original) +++ python/trunk/Doc/lib/libstdtypes.tex Tue Sep 5 14:44:58 2006 @@ -1410,15 +1410,15 @@ {(1)} \lineiii{\var{a}.clear()}{remove all items from \code{a}}{} \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{} - \lineiii{\var{a}.has_key(\var{k})} + \lineiii{\var{k} in \var{a}} {\code{True} if \var{a} has a key \var{k}, else \code{False}} - {} - \lineiii{\var{k} \code{in} \var{a}} - {Equivalent to \var{a}.has_key(\var{k})} {(2)} \lineiii{\var{k} not in \var{a}} - {Equivalent to \code{not} \var{a}.has_key(\var{k})} + {Equivalent to \code{not} \var{k} in \var{a}} {(2)} + \lineiii{\var{a}.has_key(\var{k})} + {Equivalent to \var{k} \code{in} \var{a}, use that form in new code} + {} \lineiii{\var{a}.items()} {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs} {(3)} From python-checkins at python.org Tue Sep 5 14:45:18 2006 From: python-checkins at python.org (georg.brandl) Date: Tue, 5 Sep 2006 14:45:18 +0200 (CEST) Subject: [Python-checkins] r51741 - python/branches/release25-maint/Doc/lib/libstdtypes.tex Message-ID: <20060905124518.7C9191E4004@bag.python.org> Author: georg.brandl Date: Tue Sep 5 14:45:18 2006 New Revision: 51741 Modified: python/branches/release25-maint/Doc/lib/libstdtypes.tex Log: Bug #1552618: change docs of dict.has_key() to reflect recommendation to use "in". (backport from rev. 51740) Modified: python/branches/release25-maint/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libstdtypes.tex (original) +++ python/branches/release25-maint/Doc/lib/libstdtypes.tex Tue Sep 5 14:45:18 2006 @@ -1410,15 +1410,15 @@ {(1)} \lineiii{\var{a}.clear()}{remove all items from \code{a}}{} \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{} - \lineiii{\var{a}.has_key(\var{k})} + \lineiii{\var{k} in \var{a}} {\code{True} if \var{a} has a key \var{k}, else \code{False}} - {} - \lineiii{\var{k} \code{in} \var{a}} - {Equivalent to \var{a}.has_key(\var{k})} {(2)} \lineiii{\var{k} not in \var{a}} - {Equivalent to \code{not} \var{a}.has_key(\var{k})} + {Equivalent to \code{not} \var{k} in \var{a}} {(2)} + \lineiii{\var{a}.has_key(\var{k})} + {Equivalent to \var{k} \code{in} \var{a}, use that form in new code} + {} \lineiii{\var{a}.items()} {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs} {(3)} From g.brandl at gmx.net Tue Sep 5 14:48:57 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Tue, 05 Sep 2006 14:48:57 +0200 Subject: [Python-checkins] r51731 - python/trunk/Python/ast.c In-Reply-To: <44FD6DCD.6010902@gmail.com> References: <20060905035827.07C471E4004@bag.python.org> <44FD6DCD.6010902@gmail.com> Message-ID: Nick Coghlan wrote: > neal.norwitz wrote: >> +/* XXX(nnorwitz): the listcomp and genexpr code should be refactored >> + so there is only a single version. Possibly for loops can also re-use >> + the code. >> +*/ > > I believe I tried to do exactly that back before the AST compiler landed on > the trunk. As I recall, the code generated turned out to be sufficiently > different in structure (a for loop instead of an anonymous generator function) > that it didn't seem practical to combine them. That's what I saw when I looked at the code. For my set comprehension patch (on SF) I unified all comprehensions so that listcomps are also executed in an anonymous function, hence the code is unified too. Georg From buildbot at python.org Tue Sep 5 15:01:08 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 13:01:08 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060905130108.780741E4004@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1146 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: hyeshik.chang Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 5 15:02:43 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 5 Sep 2006 15:02:43 +0200 (CEST) Subject: [Python-checkins] r51742 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060905130243.09E9C1E4004@bag.python.org> Author: andrew.kuchling Date: Tue Sep 5 15:02:40 2006 New Revision: 51742 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Rearrange example a bit, and show rpartition() when separator is not found Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Tue Sep 5 15:02:40 2006 @@ -1115,12 +1115,14 @@ \begin{verbatim} >>> ('http://www.python.org').partition('://') ('http', '://', 'www.python.org') ->>> (u'Subject: a quick question').partition(':') -(u'Subject', u':', u' a quick question') >>> ('file:/usr/share/doc/index.html').partition('://') ('file:/usr/share/doc/index.html', '', '') +>>> (u'Subject: a quick question').partition(':') +(u'Subject', u':', u' a quick question') >>> 'www.python.org'.rpartition('.') ('www.python', '.', 'org') +>>> 'www.python.org'.rpartition(':') +('', '', 'www.python.org') \end{verbatim} (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) From hyeshik at gmail.com Tue Sep 5 15:04:30 2006 From: hyeshik at gmail.com (Hye-Shik Chang) Date: Tue, 5 Sep 2006 22:04:30 +0900 Subject: [Python-checkins] r51737 - in python/trunk: Lib/test/test_codecencodings_cn.py Lib/test/test_multibytecodec.py Misc/NEWS Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h In-Reply-To: <20060905120711.469251E4004@bag.python.org> References: <20060905120711.469251E4004@bag.python.org> Message-ID: <4f0b69dc0609050604l5e7f9fa6x6129dd42398094ea@mail.gmail.com> On 9/5/06, hyeshik.chang wrote: > Author: hyeshik.chang > Date: Tue Sep 5 14:07:09 2006 > New Revision: 51737 > > Modified: > python/trunk/Lib/test/test_codecencodings_cn.py > python/trunk/Lib/test/test_multibytecodec.py > python/trunk/Misc/NEWS > python/trunk/Modules/cjkcodecs/_codecs_cn.c > python/trunk/Modules/cjkcodecs/_codecs_iso2022.c > python/trunk/Modules/cjkcodecs/cjkcodecs.h > Log: > Fix a few bugs on cjkcodecs found by Oren Tirosh: > - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. > - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 > codepoints to conform the standard. > - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 > codepoints now. > Neal, is there any chance to backport this to 2.5 branch? I think it doesn't include any dangerous change. Hye-Shik From python-checkins at python.org Tue Sep 5 15:11:33 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 5 Sep 2006 15:11:33 +0200 (CEST) Subject: [Python-checkins] r51743 - python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex Message-ID: <20060905131133.A9CDC1E4004@bag.python.org> Author: andrew.kuchling Date: Tue Sep 5 15:11:33 2006 New Revision: 51743 Modified: python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex Log: Rearrange example a bit, and show rpartition() when separator is not found Modified: python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex Tue Sep 5 15:11:33 2006 @@ -1115,12 +1115,14 @@ \begin{verbatim} >>> ('http://www.python.org').partition('://') ('http', '://', 'www.python.org') ->>> (u'Subject: a quick question').partition(':') -(u'Subject', u':', u' a quick question') >>> ('file:/usr/share/doc/index.html').partition('://') ('file:/usr/share/doc/index.html', '', '') +>>> (u'Subject: a quick question').partition(':') +(u'Subject', u':', u' a quick question') >>> 'www.python.org'.rpartition('.') ('www.python', '.', 'org') +>>> 'www.python.org'.rpartition(':') +('', '', 'www.python.org') \end{verbatim} (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) From buildbot at python.org Tue Sep 5 15:15:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 13:15:14 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060905131514.AD3191E4009@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/944 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: hyeshik.chang Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 5 15:15:42 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 5 Sep 2006 15:15:42 +0200 (CEST) Subject: [Python-checkins] r51744 - python/trunk/Lib/SimpleXMLRPCServer.py Message-ID: <20060905131542.414C71E401F@bag.python.org> Author: andrew.kuchling Date: Tue Sep 5 15:15:41 2006 New Revision: 51744 Modified: python/trunk/Lib/SimpleXMLRPCServer.py Log: [Bug #1525469] SimpleXMLRPCServer still uses the sys.exc_{value,type} module-level globals instead of calling sys.exc_info(). Reported by Russell Warren Modified: python/trunk/Lib/SimpleXMLRPCServer.py ============================================================================== --- python/trunk/Lib/SimpleXMLRPCServer.py (original) +++ python/trunk/Lib/SimpleXMLRPCServer.py Tue Sep 5 15:15:41 2006 @@ -264,8 +264,9 @@ encoding=self.encoding) except: # report exception back to server + exc_type, exc_value, exc_tb = sys.exc_info() response = xmlrpclib.dumps( - xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)), + xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)), encoding=self.encoding, allow_none=self.allow_none, ) @@ -364,9 +365,10 @@ 'faultString' : fault.faultString} ) except: + exc_type, exc_value, exc_tb = sys.exc_info() results.append( {'faultCode' : 1, - 'faultString' : "%s:%s" % (sys.exc_type, sys.exc_value)} + 'faultString' : "%s:%s" % (exc_type, exc_value)} ) return results From python-checkins at python.org Tue Sep 5 15:19:18 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 5 Sep 2006 15:19:18 +0200 (CEST) Subject: [Python-checkins] r51745 - python/trunk/Lib/pdb.py Message-ID: <20060905131918.D71CC1E4004@bag.python.org> Author: andrew.kuchling Date: Tue Sep 5 15:19:18 2006 New Revision: 51745 Modified: python/trunk/Lib/pdb.py Log: [Bug #1526834] Fix crash in pdb when you do 'b f('; the function name was placed into a regex pattern and the unbalanced paren caused re.compile() to report an error Modified: python/trunk/Lib/pdb.py ============================================================================== --- python/trunk/Lib/pdb.py (original) +++ python/trunk/Lib/pdb.py Tue Sep 5 15:19:18 2006 @@ -23,7 +23,7 @@ "post_mortem", "help"] def find_function(funcname, filename): - cre = re.compile(r'def\s+%s\s*[(]' % funcname) + cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try: fp = open(filename) except IOError: From python-checkins at python.org Tue Sep 5 15:39:06 2006 From: python-checkins at python.org (sean.reifschneider) Date: Tue, 5 Sep 2006 15:39:06 +0200 (CEST) Subject: [Python-checkins] r51746 - python/branches/release25-maint/Misc/RPM/python-2.5.spec Message-ID: <20060905133906.895081E4004@bag.python.org> Author: sean.reifschneider Date: Tue Sep 5 15:39:06 2006 New Revision: 51746 Modified: python/branches/release25-maint/Misc/RPM/python-2.5.spec Log: Fixing an improperly escaped grep in .spec file, pointed out by Neal Norwitz. Modified: python/branches/release25-maint/Misc/RPM/python-2.5.spec ============================================================================== --- python/branches/release25-maint/Misc/RPM/python-2.5.spec (original) +++ python/branches/release25-maint/Misc/RPM/python-2.5.spec Tue Sep 5 15:39:06 2006 @@ -286,7 +286,7 @@ rm -f tools.files find "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/idlelib \ "$RPM_BUILD_ROOT""%{__prefix}"/%{libdirname}/python%{libvers}/Tools -type f | - grep -v -e '\\.pyc$' -e '\\.pyo$' | + grep -v -e '\.pyc$' -e '\.pyo$' | sed "s|^${RPM_BUILD_ROOT}|/|" >tools.files echo "%{__prefix}"/bin/idle%{binsuffix} >>tools.files grep '\.py$' tools.files | sed 's/$/c/' | grep -v /idlelib/ >tools.files.tmp From python-checkins at python.org Tue Sep 5 19:47:09 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 5 Sep 2006 19:47:09 +0200 (CEST) Subject: [Python-checkins] r51748 - in python/branches/bcannon-objcap: Doc/lib/libdecimal.tex Doc/lib/libhashlib.tex Doc/lib/libstdtypes.tex Doc/lib/libunittest.tex Doc/ref/ref3.tex Doc/tut/tut.tex Doc/whatsnew/whatsnew25.tex Lib/SimpleXMLRPCServer.py Lib/bsddb/test/test_basics.py Lib/decimal.py Lib/doctest.py Lib/genericpath.py Lib/pdb.py Lib/test/string_tests.py Lib/test/test_codecencodings_cn.py Lib/test/test_contextlib.py Lib/test/test_decimal.py Lib/test/test_fcntl.py Lib/test/test_genericpath.py Lib/test/test_grammar.py Lib/test/test_itertools.py Lib/test/test_multibytecodec.py Lib/test/test_mutants.py Lib/test/test_tempfile.py Lib/test/test_tokenize.py Misc/NEWS Misc/Vim/vimrc Modules/_cursesmodule.c Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h Modules/itertoolsmodule.c Objects/dictobject.c Objects/intobject.c Objects/stringlib/partition.h Objects/stringobject.c Objects/unicodeobject.c Python/ast.c Python/bltinmodule.c Python/import.c Tools/pybench/pybench.py configure configure.in Message-ID: <20060905174709.65B401E4004@bag.python.org> Author: brett.cannon Date: Tue Sep 5 19:47:00 2006 New Revision: 51748 Modified: python/branches/bcannon-objcap/ (props changed) python/branches/bcannon-objcap/Doc/lib/libdecimal.tex python/branches/bcannon-objcap/Doc/lib/libhashlib.tex python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex python/branches/bcannon-objcap/Doc/lib/libunittest.tex python/branches/bcannon-objcap/Doc/ref/ref3.tex python/branches/bcannon-objcap/Doc/tut/tut.tex python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py python/branches/bcannon-objcap/Lib/decimal.py python/branches/bcannon-objcap/Lib/doctest.py python/branches/bcannon-objcap/Lib/genericpath.py (contents, props changed) python/branches/bcannon-objcap/Lib/pdb.py python/branches/bcannon-objcap/Lib/test/string_tests.py python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py python/branches/bcannon-objcap/Lib/test/test_contextlib.py python/branches/bcannon-objcap/Lib/test/test_decimal.py python/branches/bcannon-objcap/Lib/test/test_fcntl.py python/branches/bcannon-objcap/Lib/test/test_genericpath.py (props changed) python/branches/bcannon-objcap/Lib/test/test_grammar.py python/branches/bcannon-objcap/Lib/test/test_itertools.py python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py python/branches/bcannon-objcap/Lib/test/test_mutants.py python/branches/bcannon-objcap/Lib/test/test_tempfile.py python/branches/bcannon-objcap/Lib/test/test_tokenize.py python/branches/bcannon-objcap/Misc/NEWS python/branches/bcannon-objcap/Misc/Vim/vimrc python/branches/bcannon-objcap/Modules/_cursesmodule.c python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h python/branches/bcannon-objcap/Modules/itertoolsmodule.c python/branches/bcannon-objcap/Objects/dictobject.c python/branches/bcannon-objcap/Objects/intobject.c python/branches/bcannon-objcap/Objects/stringlib/partition.h python/branches/bcannon-objcap/Objects/stringobject.c python/branches/bcannon-objcap/Objects/unicodeobject.c python/branches/bcannon-objcap/Python/ast.c python/branches/bcannon-objcap/Python/bltinmodule.c python/branches/bcannon-objcap/Python/import.c python/branches/bcannon-objcap/Tools/pybench/pybench.py python/branches/bcannon-objcap/configure python/branches/bcannon-objcap/configure.in Log: Merged revisions 51634-51747 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/bcannon-objcap/Doc/lib/libdecimal.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libdecimal.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libdecimal.tex Tue Sep 5 19:47:00 2006 @@ -435,36 +435,37 @@ the \function{getcontext()} and \function{setcontext()} functions: \begin{funcdesc}{getcontext}{} - Return the current context for the active thread. + Return the current context for the active thread. \end{funcdesc} \begin{funcdesc}{setcontext}{c} - Set the current context for the active thread to \var{c}. + Set the current context for the active thread to \var{c}. \end{funcdesc} Beginning with Python 2.5, you can also use the \keyword{with} statement -to temporarily change the active context. For example the following code -increases the current decimal precision by 2 places, performs a -calculation, and then automatically restores the previous context: +and the \function{localcontext()} function to temporarily change the +active context. -\begin{verbatim} -from __future__ import with_statement -import decimal - -with decimal.getcontext() as ctx: - ctx.prec += 2 # add 2 more digits of precision - calculate_something() +\begin{funcdesc}{localcontext}{\optional{c}} + Return a context manager that will set the current context for + the active thread to a copy of \var{c} on entry to the with-statement + and restore the previous context when exiting the with-statement. If + no context is specified, a copy of the current context is used. + \versionadded{2.5} + + For example, the following code sets the current decimal precision + to 42 places, performs a calculation, and then automatically restores + the previous context: +\begin{verbatim} + from __future__ import with_statement + from decimal import localcontext + + with localcontext() as ctx: + ctx.prec = 42 # Perform a high precision calculation + s = calculate_something() + s = +s # Round the final result back to the default precision \end{verbatim} - -The context that's active in the body of the \keyword{with} statement is -a \emph{copy} of the context you provided to the \keyword{with} -statement, so modifying its attributes doesn't affect anything except -that temporary copy. - -You can use any decimal context in a \keyword{with} statement, but if -you just want to make a temporary change to some aspect of the current -context, it's easiest to just use \function{getcontext()} as shown -above. +\end{funcdesc} New contexts can also be created using the \class{Context} constructor described below. In addition, the module provides three pre-made Modified: python/branches/bcannon-objcap/Doc/lib/libhashlib.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libhashlib.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libhashlib.tex Tue Sep 5 19:47:00 2006 @@ -86,8 +86,8 @@ \begin{methoddesc}[hash]{digest}{} Return the digest of the strings passed to the \method{update()} -method so far. This is a 16-byte string which may contain -non-\ASCII{} characters, including null bytes. +method so far. This is a string of \member{digest_size} bytes which may +contain non-\ASCII{} characters, including null bytes. \end{methoddesc} \begin{methoddesc}[hash]{hexdigest}{} Modified: python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libstdtypes.tex Tue Sep 5 19:47:00 2006 @@ -771,8 +771,8 @@ Split the string at the last occurrence of \var{sep}, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not -found, return a 3-tuple containing the string itself, followed by -two empty strings. +found, return a 3-tuple containing two empty strings, followed by +the string itself. \versionadded{2.5} \end{methoddesc} @@ -1410,15 +1410,15 @@ {(1)} \lineiii{\var{a}.clear()}{remove all items from \code{a}}{} \lineiii{\var{a}.copy()}{a (shallow) copy of \code{a}}{} - \lineiii{\var{a}.has_key(\var{k})} + \lineiii{\var{k} in \var{a}} {\code{True} if \var{a} has a key \var{k}, else \code{False}} - {} - \lineiii{\var{k} \code{in} \var{a}} - {Equivalent to \var{a}.has_key(\var{k})} {(2)} \lineiii{\var{k} not in \var{a}} - {Equivalent to \code{not} \var{a}.has_key(\var{k})} + {Equivalent to \code{not} \var{k} in \var{a}} {(2)} + \lineiii{\var{a}.has_key(\var{k})} + {Equivalent to \var{k} \code{in} \var{a}, use that form in new code} + {} \lineiii{\var{a}.items()} {a copy of \var{a}'s list of (\var{key}, \var{value}) pairs} {(3)} Modified: python/branches/bcannon-objcap/Doc/lib/libunittest.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libunittest.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libunittest.tex Tue Sep 5 19:47:00 2006 @@ -212,8 +212,8 @@ class DefaultWidgetSizeTestCase(unittest.TestCase): def runTest(self): - widget = Widget("The widget") - self.failUnless(widget.size() == (50,50), 'incorrect default size') + widget = Widget('The widget') + self.assertEqual(widget.size(), (50, 50), 'incorrect default size') \end{verbatim} Note that in order to test something, we use the one of the @@ -247,7 +247,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') class DefaultWidgetSizeTestCase(SimpleWidgetTestCase): def runTest(self): @@ -273,7 +273,7 @@ class SimpleWidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -298,7 +298,7 @@ class WidgetTestCase(unittest.TestCase): def setUp(self): - self.widget = Widget("The widget") + self.widget = Widget('The widget') def tearDown(self): self.widget.dispose() @@ -322,8 +322,8 @@ passing the method name in the constructor: \begin{verbatim} -defaultSizeTestCase = WidgetTestCase("testDefaultSize") -resizeTestCase = WidgetTestCase("testResize") +defaultSizeTestCase = WidgetTestCase('testDefaultSize') +resizeTestCase = WidgetTestCase('testResize') \end{verbatim} Test case instances are grouped together according to the features @@ -333,8 +333,8 @@ \begin{verbatim} widgetTestSuite = unittest.TestSuite() -widgetTestSuite.addTest(WidgetTestCase("testDefaultSize")) -widgetTestSuite.addTest(WidgetTestCase("testResize")) +widgetTestSuite.addTest(WidgetTestCase('testDefaultSize')) +widgetTestSuite.addTest(WidgetTestCase('testResize')) \end{verbatim} For the ease of running tests, as we will see later, it is a good @@ -344,8 +344,8 @@ \begin{verbatim} def suite(): suite = unittest.TestSuite() - suite.addTest(WidgetTestCase("testDefaultSize")) - suite.addTest(WidgetTestCase("testResize")) + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) return suite \end{verbatim} @@ -353,7 +353,7 @@ \begin{verbatim} def suite(): - tests = ["testDefaultSize", "testResize"] + tests = ['testDefaultSize', 'testResize'] return unittest.TestSuite(map(WidgetTestCase, tests)) \end{verbatim} @@ -462,7 +462,7 @@ \subsection{Classes and functions \label{unittest-contents}} -\begin{classdesc}{TestCase}{} +\begin{classdesc}{TestCase}{\optional{methodName}} Instances of the \class{TestCase} class represent the smallest testable units in the \module{unittest} universe. This class is intended to be used as a base class, with specific tests being @@ -470,6 +470,23 @@ interface needed by the test runner to allow it to drive the test, and methods that the test code can use to check for and report various kinds of failure. + + Each instance of \class{TestCase} will run a single test method: + the method named \var{methodName}. If you remember, we had an + earlier example that went something like this: + + \begin{verbatim} + def suite(): + suite = unittest.TestSuite() + suite.addTest(WidgetTestCase('testDefaultSize')) + suite.addTest(WidgetTestCase('testResize')) + return suite + \end{verbatim} + + Here, we create two instances of \class{WidgetTestCase}, each of + which runs a single test. + + \var{methodName} defaults to \code{'runTest'}. \end{classdesc} \begin{classdesc}{FunctionTestCase}{testFunc\optional{, @@ -502,6 +519,11 @@ subclass. \end{classdesc} +\begin{classdesc}{TestResult}{} + This class is used to compile information about which tests have succeeded + and which have failed. +\end{classdesc} + \begin{datadesc}{defaultTestLoader} Instance of the \class{TestLoader} class intended to be shared. If no customization of the \class{TestLoader} is needed, this instance can @@ -574,8 +596,9 @@ \begin{methoddesc}[TestCase]{run}{\optional{result}} Run the test, collecting the result into the test result object passed as \var{result}. If \var{result} is omitted or \constant{None}, - a temporary result object is created and used, but is not made - available to the caller. + a temporary result object is created (by calling the + \method{defaultTestCase()} method) and used; this result object is not + returned to \method{run()}'s caller. The same effect may be had by simply calling the \class{TestCase} instance. @@ -684,8 +707,13 @@ \end{methoddesc} \begin{methoddesc}[TestCase]{defaultTestResult}{} - Return the default type of test result object to be used to run this - test. + Return an instance of the test result class that should be used + for this test case class (if no other result instance is provided + to the \method{run()} method). + + For \class{TestCase} instances, this will always be an instance of + \class{TestResult}; subclasses of \class{TestCase} should + override this as necessary. \end{methoddesc} \begin{methoddesc}[TestCase]{id}{} @@ -761,26 +789,20 @@ tests for reporting purposes; a \class{TestResult} instance is returned by the \method{TestRunner.run()} method for this purpose. -Each instance holds the total number of tests run, and collections of -failures and errors that occurred among those test runs. The -collections contain tuples of \code{(\var{testcase}, -\var{traceback})}, where \var{traceback} is a string containing a -formatted version of the traceback for the exception. - \class{TestResult} instances have the following attributes that will be of interest when inspecting the results of running a set of tests: \begin{memberdesc}[TestResult]{errors} A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test which raised an - unexpected exception. + strings holding formatted tracebacks. Each tuple represents a test which + raised an unexpected exception. \versionchanged[Contains formatted tracebacks instead of \function{sys.exc_info()} results]{2.2} \end{memberdesc} \begin{memberdesc}[TestResult]{failures} - A list containing 2-tuples of \class{TestCase} instances and - formatted tracebacks. Each tuple represents a test where a failure + A list containing 2-tuples of \class{TestCase} instances and strings + holding formatted tracebacks. Each tuple represents a test where a failure was explicitly signalled using the \method{TestCase.fail*()} or \method{TestCase.assert*()} methods. \versionchanged[Contains formatted tracebacks instead of @@ -817,17 +839,25 @@ \begin{methoddesc}[TestResult]{startTest}{test} Called when the test case \var{test} is about to be run. + + The default implementation simply increments the instance's + \code{testsRun} counter. \end{methoddesc} \begin{methoddesc}[TestResult]{stopTest}{test} - Called when the test case \var{test} has been executed, regardless + Called after the test case \var{test} has been executed, regardless of the outcome. + + The default implementation does nothing. \end{methoddesc} \begin{methoddesc}[TestResult]{addError}{test, err} Called when the test case \var{test} raises an unexpected exception \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{errors} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addFailure}{test, err} @@ -835,10 +865,15 @@ \var{err} is a tuple of the form returned by \function{sys.exc_info()}: \code{(\var{type}, \var{value}, \var{traceback})}. + + The default implementation appends \code{(\var{test}, \var{err})} to + the instance's \code{failures} attribute. \end{methoddesc} \begin{methoddesc}[TestResult]{addSuccess}{test} Called when the test case \var{test} succeeds. + + The default implementation does nothing. \end{methoddesc} @@ -878,9 +913,12 @@ Return a suite of all tests cases given a string specifier. The specifier \var{name} is a ``dotted name'' that may resolve - either to a module, a test case class, a \class{TestSuite} instance, - a test method within a test case class, or a callable object which - returns a \class{TestCase} or \class{TestSuite} instance. + either to a module, a test case class, a test method within a test + case class, a \class{TestSuite} instance, or a callable object which + returns a \class{TestCase} or \class{TestSuite} instance. These checks + are applied in the order listed here; that is, a method on a possible + test case class will be picked up as ``a test method within a test + case class'', rather than ``a callable object''. For example, if you have a module \module{SampleTests} containing a \class{TestCase}-derived class \class{SampleTestCase} with three test @@ -905,7 +943,7 @@ \begin{methoddesc}[TestLoader]{getTestCaseNames}{testCaseClass} Return a sorted sequence of method names found within - \var{testCaseClass}. + \var{testCaseClass}; this should be a subclass of \class{TestCase}. \end{methoddesc} Modified: python/branches/bcannon-objcap/Doc/ref/ref3.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/ref/ref3.tex (original) +++ python/branches/bcannon-objcap/Doc/ref/ref3.tex Tue Sep 5 19:47:00 2006 @@ -762,7 +762,7 @@ (call it~\class{C}) of the instance for which the attribute reference was initiated or one of its bases, it is transformed into a bound user-defined method object whose -\member{im_class} attribute is~\class{C} whose \member{im_self} attribute +\member{im_class} attribute is~\class{C} and whose \member{im_self} attribute is the instance. Static method and class method objects are also transformed, as if they had been retrieved from class~\class{C}; see above under ``Classes''. See section~\ref{descriptors} for Modified: python/branches/bcannon-objcap/Doc/tut/tut.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/tut/tut.tex (original) +++ python/branches/bcannon-objcap/Doc/tut/tut.tex Tue Sep 5 19:47:00 2006 @@ -4381,7 +4381,7 @@ makes use of private variables of the base class possible.) Notice that code passed to \code{exec}, \code{eval()} or -\code{evalfile()} does not consider the classname of the invoking +\code{execfile()} does not consider the classname of the invoking class to be the current class; this is similar to the effect of the \code{global} statement, the effect of which is likewise restricted to code that is byte-compiled together. The same restriction applies to Modified: python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex Tue Sep 5 19:47:00 2006 @@ -683,22 +683,22 @@ The lock is acquired before the block is executed and always released once the block is complete. -The \module{decimal} module's contexts, which encapsulate the desired -precision and rounding characteristics for computations, provide a -\method{context_manager()} method for getting a context manager: +The new \function{localcontext()} function in the \module{decimal} module +makes it easy to save and restore the current decimal context, which +encapsulates the desired precision and rounding characteristics for +computations: \begin{verbatim} -import decimal +from decimal import Decimal, Context, localcontext # Displays with default precision of 28 digits -v1 = decimal.Decimal('578') -print v1.sqrt() +v = Decimal('578') +print v.sqrt() -ctx = decimal.Context(prec=16) -with ctx.context_manager(): +with localcontext(Context(prec=16)): # All code in this block uses a precision of 16 digits. # The original context is restored on exiting the block. - print v1.sqrt() + print v.sqrt() \end{verbatim} \subsection{Writing Context Managers\label{context-managers}} @@ -1115,12 +1115,14 @@ \begin{verbatim} >>> ('http://www.python.org').partition('://') ('http', '://', 'www.python.org') ->>> (u'Subject: a quick question').partition(':') -(u'Subject', u':', u' a quick question') >>> ('file:/usr/share/doc/index.html').partition('://') ('file:/usr/share/doc/index.html', '', '') +>>> (u'Subject: a quick question').partition(':') +(u'Subject', u':', u' a quick question') >>> 'www.python.org'.rpartition('.') ('www.python', '.', 'org') +>>> 'www.python.org'.rpartition(':') +('', '', 'www.python.org') \end{verbatim} (Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.) Modified: python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py ============================================================================== --- python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py (original) +++ python/branches/bcannon-objcap/Lib/SimpleXMLRPCServer.py Tue Sep 5 19:47:00 2006 @@ -264,8 +264,9 @@ encoding=self.encoding) except: # report exception back to server + exc_type, exc_value, exc_tb = sys.exc_info() response = xmlrpclib.dumps( - xmlrpclib.Fault(1, "%s:%s" % (sys.exc_type, sys.exc_value)), + xmlrpclib.Fault(1, "%s:%s" % (exc_type, exc_value)), encoding=self.encoding, allow_none=self.allow_none, ) @@ -364,9 +365,10 @@ 'faultString' : fault.faultString} ) except: + exc_type, exc_value, exc_tb = sys.exc_info() results.append( {'faultCode' : 1, - 'faultString' : "%s:%s" % (sys.exc_type, sys.exc_value)} + 'faultString' : "%s:%s" % (exc_type, exc_value)} ) return results Modified: python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py ============================================================================== --- python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py (original) +++ python/branches/bcannon-objcap/Lib/bsddb/test/test_basics.py Tue Sep 5 19:47:00 2006 @@ -697,7 +697,7 @@ for log in logs: if verbose: print 'log file: ' + log - if db.version >= (4,2): + if db.version() >= (4,2): logs = self.env.log_archive(db.DB_ARCH_REMOVE) assert not logs Modified: python/branches/bcannon-objcap/Lib/decimal.py ============================================================================== --- python/branches/bcannon-objcap/Lib/decimal.py (original) +++ python/branches/bcannon-objcap/Lib/decimal.py Tue Sep 5 19:47:00 2006 @@ -131,7 +131,7 @@ 'ROUND_FLOOR', 'ROUND_UP', 'ROUND_HALF_DOWN', # Functions for manipulating contexts - 'setcontext', 'getcontext' + 'setcontext', 'getcontext', 'localcontext' ] import copy as _copy @@ -458,6 +458,49 @@ del threading, local # Don't contaminate the namespace +def localcontext(ctx=None): + """Return a context manager for a copy of the supplied context + + Uses a copy of the current context if no context is specified + The returned context manager creates a local decimal context + in a with statement: + def sin(x): + with localcontext() as ctx: + ctx.prec += 2 + # Rest of sin calculation algorithm + # uses a precision 2 greater than normal + return +s # Convert result to normal precision + + def sin(x): + with localcontext(ExtendedContext): + # Rest of sin calculation algorithm + # uses the Extended Context from the + # General Decimal Arithmetic Specification + return +s # Convert result to normal context + + """ + # The string below can't be included in the docstring until Python 2.6 + # as the doctest module doesn't understand __future__ statements + """ + >>> from __future__ import with_statement + >>> print getcontext().prec + 28 + >>> with localcontext(): + ... ctx = getcontext() + ... ctx.prec() += 2 + ... print ctx.prec + ... + 30 + >>> with localcontext(ExtendedContext): + ... print getcontext().prec + ... + 9 + >>> print getcontext().prec + 28 + """ + if ctx is None: ctx = getcontext() + return _ContextManager(ctx) + ##### Decimal class ########################################### @@ -2173,23 +2216,14 @@ del name, val, globalname, rounding_functions -class ContextManager(object): - """Helper class to simplify Context management. - - Sample usage: - - with decimal.ExtendedContext: - s = ... - return +s # Convert result to normal precision - - with decimal.getcontext() as ctx: - ctx.prec += 2 - s = ... - return +s +class _ContextManager(object): + """Context manager class to support localcontext(). + Sets a copy of the supplied context in __enter__() and restores + the previous decimal context in __exit__() """ def __init__(self, new_context): - self.new_context = new_context + self.new_context = new_context.copy() def __enter__(self): self.saved_context = getcontext() setcontext(self.new_context) @@ -2248,9 +2282,6 @@ s.append('traps=[' + ', '.join([t.__name__ for t, v in self.traps.items() if v]) + ']') return ', '.join(s) + ')' - def get_manager(self): - return ContextManager(self.copy()) - def clear_flags(self): """Reset all flags to zero""" for flag in self.flags: Modified: python/branches/bcannon-objcap/Lib/doctest.py ============================================================================== --- python/branches/bcannon-objcap/Lib/doctest.py (original) +++ python/branches/bcannon-objcap/Lib/doctest.py Tue Sep 5 19:47:00 2006 @@ -1561,7 +1561,7 @@ - test: the DocTest object being run - - excample: the Example object that failed + - example: the Example object that failed - got: the actual output """ @@ -1580,7 +1580,7 @@ - test: the DocTest object being run - - excample: the Example object that failed + - example: the Example object that failed - exc_info: the exception info """ Modified: python/branches/bcannon-objcap/Lib/genericpath.py ============================================================================== --- python/branches/bcannon-objcap/Lib/genericpath.py (original) +++ python/branches/bcannon-objcap/Lib/genericpath.py Tue Sep 5 19:47:00 2006 @@ -75,4 +75,3 @@ if s1[i] != s2[i]: return s1[:i] return s1[:n] - Modified: python/branches/bcannon-objcap/Lib/pdb.py ============================================================================== --- python/branches/bcannon-objcap/Lib/pdb.py (original) +++ python/branches/bcannon-objcap/Lib/pdb.py Tue Sep 5 19:47:00 2006 @@ -23,7 +23,7 @@ "post_mortem", "help"] def find_function(funcname, filename): - cre = re.compile(r'def\s+%s\s*[(]' % funcname) + cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname)) try: fp = open(filename) except IOError: Modified: python/branches/bcannon-objcap/Lib/test/string_tests.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/string_tests.py (original) +++ python/branches/bcannon-objcap/Lib/test/string_tests.py Tue Sep 5 19:47:00 2006 @@ -1069,7 +1069,7 @@ # from raymond's original specification S = 'http://www.python.org' self.checkequal(('http', '://', 'www.python.org'), S, 'rpartition', '://') - self.checkequal(('http://www.python.org', '', ''), S, 'rpartition', '?') + self.checkequal(('', '', 'http://www.python.org'), S, 'rpartition', '?') self.checkequal(('', 'http://', 'www.python.org'), S, 'rpartition', 'http://') self.checkequal(('http://www.python.', 'org', ''), S, 'rpartition', 'org') Modified: python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_codecencodings_cn.py Tue Sep 5 19:47:00 2006 @@ -32,6 +32,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("\x83\x34\x83\x31", "strict", None), + (u"\u30fb", "strict", None), ) class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): @@ -45,6 +46,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"), + (u"\u30fb", "strict", "\x819\xa79"), ) has_iso10646 = True Modified: python/branches/bcannon-objcap/Lib/test/test_contextlib.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_contextlib.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_contextlib.py Tue Sep 5 19:47:00 2006 @@ -330,32 +330,6 @@ return True self.boilerPlate(lock, locked) -class DecimalContextTestCase(unittest.TestCase): - - # XXX Somebody should write more thorough tests for this - - def testBasic(self): - ctx = decimal.getcontext() - orig_context = ctx.copy() - try: - ctx.prec = save_prec = decimal.ExtendedContext.prec + 5 - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - self.assertEqual(decimal.getcontext().prec, save_prec) - try: - with decimal.ExtendedContext.get_manager(): - self.assertEqual(decimal.getcontext().prec, - decimal.ExtendedContext.prec) - 1/0 - except ZeroDivisionError: - self.assertEqual(decimal.getcontext().prec, save_prec) - else: - self.fail("Didn't raise ZeroDivisionError") - finally: - decimal.setcontext(orig_context) - - # This is needed to make the test actually run under regrtest.py! def test_main(): run_suite( Modified: python/branches/bcannon-objcap/Lib/test/test_decimal.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_decimal.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_decimal.py Tue Sep 5 19:47:00 2006 @@ -23,6 +23,7 @@ you're working through IDLE, you can import this test module and call test_main() with the corresponding argument. """ +from __future__ import with_statement import unittest import glob @@ -1064,6 +1065,32 @@ self.assertNotEqual(id(c.flags), id(d.flags)) self.assertNotEqual(id(c.traps), id(d.traps)) +class WithStatementTest(unittest.TestCase): + # Can't do these as docstrings until Python 2.6 + # as doctest can't handle __future__ statements + + def test_localcontext(self): + # Use a copy of the current context in the block + orig_ctx = getcontext() + with localcontext() as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(orig_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + + def test_localcontextarg(self): + # Use a copy of the supplied context in the block + orig_ctx = getcontext() + new_ctx = Context(prec=42) + with localcontext(new_ctx) as enter_ctx: + set_ctx = getcontext() + final_ctx = getcontext() + self.assert_(orig_ctx is final_ctx, 'did not restore context correctly') + self.assert_(set_ctx.prec == new_ctx.prec, 'did not set correct context') + self.assert_(new_ctx is not set_ctx, 'did not copy the context') + self.assert_(set_ctx is enter_ctx, '__enter__ returned wrong context') + def test_main(arith=False, verbose=None): """ Execute the tests. @@ -1084,6 +1111,7 @@ DecimalPythonAPItests, ContextAPItests, DecimalTest, + WithStatementTest, ] try: Modified: python/branches/bcannon-objcap/Lib/test/test_fcntl.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_fcntl.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_fcntl.py Tue Sep 5 19:47:00 2006 @@ -25,7 +25,7 @@ 'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6', 'freebsd7', 'bsdos2', 'bsdos3', 'bsdos4', - 'openbsd', 'openbsd2', 'openbsd3'): + 'openbsd', 'openbsd2', 'openbsd3', 'openbsd4'): if struct.calcsize('l') == 8: off_t = 'l' pid_t = 'i' Modified: python/branches/bcannon-objcap/Lib/test/test_grammar.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_grammar.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_grammar.py Tue Sep 5 19:47:00 2006 @@ -825,6 +825,10 @@ verify([ x for x in range(10) if x % 2 if x % 3 ], [1, 5, 7]) verify((x for x in range(10) if x % 2 if x % 3), [1, 5, 7]) +# Verify unpacking single element tuples in listcomp/genexp. +vereq([x for x, in [(4,), (5,), (6,)]], [4, 5, 6]) +vereq(list(x for x, in [(7,), (8,), (9,)]), [7, 8, 9]) + # Test ifelse expressions in various cases def _checkeval(msg, ret): "helper to check that evaluation of expressions is done correctly" Modified: python/branches/bcannon-objcap/Lib/test/test_itertools.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_itertools.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_itertools.py Tue Sep 5 19:47:00 2006 @@ -371,6 +371,7 @@ # test values of n self.assertRaises(TypeError, tee, 'abc', 'invalid') + self.assertRaises(ValueError, tee, [], -1) for n in xrange(5): result = tee('abc', n) self.assertEqual(type(result), tuple) Modified: python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_multibytecodec.py Tue Sep 5 19:47:00 2006 @@ -202,6 +202,12 @@ uni = u':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) + def test_iso2022_jp_g0(self): + self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) + for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): + e = u'\u3406'.encode(encoding) + self.failIf(filter(lambda x: x >= '\x80', e)) + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_MultibyteCodec)) Modified: python/branches/bcannon-objcap/Lib/test/test_mutants.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_mutants.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_mutants.py Tue Sep 5 19:47:00 2006 @@ -91,12 +91,17 @@ self.hashcode = random.randrange(1000000000) def __hash__(self): + return 42 return self.hashcode def __cmp__(self, other): maybe_mutate() # The point of the test. return cmp(self.i, other.i) + def __eq__(self, other): + maybe_mutate() # The point of the test. + return self.i == other.i + def __repr__(self): return "Horrid(%d)" % self.i @@ -132,7 +137,10 @@ while dict1 and len(dict1) == len(dict2): if verbose: print ".", - c = cmp(dict1, dict2) + if random.random() < 0.5: + c = cmp(dict1, dict2) + else: + c = dict1 == dict2 if verbose: print Modified: python/branches/bcannon-objcap/Lib/test/test_tempfile.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_tempfile.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_tempfile.py Tue Sep 5 19:47:00 2006 @@ -27,7 +27,7 @@ # number of files that can be opened at one time (see ulimit -n) if sys.platform == 'mac': TEST_FILES = 32 -elif sys.platform == 'openbsd3': +elif sys.platform in ('openbsd3', 'openbsd4'): TEST_FILES = 48 else: TEST_FILES = 100 Modified: python/branches/bcannon-objcap/Lib/test/test_tokenize.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_tokenize.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_tokenize.py Tue Sep 5 19:47:00 2006 @@ -79,13 +79,16 @@ """ -import os, glob, random +import os, glob, random, time, sys from cStringIO import StringIO from test.test_support import (verbose, findfile, is_resource_enabled, TestFailed) from tokenize import (tokenize, generate_tokens, untokenize, tok_name, ENDMARKER, NUMBER, NAME, OP, STRING, COMMENT) +# How much time in seconds can pass before we print a 'Still working' message. +_PRINT_WORKING_MSG_INTERVAL = 5 * 60 + # Test roundtrip for `untokenize`. `f` is a file path. The source code in f # is tokenized, converted back to source code via tokenize.untokenize(), # and tokenized again from the latter. The test fails if the second @@ -164,6 +167,8 @@ if verbose: print 'starting...' + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + # This displays the tokenization of tokenize_tests.py to stdout, and # regrtest.py checks that this equals the expected output (in the # test/output/ directory). @@ -183,6 +188,12 @@ testfiles = random.sample(testfiles, 10) for f in testfiles: + # Print still working message since this test can be really slow + if next_time <= time.time(): + next_time = time.time() + _PRINT_WORKING_MSG_INTERVAL + print >>sys.__stdout__, ' test_main still working, be patient...' + sys.__stdout__.flush() + test_roundtrip(f) # Test detecton of IndentationError. Modified: python/branches/bcannon-objcap/Misc/NEWS ============================================================================== --- python/branches/bcannon-objcap/Misc/NEWS (original) +++ python/branches/bcannon-objcap/Misc/NEWS Tue Sep 5 19:47:00 2006 @@ -4,20 +4,36 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.6? -========================= +What's New in Python 2.6 alpha 1? +================================= *Release date: XX-XXX-200X* Core and builtins ----------------- +- Overflow checking code in integer division ran afoul of new gcc + optimizations. Changed to be more standard-conforming. + - Patch #1542451: disallow continue anywhere under a finally. +- Patch #1546288: fix seg fault in dict_equal due to ref counting bug. + +- The return tuple from str.rpartition(sep) is (tail, sep, head) where + head is the original string if sep was not found. + +- Bug #1520864: unpacking singleton tuples in list comprehensions and + generator expressions (x for x, in ... ) works again. Fixing this problem + required changing the .pyc magic number. This means that .pyc files + generated before 2.5c2 will be regenerated. + Library ------- +- Patch #1550886: Fix decimal module context management implementation + to match the localcontext() example from PEP 343. + - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. @@ -25,10 +41,23 @@ Extension Modules ----------------- +- Bug #1548092: fix curses.tparm seg fault on invalid input. + +- Bug #1550714: fix SystemError from itertools.tee on negative value for n. + +- Fixed a few bugs on cjkcodecs: + - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. + - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 + codepoints to conform the standard. + - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 + codepoints now. Tests ----- +- Fix bsddb test_basics.test06_Transactions to check the version + number properly. + Documentation ------------- @@ -41,6 +70,8 @@ Build ----- +- Patch #1540470, for OpenBSD 4.0. + C API ----- @@ -129,7 +160,7 @@ - The __repr__ method of a NULL ctypes.py_object() no longer raises an exception. -- uuid.UUID now has a bytes_le attribute. This returns the UUID in +- uuid.UUID now has a bytes_le attribute. This returns the UUID in little-endian byte order for Windows. In addition, uuid.py gained some workarounds for clocks with low resolution, to stop the code yielding duplicate UUIDs. @@ -288,7 +319,7 @@ - Bug #1002398: The documentation for os.path.sameopenfile now correctly refers to file descriptors, not file objects. -- The renaming of the xml package to xmlcore, and the import hackery done +- The renaming of the xml package to xmlcore, and the import hackery done to make it appear at both names, has been removed. Bug #1511497, #1513611, and probably others. Modified: python/branches/bcannon-objcap/Misc/Vim/vimrc ============================================================================== --- python/branches/bcannon-objcap/Misc/Vim/vimrc (original) +++ python/branches/bcannon-objcap/Misc/Vim/vimrc Tue Sep 5 19:47:00 2006 @@ -19,9 +19,10 @@ " Number of spaces to use for an indent. " This will affect Ctrl-T and 'autoindent'. " Python: 4 spaces -" C: tab (8 spaces) +" C: 8 spaces (pre-existing files) or 4 spaces (new files) au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 -au BufRead,BufNewFile *.c,*.h set shiftwidth=4 +au BufRead *.c,*.h set shiftwidth=8 +au BufNewFile *.c,*.h set shiftwidth=4 " Number of spaces that a pre-existing tab is equal to. " For the amount of space used for a new tab use shiftwidth. Modified: python/branches/bcannon-objcap/Modules/_cursesmodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/_cursesmodule.c (original) +++ python/branches/bcannon-objcap/Modules/_cursesmodule.c Tue Sep 5 19:47:00 2006 @@ -2334,6 +2334,10 @@ } result = tparm(fmt,i1,i2,i3,i4,i5,i6,i7,i8,i9); + if (!result) { + PyErr_SetString(PyCursesError, "tparm() returned NULL"); + return NULL; + } return PyString_FromString(result); } Modified: python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c ============================================================================== --- python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c (original) +++ python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_cn.c Tue Sep 5 19:47:00 2006 @@ -15,14 +15,26 @@ #undef hz #endif -#define GBK_PREDECODE(dc1, dc2, assi) \ +/* GBK and GB2312 map differently in few codepoints that are listed below: + * + * gb2312 gbk + * A1A4 U+30FB KATAKANA MIDDLE DOT U+00B7 MIDDLE DOT + * A1AA U+2015 HORIZONTAL BAR U+2014 EM DASH + * A844 undefined U+2015 HORIZONTAL BAR + */ + +#define GBK_DECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ - else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; -#define GBK_PREENCODE(code, assi) \ + else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \ + else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \ + else TRYMAP_DEC(gbkext, assi, dc1, dc2); + +#define GBK_ENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ - else if ((code) == 0x00b7) (assi) = 0xa1a4; + else if ((code) == 0x00b7) (assi) = 0xa1a4; \ + else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code)); /* * GB2312 codec @@ -99,8 +111,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); + GBK_ENCODE(c, code) else return 1; OUT1((code >> 8) | 0x80) @@ -129,9 +140,7 @@ REQUIRE_INBUF(2) - GBK_PREDECODE(c, IN2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, IN2); + GBK_DECODE(c, IN2, **outbuf) else return 2; NEXT(2, 1) @@ -187,9 +196,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); - else TRYMAP_ENC(gb18030ext, code, c); + GBK_ENCODE(c, code) else { const struct _gb18030_to_unibmp_ranges *utrrange; @@ -287,9 +294,7 @@ return 4; } - GBK_PREDECODE(c, c2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, c2); + GBK_DECODE(c, c2, **outbuf) else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; Modified: python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/branches/bcannon-objcap/Modules/cjkcodecs/_codecs_iso2022.c Tue Sep 5 19:47:00 2006 @@ -854,7 +854,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -901,7 +901,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -992,7 +992,10 @@ /*-*- registry tables -*-*/ -#define REGISTRY_KSX1001 { CHARSET_KSX1001, 1, 2, \ +#define REGISTRY_KSX1001_G0 { CHARSET_KSX1001, 0, 2, \ + ksx1001_init, \ + ksx1001_decoder, ksx1001_encoder } +#define REGISTRY_KSX1001_G1 { CHARSET_KSX1001, 1, 2, \ ksx1001_init, \ ksx1001_decoder, ksx1001_encoder } #define REGISTRY_JISX0201_R { CHARSET_JISX0201_R, 0, 1, \ @@ -1034,7 +1037,7 @@ jisx0213_init, \ jisx0213_2004_2_decoder, \ jisx0213_2004_2_encoder } -#define REGISTRY_GB2312 { CHARSET_GB2312, 1, 2, \ +#define REGISTRY_GB2312 { CHARSET_GB2312, 0, 2, \ gb2312_init, \ gb2312_decoder, gb2312_encoder } #define REGISTRY_CNS11643_1 { CHARSET_CNS11643_1, 1, 2, \ @@ -1054,7 +1057,7 @@ }; static const struct iso2022_designation iso2022_kr_designations[] = { - REGISTRY_KSX1001, REGISTRY_SENTINEL + REGISTRY_KSX1001_G1, REGISTRY_SENTINEL }; CONFIGDEF(kr, 0) @@ -1071,7 +1074,7 @@ CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) static const struct iso2022_designation iso2022_jp_2_designations[] = { - REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; Modified: python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h ============================================================================== --- python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h (original) +++ python/branches/bcannon-objcap/Modules/cjkcodecs/cjkcodecs.h Tue Sep 5 19:47:00 2006 @@ -159,29 +159,32 @@ #endif #define _TRYMAP_ENC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) -#define TRYMAP_ENC(charset, assi, uni) \ +#define TRYMAP_ENC_COND(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) +#define TRYMAP_ENC(charset, assi, uni) \ + if TRYMAP_ENC_COND(charset, assi, uni) + #define _TRYMAP_DEC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ - _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ + if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ Modified: python/branches/bcannon-objcap/Modules/itertoolsmodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/itertoolsmodule.c (original) +++ python/branches/bcannon-objcap/Modules/itertoolsmodule.c Tue Sep 5 19:47:00 2006 @@ -618,11 +618,15 @@ static PyObject * tee(PyObject *self, PyObject *args) { - int i, n=2; + Py_ssize_t i, n=2; PyObject *it, *iterable, *copyable, *result; - if (!PyArg_ParseTuple(args, "O|i", &iterable, &n)) + if (!PyArg_ParseTuple(args, "O|n", &iterable, &n)) return NULL; + if (n < 0) { + PyErr_SetString(PyExc_ValueError, "n must be >= 0"); + return NULL; + } result = PyTuple_New(n); if (result == NULL) return NULL; Modified: python/branches/bcannon-objcap/Objects/dictobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/dictobject.c (original) +++ python/branches/bcannon-objcap/Objects/dictobject.c Tue Sep 5 19:47:00 2006 @@ -1585,7 +1585,10 @@ /* temporarily bump aval's refcount to ensure it stays alive until we're done with it */ Py_INCREF(aval); + /* ditto for key */ + Py_INCREF(key); bval = PyDict_GetItem((PyObject *)b, key); + Py_DECREF(key); if (bval == NULL) { Py_DECREF(aval); return 0; Modified: python/branches/bcannon-objcap/Objects/intobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/intobject.c (original) +++ python/branches/bcannon-objcap/Objects/intobject.c Tue Sep 5 19:47:00 2006 @@ -565,7 +565,7 @@ return DIVMOD_ERROR; } /* (-sys.maxint-1)/-1 is the only overflow case. */ - if (y == -1 && x < 0 && x == -x) + if (y == -1 && x == LONG_MIN) return DIVMOD_OVERFLOW; xdivy = x / y; xmody = x - xdivy * y; Modified: python/branches/bcannon-objcap/Objects/stringlib/partition.h ============================================================================== --- python/branches/bcannon-objcap/Objects/stringlib/partition.h (original) +++ python/branches/bcannon-objcap/Objects/stringlib/partition.h Tue Sep 5 19:47:00 2006 @@ -78,12 +78,12 @@ } if (pos < 0) { - Py_INCREF(str_obj); - PyTuple_SET_ITEM(out, 0, (PyObject*) str_obj); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 0, (PyObject*) STRINGLIB_EMPTY); Py_INCREF(STRINGLIB_EMPTY); - PyTuple_SET_ITEM(out, 2, (PyObject*) STRINGLIB_EMPTY); + PyTuple_SET_ITEM(out, 1, (PyObject*) STRINGLIB_EMPTY); + Py_INCREF(str_obj); + PyTuple_SET_ITEM(out, 2, (PyObject*) str_obj); return out; } Modified: python/branches/bcannon-objcap/Objects/stringobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/stringobject.c (original) +++ python/branches/bcannon-objcap/Objects/stringobject.c Tue Sep 5 19:47:00 2006 @@ -1543,11 +1543,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject * string_rpartition(PyStringObject *self, PyObject *sep_obj) Modified: python/branches/bcannon-objcap/Objects/unicodeobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/unicodeobject.c (original) +++ python/branches/bcannon-objcap/Objects/unicodeobject.c Tue Sep 5 19:47:00 2006 @@ -6712,11 +6712,11 @@ } PyDoc_STRVAR(rpartition__doc__, -"S.rpartition(sep) -> (head, sep, tail)\n\ +"S.rpartition(sep) -> (tail, sep, head)\n\ \n\ Searches for the separator sep in S, starting at the end of S, and returns\n\ the part before it, the separator itself, and the part after it. If the\n\ -separator is not found, returns S and two empty strings."); +separator is not found, returns two empty strings and S."); static PyObject* unicode_rpartition(PyUnicodeObject *self, PyObject *separator) Modified: python/branches/bcannon-objcap/Python/ast.c ============================================================================== --- python/branches/bcannon-objcap/Python/ast.c (original) +++ python/branches/bcannon-objcap/Python/ast.c Tue Sep 5 19:47:00 2006 @@ -15,12 +15,6 @@ #include -/* XXX TO DO - - re-indent this file (should be done) - - internal error checking (freeing memory, etc.) - - syntax errors -*/ - /* Data structure used internally */ struct compiling { char *c_encoding; /* source encoding */ @@ -43,7 +37,7 @@ static PyObject *parsestrplus(struct compiling *, const node *n); #ifndef LINENO -#define LINENO(n) ((n)->n_lineno) +#define LINENO(n) ((n)->n_lineno) #endif static identifier @@ -68,7 +62,7 @@ { PyObject *u = Py_BuildValue("zi", errstr, LINENO(n)); if (!u) - return 0; + return 0; PyErr_SetObject(PyExc_SyntaxError, u); Py_DECREF(u); return 0; @@ -82,36 +76,36 @@ assert(PyErr_Occurred()); if (!PyErr_ExceptionMatches(PyExc_SyntaxError)) - return; + return; PyErr_Fetch(&type, &value, &tback); errstr = PyTuple_GetItem(value, 0); if (!errstr) - return; + return; Py_INCREF(errstr); lineno = PyInt_AsLong(PyTuple_GetItem(value, 1)); if (lineno == -1) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } Py_DECREF(value); loc = PyErr_ProgramText(filename, lineno); if (!loc) { - Py_INCREF(Py_None); - loc = Py_None; + Py_INCREF(Py_None); + loc = Py_None; } tmp = Py_BuildValue("(zlOO)", filename, lineno, Py_None, loc); Py_DECREF(loc); if (!tmp) { - Py_DECREF(errstr); - return; + Py_DECREF(errstr); + return; } value = PyTuple_Pack(2, errstr, tmp); Py_DECREF(errstr); Py_DECREF(tmp); if (!value) - return; + return; PyErr_Restore(type, value, tback); } @@ -246,7 +240,7 @@ if (TYPE(CHILD(n, 0)) == NEWLINE) { stmts = asdl_seq_new(1, arena); if (!stmts) - goto error; + goto error; asdl_seq_SET(stmts, 0, Pass(n->n_lineno, n->n_col_offset, arena)); return Interactive(stmts, arena); @@ -256,11 +250,11 @@ num = num_stmts(n); stmts = asdl_seq_new(num, arena); if (!stmts) - goto error; + goto error; if (num == 1) { - s = ast_for_stmt(&c, n); - if (!s) - goto error; + s = ast_for_stmt(&c, n); + if (!s) + goto error; asdl_seq_SET(stmts, 0, s); } else { @@ -347,38 +341,38 @@ switch (e->kind) { case Attribute_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Attribute.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Attribute.attr), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Attribute.ctx = ctx; + break; case Subscript_kind: - e->v.Subscript.ctx = ctx; - break; + e->v.Subscript.ctx = ctx; + break; case Name_kind: - if (ctx == Store && - !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { - return ast_error(n, "assignment to None"); - } - e->v.Name.ctx = ctx; - break; + if (ctx == Store && + !strcmp(PyString_AS_STRING(e->v.Name.id), "None")) { + return ast_error(n, "assignment to None"); + } + e->v.Name.ctx = ctx; + break; case List_kind: - e->v.List.ctx = ctx; - s = e->v.List.elts; - break; + e->v.List.ctx = ctx; + s = e->v.List.elts; + break; case Tuple_kind: if (asdl_seq_LEN(e->v.Tuple.elts) == 0) return ast_error(n, "can't assign to ()"); - e->v.Tuple.ctx = ctx; - s = e->v.Tuple.elts; - break; + e->v.Tuple.ctx = ctx; + s = e->v.Tuple.elts; + break; case Lambda_kind: expr_name = "lambda"; break; case Call_kind: expr_name = "function call"; - break; + break; case BoolOp_kind: case BinOp_kind: case UnaryOp_kind: @@ -427,12 +421,12 @@ context for all the contained elements. */ if (s) { - int i; + int i; - for (i = 0; i < asdl_seq_LEN(s); i++) { - if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) - return 0; - } + for (i = 0; i < asdl_seq_LEN(s); i++) { + if (!set_context((expr_ty)asdl_seq_GET(s, i), ctx, n)) + return 0; + } } return 1; } @@ -483,13 +477,13 @@ */ REQ(n, comp_op); if (NCH(n) == 1) { - n = CHILD(n, 0); - switch (TYPE(n)) { + n = CHILD(n, 0); + switch (TYPE(n)) { case LESS: return Lt; case GREATER: return Gt; - case EQEQUAL: /* == */ + case EQEQUAL: /* == */ return Eq; case LESSEQUAL: return LtE; @@ -506,11 +500,11 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s", STR(n)); return (cmpop_ty)0; - } + } } else if (NCH(n) == 2) { - /* handle "not in" and "is not" */ - switch (TYPE(CHILD(n, 0))) { + /* handle "not in" and "is not" */ + switch (TYPE(CHILD(n, 0))) { case NAME: if (strcmp(STR(CHILD(n, 1)), "in") == 0) return NotIn; @@ -520,7 +514,7 @@ PyErr_Format(PyExc_SystemError, "invalid comp_op: %s %s", STR(CHILD(n, 0)), STR(CHILD(n, 1))); return (cmpop_ty)0; - } + } } PyErr_Format(PyExc_SystemError, "invalid comp_op: has %d children", NCH(n)); @@ -535,10 +529,10 @@ expr_ty expression; int i; assert(TYPE(n) == testlist - || TYPE(n) == listmaker - || TYPE(n) == testlist_gexp - || TYPE(n) == testlist_safe - ); + || TYPE(n) == listmaker + || TYPE(n) == testlist_gexp + || TYPE(n) == testlist_safe + ); seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) @@ -571,13 +565,13 @@ const node *child = CHILD(CHILD(n, 2*i), 0); expr_ty arg; if (TYPE(child) == NAME) { - if (!strcmp(STR(child), "None")) { - ast_error(child, "assignment to None"); - return NULL; - } + if (!strcmp(STR(child), "None")) { + ast_error(child, "assignment to None"); + return NULL; + } arg = Name(NEW_IDENTIFIER(child), Store, LINENO(child), child->n_col_offset, c->c_arena); - } + } else { arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); } @@ -606,26 +600,26 @@ node *ch; if (TYPE(n) == parameters) { - if (NCH(n) == 2) /* () as argument list */ - return arguments(NULL, NULL, NULL, NULL, c->c_arena); - n = CHILD(n, 1); + if (NCH(n) == 2) /* () as argument list */ + return arguments(NULL, NULL, NULL, NULL, c->c_arena); + n = CHILD(n, 1); } REQ(n, varargslist); /* first count the number of normal args & defaults */ for (i = 0; i < NCH(n); i++) { - ch = CHILD(n, i); - if (TYPE(ch) == fpdef) - n_args++; - if (TYPE(ch) == EQUAL) - n_defaults++; + ch = CHILD(n, i); + if (TYPE(ch) == fpdef) + n_args++; + if (TYPE(ch) == EQUAL) + n_defaults++; } args = (n_args ? asdl_seq_new(n_args, c->c_arena) : NULL); if (!args && n_args) - return NULL; /* Don't need to goto error; no objects allocated */ + return NULL; /* Don't need to goto error; no objects allocated */ defaults = (n_defaults ? asdl_seq_new(n_defaults, c->c_arena) : NULL); if (!defaults && n_defaults) - return NULL; /* Don't need to goto error; no objects allocated */ + return NULL; /* Don't need to goto error; no objects allocated */ /* fpdef: NAME | '(' fplist ')' fplist: fpdef (',' fpdef)* [','] @@ -634,8 +628,8 @@ j = 0; /* index for defaults */ k = 0; /* index for args */ while (i < NCH(n)) { - ch = CHILD(n, i); - switch (TYPE(ch)) { + ch = CHILD(n, i); + switch (TYPE(ch)) { case fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ @@ -647,53 +641,53 @@ assert(defaults != NULL); asdl_seq_SET(defaults, j++, expression); i += 2; - found_default = 1; + found_default = 1; + } + else if (found_default) { + ast_error(n, + "non-default argument follows default argument"); + goto error; } - else if (found_default) { - ast_error(n, - "non-default argument follows default argument"); - goto error; - } if (NCH(ch) == 3) { - ch = CHILD(ch, 1); - /* def foo((x)): is not complex, special case. */ - if (NCH(ch) != 1) { - /* We have complex arguments, setup for unpacking. */ - asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); - } else { - /* def foo((x)): setup for checking NAME below. */ - ch = CHILD(ch, 0); - } + ch = CHILD(ch, 1); + /* def foo((x)): is not complex, special case. */ + if (NCH(ch) != 1) { + /* We have complex arguments, setup for unpacking. */ + asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); + } else { + /* def foo((x)): setup for checking NAME below. */ + ch = CHILD(ch, 0); + } } if (TYPE(CHILD(ch, 0)) == NAME) { - expr_ty name; - if (!strcmp(STR(CHILD(ch, 0)), "None")) { - ast_error(CHILD(ch, 0), "assignment to None"); - goto error; - } + expr_ty name; + if (!strcmp(STR(CHILD(ch, 0)), "None")) { + ast_error(CHILD(ch, 0), "assignment to None"); + goto error; + } name = Name(NEW_IDENTIFIER(CHILD(ch, 0)), Param, LINENO(ch), ch->n_col_offset, c->c_arena); if (!name) goto error; asdl_seq_SET(args, k++, name); - - } + + } i += 2; /* the name and the comma */ break; case STAR: - if (!strcmp(STR(CHILD(n, i+1)), "None")) { - ast_error(CHILD(n, i+1), "assignment to None"); - goto error; - } + if (!strcmp(STR(CHILD(n, i+1)), "None")) { + ast_error(CHILD(n, i+1), "assignment to None"); + goto error; + } vararg = NEW_IDENTIFIER(CHILD(n, i+1)); i += 3; break; case DOUBLESTAR: - if (!strcmp(STR(CHILD(n, i+1)), "None")) { - ast_error(CHILD(n, i+1), "assignment to None"); - goto error; - } + if (!strcmp(STR(CHILD(n, i+1)), "None")) { + ast_error(CHILD(n, i+1), "assignment to None"); + goto error; + } kwarg = NEW_IDENTIFIER(CHILD(n, i+1)); i += 3; break; @@ -702,7 +696,7 @@ "unexpected node in varargslist: %d @ %d", TYPE(ch), i); goto error; - } + } } return arguments(args, vararg, kwarg, defaults, c->c_arena); @@ -731,15 +725,15 @@ return NULL; e = Name(id, Load, lineno, col_offset, c->c_arena); if (!e) - return NULL; + return NULL; for (i = 2; i < NCH(n); i+=2) { id = NEW_IDENTIFIER(CHILD(n, i)); - if (!id) - return NULL; - e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); - if (!e) - return NULL; + if (!id) + return NULL; + e = Attribute(e, id, Load, lineno, col_offset, c->c_arena); + if (!e) + return NULL; } return e; @@ -758,24 +752,24 @@ name_expr = ast_for_dotted_name(c, CHILD(n, 1)); if (!name_expr) - return NULL; - + return NULL; + if (NCH(n) == 3) { /* No arguments */ - d = name_expr; - name_expr = NULL; + d = name_expr; + name_expr = NULL; } else if (NCH(n) == 5) { /* Call with no arguments */ - d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), + d = Call(name_expr, NULL, NULL, NULL, NULL, LINENO(n), n->n_col_offset, c->c_arena); - if (!d) - return NULL; - name_expr = NULL; + if (!d) + return NULL; + name_expr = NULL; } else { - d = ast_for_call(c, CHILD(n, 3), name_expr); - if (!d) - return NULL; - name_expr = NULL; + d = ast_for_call(c, CHILD(n, 3), name_expr); + if (!d) + return NULL; + name_expr = NULL; } return d; @@ -792,12 +786,12 @@ decorator_seq = asdl_seq_new(NCH(n), c->c_arena); if (!decorator_seq) return NULL; - + for (i = 0; i < NCH(n); i++) { d = ast_for_decorator(c, CHILD(n, i)); - if (!d) - return NULL; - asdl_seq_SET(decorator_seq, i, d); + if (!d) + return NULL; + asdl_seq_SET(decorator_seq, i, d); } return decorator_seq; } @@ -815,28 +809,28 @@ REQ(n, funcdef); if (NCH(n) == 6) { /* decorators are present */ - decorator_seq = ast_for_decorators(c, CHILD(n, 0)); - if (!decorator_seq) - return NULL; - name_i = 2; + decorator_seq = ast_for_decorators(c, CHILD(n, 0)); + if (!decorator_seq) + return NULL; + name_i = 2; } else { - name_i = 1; + name_i = 1; } name = NEW_IDENTIFIER(CHILD(n, name_i)); if (!name) - return NULL; + return NULL; else if (!strcmp(STR(CHILD(n, name_i)), "None")) { - ast_error(CHILD(n, name_i), "assignment to None"); - return NULL; + ast_error(CHILD(n, name_i), "assignment to None"); + return NULL; } args = ast_for_arguments(c, CHILD(n, name_i + 1)); if (!args) - return NULL; + return NULL; body = ast_for_suite(c, CHILD(n, name_i + 3)); if (!body) - return NULL; + return NULL; return FunctionDef(name, args, body, decorator_seq, LINENO(n), n->n_col_offset, c->c_arena); @@ -878,17 +872,22 @@ assert(NCH(n) == 5); body = ast_for_expr(c, CHILD(n, 0)); if (!body) - return NULL; + return NULL; expression = ast_for_expr(c, CHILD(n, 2)); if (!expression) - return NULL; + return NULL; orelse = ast_for_expr(c, CHILD(n, 4)); if (!orelse) - return NULL; + return NULL; return IfExp(expression, body, orelse, LINENO(n), n->n_col_offset, c->c_arena); } +/* XXX(nnorwitz): the listcomp and genexpr code should be refactored + so there is only a single version. Possibly for loops can also re-use + the code. +*/ + /* Count the number of 'for' loop in a list comprehension. Helper for ast_for_listcomp(). @@ -904,14 +903,14 @@ n_fors++; REQ(ch, list_for); if (NCH(ch) == 5) - ch = CHILD(ch, 4); + ch = CHILD(ch, 4); else - return n_fors; + return n_fors; count_list_iter: REQ(ch, list_iter); ch = CHILD(ch, 0); if (TYPE(ch) == list_for) - goto count_list_for; + goto count_list_for; else if (TYPE(ch) == list_if) { if (NCH(ch) == 3) { ch = CHILD(ch, 2); @@ -939,12 +938,12 @@ count_list_iter: REQ(n, list_iter); if (TYPE(CHILD(n, 0)) == list_for) - return n_ifs; + return n_ifs; n = CHILD(n, 0); REQ(n, list_if); n_ifs++; if (NCH(n) == 2) - return n_ifs; + return n_ifs; n = CHILD(n, 2); goto count_list_iter; } @@ -976,61 +975,65 @@ listcomps = asdl_seq_new(n_fors, c->c_arena); if (!listcomps) - return NULL; + return NULL; ch = CHILD(n, 1); for (i = 0; i < n_fors; i++) { - comprehension_ty lc; - asdl_seq *t; + comprehension_ty lc; + asdl_seq *t; expr_ty expression; + node *for_ch; - REQ(ch, list_for); + REQ(ch, list_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_testlist(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) - lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, + /* Check the # of children rather than the length of t, since + [x for x, in ... ] has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) + lc = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); - else - lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, + else + lc = comprehension(Tuple(t, Store, LINENO(ch), ch->n_col_offset, c->c_arena), expression, NULL, c->c_arena); if (!lc) return NULL; - if (NCH(ch) == 5) { - int j, n_ifs; - asdl_seq *ifs; + if (NCH(ch) == 5) { + int j, n_ifs; + asdl_seq *ifs; - ch = CHILD(ch, 4); - n_ifs = count_list_ifs(ch); + ch = CHILD(ch, 4); + n_ifs = count_list_ifs(ch); if (n_ifs == -1) return NULL; - ifs = asdl_seq_new(n_ifs, c->c_arena); - if (!ifs) - return NULL; + ifs = asdl_seq_new(n_ifs, c->c_arena); + if (!ifs) + return NULL; - for (j = 0; j < n_ifs; j++) { + for (j = 0; j < n_ifs; j++) { REQ(ch, list_iter); - ch = CHILD(ch, 0); - REQ(ch, list_if); + ch = CHILD(ch, 0); + REQ(ch, list_if); - asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); - if (NCH(ch) == 3) - ch = CHILD(ch, 2); - } - /* on exit, must guarantee that ch is a list_for */ - if (TYPE(ch) == list_iter) - ch = CHILD(ch, 0); + asdl_seq_SET(ifs, j, ast_for_expr(c, CHILD(ch, 1))); + if (NCH(ch) == 3) + ch = CHILD(ch, 2); + } + /* on exit, must guarantee that ch is a list_for */ + if (TYPE(ch) == list_iter) + ch = CHILD(ch, 0); lc->ifs = ifs; - } - asdl_seq_SET(listcomps, i, lc); + } + asdl_seq_SET(listcomps, i, lc); } return ListComp(elt, listcomps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1045,34 +1048,34 @@ static int count_gen_fors(const node *n) { - int n_fors = 0; - node *ch = CHILD(n, 1); + int n_fors = 0; + node *ch = CHILD(n, 1); count_gen_for: - n_fors++; - REQ(ch, gen_for); - if (NCH(ch) == 5) - ch = CHILD(ch, 4); - else - return n_fors; + n_fors++; + REQ(ch, gen_for); + if (NCH(ch) == 5) + ch = CHILD(ch, 4); + else + return n_fors; count_gen_iter: - REQ(ch, gen_iter); - ch = CHILD(ch, 0); - if (TYPE(ch) == gen_for) - goto count_gen_for; - else if (TYPE(ch) == gen_if) { - if (NCH(ch) == 3) { - ch = CHILD(ch, 2); - goto count_gen_iter; - } - else - return n_fors; - } - - /* Should never be reached */ - PyErr_SetString(PyExc_SystemError, - "logic error in count_gen_fors"); - return -1; + REQ(ch, gen_iter); + ch = CHILD(ch, 0); + if (TYPE(ch) == gen_for) + goto count_gen_for; + else if (TYPE(ch) == gen_if) { + if (NCH(ch) == 3) { + ch = CHILD(ch, 2); + goto count_gen_iter; + } + else + return n_fors; + } + + /* Should never be reached */ + PyErr_SetString(PyExc_SystemError, + "logic error in count_gen_fors"); + return -1; } /* Count the number of 'if' statements in a generator expression. @@ -1083,19 +1086,19 @@ static int count_gen_ifs(const node *n) { - int n_ifs = 0; + int n_ifs = 0; - while (1) { - REQ(n, gen_iter); - if (TYPE(CHILD(n, 0)) == gen_for) - return n_ifs; - n = CHILD(n, 0); - REQ(n, gen_if); - n_ifs++; - if (NCH(n) == 2) - return n_ifs; - n = CHILD(n, 2); - } + while (1) { + REQ(n, gen_iter); + if (TYPE(CHILD(n, 0)) == gen_for) + return n_ifs; + n = CHILD(n, 0); + REQ(n, gen_if); + n_ifs++; + if (NCH(n) == 2) + return n_ifs; + n = CHILD(n, 2); + } } /* TODO(jhylton): Combine with list comprehension code? */ @@ -1103,7 +1106,7 @@ ast_for_genexp(struct compiling *c, const node *n) { /* testlist_gexp: test ( gen_for | (',' test)* [','] ) - argument: [test '='] test [gen_for] # Really [keyword '='] test */ + argument: [test '='] test [gen_for] # Really [keyword '='] test */ expr_ty elt; asdl_seq *genexps; int i, n_fors; @@ -1129,17 +1132,21 @@ comprehension_ty ge; asdl_seq *t; expr_ty expression; + node *for_ch; REQ(ch, gen_for); - t = ast_for_exprlist(c, CHILD(ch, 1), Store); + for_ch = CHILD(ch, 1); + t = ast_for_exprlist(c, for_ch, Store); if (!t) return NULL; expression = ast_for_expr(c, CHILD(ch, 3)); if (!expression) return NULL; - if (asdl_seq_LEN(t) == 1) + /* Check the # of children rather than the length of t, since + (x for x, in ...) has 1 element in t, but still requires a Tuple. */ + if (NCH(for_ch) == 1) ge = comprehension((expr_ty)asdl_seq_GET(t, 0), expression, NULL, c->c_arena); else @@ -1196,96 +1203,96 @@ switch (TYPE(ch)) { case NAME: - /* All names start in Load context, but may later be - changed. */ - return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); + /* All names start in Load context, but may later be + changed. */ + return Name(NEW_IDENTIFIER(ch), Load, LINENO(n), n->n_col_offset, c->c_arena); case STRING: { - PyObject *str = parsestrplus(c, n); - if (!str) - return NULL; + PyObject *str = parsestrplus(c, n); + if (!str) + return NULL; - PyArena_AddPyObject(c->c_arena, str); - return Str(str, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, str); + return Str(str, LINENO(n), n->n_col_offset, c->c_arena); } case NUMBER: { - PyObject *pynum = parsenumber(STR(ch)); - if (!pynum) - return NULL; + PyObject *pynum = parsenumber(STR(ch)); + if (!pynum) + return NULL; - PyArena_AddPyObject(c->c_arena, pynum); - return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); + PyArena_AddPyObject(c->c_arena, pynum); + return Num(pynum, LINENO(n), n->n_col_offset, c->c_arena); } case LPAR: /* some parenthesized expressions */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RPAR) - return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - if (TYPE(ch) == yield_expr) - return ast_for_expr(c, ch); - - if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) - return ast_for_genexp(c, ch); - - return ast_for_testlist_gexp(c, ch); + ch = CHILD(n, 1); + + if (TYPE(ch) == RPAR) + return Tuple(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + if (TYPE(ch) == yield_expr) + return ast_for_expr(c, ch); + + if ((NCH(ch) > 1) && (TYPE(CHILD(ch, 1)) == gen_for)) + return ast_for_genexp(c, ch); + + return ast_for_testlist_gexp(c, ch); case LSQB: /* list (or list comprehension) */ - ch = CHILD(n, 1); - - if (TYPE(ch) == RSQB) - return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); - - REQ(ch, listmaker); - if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { - asdl_seq *elts = seq_for_testlist(c, ch); - if (!elts) - return NULL; - - return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); - } - else - return ast_for_listcomp(c, ch); + ch = CHILD(n, 1); + + if (TYPE(ch) == RSQB) + return List(NULL, Load, LINENO(n), n->n_col_offset, c->c_arena); + + REQ(ch, listmaker); + if (NCH(ch) == 1 || TYPE(CHILD(ch, 1)) == COMMA) { + asdl_seq *elts = seq_for_testlist(c, ch); + if (!elts) + return NULL; + + return List(elts, Load, LINENO(n), n->n_col_offset, c->c_arena); + } + else + return ast_for_listcomp(c, ch); case LBRACE: { - /* dictmaker: test ':' test (',' test ':' test)* [','] */ - int i, size; - asdl_seq *keys, *values; - - ch = CHILD(n, 1); - size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ - keys = asdl_seq_new(size, c->c_arena); - if (!keys) - return NULL; - - values = asdl_seq_new(size, c->c_arena); - if (!values) - return NULL; - - for (i = 0; i < NCH(ch); i += 4) { - expr_ty expression; - - expression = ast_for_expr(c, CHILD(ch, i)); - if (!expression) - return NULL; - - asdl_seq_SET(keys, i / 4, expression); - - expression = ast_for_expr(c, CHILD(ch, i + 2)); - if (!expression) - return NULL; - - asdl_seq_SET(values, i / 4, expression); - } - return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); + /* dictmaker: test ':' test (',' test ':' test)* [','] */ + int i, size; + asdl_seq *keys, *values; + + ch = CHILD(n, 1); + size = (NCH(ch) + 1) / 4; /* +1 in case no trailing comma */ + keys = asdl_seq_new(size, c->c_arena); + if (!keys) + return NULL; + + values = asdl_seq_new(size, c->c_arena); + if (!values) + return NULL; + + for (i = 0; i < NCH(ch); i += 4) { + expr_ty expression; + + expression = ast_for_expr(c, CHILD(ch, i)); + if (!expression) + return NULL; + + asdl_seq_SET(keys, i / 4, expression); + + expression = ast_for_expr(c, CHILD(ch, i + 2)); + if (!expression) + return NULL; + + asdl_seq_SET(values, i / 4, expression); + } + return Dict(keys, values, LINENO(n), n->n_col_offset, c->c_arena); } case BACKQUOTE: { /* repr */ - expr_ty expression = ast_for_testlist(c, CHILD(n, 1)); - if (!expression) - return NULL; + expr_ty expression = ast_for_testlist(c, CHILD(n, 1)); + if (!expression) + return NULL; - return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena); + return Repr(expression, LINENO(n), n->n_col_offset, c->c_arena); } default: - PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); - return NULL; + PyErr_Format(PyExc_SystemError, "unhandled atom %d", TYPE(ch)); + return NULL; } } @@ -1303,7 +1310,7 @@ */ ch = CHILD(n, 0); if (TYPE(ch) == DOT) - return Ellipsis(c->c_arena); + return Ellipsis(c->c_arena); if (NCH(n) == 1 && TYPE(ch) == test) { /* 'step' variable hold no significance in terms of being used over @@ -1312,31 +1319,31 @@ if (!step) return NULL; - return Index(step, c->c_arena); + return Index(step, c->c_arena); } if (TYPE(ch) == test) { - lower = ast_for_expr(c, ch); + lower = ast_for_expr(c, ch); if (!lower) return NULL; } /* If there's an upper bound it's in the second or third position. */ if (TYPE(ch) == COLON) { - if (NCH(n) > 1) { - node *n2 = CHILD(n, 1); + if (NCH(n) > 1) { + node *n2 = CHILD(n, 1); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } - } + } } else if (NCH(n) > 2) { - node *n2 = CHILD(n, 2); + node *n2 = CHILD(n, 2); - if (TYPE(n2) == test) { - upper = ast_for_expr(c, n2); + if (TYPE(n2) == test) { + upper = ast_for_expr(c, n2); if (!upper) return NULL; } @@ -1367,13 +1374,13 @@ static expr_ty ast_for_binop(struct compiling *c, const node *n) { - /* Must account for a sequence of expressions. - How should A op B op C by represented? - BinOp(BinOp(A, op, B), op, C). - */ + /* Must account for a sequence of expressions. + How should A op B op C by represented? + BinOp(BinOp(A, op, B), op, C). + */ - int i, nops; - expr_ty expr1, expr2, result; + int i, nops; + expr_ty expr1, expr2, result; operator_ty newoperator; expr1 = ast_for_expr(c, CHILD(n, 0)); @@ -1388,17 +1395,17 @@ if (!newoperator) return NULL; - result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, + result = BinOp(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); - if (!result) + if (!result) return NULL; - nops = (NCH(n) - 1) / 2; - for (i = 1; i < nops; i++) { - expr_ty tmp_result, tmp; - const node* next_oper = CHILD(n, i * 2 + 1); + nops = (NCH(n) - 1) / 2; + for (i = 1; i < nops; i++) { + expr_ty tmp_result, tmp; + const node* next_oper = CHILD(n, i * 2 + 1); - newoperator = get_operator(next_oper); + newoperator = get_operator(next_oper); if (!newoperator) return NULL; @@ -1407,13 +1414,13 @@ return NULL; tmp_result = BinOp(result, newoperator, tmp, - LINENO(next_oper), next_oper->n_col_offset, + LINENO(next_oper), next_oper->n_col_offset, c->c_arena); - if (!tmp) - return NULL; - result = tmp_result; - } - return result; + if (!tmp) + return NULL; + result = tmp_result; + } + return result; } static expr_ty @@ -1560,8 +1567,8 @@ tmp = ast_for_trailer(c, ch, e); if (!tmp) return NULL; - tmp->lineno = e->lineno; - tmp->col_offset = e->col_offset; + tmp->lineno = e->lineno; + tmp->col_offset = e->col_offset; e = tmp; } if (TYPE(CHILD(n, NCH(n) - 1)) == factor) { @@ -1619,8 +1626,8 @@ return ast_for_lambdef(c, CHILD(n, 0)); else if (NCH(n) > 1) return ast_for_ifexpr(c, n); - /* Fallthrough */ - case or_test: + /* Fallthrough */ + case or_test: case and_test: if (NCH(n) == 1) { n = CHILD(n, 0); @@ -1661,7 +1668,7 @@ else { expr_ty expression; asdl_int_seq *ops; - asdl_seq *cmps; + asdl_seq *cmps; ops = asdl_int_seq_new(NCH(n) / 2, c->c_arena); if (!ops) return NULL; @@ -1675,12 +1682,12 @@ newoperator = ast_for_comp_op(CHILD(n, i)); if (!newoperator) { return NULL; - } + } expression = ast_for_expr(c, CHILD(n, i + 1)); if (!expression) { return NULL; - } + } asdl_seq_SET(ops, i / 2, newoperator); asdl_seq_SET(cmps, i / 2, expression); @@ -1688,7 +1695,7 @@ expression = ast_for_expr(c, CHILD(n, 0)); if (!expression) { return NULL; - } + } return Compare(expression, ops, cmps, LINENO(n), n->n_col_offset, c->c_arena); @@ -1711,20 +1718,20 @@ } return ast_for_binop(c, n); case yield_expr: { - expr_ty exp = NULL; - if (NCH(n) == 2) { - exp = ast_for_testlist(c, CHILD(n, 1)); - if (!exp) - return NULL; - } - return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); - } + expr_ty exp = NULL; + if (NCH(n) == 2) { + exp = ast_for_testlist(c, CHILD(n, 1)); + if (!exp) + return NULL; + } + return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena); + } case factor: if (NCH(n) == 1) { n = CHILD(n, 0); goto loop; } - return ast_for_factor(c, n); + return ast_for_factor(c, n); case power: return ast_for_power(c, n); default: @@ -1741,7 +1748,7 @@ /* arglist: (argument ',')* (argument [',']| '*' test [',' '**' test] | '**' test) - argument: [test '='] test [gen_for] # Really [keyword '='] test + argument: [test '='] test [gen_for] # Really [keyword '='] test */ int i, nargs, nkeywords, ngens; @@ -1755,20 +1762,20 @@ nkeywords = 0; ngens = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - if (NCH(ch) == 1) - nargs++; - else if (TYPE(CHILD(ch, 1)) == gen_for) - ngens++; + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + if (NCH(ch) == 1) + nargs++; + else if (TYPE(CHILD(ch, 1)) == gen_for) + ngens++; else - nkeywords++; - } + nkeywords++; + } } if (ngens > 1 || (ngens && (nargs || nkeywords))) { ast_error(n, "Generator expression must be parenthesized " - "if not sole argument"); - return NULL; + "if not sole argument"); + return NULL; } if (nargs + nkeywords + ngens > 255) { @@ -1785,32 +1792,32 @@ nargs = 0; nkeywords = 0; for (i = 0; i < NCH(n); i++) { - node *ch = CHILD(n, i); - if (TYPE(ch) == argument) { - expr_ty e; - if (NCH(ch) == 1) { - if (nkeywords) { - ast_error(CHILD(ch, 0), - "non-keyword arg after keyword arg"); - return NULL; - } - e = ast_for_expr(c, CHILD(ch, 0)); + node *ch = CHILD(n, i); + if (TYPE(ch) == argument) { + expr_ty e; + if (NCH(ch) == 1) { + if (nkeywords) { + ast_error(CHILD(ch, 0), + "non-keyword arg after keyword arg"); + return NULL; + } + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); - } - else if (TYPE(CHILD(ch, 1)) == gen_for) { - e = ast_for_genexp(c, ch); + asdl_seq_SET(args, nargs++, e); + } + else if (TYPE(CHILD(ch, 1)) == gen_for) { + e = ast_for_genexp(c, ch); if (!e) return NULL; - asdl_seq_SET(args, nargs++, e); + asdl_seq_SET(args, nargs++, e); } - else { - keyword_ty kw; - identifier key; + else { + keyword_ty kw; + identifier key; - /* CHILD(ch, 0) is test, but must be an identifier? */ - e = ast_for_expr(c, CHILD(ch, 0)); + /* CHILD(ch, 0) is test, but must be an identifier? */ + e = ast_for_expr(c, CHILD(ch, 0)); if (!e) return NULL; /* f(lambda x: x[0] = 3) ends up getting parsed with @@ -1825,24 +1832,24 @@ ast_error(CHILD(ch, 0), "keyword can't be an expression"); return NULL; } - key = e->v.Name.id; - e = ast_for_expr(c, CHILD(ch, 2)); + key = e->v.Name.id; + e = ast_for_expr(c, CHILD(ch, 2)); if (!e) return NULL; - kw = keyword(key, e, c->c_arena); + kw = keyword(key, e, c->c_arena); if (!kw) return NULL; - asdl_seq_SET(keywords, nkeywords++, kw); - } - } - else if (TYPE(ch) == STAR) { - vararg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } - else if (TYPE(ch) == DOUBLESTAR) { - kwarg = ast_for_expr(c, CHILD(n, i+1)); - i++; - } + asdl_seq_SET(keywords, nkeywords++, kw); + } + } + else if (TYPE(ch) == STAR) { + vararg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } + else if (TYPE(ch) == DOUBLESTAR) { + kwarg = ast_for_expr(c, CHILD(n, i+1)); + i++; + } } return Call(func, args, keywords, vararg, kwarg, func->lineno, func->col_offset, c->c_arena); @@ -1866,12 +1873,12 @@ TYPE(n) == testlist1); } if (NCH(n) == 1) - return ast_for_expr(c, CHILD(n, 0)); + return ast_for_expr(c, CHILD(n, 0)); else { asdl_seq *tmp = seq_for_testlist(c, n); if (!tmp) return NULL; - return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); + return Tuple(tmp, Load, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -1882,7 +1889,7 @@ /* argument: test [ gen_for ] */ assert(TYPE(n) == testlist_gexp || TYPE(n) == argument); if (NCH(n) > 1 && TYPE(CHILD(n, 1)) == gen_for) - return ast_for_genexp(c, n); + return ast_for_genexp(c, n); return ast_for_testlist(c, n); } @@ -1916,23 +1923,23 @@ | ('=' (yield_expr|testlist))*) testlist: test (',' test)* [','] augassign: '+=' | '-=' | '*=' | '/=' | '%=' | '&=' | '|=' | '^=' - | '<<=' | '>>=' | '**=' | '//=' + | '<<=' | '>>=' | '**=' | '//=' test: ... here starts the operator precendence dance */ if (NCH(n) == 1) { - expr_ty e = ast_for_testlist(c, CHILD(n, 0)); + expr_ty e = ast_for_testlist(c, CHILD(n, 0)); if (!e) return NULL; - return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); + return Expr(e, LINENO(n), n->n_col_offset, c->c_arena); } else if (TYPE(CHILD(n, 1)) == augassign) { expr_ty expr1, expr2; operator_ty newoperator; - node *ch = CHILD(n, 0); + node *ch = CHILD(n, 0); - expr1 = ast_for_testlist(c, ch); + expr1 = ast_for_testlist(c, ch); if (!expr1) return NULL; /* TODO(nas): Remove duplicated error checks (set_context does it) */ @@ -1961,13 +1968,13 @@ "assignment"); return NULL; } - set_context(expr1, Store, ch); + set_context(expr1, Store, ch); - ch = CHILD(n, 2); - if (TYPE(ch) == testlist) - expr2 = ast_for_testlist(c, ch); - else - expr2 = ast_for_expr(c, ch); + ch = CHILD(n, 2); + if (TYPE(ch) == testlist) + expr2 = ast_for_testlist(c, ch); + else + expr2 = ast_for_expr(c, ch); if (!expr2) return NULL; @@ -1975,45 +1982,45 @@ if (!newoperator) return NULL; - return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return AugAssign(expr1, newoperator, expr2, LINENO(n), n->n_col_offset, c->c_arena); } else { - int i; - asdl_seq *targets; - node *value; + int i; + asdl_seq *targets; + node *value; expr_ty expression; - /* a normal assignment */ - REQ(CHILD(n, 1), EQUAL); - targets = asdl_seq_new(NCH(n) / 2, c->c_arena); - if (!targets) - return NULL; - for (i = 0; i < NCH(n) - 2; i += 2) { - expr_ty e; - node *ch = CHILD(n, i); - if (TYPE(ch) == yield_expr) { - ast_error(ch, "assignment to yield expression not possible"); - return NULL; - } - e = ast_for_testlist(c, ch); - - /* set context to assign */ - if (!e) - return NULL; - - if (!set_context(e, Store, CHILD(n, i))) - return NULL; - - asdl_seq_SET(targets, i / 2, e); - } - value = CHILD(n, NCH(n) - 1); - if (TYPE(value) == testlist) - expression = ast_for_testlist(c, value); - else - expression = ast_for_expr(c, value); - if (!expression) - return NULL; - return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); + /* a normal assignment */ + REQ(CHILD(n, 1), EQUAL); + targets = asdl_seq_new(NCH(n) / 2, c->c_arena); + if (!targets) + return NULL; + for (i = 0; i < NCH(n) - 2; i += 2) { + expr_ty e; + node *ch = CHILD(n, i); + if (TYPE(ch) == yield_expr) { + ast_error(ch, "assignment to yield expression not possible"); + return NULL; + } + e = ast_for_testlist(c, ch); + + /* set context to assign */ + if (!e) + return NULL; + + if (!set_context(e, Store, CHILD(n, i))) + return NULL; + + asdl_seq_SET(targets, i / 2, e); + } + value = CHILD(n, NCH(n) - 1); + if (TYPE(value) == testlist) + expression = ast_for_testlist(c, value); + else + expression = ast_for_expr(c, value); + if (!expression) + return NULL; + return Assign(targets, expression, LINENO(n), n->n_col_offset, c->c_arena); } } @@ -2030,19 +2037,19 @@ REQ(n, print_stmt); if (NCH(n) >= 2 && TYPE(CHILD(n, 1)) == RIGHTSHIFT) { - dest = ast_for_expr(c, CHILD(n, 2)); + dest = ast_for_expr(c, CHILD(n, 2)); if (!dest) return NULL; - start = 4; + start = 4; } seq = asdl_seq_new((NCH(n) + 1 - start) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = start, j = 0; i < NCH(n); i += 2, ++j) { expression = ast_for_expr(c, CHILD(n, i)); if (!expression) return NULL; - asdl_seq_SET(seq, j, expression); + asdl_seq_SET(seq, j, expression); } nl = (TYPE(CHILD(n, NCH(n) - 1)) == COMMA) ? false : true; return Print(dest, seq, nl, LINENO(n), n->n_col_offset, c->c_arena); @@ -2059,14 +2066,14 @@ seq = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); if (!seq) - return NULL; + return NULL; for (i = 0; i < NCH(n); i += 2) { - e = ast_for_expr(c, CHILD(n, i)); - if (!e) - return NULL; - asdl_seq_SET(seq, i / 2, e); - if (context && !set_context(e, context, CHILD(n, i))) - return NULL; + e = ast_for_expr(c, CHILD(n, i)); + if (!e) + return NULL; + asdl_seq_SET(seq, i / 2, e); + if (context && !set_context(e, context, CHILD(n, i))) + return NULL; } return seq; } @@ -2108,9 +2115,9 @@ case continue_stmt: return Continue(LINENO(n), n->n_col_offset, c->c_arena); case yield_stmt: { /* will reduce to yield_expr */ - expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); - if (!exp) - return NULL; + expr_ty exp = ast_for_expr(c, CHILD(ch, 0)); + if (!exp) + return NULL; return Expr(exp, LINENO(n), n->n_col_offset, c->c_arena); } case return_stmt: @@ -2237,13 +2244,13 @@ --s; *s = '\0'; PyString_InternInPlace(&str); - PyArena_AddPyObject(c->c_arena, str); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); } break; case STAR: - str = PyString_InternFromString("*"); - PyArena_AddPyObject(c->c_arena, str); + str = PyString_InternFromString("*"); + PyArena_AddPyObject(c->c_arena, str); return alias(str, NULL, c->c_arena); default: PyErr_Format(PyExc_SystemError, @@ -2275,69 +2282,69 @@ n = CHILD(n, 0); if (TYPE(n) == import_name) { n = CHILD(n, 1); - REQ(n, dotted_as_names); - aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); - if (!aliases) - return NULL; - for (i = 0; i < NCH(n); i += 2) { + REQ(n, dotted_as_names); + aliases = asdl_seq_new((NCH(n) + 1) / 2, c->c_arena); + if (!aliases) + return NULL; + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } - return Import(aliases, lineno, col_offset, c->c_arena); + return Import(aliases, lineno, col_offset, c->c_arena); } else if (TYPE(n) == import_from) { int n_children; - int idx, ndots = 0; - alias_ty mod = NULL; - identifier modname; - + int idx, ndots = 0; + alias_ty mod = NULL; + identifier modname; + /* Count the number of dots (for relative imports) and check for the optional module name */ - for (idx = 1; idx < NCH(n); idx++) { - if (TYPE(CHILD(n, idx)) == dotted_name) { - mod = alias_for_import_name(c, CHILD(n, idx)); - idx++; - break; - } else if (TYPE(CHILD(n, idx)) != DOT) { - break; - } - ndots++; - } - idx++; /* skip over the 'import' keyword */ + for (idx = 1; idx < NCH(n); idx++) { + if (TYPE(CHILD(n, idx)) == dotted_name) { + mod = alias_for_import_name(c, CHILD(n, idx)); + idx++; + break; + } else if (TYPE(CHILD(n, idx)) != DOT) { + break; + } + ndots++; + } + idx++; /* skip over the 'import' keyword */ switch (TYPE(CHILD(n, idx))) { case STAR: /* from ... import * */ - n = CHILD(n, idx); - n_children = 1; - if (ndots) { - ast_error(n, "'import *' not allowed with 'from .'"); - return NULL; - } - break; - case LPAR: - /* from ... import (x, y, z) */ - n = CHILD(n, idx + 1); - n_children = NCH(n); - break; - case import_as_names: - /* from ... import x, y, z */ - n = CHILD(n, idx); - n_children = NCH(n); + n = CHILD(n, idx); + n_children = 1; + if (ndots) { + ast_error(n, "'import *' not allowed with 'from .'"); + return NULL; + } + break; + case LPAR: + /* from ... import (x, y, z) */ + n = CHILD(n, idx + 1); + n_children = NCH(n); + break; + case import_as_names: + /* from ... import x, y, z */ + n = CHILD(n, idx); + n_children = NCH(n); if (n_children % 2 == 0) { ast_error(n, "trailing comma not allowed without" " surrounding parentheses"); return NULL; } - break; - default: - ast_error(n, "Unexpected node-type in from-import"); - return NULL; - } + break; + default: + ast_error(n, "Unexpected node-type in from-import"); + return NULL; + } - aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); - if (!aliases) + aliases = asdl_seq_new((n_children + 1) / 2, c->c_arena); + if (!aliases) return NULL; /* handle "from ... import *" special b/c there's no children */ @@ -2345,14 +2352,14 @@ alias_ty import_alias = alias_for_import_name(c, n); if (!import_alias) return NULL; - asdl_seq_SET(aliases, 0, import_alias); + asdl_seq_SET(aliases, 0, import_alias); } else { - for (i = 0; i < NCH(n); i += 2) { + for (i = 0; i < NCH(n); i += 2) { alias_ty import_alias = alias_for_import_name(c, CHILD(n, i)); if (!import_alias) return NULL; - asdl_seq_SET(aliases, i / 2, import_alias); + asdl_seq_SET(aliases, i / 2, import_alias); } } if (mod != NULL) @@ -2379,12 +2386,12 @@ REQ(n, global_stmt); s = asdl_seq_new(NCH(n) / 2, c->c_arena); if (!s) - return NULL; + return NULL; for (i = 1; i < NCH(n); i += 2) { - name = NEW_IDENTIFIER(CHILD(n, i)); - if (!name) - return NULL; - asdl_seq_SET(s, i / 2, name); + name = NEW_IDENTIFIER(CHILD(n, i)); + if (!name) + return NULL; + asdl_seq_SET(s, i / 2, name); } return Global(s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -2429,7 +2436,7 @@ expr_ty expression = ast_for_expr(c, CHILD(n, 1)); if (!expression) return NULL; - return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expression, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 4) { expr_ty expr1, expr2; @@ -2441,7 +2448,7 @@ if (!expr2) return NULL; - return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); + return Assert(expr1, expr2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, "improper number of parts to 'assert' statement: %d", @@ -2463,53 +2470,53 @@ total = num_stmts(n); seq = asdl_seq_new(total, c->c_arena); if (!seq) - return NULL; + return NULL; if (TYPE(CHILD(n, 0)) == simple_stmt) { - n = CHILD(n, 0); - /* simple_stmt always ends with a NEWLINE, - and may have a trailing SEMI - */ - end = NCH(n) - 1; - if (TYPE(CHILD(n, end - 1)) == SEMI) - end--; + n = CHILD(n, 0); + /* simple_stmt always ends with a NEWLINE, + and may have a trailing SEMI + */ + end = NCH(n) - 1; + if (TYPE(CHILD(n, end - 1)) == SEMI) + end--; /* loop by 2 to skip semi-colons */ - for (i = 0; i < end; i += 2) { - ch = CHILD(n, i); - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } + for (i = 0; i < end; i += 2) { + ch = CHILD(n, i); + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } } else { - for (i = 2; i < (NCH(n) - 1); i++) { - ch = CHILD(n, i); - REQ(ch, stmt); - num = num_stmts(ch); - if (num == 1) { - /* small_stmt or compound_stmt with only one child */ - s = ast_for_stmt(c, ch); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - else { - int j; - ch = CHILD(ch, 0); - REQ(ch, simple_stmt); - for (j = 0; j < NCH(ch); j += 2) { - /* statement terminates with a semi-colon ';' */ - if (NCH(CHILD(ch, j)) == 0) { - assert((j + 1) == NCH(ch)); - break; - } - s = ast_for_stmt(c, CHILD(ch, j)); - if (!s) - return NULL; - asdl_seq_SET(seq, pos++, s); - } - } - } + for (i = 2; i < (NCH(n) - 1); i++) { + ch = CHILD(n, i); + REQ(ch, stmt); + num = num_stmts(ch); + if (num == 1) { + /* small_stmt or compound_stmt with only one child */ + s = ast_for_stmt(c, ch); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + else { + int j; + ch = CHILD(ch, 0); + REQ(ch, simple_stmt); + for (j = 0; j < NCH(ch); j += 2) { + /* statement terminates with a semi-colon ';' */ + if (NCH(CHILD(ch, j)) == 0) { + assert((j + 1) == NCH(ch)); + break; + } + s = ast_for_stmt(c, CHILD(ch, j)); + if (!s) + return NULL; + asdl_seq_SET(seq, pos++, s); + } + } + } } assert(pos == seq->size); return seq; @@ -2536,7 +2543,7 @@ if (!suite_seq) return NULL; - return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } s = STR(CHILD(n, 4)); @@ -2558,28 +2565,28 @@ if (!seq2) return NULL; - return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return If(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } else if (s[2] == 'i') { - int i, n_elif, has_else = 0; - asdl_seq *orelse = NULL; - n_elif = NCH(n) - 4; + int i, n_elif, has_else = 0; + asdl_seq *orelse = NULL; + n_elif = NCH(n) - 4; /* must reference the child n_elif+1 since 'else' token is third, not fourth, child from the end. */ - if (TYPE(CHILD(n, (n_elif + 1))) == NAME - && STR(CHILD(n, (n_elif + 1)))[2] == 's') { - has_else = 1; - n_elif -= 3; - } - n_elif /= 4; + if (TYPE(CHILD(n, (n_elif + 1))) == NAME + && STR(CHILD(n, (n_elif + 1)))[2] == 's') { + has_else = 1; + n_elif -= 3; + } + n_elif /= 4; - if (has_else) { + if (has_else) { expr_ty expression; asdl_seq *seq1, *seq2; - orelse = asdl_seq_new(1, c->c_arena); - if (!orelse) - return NULL; + orelse = asdl_seq_new(1, c->c_arena); + if (!orelse) + return NULL; expression = ast_for_expr(c, CHILD(n, NCH(n) - 6)); if (!expression) return NULL; @@ -2590,20 +2597,20 @@ if (!seq2) return NULL; - asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, - LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, + asdl_seq_SET(orelse, 0, If(expression, seq1, seq2, + LINENO(CHILD(n, NCH(n) - 6)), CHILD(n, NCH(n) - 6)->n_col_offset, c->c_arena)); - /* the just-created orelse handled the last elif */ - n_elif--; - } + /* the just-created orelse handled the last elif */ + n_elif--; + } - for (i = 0; i < n_elif; i++) { - int off = 5 + (n_elif - i - 1) * 4; + for (i = 0; i < n_elif; i++) { + int off = 5 + (n_elif - i - 1) * 4; expr_ty expression; asdl_seq *suite_seq; - asdl_seq *newobj = asdl_seq_new(1, c->c_arena); - if (!newobj) - return NULL; + asdl_seq *newobj = asdl_seq_new(1, c->c_arena); + if (!newobj) + return NULL; expression = ast_for_expr(c, CHILD(n, off)); if (!expression) return NULL; @@ -2611,14 +2618,14 @@ if (!suite_seq) return NULL; - asdl_seq_SET(newobj, 0, - If(expression, suite_seq, orelse, - LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); - orelse = newobj; - } - return If(ast_for_expr(c, CHILD(n, 1)), - ast_for_suite(c, CHILD(n, 3)), - orelse, LINENO(n), n->n_col_offset, c->c_arena); + asdl_seq_SET(newobj, 0, + If(expression, suite_seq, orelse, + LINENO(CHILD(n, off)), CHILD(n, off)->n_col_offset, c->c_arena)); + orelse = newobj; + } + return If(ast_for_expr(c, CHILD(n, 1)), + ast_for_suite(c, CHILD(n, 3)), + orelse, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2642,7 +2649,7 @@ suite_seq = ast_for_suite(c, CHILD(n, 3)); if (!suite_seq) return NULL; - return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, suite_seq, NULL, LINENO(n), n->n_col_offset, c->c_arena); } else if (NCH(n) == 7) { expr_ty expression; @@ -2658,7 +2665,7 @@ if (!seq2) return NULL; - return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); + return While(expression, seq1, seq2, LINENO(n), n->n_col_offset, c->c_arena); } PyErr_Format(PyExc_SystemError, @@ -2678,7 +2685,7 @@ REQ(n, for_stmt); if (NCH(n) == 9) { - seq = ast_for_suite(c, CHILD(n, 8)); + seq = ast_for_suite(c, CHILD(n, 8)); if (!seq) return NULL; } @@ -2690,9 +2697,9 @@ /* Check the # of children rather than the length of _target, since for x, in ... has 1 element in _target, but still requires a Tuple. */ if (NCH(node_target) == 1) - target = (expr_ty)asdl_seq_GET(_target, 0); + target = (expr_ty)asdl_seq_GET(_target, 0); else - target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); + target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena); expression = ast_for_testlist(c, CHILD(n, 3)); if (!expression) @@ -2717,7 +2724,7 @@ if (!suite_seq) return NULL; - return excepthandler(NULL, NULL, suite_seq, LINENO(exc), + return excepthandler(NULL, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 2) { @@ -2731,16 +2738,16 @@ if (!suite_seq) return NULL; - return excepthandler(expression, NULL, suite_seq, LINENO(exc), + return excepthandler(expression, NULL, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } else if (NCH(exc) == 4) { asdl_seq *suite_seq; expr_ty expression; - expr_ty e = ast_for_expr(c, CHILD(exc, 3)); - if (!e) + expr_ty e = ast_for_expr(c, CHILD(exc, 3)); + if (!e) return NULL; - if (!set_context(e, Store, CHILD(exc, 3))) + if (!set_context(e, Store, CHILD(exc, 3))) return NULL; expression = ast_for_expr(c, CHILD(exc, 1)); if (!expression) @@ -2749,7 +2756,7 @@ if (!suite_seq) return NULL; - return excepthandler(expression, e, suite_seq, LINENO(exc), + return excepthandler(expression, e, suite_seq, LINENO(exc), exc->n_col_offset, c->c_arena); } @@ -2804,8 +2811,8 @@ } if (n_except > 0) { - int i; - stmt_ty except_st; + int i; + stmt_ty except_st; /* process except statements to create a try ... except */ asdl_seq *handlers = asdl_seq_new(n_except, c->c_arena); if (handlers == NULL) @@ -2819,17 +2826,17 @@ asdl_seq_SET(handlers, i, e); } - except_st = TryExcept(body, handlers, orelse, LINENO(n), + except_st = TryExcept(body, handlers, orelse, LINENO(n), n->n_col_offset, c->c_arena); if (!finally) - return except_st; + return except_st; /* if a 'finally' is present too, we nest the TryExcept within a TryFinally to emulate try ... except ... finally */ - body = asdl_seq_new(1, c->c_arena); - if (body == NULL) - return NULL; - asdl_seq_SET(body, 0, except_st); + body = asdl_seq_new(1, c->c_arena); + if (body == NULL) + return NULL; + asdl_seq_SET(body, 0, except_st); } /* must be a try ... finally (except clauses are in body, if any exist) */ @@ -2864,9 +2871,9 @@ if (!optional_vars) { return NULL; } - if (!set_context(optional_vars, Store, n)) { - return NULL; - } + if (!set_context(optional_vars, Store, n)) { + return NULL; + } suite_index = 4; } @@ -2875,7 +2882,7 @@ return NULL; } return With(context_expr, optional_vars, suite_seq, LINENO(n), - n->n_col_offset, c->c_arena); + n->n_col_offset, c->c_arena); } static stmt_ty @@ -2887,23 +2894,23 @@ REQ(n, classdef); if (!strcmp(STR(CHILD(n, 1)), "None")) { - ast_error(n, "assignment to None"); - return NULL; + ast_error(n, "assignment to None"); + return NULL; } if (NCH(n) == 4) { s = ast_for_suite(c, CHILD(n, 3)); if (!s) return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } /* check for empty base list */ if (TYPE(CHILD(n,3)) == RPAR) { - s = ast_for_suite(c, CHILD(n,5)); - if (!s) - return NULL; - return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), + s = ast_for_suite(c, CHILD(n,5)); + if (!s) + return NULL; + return ClassDef(NEW_IDENTIFIER(CHILD(n, 1)), NULL, s, LINENO(n), n->n_col_offset, c->c_arena); } @@ -2923,21 +2930,21 @@ ast_for_stmt(struct compiling *c, const node *n) { if (TYPE(n) == stmt) { - assert(NCH(n) == 1); - n = CHILD(n, 0); + assert(NCH(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == simple_stmt) { - assert(num_stmts(n) == 1); - n = CHILD(n, 0); + assert(num_stmts(n) == 1); + n = CHILD(n, 0); } if (TYPE(n) == small_stmt) { - REQ(n, small_stmt); - n = CHILD(n, 0); - /* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt - | flow_stmt | import_stmt | global_stmt | exec_stmt + REQ(n, small_stmt); + n = CHILD(n, 0); + /* small_stmt: expr_stmt | print_stmt | del_stmt | pass_stmt + | flow_stmt | import_stmt | global_stmt | exec_stmt | assert_stmt - */ - switch (TYPE(n)) { + */ + switch (TYPE(n)) { case expr_stmt: return ast_for_expr_stmt(c, n); case print_stmt: @@ -2965,11 +2972,11 @@ } else { /* compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt - | funcdef | classdef - */ - node *ch = CHILD(n, 0); - REQ(n, compound_stmt); - switch (TYPE(ch)) { + | funcdef | classdef + */ + node *ch = CHILD(n, 0); + REQ(n, compound_stmt); + switch (TYPE(ch)) { case if_stmt: return ast_for_if_stmt(c, ch); case while_stmt: @@ -2989,144 +2996,144 @@ "unhandled small_stmt: TYPE=%d NCH=%d\n", TYPE(n), NCH(n)); return NULL; - } + } } } static PyObject * parsenumber(const char *s) { - const char *end; - long x; - double dx; + const char *end; + long x; + double dx; #ifndef WITHOUT_COMPLEX - Py_complex c; - int imflag; + Py_complex c; + int imflag; #endif - errno = 0; - end = s + strlen(s) - 1; + errno = 0; + end = s + strlen(s) - 1; #ifndef WITHOUT_COMPLEX - imflag = *end == 'j' || *end == 'J'; + imflag = *end == 'j' || *end == 'J'; #endif - if (*end == 'l' || *end == 'L') - return PyLong_FromString((char *)s, (char **)0, 0); - if (s[0] == '0') { - x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); - if (x < 0 && errno == 0) { - return PyLong_FromString((char *)s, - (char **)0, - 0); - } - } - else - x = PyOS_strtol((char *)s, (char **)&end, 0); - if (*end == '\0') { - if (errno != 0) - return PyLong_FromString((char *)s, (char **)0, 0); - return PyInt_FromLong(x); - } - /* XXX Huge floats may silently fail */ + if (*end == 'l' || *end == 'L') + return PyLong_FromString((char *)s, (char **)0, 0); + if (s[0] == '0') { + x = (long) PyOS_strtoul((char *)s, (char **)&end, 0); + if (x < 0 && errno == 0) { + return PyLong_FromString((char *)s, + (char **)0, + 0); + } + } + else + x = PyOS_strtol((char *)s, (char **)&end, 0); + if (*end == '\0') { + if (errno != 0) + return PyLong_FromString((char *)s, (char **)0, 0); + return PyInt_FromLong(x); + } + /* XXX Huge floats may silently fail */ #ifndef WITHOUT_COMPLEX - if (imflag) { - c.real = 0.; - PyFPE_START_PROTECT("atof", return 0) - c.imag = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(c) - return PyComplex_FromCComplex(c); - } - else + if (imflag) { + c.real = 0.; + PyFPE_START_PROTECT("atof", return 0) + c.imag = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(c) + return PyComplex_FromCComplex(c); + } + else #endif - { - PyFPE_START_PROTECT("atof", return 0) - dx = PyOS_ascii_atof(s); - PyFPE_END_PROTECT(dx) - return PyFloat_FromDouble(dx); - } + { + PyFPE_START_PROTECT("atof", return 0) + dx = PyOS_ascii_atof(s); + PyFPE_END_PROTECT(dx) + return PyFloat_FromDouble(dx); + } } static PyObject * decode_utf8(const char **sPtr, const char *end, char* encoding) { #ifndef Py_USING_UNICODE - Py_FatalError("decode_utf8 should not be called in this build."); + Py_FatalError("decode_utf8 should not be called in this build."); return NULL; #else - PyObject *u, *v; - char *s, *t; - t = s = (char *)*sPtr; - /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ - while (s < end && (*s & 0x80)) s++; - *sPtr = s; - u = PyUnicode_DecodeUTF8(t, s - t, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *u, *v; + char *s, *t; + t = s = (char *)*sPtr; + /* while (s < end && *s != '\\') s++; */ /* inefficient for u".." */ + while (s < end && (*s & 0x80)) s++; + *sPtr = s; + u = PyUnicode_DecodeUTF8(t, s - t, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif } static PyObject * decode_unicode(const char *s, size_t len, int rawmode, const char *encoding) { - PyObject *v, *u; - char *buf; - char *p; - const char *end; - if (encoding == NULL) { - buf = (char *)s; - u = NULL; - } else if (strcmp(encoding, "iso-8859-1") == 0) { - buf = (char *)s; - u = NULL; - } else { - /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ - u = PyString_FromStringAndSize((char *)NULL, len * 4); - if (u == NULL) - return NULL; - p = buf = PyString_AsString(u); - end = s + len; - while (s < end) { - if (*s == '\\') { - *p++ = *s++; - if (*s & 0x80) { - strcpy(p, "u005c"); - p += 5; - } - } - if (*s & 0x80) { /* XXX inefficient */ - PyObject *w; - char *r; - Py_ssize_t rn, i; - w = decode_utf8(&s, end, "utf-16-be"); - if (w == NULL) { - Py_DECREF(u); - return NULL; - } - r = PyString_AsString(w); - rn = PyString_Size(w); - assert(rn % 2 == 0); - for (i = 0; i < rn; i += 2) { - sprintf(p, "\\u%02x%02x", - r[i + 0] & 0xFF, - r[i + 1] & 0xFF); - p += 6; - } - Py_DECREF(w); - } else { - *p++ = *s++; - } - } - len = p - buf; - s = buf; - } - if (rawmode) - v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); - else - v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); - Py_XDECREF(u); - return v; + PyObject *v, *u; + char *buf; + char *p; + const char *end; + if (encoding == NULL) { + buf = (char *)s; + u = NULL; + } else if (strcmp(encoding, "iso-8859-1") == 0) { + buf = (char *)s; + u = NULL; + } else { + /* "\XX" may become "\u005c\uHHLL" (12 bytes) */ + u = PyString_FromStringAndSize((char *)NULL, len * 4); + if (u == NULL) + return NULL; + p = buf = PyString_AsString(u); + end = s + len; + while (s < end) { + if (*s == '\\') { + *p++ = *s++; + if (*s & 0x80) { + strcpy(p, "u005c"); + p += 5; + } + } + if (*s & 0x80) { /* XXX inefficient */ + PyObject *w; + char *r; + Py_ssize_t rn, i; + w = decode_utf8(&s, end, "utf-16-be"); + if (w == NULL) { + Py_DECREF(u); + return NULL; + } + r = PyString_AsString(w); + rn = PyString_Size(w); + assert(rn % 2 == 0); + for (i = 0; i < rn; i += 2) { + sprintf(p, "\\u%02x%02x", + r[i + 0] & 0xFF, + r[i + 1] & 0xFF); + p += 6; + } + Py_DECREF(w); + } else { + *p++ = *s++; + } + } + len = p - buf; + s = buf; + } + if (rawmode) + v = PyUnicode_DecodeRawUnicodeEscape(s, len, NULL); + else + v = PyUnicode_DecodeUnicodeEscape(s, len, NULL); + Py_XDECREF(u); + return v; } /* s is a Python string literal, including the bracketing quote characters, @@ -3136,75 +3143,75 @@ static PyObject * parsestr(const char *s, const char *encoding) { - size_t len; - int quote = Py_CHARMASK(*s); - int rawmode = 0; - int need_encoding; - int unicode = 0; - - if (isalpha(quote) || quote == '_') { - if (quote == 'u' || quote == 'U') { - quote = *++s; - unicode = 1; - } - if (quote == 'r' || quote == 'R') { - quote = *++s; - rawmode = 1; - } - } - if (quote != '\'' && quote != '\"') { - PyErr_BadInternalCall(); - return NULL; - } - s++; - len = strlen(s); - if (len > INT_MAX) { - PyErr_SetString(PyExc_OverflowError, - "string to parse is too long"); - return NULL; - } - if (s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - if (len >= 4 && s[0] == quote && s[1] == quote) { - s += 2; - len -= 2; - if (s[--len] != quote || s[--len] != quote) { - PyErr_BadInternalCall(); - return NULL; - } - } + size_t len; + int quote = Py_CHARMASK(*s); + int rawmode = 0; + int need_encoding; + int unicode = 0; + + if (isalpha(quote) || quote == '_') { + if (quote == 'u' || quote == 'U') { + quote = *++s; + unicode = 1; + } + if (quote == 'r' || quote == 'R') { + quote = *++s; + rawmode = 1; + } + } + if (quote != '\'' && quote != '\"') { + PyErr_BadInternalCall(); + return NULL; + } + s++; + len = strlen(s); + if (len > INT_MAX) { + PyErr_SetString(PyExc_OverflowError, + "string to parse is too long"); + return NULL; + } + if (s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + if (len >= 4 && s[0] == quote && s[1] == quote) { + s += 2; + len -= 2; + if (s[--len] != quote || s[--len] != quote) { + PyErr_BadInternalCall(); + return NULL; + } + } #ifdef Py_USING_UNICODE - if (unicode || Py_UnicodeFlag) { - return decode_unicode(s, len, rawmode, encoding); - } + if (unicode || Py_UnicodeFlag) { + return decode_unicode(s, len, rawmode, encoding); + } #endif - need_encoding = (encoding != NULL && - strcmp(encoding, "utf-8") != 0 && - strcmp(encoding, "iso-8859-1") != 0); - if (rawmode || strchr(s, '\\') == NULL) { - if (need_encoding) { + need_encoding = (encoding != NULL && + strcmp(encoding, "utf-8") != 0 && + strcmp(encoding, "iso-8859-1") != 0); + if (rawmode || strchr(s, '\\') == NULL) { + if (need_encoding) { #ifndef Py_USING_UNICODE - /* This should not happen - we never see any other - encoding. */ - Py_FatalError( + /* This should not happen - we never see any other + encoding. */ + Py_FatalError( "cannot deal with encodings in this build."); #else - PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); - if (u == NULL) - return NULL; - v = PyUnicode_AsEncodedString(u, encoding, NULL); - Py_DECREF(u); - return v; + PyObject *v, *u = PyUnicode_DecodeUTF8(s, len, NULL); + if (u == NULL) + return NULL; + v = PyUnicode_AsEncodedString(u, encoding, NULL); + Py_DECREF(u); + return v; #endif - } else { - return PyString_FromStringAndSize(s, len); - } - } + } else { + return PyString_FromStringAndSize(s, len); + } + } - return PyString_DecodeEscape(s, len, NULL, unicode, - need_encoding ? encoding : NULL); + return PyString_DecodeEscape(s, len, NULL, unicode, + need_encoding ? encoding : NULL); } /* Build a Python string object out of a STRING atom. This takes care of @@ -3214,36 +3221,36 @@ static PyObject * parsestrplus(struct compiling *c, const node *n) { - PyObject *v; - int i; - REQ(CHILD(n, 0), STRING); - if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { - /* String literal concatenation */ - for (i = 1; i < NCH(n); i++) { - PyObject *s; - s = parsestr(STR(CHILD(n, i)), c->c_encoding); - if (s == NULL) - goto onError; - if (PyString_Check(v) && PyString_Check(s)) { - PyString_ConcatAndDel(&v, s); - if (v == NULL) - goto onError; - } + PyObject *v; + int i; + REQ(CHILD(n, 0), STRING); + if ((v = parsestr(STR(CHILD(n, 0)), c->c_encoding)) != NULL) { + /* String literal concatenation */ + for (i = 1; i < NCH(n); i++) { + PyObject *s; + s = parsestr(STR(CHILD(n, i)), c->c_encoding); + if (s == NULL) + goto onError; + if (PyString_Check(v) && PyString_Check(s)) { + PyString_ConcatAndDel(&v, s); + if (v == NULL) + goto onError; + } #ifdef Py_USING_UNICODE - else { - PyObject *temp = PyUnicode_Concat(v, s); - Py_DECREF(s); - Py_DECREF(v); - v = temp; - if (v == NULL) - goto onError; - } + else { + PyObject *temp = PyUnicode_Concat(v, s); + Py_DECREF(s); + Py_DECREF(v); + v = temp; + if (v == NULL) + goto onError; + } #endif - } - } - return v; + } + } + return v; onError: - Py_XDECREF(v); - return NULL; + Py_XDECREF(v); + return NULL; } Modified: python/branches/bcannon-objcap/Python/bltinmodule.c ============================================================================== --- python/branches/bcannon-objcap/Python/bltinmodule.c (original) +++ python/branches/bcannon-objcap/Python/bltinmodule.c Tue Sep 5 19:47:00 2006 @@ -607,7 +607,7 @@ Evaluate the source in the context of globals and locals.\n\ The source may be a string representing a Python expression\n\ or a code object as returned by compile().\n\ -The globals must be a dictionary and locals can be any mappping,\n\ +The globals must be a dictionary and locals can be any mapping,\n\ defaulting to the current globals and locals.\n\ If only globals is given, locals defaults to it.\n"); Modified: python/branches/bcannon-objcap/Python/import.c ============================================================================== --- python/branches/bcannon-objcap/Python/import.c (original) +++ python/branches/bcannon-objcap/Python/import.c Tue Sep 5 19:47:00 2006 @@ -64,9 +64,10 @@ Python 2.5b3: 62111 (fix wrong code: x += yield) Python 2.5c1: 62121 (fix wrong lnotab with for loops and storing constants that should have been removed) + Python 2.5c2: 62131 (fix wrong code: for x, in ... in listcomp/genexp) . */ -#define MAGIC (62121 | ((long)'\r'<<16) | ((long)'\n'<<24)) +#define MAGIC (62131 | ((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 Modified: python/branches/bcannon-objcap/Tools/pybench/pybench.py ============================================================================== --- python/branches/bcannon-objcap/Tools/pybench/pybench.py (original) +++ python/branches/bcannon-objcap/Tools/pybench/pybench.py Tue Sep 5 19:47:00 2006 @@ -885,7 +885,7 @@ else: bench.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) - except IOError: + except IOError, reason: print '* Error opening/reading file %s: %s' % ( repr(show_bench), reason) @@ -931,8 +931,13 @@ bench.name = reportfile pickle.dump(bench,f) f.close() - except IOError: + except IOError, reason: print '* Error opening/writing reportfile' + except IOError, reason: + print '* Error opening/writing reportfile %s: %s' % ( + reportfile, + reason) + print if __name__ == '__main__': PyBenchCmdline() Modified: python/branches/bcannon-objcap/configure ============================================================================== --- python/branches/bcannon-objcap/configure (original) +++ python/branches/bcannon-objcap/configure Tue Sep 5 19:47:00 2006 @@ -1553,7 +1553,7 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.[0123456789]) + OpenBSD/2.* | OpenBSD/3.[0123456789] | OpenBSD/4.[0]) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. Modified: python/branches/bcannon-objcap/configure.in ============================================================================== --- python/branches/bcannon-objcap/configure.in (original) +++ python/branches/bcannon-objcap/configure.in Tue Sep 5 19:47:00 2006 @@ -201,7 +201,7 @@ # On OpenBSD, select(2) is not available if _XOPEN_SOURCE is defined, # even though select is a POSIX function. Reported by J. Ribbens. # Reconfirmed for OpenBSD 3.3 by Zachary Hamm, for 3.4 by Jason Ish. - OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@) + OpenBSD/2.* | OpenBSD/3.@<:@0123456789@:>@ | OpenBSD/4.@<:@0@:>@) define_xopen_source=no;; # On Solaris 2.6, sys/wait.h is inconsistent in the usage # of union __?sigval. Reported by Stuart Bishop. From python-checkins at python.org Tue Sep 5 19:58:14 2006 From: python-checkins at python.org (kristjan.jonsson) Date: Tue, 5 Sep 2006 19:58:14 +0200 (CEST) Subject: [Python-checkins] r51751 - in python/trunk: PC/example_nt/example.vcproj PCbuild8/_ctypes.vcproj PCbuild8/_ctypes_test.vcproj PCbuild8/_elementtree.vcproj PCbuild8/_msi.vcproj PCbuild8/_sqlite3.vcproj PCbuild8/make_buildinfo.c PCbuild8/make_buildinfo.vcproj PCbuild8/pcbuild.sln PCbuild8/python.vcproj PCbuild8/pythoncore.vcproj PCbuild8/pythoncore_pgo.vcproj PCbuild8/pythoncore_pgo_link.txt PCbuild8/pythonw.vcproj PCbuild8/readme.txt PCbuild8/select.vcproj PCbuild8/unicodedata.vcproj PCbuild8/w9xpopen.vcproj PCbuild8/winsound.vcproj Message-ID: <20060905175814.787A31E4004@bag.python.org> Author: kristjan.jonsson Date: Tue Sep 5 19:58:12 2006 New Revision: 51751 Removed: python/trunk/PCbuild8/pythoncore_pgo.vcproj python/trunk/PCbuild8/pythoncore_pgo_link.txt Modified: python/trunk/PC/example_nt/example.vcproj python/trunk/PCbuild8/_ctypes.vcproj python/trunk/PCbuild8/_ctypes_test.vcproj python/trunk/PCbuild8/_elementtree.vcproj python/trunk/PCbuild8/_msi.vcproj python/trunk/PCbuild8/_sqlite3.vcproj python/trunk/PCbuild8/make_buildinfo.c python/trunk/PCbuild8/make_buildinfo.vcproj python/trunk/PCbuild8/pcbuild.sln python/trunk/PCbuild8/python.vcproj python/trunk/PCbuild8/pythoncore.vcproj python/trunk/PCbuild8/pythonw.vcproj python/trunk/PCbuild8/readme.txt python/trunk/PCbuild8/select.vcproj python/trunk/PCbuild8/unicodedata.vcproj python/trunk/PCbuild8/w9xpopen.vcproj python/trunk/PCbuild8/winsound.vcproj Log: Update the PCBuild8 solution. Facilitate cross-compilation by having binaries in separate Win32 and x64 directories. Rationalized configs by making proper use of platforms/configurations. Remove pythoncore_pgo project. Add new PGIRelease and PGORelease configurations to perform Profile Guided Optimisation. Removed I64 support, but this can be easily added by copying the x64 platform settings. Modified: python/trunk/PC/example_nt/example.vcproj ============================================================================== --- python/trunk/PC/example_nt/example.vcproj (original) +++ python/trunk/PC/example_nt/example.vcproj Tue Sep 5 19:58:12 2006 @@ -39,7 +39,7 @@ + + + @@ -236,17 +236,17 @@ /> @@ -327,17 +325,17 @@ /> + + @@ -238,18 +238,18 @@ /> @@ -330,18 +327,18 @@ /> #include -/* This file creates the getbuildinfo.o object, by first - invoking subwcrev.exe (if found), and then invoking cl.exe. - As a side effect, it might generate PCBuild\getbuildinfo2.c - also. If this isn't a subversion checkout, or subwcrev isn't - found, it compiles ..\\Modules\\getbuildinfo.c instead. +/* This file creates the getbuildinfo2.c file, by + invoking subwcrev.exe (if found). + If this isn't a subversion checkout, or subwcrev isn't + found, it copies ..\\Modules\\getbuildinfo.c instead. + + A file, getbuildinfo2.h is then updated to define + SUBWCREV if it was a subversion checkout. + + getbuildinfo2.c is part of the pythoncore project with + getbuildinfo2.h as a forced include. This helps + VisualStudio refrain from unnecessary compiles much of the + time. Currently, subwcrev.exe is found from the registry entries of TortoiseSVN. - No attempt is made to place getbuildinfo.o into the proper - binary directory. This isn't necessary, as this tool is - invoked as a pre-link step for pythoncore, so that overwrites - any previous getbuildinfo.o. + make_buildinfo.exe is called as a pre-build step for pythoncore. */ @@ -40,11 +44,11 @@ type != REG_SZ) /* Registry corrupted */ return 0; - strcat(command, "bin\\subwcrev.exe"); + strcat_s(command, sizeof(command), "bin\\subwcrev.exe"); if (_stat(command+1, &st) < 0) /* subwcrev.exe not part of the release */ return 0; - strcat(command, "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + strcat_s(command, sizeof(command), "\" .. ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); puts(command); fflush(stdout); if (system(command) < 0) return 0; @@ -53,40 +57,25 @@ int main(int argc, char*argv[]) { - char command[500] = "cl.exe -c -D_WIN32 -DUSE_DL_EXPORT -D_WINDOWS -DWIN32 -D_WINDLL "; - int do_unlink, result; - if (argc != 2) { - fprintf(stderr, "make_buildinfo $(ConfigurationName)\n"); - return EXIT_FAILURE; - } - if (strcmp(argv[1], "Release") == 0) { - strcat(command, "-MD "); - } - else if (strcmp(argv[1], "Debug") == 0) { - strcat(command, "-D_DEBUG -MDd "); - } - else if (strcmp(argv[1], "ReleaseItanium") == 0) { - strcat(command, "-MD /USECL:MS_ITANIUM "); - } - else if (strcmp(argv[1], "ReleaseAMD64") == 0) { - strcat(command, "-MD "); - strcat(command, "-MD /USECL:MS_OPTERON "); - } - else { - fprintf(stderr, "unsupported configuration %s\n", argv[1]); - return EXIT_FAILURE; - } + char command[500] = ""; + int svn; + FILE *f; - if ((do_unlink = make_buildinfo2())) - strcat(command, "getbuildinfo2.c -DSUBWCREV "); - else - strcat(command, "..\\Modules\\getbuildinfo.c"); - strcat(command, " -Fogetbuildinfo.o -I..\\Include -I..\\PC"); - puts(command); fflush(stdout); - result = system(command); - if (do_unlink) - unlink("getbuildinfo2.c"); - if (result < 0) + if (fopen_s(&f, "getbuildinfo2.h", "w")) return EXIT_FAILURE; + /* Get getbuildinfo.c from svn as getbuildinfo2.c */ + svn = make_buildinfo2(); + if (svn) { + puts("got getbuildinfo2.c from svn. Updating getbuildinfo2.h"); + /* yes. make sure SUBWCREV is defined */ + fprintf(f, "#define SUBWCREV\n"); + } else { + puts("didn't get getbuildinfo2.c from svn. Copying from Modules and clearing getbuildinfo2.h"); + strcat_s(command, sizeof(command), "copy ..\\Modules\\getbuildinfo.c getbuildinfo2.c"); + puts(command); fflush(stdout); + if (system(command) < 0) + return EXIT_FAILURE; + } + fclose(f); return 0; } \ No newline at end of file Modified: python/trunk/PCbuild8/make_buildinfo.vcproj ============================================================================== --- python/trunk/PCbuild8/make_buildinfo.vcproj (original) +++ python/trunk/PCbuild8/make_buildinfo.vcproj Tue Sep 5 19:58:12 2006 @@ -4,6 +4,7 @@ Version="8,00" Name="make_buildinfo" ProjectGUID="{C73F0EC1-358B-4177-940F-0846AC8B04CD}" + RootNamespace="make_buildinfo" Keyword="Win32Proj" > @@ -40,7 +41,7 @@ - - - - - - - - - - - - - - - - - - - - Modified: python/trunk/PCbuild8/pcbuild.sln ============================================================================== --- python/trunk/PCbuild8/pcbuild.sln (original) +++ python/trunk/PCbuild8/pcbuild.sln Tue Sep 5 19:58:12 2006 @@ -2,8 +2,8 @@ # Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore", "pythoncore.vcproj", "{CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}" ProjectSection(ProjectDependencies) = postProject - {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} {F0E0541E-F17D-430B-97C4-93ADF0DD284E} = {F0E0541E-F17D-430B-97C4-93ADF0DD284E} + {C73F0EC1-358B-4177-940F-0846AC8B04CD} = {C73F0EC1-358B-4177-940F-0846AC8B04CD} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythonw", "pythonw.vcproj", "{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" @@ -61,137 +61,244 @@ readme.txt = readme.txt EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pythoncore_pgo", "pythoncore_pgo.vcproj", "{8B59C1FF-2439-4BE9-9F24-84D4982D28D4}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" ProjectSection(ProjectDependencies) = postProject {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} = {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "python", "python.vcproj", "{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_versioninfo", "make_versioninfo.vcproj", "{F0E0541E-F17D-430B-97C4-93ADF0DD284E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + PGIRelease|Win32 = PGIRelease|Win32 + PGIRelease|x64 = PGIRelease|x64 + PGORelease|Win32 = PGORelease|Win32 + PGORelease|x64 = PGORelease|x64 Release|Win32 = Release|Win32 - ReleaseAMD64|Win32 = ReleaseAMD64|Win32 - ReleaseItanium|Win32 = ReleaseItanium|Win32 + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.ActiveCfg = Debug|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|Win32.Build.0 = Debug|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.ActiveCfg = Debug|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Debug|x64.Build.0 = Debug|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|Win32.ActiveCfg = PGIRelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|Win32.Build.0 = PGIRelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|x64.ActiveCfg = PGIRelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGIRelease|x64.Build.0 = PGIRelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|Win32.ActiveCfg = PGORelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|Win32.Build.0 = PGORelease|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|x64.ActiveCfg = PGORelease|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.PGORelease|x64.Build.0 = PGORelease|x64 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.ActiveCfg = Release|Win32 {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|Win32.Build.0 = Release|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.ActiveCfg = Release|x64 + {CF7AC3D1-E2DF-41D2-BEA6-1E2556CDEA26}.Release|x64.Build.0 = Release|x64 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.ActiveCfg = Debug|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|Win32.Build.0 = Debug|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.ActiveCfg = Debug|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Debug|x64.Build.0 = Debug|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGIRelease|x64.Build.0 = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|Win32.Build.0 = Release|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.PGORelease|x64.Build.0 = Release|x64 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.ActiveCfg = Release|Win32 {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|Win32.Build.0 = Release|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.ActiveCfg = Release|x64 + {F4229CC3-873C-49AE-9729-DD308ED4CD4A}.Release|x64.Build.0 = Release|x64 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.ActiveCfg = Debug|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|Win32.Build.0 = Debug|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|x64.ActiveCfg = Debug|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Debug|x64.Build.0 = Debug|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGIRelease|x64.Build.0 = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|Win32.ActiveCfg = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|Win32.Build.0 = Release|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.PGORelease|x64.Build.0 = Release|x64 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.ActiveCfg = Release|Win32 {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|Win32.Build.0 = Release|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|x64.ActiveCfg = Release|x64 + {97239A56-DBC0-41D2-BC14-C87D9B97D63B}.Release|x64.Build.0 = Release|x64 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.ActiveCfg = Debug|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|Win32.Build.0 = Debug|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|x64.ActiveCfg = Debug|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Debug|x64.Build.0 = Debug|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGIRelease|x64.Build.0 = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|Win32.ActiveCfg = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|Win32.Build.0 = Release|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.PGORelease|x64.Build.0 = Release|x64 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.ActiveCfg = Release|Win32 {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|Win32.Build.0 = Release|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|x64.ActiveCfg = Release|x64 + {FA5FC7EB-C72F-415F-AE42-91DD605ABDDA}.Release|x64.Build.0 = Release|x64 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.ActiveCfg = Debug|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|Win32.Build.0 = Debug|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.ActiveCfg = Debug|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Debug|x64.Build.0 = Debug|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGIRelease|x64.Build.0 = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|Win32.Build.0 = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.PGORelease|x64.Build.0 = Release|x64 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.ActiveCfg = Release|Win32 {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|Win32.Build.0 = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.ActiveCfg = Release|x64 + {E9E0A1F6-0009-4E8C-B8F8-1B8F5D49A058}.Release|x64.Build.0 = Release|x64 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.ActiveCfg = Debug|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|Win32.Build.0 = Debug|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|x64.ActiveCfg = Debug|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Debug|x64.Build.0 = Debug|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGIRelease|x64.Build.0 = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|Win32.ActiveCfg = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|Win32.Build.0 = Release|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.PGORelease|x64.Build.0 = Release|x64 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.ActiveCfg = Release|Win32 {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|Win32.Build.0 = Release|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {51F35FAE-FB92-4B2C-9187-1542C065AD77}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|x64.ActiveCfg = Release|x64 + {51F35FAE-FB92-4B2C-9187-1542C065AD77}.Release|x64.Build.0 = Release|x64 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.ActiveCfg = Debug|Win32 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|Win32.Build.0 = Debug|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|x64.ActiveCfg = Debug|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Debug|x64.Build.0 = Debug|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGIRelease|x64.Build.0 = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|Win32.ActiveCfg = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|Win32.Build.0 = Release|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.PGORelease|x64.Build.0 = Release|x64 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.ActiveCfg = Release|Win32 {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|Win32.Build.0 = Release|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|x64.ActiveCfg = Release|x64 + {1966DDE2-4AB7-4E4E-ACC9-C121E4D37F8E}.Release|x64.Build.0 = Release|x64 {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.ActiveCfg = Debug|Win32 {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|Win32.Build.0 = Debug|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {C73F0EC1-358B-4177-940F-0846AC8B04CD}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Debug|x64.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGIRelease|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.PGORelease|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|Win32.Build.0 = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.ActiveCfg = Debug|Win32 + {C73F0EC1-358B-4177-940F-0846AC8B04CD}.Release|x64.Build.0 = Debug|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.ActiveCfg = Debug|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|Win32.Build.0 = Debug|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|x64.ActiveCfg = Debug|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Debug|x64.Build.0 = Debug|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGIRelease|x64.Build.0 = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|Win32.ActiveCfg = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|Win32.Build.0 = Release|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.PGORelease|x64.Build.0 = Release|x64 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.ActiveCfg = Release|Win32 {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|Win32.Build.0 = Release|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|x64.ActiveCfg = Release|x64 + {2C0BEFB9-70E2-4F80-AC5B-4AB8EE023574}.Release|x64.Build.0 = Release|x64 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.ActiveCfg = Debug|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|Win32.Build.0 = Debug|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|x64.ActiveCfg = Debug|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Debug|x64.Build.0 = Debug|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|x64.ActiveCfg = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGIRelease|x64.Build.0 = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|Win32.Build.0 = Release|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|x64.ActiveCfg = Release|x64 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.PGORelease|x64.Build.0 = Release|x64 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.ActiveCfg = Release|Win32 {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|Win32.Build.0 = Release|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {F22F40F4-D318-40DC-96B3-88DC81CE0894}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {F22F40F4-D318-40DC-96B3-88DC81CE0894}.Release|x64.ActiveCfg = Release|x64 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.ActiveCfg = Debug|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|Win32.Build.0 = Debug|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|x64.ActiveCfg = Debug|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Debug|x64.Build.0 = Debug|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGIRelease|x64.Build.0 = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|Win32.ActiveCfg = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|Win32.Build.0 = Release|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.PGORelease|x64.Build.0 = Release|x64 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.ActiveCfg = Release|Win32 {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|Win32.Build.0 = Release|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|x64.ActiveCfg = Release|x64 + {8CF334D9-4F82-42EB-97AF-83592C5AFD2F}.Release|x64.Build.0 = Release|x64 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.ActiveCfg = Debug|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|Win32.Build.0 = Debug|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|x64.ActiveCfg = Debug|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Debug|x64.Build.0 = Debug|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGIRelease|x64.Build.0 = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|Win32.ActiveCfg = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.PGORelease|x64.Build.0 = Release|x64 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.ActiveCfg = Release|Win32 {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|Win32.Build.0 = Release|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {2FF0A312-22F9-4C34-B070-842916DE27A9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Debug|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.Release|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {8B59C1FF-2439-4BE9-9F24-84D4982D28D4}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|x64.ActiveCfg = Release|x64 + {2FF0A312-22F9-4C34-B070-842916DE27A9}.Release|x64.Build.0 = Release|x64 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.ActiveCfg = Debug|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|Win32.Build.0 = Debug|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.ActiveCfg = Debug|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Debug|x64.Build.0 = Debug|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGIRelease|x64.Build.0 = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|Win32.ActiveCfg = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|Win32.Build.0 = Release|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.PGORelease|x64.Build.0 = Release|x64 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.ActiveCfg = Release|Win32 {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|Win32.Build.0 = Release|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.ActiveCfg = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseAMD64|Win32.Build.0 = ReleaseAMD64|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.ActiveCfg = ReleaseItanium|Win32 - {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.ReleaseItanium|Win32.Build.0 = ReleaseItanium|Win32 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.ActiveCfg = Release|x64 + {B11D750F-CD1F-4A96-85CE-E69A5C5259F9}.Release|x64.Build.0 = Release|x64 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.ActiveCfg = Debug|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|Win32.Build.0 = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.ActiveCfg = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Debug|x64.Build.0 = Debug|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|Win32.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGIRelease|x64.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|Win32.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.PGORelease|x64.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.ActiveCfg = Release|Win32 {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseAMD64|Win32.Build.0 = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium|Win32.ActiveCfg = Release|Win32 - {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.ReleaseItanium|Win32.Build.0 = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.ActiveCfg = Release|Win32 + {F0E0541E-F17D-430B-97C4-93ADF0DD284E}.Release|x64.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Modified: python/trunk/PCbuild8/python.vcproj ============================================================================== --- python/trunk/PCbuild8/python.vcproj (original) +++ python/trunk/PCbuild8/python.vcproj Tue Sep 5 19:58:12 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="python" ProjectGUID="{B11D750F-CD1F-4A96-85CE-E69A5C5259F9}" + RootNamespace="python" > + @@ -239,25 +241,26 @@ /> @@ -333,25 +331,26 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -253,23 +440,21 @@ /> @@ -350,23 +537,21 @@ /> - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -558,6 +1297,10 @@ > + + @@ -738,6 +1481,74 @@ > + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -797,6 +1608,14 @@ /> + + + + + + + + + + + + + + Deleted: /python/trunk/PCbuild8/pythoncore_pgo.vcproj ============================================================================== --- /python/trunk/PCbuild8/pythoncore_pgo.vcproj Tue Sep 5 19:58:12 2006 +++ (empty file) @@ -1,781 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted: /python/trunk/PCbuild8/pythoncore_pgo_link.txt ============================================================================== --- /python/trunk/PCbuild8/pythoncore_pgo_link.txt Tue Sep 5 19:58:12 2006 +++ (empty file) @@ -1,311 +0,0 @@ -/OUT:".\pythoncore_pgo/python25.dll" /INCREMENTAL:NO /DLL /MANIFEST /MANIFESTFILE:".\x86-temp-release\pythoncore_pgo\python25.dll.intermediate.manifest" /NODEFAULTLIB:"libc" /DEBUG /PDB:".\pythoncore_pgo/python25.pdb" /SUBSYSTEM:WINDOWS /LTCG:PGINSTRUMENT /PGD:".\pythoncore_pgo\python25.pgd" /BASE:"0x1e000000" /IMPLIB:"pythoncore_pgo/python25.lib" /MACHINE:X86 getbuildinfo.o kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib - -".\x86-temp-release\pythoncore_pgo\adler32.obj" - -".\x86-temp-release\pythoncore_pgo\compress.obj" - -".\x86-temp-release\pythoncore_pgo\crc32.obj" - -".\x86-temp-release\pythoncore_pgo\deflate.obj" - -".\x86-temp-release\pythoncore_pgo\gzio.obj" - -".\x86-temp-release\pythoncore_pgo\infback.obj" - -".\x86-temp-release\pythoncore_pgo\inffast.obj" - -".\x86-temp-release\pythoncore_pgo\inflate.obj" - -".\x86-temp-release\pythoncore_pgo\inftrees.obj" - -".\x86-temp-release\pythoncore_pgo\trees.obj" - -".\x86-temp-release\pythoncore_pgo\uncompr.obj" - -".\x86-temp-release\pythoncore_pgo\zlibmodule.obj" - -".\x86-temp-release\pythoncore_pgo\zutil.obj" - -".\x86-temp-release\pythoncore_pgo\_bisectmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_cn.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_hk.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_iso2022.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_jp.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_kr.obj" - -".\x86-temp-release\pythoncore_pgo\_codecs_tw.obj" - -".\x86-temp-release\pythoncore_pgo\_codecsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_csv.obj" - -".\x86-temp-release\pythoncore_pgo\_functoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_heapqmodule.obj" - -".\x86-temp-release\pythoncore_pgo\_hotshot.obj" - -".\x86-temp-release\pythoncore_pgo\_localemodule.obj" - -".\x86-temp-release\pythoncore_pgo\_lsprof.obj" - -".\x86-temp-release\pythoncore_pgo\_randommodule.obj" - -".\x86-temp-release\pythoncore_pgo\_sre.obj" - -".\x86-temp-release\pythoncore_pgo\_struct.obj" - -".\x86-temp-release\pythoncore_pgo\_subprocess.obj" - -".\x86-temp-release\pythoncore_pgo\_weakref.obj" - -".\x86-temp-release\pythoncore_pgo\_winreg.obj" - -".\x86-temp-release\pythoncore_pgo\abstract.obj" - -".\x86-temp-release\pythoncore_pgo\acceler.obj" - -".\x86-temp-release\pythoncore_pgo\arraymodule.obj" - -".\x86-temp-release\pythoncore_pgo\asdl.obj" - -".\x86-temp-release\pythoncore_pgo\ast.obj" - -".\x86-temp-release\pythoncore_pgo\audioop.obj" - -".\x86-temp-release\pythoncore_pgo\binascii.obj" - -".\x86-temp-release\pythoncore_pgo\bitset.obj" - -".\x86-temp-release\pythoncore_pgo\bltinmodule.obj" - -".\x86-temp-release\pythoncore_pgo\boolobject.obj" - -".\x86-temp-release\pythoncore_pgo\bufferobject.obj" - -".\x86-temp-release\pythoncore_pgo\cellobject.obj" - -".\x86-temp-release\pythoncore_pgo\ceval.obj" - -".\x86-temp-release\pythoncore_pgo\classobject.obj" - -".\x86-temp-release\pythoncore_pgo\cmathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\cobject.obj" - -".\x86-temp-release\pythoncore_pgo\codecs.obj" - -".\x86-temp-release\pythoncore_pgo\codeobject.obj" - -".\x86-temp-release\pythoncore_pgo\collectionsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\compile.obj" - -".\x86-temp-release\pythoncore_pgo\complexobject.obj" - -".\x86-temp-release\pythoncore_pgo\config.obj" - -".\x86-temp-release\pythoncore_pgo\cPickle.obj" - -".\x86-temp-release\pythoncore_pgo\cStringIO.obj" - -".\x86-temp-release\pythoncore_pgo\datetimemodule.obj" - -".\x86-temp-release\pythoncore_pgo\descrobject.obj" - -".\x86-temp-release\pythoncore_pgo\dictobject.obj" - -".\x86-temp-release\pythoncore_pgo\dl_nt.obj" - -".\x86-temp-release\pythoncore_pgo\dynload_win.obj" - -".\x86-temp-release\pythoncore_pgo\enumobject.obj" - -".\x86-temp-release\pythoncore_pgo\errnomodule.obj" - -".\x86-temp-release\pythoncore_pgo\errors.obj" - -".\x86-temp-release\pythoncore_pgo\exceptions.obj" - -".\x86-temp-release\pythoncore_pgo\fileobject.obj" - -".\x86-temp-release\pythoncore_pgo\firstsets.obj" - -".\x86-temp-release\pythoncore_pgo\floatobject.obj" - -".\x86-temp-release\pythoncore_pgo\frameobject.obj" - -".\x86-temp-release\pythoncore_pgo\frozen.obj" - -".\x86-temp-release\pythoncore_pgo\funcobject.obj" - -".\x86-temp-release\pythoncore_pgo\future.obj" - -".\x86-temp-release\pythoncore_pgo\gcmodule.obj" - -".\x86-temp-release\pythoncore_pgo\genobject.obj" - -".\x86-temp-release\pythoncore_pgo\getargs.obj" - -".\x86-temp-release\pythoncore_pgo\getcompiler.obj" - -".\x86-temp-release\pythoncore_pgo\getcopyright.obj" - -".\x86-temp-release\pythoncore_pgo\getmtime.obj" - -".\x86-temp-release\pythoncore_pgo\getopt.obj" - -".\x86-temp-release\pythoncore_pgo\getpathp.obj" - -".\x86-temp-release\pythoncore_pgo\getplatform.obj" - -".\x86-temp-release\pythoncore_pgo\getversion.obj" - -".\x86-temp-release\pythoncore_pgo\graminit.obj" - -".\x86-temp-release\pythoncore_pgo\grammar.obj" - -".\x86-temp-release\pythoncore_pgo\grammar1.obj" - -".\x86-temp-release\pythoncore_pgo\imageop.obj" - -".\x86-temp-release\pythoncore_pgo\import.obj" - -".\x86-temp-release\pythoncore_pgo\import_nt.obj" - -".\x86-temp-release\pythoncore_pgo\importdl.obj" - -".\x86-temp-release\pythoncore_pgo\intobject.obj" - -".\x86-temp-release\pythoncore_pgo\iterobject.obj" - -".\x86-temp-release\pythoncore_pgo\itertoolsmodule.obj" - -".\x86-temp-release\pythoncore_pgo\listnode.obj" - -".\x86-temp-release\pythoncore_pgo\listobject.obj" - -".\x86-temp-release\pythoncore_pgo\longobject.obj" - -".\x86-temp-release\pythoncore_pgo\main.obj" - -".\x86-temp-release\pythoncore_pgo\marshal.obj" - -".\x86-temp-release\pythoncore_pgo\mathmodule.obj" - -".\x86-temp-release\pythoncore_pgo\md5.obj" - -".\x86-temp-release\pythoncore_pgo\md5module.obj" - -".\x86-temp-release\pythoncore_pgo\metagrammar.obj" - -".\x86-temp-release\pythoncore_pgo\methodobject.obj" - -".\x86-temp-release\pythoncore_pgo\mmapmodule.obj" - -".\x86-temp-release\pythoncore_pgo\modsupport.obj" - -".\x86-temp-release\pythoncore_pgo\moduleobject.obj" - -".\x86-temp-release\pythoncore_pgo\msvcrtmodule.obj" - -".\x86-temp-release\pythoncore_pgo\multibytecodec.obj" - -".\x86-temp-release\pythoncore_pgo\myreadline.obj" - -".\x86-temp-release\pythoncore_pgo\mysnprintf.obj" - -".\x86-temp-release\pythoncore_pgo\mystrtoul.obj" - -".\x86-temp-release\pythoncore_pgo\node.obj" - -".\x86-temp-release\pythoncore_pgo\object.obj" - -".\x86-temp-release\pythoncore_pgo\obmalloc.obj" - -".\x86-temp-release\pythoncore_pgo\operator.obj" - -".\x86-temp-release\pythoncore_pgo\parser.obj" - -".\x86-temp-release\pythoncore_pgo\parsermodule.obj" - -".\x86-temp-release\pythoncore_pgo\parsetok.obj" - -".\x86-temp-release\pythoncore_pgo\posixmodule.obj" - -".\x86-temp-release\pythoncore_pgo\pyarena.obj" - -".\x86-temp-release\pythoncore_pgo\pyfpe.obj" - -".\x86-temp-release\pythoncore_pgo\pystate.obj" - -".\x86-temp-release\pythoncore_pgo\pystrtod.obj" - -".\x86-temp-release\pythoncore_pgo\Python-ast.obj" - -".\x86-temp-release\pythoncore_pgo\python_nt.res" - -".\x86-temp-release\pythoncore_pgo\pythonrun.obj" - -".\x86-temp-release\pythoncore_pgo\rangeobject.obj" - -".\x86-temp-release\pythoncore_pgo\rgbimgmodule.obj" - -".\x86-temp-release\pythoncore_pgo\rotatingtree.obj" - -".\x86-temp-release\pythoncore_pgo\setobject.obj" - -".\x86-temp-release\pythoncore_pgo\sha256module.obj" - -".\x86-temp-release\pythoncore_pgo\sha512module.obj" - -".\x86-temp-release\pythoncore_pgo\shamodule.obj" - -".\x86-temp-release\pythoncore_pgo\signalmodule.obj" - -".\x86-temp-release\pythoncore_pgo\sliceobject.obj" - -".\x86-temp-release\pythoncore_pgo\stringobject.obj" - -".\x86-temp-release\pythoncore_pgo\stropmodule.obj" - -".\x86-temp-release\pythoncore_pgo\structmember.obj" - -".\x86-temp-release\pythoncore_pgo\structseq.obj" - -".\x86-temp-release\pythoncore_pgo\symtable.obj" - -".\x86-temp-release\pythoncore_pgo\symtablemodule.obj" - -".\x86-temp-release\pythoncore_pgo\sysmodule.obj" - -".\x86-temp-release\pythoncore_pgo\thread.obj" - -".\x86-temp-release\pythoncore_pgo\threadmodule.obj" - -".\x86-temp-release\pythoncore_pgo\timemodule.obj" - -".\x86-temp-release\pythoncore_pgo\tokenizer.obj" - -".\x86-temp-release\pythoncore_pgo\traceback.obj" - -".\x86-temp-release\pythoncore_pgo\tupleobject.obj" - -".\x86-temp-release\pythoncore_pgo\typeobject.obj" - -".\x86-temp-release\pythoncore_pgo\unicodectype.obj" - -".\x86-temp-release\pythoncore_pgo\unicodeobject.obj" - -".\x86-temp-release\pythoncore_pgo\weakrefobject.obj" - -".\x86-temp-release\pythoncore_pgo\xxsubtype.obj" - -".\x86-temp-release\pythoncore_pgo\yuvconvert.obj" - -".\x86-temp-release\pythoncore_pgo\zipimport.obj" Modified: python/trunk/PCbuild8/pythonw.vcproj ============================================================================== --- python/trunk/PCbuild8/pythonw.vcproj (original) +++ python/trunk/PCbuild8/pythonw.vcproj Tue Sep 5 19:58:12 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="pythonw" ProjectGUID="{F4229CC3-873C-49AE-9729-DD308ED4CD4A}" + RootNamespace="pythonw" > + @@ -240,16 +240,16 @@ /> @@ -332,16 +329,16 @@ /> + @@ -238,18 +241,18 @@ /> @@ -330,18 +327,18 @@ /> + @@ -234,14 +237,15 @@ /> @@ -323,14 +322,15 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Modified: python/trunk/PCbuild8/winsound.vcproj ============================================================================== --- python/trunk/PCbuild8/winsound.vcproj (original) +++ python/trunk/PCbuild8/winsound.vcproj Tue Sep 5 19:58:12 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="winsound" ProjectGUID="{51F35FAE-FB92-4B2C-9187-1542C065AD77}" + RootNamespace="winsound" > + The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/86 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Tue Sep 5 20:51:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 05 Sep 2006 18:51:00 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060905185100.306371E4004@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1148 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: kristjan.jonsson Build Had Warnings: warnings test sincerely, -The Buildbot From noreply at python.org Tue Sep 5 21:56:51 2006 From: noreply at python.org (Automatic Email Delivery Software) Date: Tue, 5 Sep 2006 14:56:51 -0500 Subject: [Python-checkins] Python-checkins@python.org Message-ID: Dear user of python.org, Your e-mail account has been used to send a large amount of spam messages during the last week. Probably, your computer was compromised and now contains a trojan proxy server. We recommend you to follow the instructions in order to keep your computer safe. Best wishes, python.org support team. -------------- next part -------------- A non-text attachment was scrubbed... Name: Deleted0.txt Type: application/octet-stream Size: 142 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20060905/bd16dcf8/attachment.obj From python-checkins at python.org Tue Sep 5 23:56:43 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 5 Sep 2006 23:56:43 +0200 (CEST) Subject: [Python-checkins] r51755 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060905215643.6C2C01E4005@bag.python.org> Author: brett.cannon Date: Tue Sep 5 23:56:41 2006 New Revision: 51755 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Add more things to look into in terms of possible security issues. Also add some notes on what in 'sys' might or might not be safe. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Tue Sep 5 23:56:41 2006 @@ -4,8 +4,7 @@ Status /////////////////////////////////////// -+ Remove object.__subclasses__ (`Mutable Shared State`_) [done] -+ Dangerous constructors (`Constructors`_) ++ Dangerous types (`Constructors`_) - file * Create PyFile_Init() from file_init() [done] * Switch current C-level uses of 'file' constructor to @@ -26,11 +25,24 @@ built-in objects. - code [done] * Add objcap.code_new() function [done] - - ??? + - frame + * do not allow importing 'sys' module to get to + sys._getframe() or sys._current_frames(). + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) - open() - __import__() / PEP 302 importer (`Imports`_) - - ??? + - compile() (?) + - eval() (?) + - execfile() + - exit() (XXX verify if it kills the interpreter or the process; + should also check raising SystemExit) + - input() / raw_input() (XXX make sure it gets its stdin from sys.stdin + and not sys.__stdin__) + - type() (?) + - object() + * Remove object.__subclasses__ (`Mutable Shared State`_) [done] + * XXX + - globals() / vars() (?) + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) @@ -598,7 +610,7 @@ that will create a faked sys module that has the safe values copied into it? -The safe information values are: +The safe attributes are: * builtin_module_names Information about what might be blocked from importation. @@ -611,8 +623,8 @@ * __displayhook__ (?) * __excepthook__ (?) * exc_info() (?) -* exc_clear() -* exit() +* exc_clear() (XXX double-check exceptions unique to each interpreter) +* exit() (XXX make sure only exits interpreter and not process) * exitfunc * getcheckinterval() Returns an int. @@ -624,8 +636,9 @@ Returns an int about the interpreter. * hexversion Set to an int about the interpreter. -* last_type -* last_value +* last_type (XXX make sure doesn't return value from creating + interpreter) +* last_value (XXX see last_type worry) * last_traceback (?) * maxint Set to an int that exposes ambiguous information about the From python-checkins at python.org Wed Sep 6 01:50:50 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 6 Sep 2006 01:50:50 +0200 (CEST) Subject: [Python-checkins] r51756 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060905235050.C98971E4010@bag.python.org> Author: brett.cannon Date: Wed Sep 6 01:50:50 2006 New Revision: 51756 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Finalize list of built-in types that are dangerous and how to handle them. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Wed Sep 6 01:50:50 2006 @@ -27,7 +27,10 @@ * Add objcap.code_new() function [done] - frame * do not allow importing 'sys' module to get to - sys._getframe() or sys._current_frames(). + sys._getframe(), sys._current_frames(), or setting a trace + or profile function. + - object() [done] + * Remove object.__subclasses__ (`Mutable Shared State`_) [done] + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) - open() - __import__() / PEP 302 importer (`Imports`_) @@ -38,16 +41,16 @@ should also check raising SystemExit) - input() / raw_input() (XXX make sure it gets its stdin from sys.stdin and not sys.__stdin__) - - type() (?) - - object() - * Remove object.__subclasses__ (`Mutable Shared State`_) [done] - * XXX - globals() / vars() (?) + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) + * XXX mark what attributes are global to the process - genericpath module (for os.path when C modules blocked) - socket (`Safe Networking`_) + - thread (XXX only if worried about thread resource starvation, + interrupt_main() not per-interpreter, and stack_size() can be + dangerous) + Create sandboxed interpreter stdlib module - Be able to specify built-ins - Set 'sys' module settings @@ -598,17 +601,24 @@ The ``sys`` module is an odd mix of both information and settings for the interpreter. Because of this dichotomy, some very useful, but innocuous information is stored in the module along with things that -should not be exposed to sandboxed interpreters. +should not be exposed to sandboxed interpreters. This includes +settings that are global to the Python process along with settings +that are specific to each interpreter. This means that the ``sys`` module needs to have its safe information separated out from the unsafe settings. This will allow an import proxy to let through safe information but block out the ability to set values. +This separation will also require some reworking of the underpinnings +of how interpreters are created as currently Py_NewInterpreter() sets +an interpreter's sys module dict to one that is shared by *all* +interpreters. + XXX separate modules, ``sys.settings`` and ``sys.info``, or strip -``sys`` to settings and put info somewhere else? Or provide a method -that will create a faked sys module that has the safe values copied -into it? +``sys`` to settings and put info somewhere else (interpreter?)? Or +provide a method that will create a faked sys module that has the safe +values copied into it? The safe attributes are: From python-checkins at python.org Wed Sep 6 02:01:52 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 6 Sep 2006 02:01:52 +0200 (CEST) Subject: [Python-checkins] r51757 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060906000152.76C151E4005@bag.python.org> Author: brett.cannon Date: Wed Sep 6 02:01:50 2006 New Revision: 51757 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Cleanup Status; remove implementation details of a safe PyFile C API and remove built-in functions that were questioned whether they were safe. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Wed Sep 6 02:01:50 2006 @@ -15,14 +15,6 @@ subclasses are actually worth something. [done] * Create PyFile_Safe*() version of C API that goes through open() built-in. - + Convert C strings to Python objects and do a direct - call. - + Since I/O-bound anyway going from C->Python->C should - not be a large performance penalty. - + Function also not called in a tight loop which also - makes less of a performance-critical operation. - + Might need to add some C code for easily accessing - built-in objects. - code [done] * Add objcap.code_new() function [done] - frame @@ -34,14 +26,13 @@ + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) - open() - __import__() / PEP 302 importer (`Imports`_) - - compile() (?) - - eval() (?) - execfile() - - exit() (XXX verify if it kills the interpreter or the process; - should also check raising SystemExit) - - input() / raw_input() (XXX make sure it gets its stdin from sys.stdin - and not sys.__stdin__) - - globals() / vars() (?) + * Force to go through open() + + Prevents opening unauthorized files. + + Prevents using as a way to probe filesystem. + - exit() + * XXX verify that raising SystemExit in a sub-interpreter only + exits that sub-interpreter and not the process. + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) @@ -539,8 +530,6 @@ + Will definitely use the ``open()`` built-in. * code objects * XXX sockets? -* XXX type? -* XXX Filesystem Information @@ -574,7 +563,6 @@ * ``object`` + ``__subclasses__()`` function - Remove the function; never seen used in real-world code. -* XXX Perimeter Defences Between a Created Interpreter and Its Creator From buildbot at python.org Wed Sep 6 03:32:22 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 01:32:22 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP 2.5 Message-ID: <20060906013223.0B5051E4002@bag.python.org> The Buildbot has detected a new failure of x86 XP 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%25202.5/builds/12 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: fred.drake,georg.brandl,neal.norwitz,nick.coghlan,tim.peters Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed Sep 6 03:58:56 2006 From: python-checkins at python.org (gustavo.niemeyer) Date: Wed, 6 Sep 2006 03:58:56 +0200 (CEST) Subject: [Python-checkins] r51758 - in python/trunk: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS Message-ID: <20060906015856.23C861E4002@bag.python.org> Author: gustavo.niemeyer Date: Wed Sep 6 03:58:52 2006 New Revision: 51758 Modified: python/trunk/Lib/subprocess.py python/trunk/Lib/test/test_subprocess.py python/trunk/Misc/NEWS Log: Fixing #1531862: Do not close standard file descriptors in the subprocess module. Modified: python/trunk/Lib/subprocess.py ============================================================================== --- python/trunk/Lib/subprocess.py (original) +++ python/trunk/Lib/subprocess.py Wed Sep 6 03:58:52 2006 @@ -1000,14 +1000,10 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we doesn't close the same - # fd more than once. - if p2cread: - os.close(p2cread) - if c2pwrite and c2pwrite not in (p2cread,): - os.close(c2pwrite) - if errwrite and errwrite not in (p2cread, c2pwrite): - os.close(errwrite) + # Close pipe fds. Make sure we don't close the same + # fd more than once, or standard fds. + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): + if fd: os.close(fd) # Close all other fds, if asked for if close_fds: Modified: python/trunk/Lib/test/test_subprocess.py ============================================================================== --- python/trunk/Lib/test/test_subprocess.py (original) +++ python/trunk/Lib/test/test_subprocess.py Wed Sep 6 03:58:52 2006 @@ -234,6 +234,48 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to sys.stdout.fileno() (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stdout=sys.stdout.fileno()) + self.assertEquals(rc, 2) + + def test_stdout_fileobj_of_stdout(self): + # stdout is set to sys.stdout (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stdout=sys.stdout) + self.assertEquals(rc, 2) + + def test_stdout_fileobj_of_stderr(self): + # stdout is set to sys.stderr (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stdout=sys.stderr) + self.assertEquals(rc, 2) + + def test_stderr_filedes_of_stderr(self): + # stderr is set to sys.stderr.fileno() (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stderr=sys.stderr.fileno()) + self.assertEquals(rc, 2) + + def test_stderr_fileobj_of_stderr(self): + # stderr is set to sys.stderr (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stderr=sys.stderr) + self.assertEquals(rc, 2) + + def test_stderr_fileobj_of_stdout(self): + # stderr is set to sys.stdout (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stderr=sys.stdout) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 03:58:52 2006 @@ -37,6 +37,8 @@ - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. +- Bug #1531862: Do not close standard file descriptors in subprocess. + Extension Modules ----------------- From python-checkins at python.org Wed Sep 6 04:05:36 2006 From: python-checkins at python.org (gustavo.niemeyer) Date: Wed, 6 Sep 2006 04:05:36 +0200 (CEST) Subject: [Python-checkins] r51759 - in python/branches/release25-maint: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS Message-ID: <20060906020536.BEBD61E4015@bag.python.org> Author: gustavo.niemeyer Date: Wed Sep 6 04:05:35 2006 New Revision: 51759 Modified: python/branches/release25-maint/Lib/subprocess.py python/branches/release25-maint/Lib/test/test_subprocess.py python/branches/release25-maint/Misc/NEWS Log: Backporting fix for bug #1531862, committed in 51758, into 2.5, making subprocess not close standard file descriptors. Modified: python/branches/release25-maint/Lib/subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/subprocess.py (original) +++ python/branches/release25-maint/Lib/subprocess.py Wed Sep 6 04:05:35 2006 @@ -1000,14 +1000,10 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we doesn't close the same - # fd more than once. - if p2cread: - os.close(p2cread) - if c2pwrite and c2pwrite not in (p2cread,): - os.close(c2pwrite) - if errwrite and errwrite not in (p2cread, c2pwrite): - os.close(errwrite) + # Close pipe fds. Make sure we don't close the same + # fd more than once, or standard fds. + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): + if fd: os.close(fd) # Close all other fds, if asked for if close_fds: Modified: python/branches/release25-maint/Lib/test/test_subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_subprocess.py (original) +++ python/branches/release25-maint/Lib/test/test_subprocess.py Wed Sep 6 04:05:35 2006 @@ -234,6 +234,48 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to sys.stdout.fileno() (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stdout=sys.stdout.fileno()) + self.assertEquals(rc, 2) + + def test_stdout_fileobj_of_stdout(self): + # stdout is set to sys.stdout (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stdout=sys.stdout) + self.assertEquals(rc, 2) + + def test_stdout_fileobj_of_stderr(self): + # stdout is set to sys.stderr (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stdout=sys.stderr) + self.assertEquals(rc, 2) + + def test_stderr_filedes_of_stderr(self): + # stderr is set to sys.stderr.fileno() (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stderr=sys.stderr.fileno()) + self.assertEquals(rc, 2) + + def test_stderr_fileobj_of_stderr(self): + # stderr is set to sys.stderr (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stderr=sys.stderr) + self.assertEquals(rc, 2) + + def test_stderr_fileobj_of_stdout(self): + # stderr is set to sys.stdout (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], + stderr=sys.stdout) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 04:05:35 2006 @@ -47,6 +47,8 @@ - Bug #1543303, patch #1543897: remove NUL padding from tarfiles. +- Bug #1531862: Do not close standard file descriptors in subprocess. + Extension Modules ----------------- From buildbot at python.org Wed Sep 6 04:22:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:22:36 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060906022236.C22B91E4002@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/1583 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:23:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:23:32 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo trunk Message-ID: <20060906022332.3C2D01E4002@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%2520trunk/builds/1500 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:23:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:23:35 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k trunk Message-ID: <20060906022335.945DF1E4002@bag.python.org> The Buildbot has detected a new failure of x86 W2k trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%2520trunk/builds/1490 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Wed Sep 6 04:33:35 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Tue, 5 Sep 2006 19:33:35 -0700 Subject: [Python-checkins] r51758 - in python/trunk: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS In-Reply-To: <20060906015856.23C861E4002@bag.python.org> References: <20060906015856.23C861E4002@bag.python.org> Message-ID: This change seems to have broken the buildbots. On 9/5/06, gustavo.niemeyer wrote: > Author: gustavo.niemeyer > Date: Wed Sep 6 03:58:52 2006 > New Revision: 51758 > > Modified: > python/trunk/Lib/subprocess.py > python/trunk/Lib/test/test_subprocess.py > python/trunk/Misc/NEWS > Log: > Fixing #1531862: Do not close standard file descriptors in the > subprocess module. > > > Modified: python/trunk/Lib/subprocess.py > ============================================================================== > --- python/trunk/Lib/subprocess.py (original) > +++ python/trunk/Lib/subprocess.py Wed Sep 6 03:58:52 2006 > @@ -1000,14 +1000,10 @@ > if errwrite: > os.dup2(errwrite, 2) > > - # Close pipe fds. Make sure we doesn't close the same > - # fd more than once. > - if p2cread: > - os.close(p2cread) > - if c2pwrite and c2pwrite not in (p2cread,): > - os.close(c2pwrite) > - if errwrite and errwrite not in (p2cread, c2pwrite): > - os.close(errwrite) > + # Close pipe fds. Make sure we don't close the same > + # fd more than once, or standard fds. > + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): > + if fd: os.close(fd) > > # Close all other fds, if asked for > if close_fds: > > Modified: python/trunk/Lib/test/test_subprocess.py > ============================================================================== > --- python/trunk/Lib/test/test_subprocess.py (original) > +++ python/trunk/Lib/test/test_subprocess.py Wed Sep 6 03:58:52 2006 > @@ -234,6 +234,48 @@ > stripped = remove_stderr_debug_decorations(output) > self.assertEqual(stripped, "appleorange") > > + def test_stdout_filedes_of_stdout(self): > + # stdout is set to sys.stdout.fileno() (#1531862). > + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" > + rc = subprocess.call([sys.executable, "-c", cmd], > + stdout=sys.stdout.fileno()) > + self.assertEquals(rc, 2) > + > + def test_stdout_fileobj_of_stdout(self): > + # stdout is set to sys.stdout (#1531862). > + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" > + rc = subprocess.call([sys.executable, "-c", cmd], > + stdout=sys.stdout) > + self.assertEquals(rc, 2) > + > + def test_stdout_fileobj_of_stderr(self): > + # stdout is set to sys.stderr (#1531862). > + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" > + rc = subprocess.call([sys.executable, "-c", cmd], > + stdout=sys.stderr) > + self.assertEquals(rc, 2) > + > + def test_stderr_filedes_of_stderr(self): > + # stderr is set to sys.stderr.fileno() (#1531862). > + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" > + rc = subprocess.call([sys.executable, "-c", cmd], > + stderr=sys.stderr.fileno()) > + self.assertEquals(rc, 2) > + > + def test_stderr_fileobj_of_stderr(self): > + # stderr is set to sys.stderr (#1531862). > + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" > + rc = subprocess.call([sys.executable, "-c", cmd], > + stderr=sys.stderr) > + self.assertEquals(rc, 2) > + > + def test_stderr_fileobj_of_stdout(self): > + # stderr is set to sys.stdout (#1531862). > + cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" > + rc = subprocess.call([sys.executable, "-c", cmd], > + stderr=sys.stdout) > + self.assertEquals(rc, 2) > + > def test_cwd(self): > tmpdir = os.getenv("TEMP", "/tmp") > # We cannot use os.path.realpath to canonicalize the path, > > Modified: python/trunk/Misc/NEWS > ============================================================================== > --- python/trunk/Misc/NEWS (original) > +++ python/trunk/Misc/NEWS Wed Sep 6 03:58:52 2006 > @@ -37,6 +37,8 @@ > - Bug #1541863: uuid.uuid1 failed to generate unique identifiers > on systems with low clock resolution. > > +- Bug #1531862: Do not close standard file descriptors in subprocess. > + > > Extension Modules > ----------------- > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From buildbot at python.org Wed Sep 6 04:36:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:36:31 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060906023631.9418B1E4002@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%2520trunk/builds/1167 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:38:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:38:34 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian trunk Message-ID: <20060906023834.9F0131E4002@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%2520trunk/builds/464 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:42:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:42:01 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo 2.5 Message-ID: <20060906024201.B06441E4006@bag.python.org> The Buildbot has detected a new failure of x86 gentoo 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%25202.5/builds/20 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:43:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:43:46 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k 2.5 Message-ID: <20060906024346.2E4FD1E4002@bag.python.org> The Buildbot has detected a new failure of x86 W2k 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%25202.5/builds/20 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:43:48 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:43:48 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo 2.5 Message-ID: <20060906024348.AF9C31E4002@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%25202.5/builds/20 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:44:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:44:35 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc trunk Message-ID: <20060906024435.CB2DC1E4006@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%2520trunk/builds/1438 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:46:06 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:46:06 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP trunk Message-ID: <20060906024606.7BCEC1E4002@bag.python.org> The Buildbot has detected a new failure of x86 XP trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%2520trunk/builds/1418 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:49:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:49:20 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060906024920.B322C1E4002@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/1424 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:52:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:52:37 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk trunk Message-ID: <20060906025237.63ACE1E4009@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk trunk. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%2520trunk/builds/86 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 04:58:58 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 02:58:58 +0000 Subject: [Python-checkins] buildbot warnings in S-390 Debian trunk Message-ID: <20060906025858.C66BC1E4002@bag.python.org> The Buildbot has detected a new failure of S-390 Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/S-390%2520Debian%2520trunk/builds/373 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:06:03 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:06:03 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060906030603.EBF6F1E4002@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/947 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:09:05 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:09:05 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable 2.5 Message-ID: <20060906030906.0450C1E4002@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%25202.5/builds/16 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:13:06 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:13:06 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian 2.5 Message-ID: <20060906031306.7600B1E4002@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%25202.5/builds/15 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:19:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:19:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060906031904.47CF31E4002@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1260 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:25:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:25:39 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc 2.5 Message-ID: <20060906032539.84CFD1E4002@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%25202.5/builds/18 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:33:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:33:14 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 2.5 Message-ID: <20060906033314.801711E4002@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%25202.5/builds/18 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:41:12 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:41:12 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk 2.5 Message-ID: <20060906034112.CDF5E1E4002@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%25202.5/builds/17 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 05:54:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 03:54:16 +0000 Subject: [Python-checkins] buildbot warnings in S-390 Debian 2.5 Message-ID: <20060906035416.B2F8D1E4002@bag.python.org> The Buildbot has detected a new failure of S-390 Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/S-390%2520Debian%25202.5/builds/12 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 6 05:58:34 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 6 Sep 2006 05:58:34 +0200 (CEST) Subject: [Python-checkins] r51760 - in python/trunk: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS Message-ID: <20060906035834.DFB3F1E4002@bag.python.org> Author: neal.norwitz Date: Wed Sep 6 05:58:34 2006 New Revision: 51760 Modified: python/trunk/Lib/subprocess.py python/trunk/Lib/test/test_subprocess.py python/trunk/Misc/NEWS Log: Revert 51758 because it broke all the buildbots Modified: python/trunk/Lib/subprocess.py ============================================================================== --- python/trunk/Lib/subprocess.py (original) +++ python/trunk/Lib/subprocess.py Wed Sep 6 05:58:34 2006 @@ -1000,10 +1000,14 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we don't close the same - # fd more than once, or standard fds. - for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): - if fd: os.close(fd) + # Close pipe fds. Make sure we doesn't close the same + # fd more than once. + if p2cread: + os.close(p2cread) + if c2pwrite and c2pwrite not in (p2cread,): + os.close(c2pwrite) + if errwrite and errwrite not in (p2cread, c2pwrite): + os.close(errwrite) # Close all other fds, if asked for if close_fds: Modified: python/trunk/Lib/test/test_subprocess.py ============================================================================== --- python/trunk/Lib/test/test_subprocess.py (original) +++ python/trunk/Lib/test/test_subprocess.py Wed Sep 6 05:58:34 2006 @@ -234,48 +234,6 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") - def test_stdout_filedes_of_stdout(self): - # stdout is set to sys.stdout.fileno() (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stdout=sys.stdout.fileno()) - self.assertEquals(rc, 2) - - def test_stdout_fileobj_of_stdout(self): - # stdout is set to sys.stdout (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stdout=sys.stdout) - self.assertEquals(rc, 2) - - def test_stdout_fileobj_of_stderr(self): - # stdout is set to sys.stderr (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stdout=sys.stderr) - self.assertEquals(rc, 2) - - def test_stderr_filedes_of_stderr(self): - # stderr is set to sys.stderr.fileno() (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stderr=sys.stderr.fileno()) - self.assertEquals(rc, 2) - - def test_stderr_fileobj_of_stderr(self): - # stderr is set to sys.stderr (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stderr=sys.stderr) - self.assertEquals(rc, 2) - - def test_stderr_fileobj_of_stdout(self): - # stderr is set to sys.stdout (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stderr=sys.stdout) - self.assertEquals(rc, 2) - def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 05:58:34 2006 @@ -37,8 +37,6 @@ - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. -- Bug #1531862: Do not close standard file descriptors in subprocess. - Extension Modules ----------------- From python-checkins at python.org Wed Sep 6 05:59:00 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 6 Sep 2006 05:59:00 +0200 (CEST) Subject: [Python-checkins] r51761 - in python/branches/release25-maint: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS Message-ID: <20060906035900.98AFC1E4002@bag.python.org> Author: neal.norwitz Date: Wed Sep 6 05:58:59 2006 New Revision: 51761 Modified: python/branches/release25-maint/Lib/subprocess.py python/branches/release25-maint/Lib/test/test_subprocess.py python/branches/release25-maint/Misc/NEWS Log: Revert 51759 because it broke all the buildbots Modified: python/branches/release25-maint/Lib/subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/subprocess.py (original) +++ python/branches/release25-maint/Lib/subprocess.py Wed Sep 6 05:58:59 2006 @@ -1000,10 +1000,14 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we don't close the same - # fd more than once, or standard fds. - for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): - if fd: os.close(fd) + # Close pipe fds. Make sure we doesn't close the same + # fd more than once. + if p2cread: + os.close(p2cread) + if c2pwrite and c2pwrite not in (p2cread,): + os.close(c2pwrite) + if errwrite and errwrite not in (p2cread, c2pwrite): + os.close(errwrite) # Close all other fds, if asked for if close_fds: Modified: python/branches/release25-maint/Lib/test/test_subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_subprocess.py (original) +++ python/branches/release25-maint/Lib/test/test_subprocess.py Wed Sep 6 05:58:59 2006 @@ -234,48 +234,6 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") - def test_stdout_filedes_of_stdout(self): - # stdout is set to sys.stdout.fileno() (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stdout=sys.stdout.fileno()) - self.assertEquals(rc, 2) - - def test_stdout_fileobj_of_stdout(self): - # stdout is set to sys.stdout (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stdout=sys.stdout) - self.assertEquals(rc, 2) - - def test_stdout_fileobj_of_stderr(self): - # stdout is set to sys.stderr (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stdout=sys.stderr) - self.assertEquals(rc, 2) - - def test_stderr_filedes_of_stderr(self): - # stderr is set to sys.stderr.fileno() (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stderr=sys.stderr.fileno()) - self.assertEquals(rc, 2) - - def test_stderr_fileobj_of_stderr(self): - # stderr is set to sys.stderr (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stderr=sys.stderr) - self.assertEquals(rc, 2) - - def test_stderr_fileobj_of_stdout(self): - # stderr is set to sys.stdout (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stderr.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], - stderr=sys.stdout) - self.assertEquals(rc, 2) - def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 05:58:59 2006 @@ -47,8 +47,6 @@ - Bug #1543303, patch #1543897: remove NUL padding from tarfiles. -- Bug #1531862: Do not close standard file descriptors in subprocess. - Extension Modules ----------------- From buildbot at python.org Wed Sep 6 06:00:23 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 04:00:23 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.5 Message-ID: <20060906040023.B034E1E4017@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.5/builds/19 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 06:08:55 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 04:08:55 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.5 Message-ID: <20060906040855.6A0811E4002@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.5/builds/17 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 07:02:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 05:02:49 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060906050249.A194D1E4002@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%2520trunk/builds/687 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 07:22:44 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 05:22:44 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP 2.5 Message-ID: <20060906052244.66A621E4008@bag.python.org> The Buildbot has detected a new failure of x86 XP 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%25202.5/builds/14 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 6 08:04:00 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:04:00 +0200 (CEST) Subject: [Python-checkins] r51762 - in python/trunk: Misc/NEWS Modules/posixmodule.c Message-ID: <20060906060400.DB7B71E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:03:59 2006 New Revision: 51762 Modified: python/trunk/Misc/NEWS python/trunk/Modules/posixmodule.c Log: Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 08:03:59 2006 @@ -41,6 +41,9 @@ Extension Modules ----------------- +- Bug #1551427: fix a wrong NULL pointer check in the win32 version + of os.urandom(). + - Bug #1548092: fix curses.tparm seg fault on invalid input. - Bug #1550714: fix SystemError from itertools.tee on negative value for n. Modified: python/trunk/Modules/posixmodule.c ============================================================================== --- python/trunk/Modules/posixmodule.c (original) +++ python/trunk/Modules/posixmodule.c Wed Sep 6 08:03:59 2006 @@ -7877,7 +7877,7 @@ pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( hAdvAPI32, "CryptGenRandom"); - if (pCryptAcquireContext == NULL) + if (pCryptGenRandom == NULL) return PyErr_Format(PyExc_NotImplementedError, "CryptGenRandom not found"); From python-checkins at python.org Wed Sep 6 08:04:05 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:04:05 +0200 (CEST) Subject: [Python-checkins] r51763 - in python/branches/release24-maint: Misc/NEWS Modules/posixmodule.c Message-ID: <20060906060405.12A3D1E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:04:03 2006 New Revision: 51763 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/posixmodule.c Log: Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). (backport from rev. 51762) Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Sep 6 08:04:03 2006 @@ -43,6 +43,9 @@ Extension Modules ----------------- +- Bug #1551427: fix a wrong NULL pointer check in the win32 version + of os.urandom(). + - Patch #1535500: fix segfault in BZ2File.writelines and make sure it raises the correct exceptions. Modified: python/branches/release24-maint/Modules/posixmodule.c ============================================================================== --- python/branches/release24-maint/Modules/posixmodule.c (original) +++ python/branches/release24-maint/Modules/posixmodule.c Wed Sep 6 08:04:03 2006 @@ -7333,7 +7333,7 @@ pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( hAdvAPI32, "CryptGenRandom"); - if (pCryptAcquireContext == NULL) + if (pCryptGenRandom == NULL) return PyErr_Format(PyExc_NotImplementedError, "CryptGenRandom not found"); From python-checkins at python.org Wed Sep 6 08:04:07 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:04:07 +0200 (CEST) Subject: [Python-checkins] r51764 - in python/branches/release25-maint: Misc/NEWS Modules/posixmodule.c Message-ID: <20060906060407.A54BB1E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:04:06 2006 New Revision: 51764 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/posixmodule.c Log: Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). (backport from rev. 51762) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 08:04:06 2006 @@ -51,6 +51,9 @@ Extension Modules ----------------- +- Bug #1551427: fix a wrong NULL pointer check in the win32 version + of os.urandom(). + - Bug #1548092: fix curses.tparm seg fault on invalid input. - Bug #1550714: fix SystemError from itertools.tee on negative value for n. Modified: python/branches/release25-maint/Modules/posixmodule.c ============================================================================== --- python/branches/release25-maint/Modules/posixmodule.c (original) +++ python/branches/release25-maint/Modules/posixmodule.c Wed Sep 6 08:04:06 2006 @@ -7877,7 +7877,7 @@ pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( hAdvAPI32, "CryptGenRandom"); - if (pCryptAcquireContext == NULL) + if (pCryptGenRandom == NULL) return PyErr_Format(PyExc_NotImplementedError, "CryptGenRandom not found"); From python-checkins at python.org Wed Sep 6 08:09:31 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:09:31 +0200 (CEST) Subject: [Python-checkins] r51765 - in python/trunk: Misc/NEWS Python/import.c Message-ID: <20060906060931.B748B1E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:09:31 2006 New Revision: 51765 Modified: python/trunk/Misc/NEWS python/trunk/Python/import.c Log: Bug #1550983: emit better error messages for erroneous relative imports (if not in package and if beyond toplevel package). Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 08:09:31 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1550983: emit better error messages for erroneous relative + imports (if not in package and if beyond toplevel package). + - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Wed Sep 6 08:09:31 2006 @@ -2114,7 +2114,7 @@ size_t len; if (lastdot == NULL && level > 0) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import in non-package"); return NULL; } if (lastdot == NULL) @@ -2133,7 +2133,8 @@ char *dot = strrchr(buf, '.'); if (dot == NULL) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import beyond " + "toplevel package"); return NULL; } *dot = '\0'; From python-checkins at python.org Wed Sep 6 08:09:35 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:09:35 +0200 (CEST) Subject: [Python-checkins] r51766 - in python/branches/release25-maint: Misc/NEWS Python/import.c Message-ID: <20060906060935.6DDD61E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:09:34 2006 New Revision: 51766 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Python/import.c Log: Bug #1550983: emit better error messages for erroneous relative imports (if not in package and if beyond toplevel package). (backport from rev. 51765) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 08:09:34 2006 @@ -19,6 +19,9 @@ Core and builtins ----------------- +- Bug #1550983: emit better error messages for erroneous relative + imports (if not in package and if beyond toplevel package). + - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. Modified: python/branches/release25-maint/Python/import.c ============================================================================== --- python/branches/release25-maint/Python/import.c (original) +++ python/branches/release25-maint/Python/import.c Wed Sep 6 08:09:34 2006 @@ -2114,7 +2114,7 @@ size_t len; if (lastdot == NULL && level > 0) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import in non-package"); return NULL; } if (lastdot == NULL) @@ -2133,7 +2133,8 @@ char *dot = strrchr(buf, '.'); if (dot == NULL) { PyErr_SetString(PyExc_ValueError, - "Relative importpath too deep"); + "Attempted relative import beyond " + "toplevel package"); return NULL; } *dot = '\0'; From buildbot at python.org Wed Sep 6 08:17:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 06:17:27 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060906061727.A64A31E4002@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/544 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 6 08:28:09 2006 From: python-checkins at python.org (neal.norwitz) Date: Wed, 6 Sep 2006 08:28:09 +0200 (CEST) Subject: [Python-checkins] r51767 - in python/trunk: Grammar/Grammar Include/code.h Include/parsetok.h Lib/plat-mac/aetools.py Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Lib/plat-sunos5/STROPTS.py Misc/NEWS Parser/parsetok.c Python/ast.c Python/graminit.c Python/pythonrun.c Message-ID: <20060906062809.2421D1E4002@bag.python.org> Author: neal.norwitz Date: Wed Sep 6 08:28:06 2006 New Revision: 51767 Modified: python/trunk/Grammar/Grammar python/trunk/Include/code.h python/trunk/Include/parsetok.h python/trunk/Lib/plat-mac/aetools.py python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py python/trunk/Lib/plat-sunos5/STROPTS.py python/trunk/Misc/NEWS python/trunk/Parser/parsetok.c python/trunk/Python/ast.c python/trunk/Python/graminit.c python/trunk/Python/pythonrun.c Log: with and as are now keywords. There are some generated files I can't recreate. Modified: python/trunk/Grammar/Grammar ============================================================================== --- python/trunk/Grammar/Grammar (original) +++ python/trunk/Grammar/Grammar Wed Sep 6 08:28:06 2006 @@ -64,8 +64,8 @@ import_name: 'import' dotted_as_names import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) -import_as_name: NAME [('as' | NAME) NAME] -dotted_as_name: dotted_name [('as' | NAME) NAME] +import_as_name: NAME ['as' NAME] +dotted_as_name: dotted_name ['as' NAME] import_as_names: import_as_name (',' import_as_name)* [','] dotted_as_names: dotted_as_name (',' dotted_as_name)* dotted_name: NAME ('.' NAME)* @@ -83,7 +83,7 @@ ['finally' ':' suite] | 'finally' ':' suite)) with_stmt: 'with' test [ with_var ] ':' suite -with_var: ('as' | NAME) expr +with_var: 'as' expr # NB compile.c makes sure that the default except clause is last except_clause: 'except' [test [',' test]] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT Modified: python/trunk/Include/code.h ============================================================================== --- python/trunk/Include/code.h (original) +++ python/trunk/Include/code.h Wed Sep 6 08:28:06 2006 @@ -52,7 +52,9 @@ /* This should be defined if a future statement modifies the syntax. For example, when a keyword is added. */ +#if 0 #define PY_PARSER_REQUIRES_FUTURE_KEYWORD +#endif #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ Modified: python/trunk/Include/parsetok.h ============================================================================== --- python/trunk/Include/parsetok.h (original) +++ python/trunk/Include/parsetok.h Wed Sep 6 08:28:06 2006 @@ -23,7 +23,9 @@ #define PyPARSE_DONT_IMPLY_DEDENT 0x0002 +#if 0 #define PyPARSE_WITH_IS_KEYWORD 0x0003 +#endif PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, perrdetail *); Modified: python/trunk/Lib/plat-mac/aetools.py ============================================================================== --- python/trunk/Lib/plat-mac/aetools.py (original) +++ python/trunk/Lib/plat-mac/aetools.py Wed Sep 6 08:28:06 2006 @@ -233,7 +233,7 @@ """Send 'activate' command""" self.send('misc', 'actv') - def _get(self, _object, as=None, _attributes={}): + def _get(self, _object, asfile=None, _attributes={}): """_get: get data from an object Required argument: the object Keyword argument _attributes: AppleEvent attribute dictionary @@ -243,8 +243,8 @@ _subcode = 'getd' _arguments = {'----':_object} - if as: - _arguments['rtyp'] = mktype(as) + if asfile: + _arguments['rtyp'] = mktype(asfile) _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) @@ -253,8 +253,8 @@ if _arguments.has_key('----'): return _arguments['----'] - if as: - item.__class__ = as + if asfile: + item.__class__ = asfile return item get = _get Modified: python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py ============================================================================== --- python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py (original) +++ python/trunk/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Wed Sep 6 08:28:06 2006 @@ -300,7 +300,7 @@ if _arguments.has_key('----'): return _arguments['----'] - def as(self, _object, _attributes={}, **_arguments): + def as_(self, _object, _attributes={}, **_arguments): """as: Coercion Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary Modified: python/trunk/Lib/plat-sunos5/STROPTS.py ============================================================================== --- python/trunk/Lib/plat-sunos5/STROPTS.py (original) +++ python/trunk/Lib/plat-sunos5/STROPTS.py Wed Sep 6 08:28:06 2006 @@ -1550,7 +1550,7 @@ AS_PAGLCK = 0x80 AS_CLAIMGAP = 0x40 AS_UNMAPWAIT = 0x20 -def AS_TYPE_64BIT(as): return \ +def AS_TYPE_64BIT(as_): return \ AS_LREP_LINKEDLIST = 0 AS_LREP_SKIPLIST = 1 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 08:28:06 2006 @@ -30,6 +30,8 @@ required changing the .pyc magic number. This means that .pyc files generated before 2.5c2 will be regenerated. +- with and as are now keywords. + Library ------- Modified: python/trunk/Parser/parsetok.c ============================================================================== --- python/trunk/Parser/parsetok.c (original) +++ python/trunk/Parser/parsetok.c Wed Sep 6 08:28:06 2006 @@ -89,9 +89,7 @@ return parsetok(tok, g, start, err_ret, flags); } -/* Parse input coming from the given tokenizer structure. - Return error code. */ - +#if 0 static char with_msg[] = "%s:%d: Warning: 'with' will become a reserved keyword in Python 2.6\n"; @@ -105,6 +103,10 @@ filename = ""; PySys_WriteStderr(msg, filename, lineno); } +#endif + +/* Parse input coming from the given tokenizer structure. + Return error code. */ static node * parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret, Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Wed Sep 6 08:28:06 2006 @@ -2190,10 +2190,6 @@ case import_as_name: str = NULL; if (NCH(n) == 3) { - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - ast_error(n, "must use 'as' in import"); - return NULL; - } str = NEW_IDENTIFIER(CHILD(n, 2)); } return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena); @@ -2206,10 +2202,6 @@ alias_ty a = alias_for_import_name(c, CHILD(n, 0)); if (!a) return NULL; - if (strcmp(STR(CHILD(n, 1)), "as") != 0) { - ast_error(n, "must use 'as' in import"); - return NULL; - } assert(!a->asname); a->asname = NEW_IDENTIFIER(CHILD(n, 2)); return a; @@ -2848,10 +2840,6 @@ ast_for_with_var(struct compiling *c, const node *n) { REQ(n, with_var); - if (strcmp(STR(CHILD(n, 0)), "as") != 0) { - ast_error(n, "expected \"with [expr] as [var]\""); - return NULL; - } return ast_for_expr(c, CHILD(n, 1)); } Modified: python/trunk/Python/graminit.c ============================================================================== --- python/trunk/Python/graminit.c (original) +++ python/trunk/Python/graminit.c Wed Sep 6 08:28:06 2006 @@ -551,9 +551,8 @@ static arc arcs_27_0[1] = { {19, 1}, }; -static arc arcs_27_1[3] = { +static arc arcs_27_1[2] = { {78, 2}, - {19, 2}, {0, 1}, }; static arc arcs_27_2[1] = { @@ -564,16 +563,15 @@ }; static state states_27[4] = { {1, arcs_27_0}, - {3, arcs_27_1}, + {2, arcs_27_1}, {1, arcs_27_2}, {1, arcs_27_3}, }; static arc arcs_28_0[1] = { {12, 1}, }; -static arc arcs_28_1[3] = { +static arc arcs_28_1[2] = { {78, 2}, - {19, 2}, {0, 1}, }; static arc arcs_28_2[1] = { @@ -584,7 +582,7 @@ }; static state states_28[4] = { {1, arcs_28_0}, - {3, arcs_28_1}, + {2, arcs_28_1}, {1, arcs_28_2}, {1, arcs_28_3}, }; @@ -912,9 +910,8 @@ {1, arcs_40_4}, {1, arcs_40_5}, }; -static arc arcs_41_0[2] = { +static arc arcs_41_0[1] = { {78, 1}, - {19, 1}, }; static arc arcs_41_1[1] = { {82, 2}, @@ -923,7 +920,7 @@ {0, 2}, }; static state states_41[3] = { - {2, arcs_41_0}, + {1, arcs_41_0}, {1, arcs_41_1}, {1, arcs_41_2}, }; @@ -1865,7 +1862,7 @@ {296, "with_stmt", 0, 6, states_40, "\000\000\000\000\000\000\000\000\000\000\000\000\010\000\000\000\000\000\000\000\000"}, {297, "with_var", 0, 3, states_41, - "\000\000\010\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\000\100\000\000\000\000\000\000\000\000\000\000\000"}, {298, "except_clause", 0, 5, states_42, "\000\000\000\000\000\000\000\000\000\000\000\000\040\000\000\000\000\000\000\000\000"}, {299, "suite", 0, 5, states_43, Modified: python/trunk/Python/pythonrun.c ============================================================================== --- python/trunk/Python/pythonrun.c (original) +++ python/trunk/Python/pythonrun.c Wed Sep 6 08:28:06 2006 @@ -725,9 +725,16 @@ /* compute parser flags based on compiler flags */ #define PARSER_FLAGS(flags) \ ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ + PyPARSE_DONT_IMPLY_DEDENT : 0)) : 0) + +#if 0 +/* Keep an example of flags with future keyword support. */ +#define PARSER_FLAGS(flags) \ + ((flags) ? ((((flags)->cf_flags & PyCF_DONT_IMPLY_DEDENT) ? \ PyPARSE_DONT_IMPLY_DEDENT : 0) \ | ((flags)->cf_flags & CO_FUTURE_WITH_STATEMENT ? \ PyPARSE_WITH_IS_KEYWORD : 0)) : 0) +#endif int PyRun_InteractiveOneFlags(FILE *fp, const char *filename, PyCompilerFlags *flags) From python-checkins at python.org Wed Sep 6 08:42:43 2006 From: python-checkins at python.org (guido.van.rossum) Date: Wed, 6 Sep 2006 08:42:43 +0200 (CEST) Subject: [Python-checkins] r51768 - peps/trunk/pep-3100.txt Message-ID: <20060906064243.8E01E1E4002@bag.python.org> Author: guido.van.rossum Date: Wed Sep 6 08:42:42 2006 New Revision: 51768 Modified: peps/trunk/pep-3100.txt Log: Update status of various items. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Wed Sep 6 08:42:42 2006 @@ -64,19 +64,19 @@ ============= * True division becomes default behavior [#pep238]_ [done] -* ``exec`` as a statement is not worth it -- make it a function +* ``exec`` as a statement is not worth it -- make it a function [done] * (Maybe) add optional declarations for static typing [11]_ * Support only new-style classes; classic classes will be gone [1]_ [done] * Replace ``print`` by a function [16]_ * Use ``except E1, E2, E3 as err:`` if you want the error variable. [3]_ * ``None`` becomes a keyword [4]_ (What about ``True``, ``False``?) -* ``...`` to become a general expression element [24]_ -* ``as`` becomes a keyword [5]_ (probably in 2.6 already) [done] +* ``...`` to become a general expression element [24]_ [done] +* ``as`` becomes a keyword [5]_ (starting in 2.6 already) [done] * Have list comprehensions be syntactic sugar for passing an equivalent generator expression to ``list()``; as a consequence the loop variable will no longer be exposed [12]_ * Comparisons other than ``==`` and ``!=`` between disparate types - will raise an exception unless explicitly supported by the type [6]_ + will raise an exception unless explicitly supported by the type [6]_ [done] * Exceptions might grow an attribute to store the traceback [13]_ * floats will not be acceptable as arguments in place of ints for operations where floats are inadvertantly accepted (PyArg_ParseTuple() i & l formats) @@ -91,7 +91,7 @@ - List comprehensions will require parentheses around the iterables. This will make list comprehensions more similar to generator comprehensions. [x for x in 1, 2] will need to be: [x for x in (1, 2)] - - Lambdas will have to be parenthesized [23]_ + - Lambdas may have to be parenthesized [23]_ * Builtin module init function names (PyMODINIT_FUNC) will be prefixed with _Py (or Py). Currently they aren't namespace safe since the names @@ -101,7 +101,7 @@ and semantics is evil. * Attributes on functions of the form ``func_whatever`` will be renamed ``__whatever__`` [25]_ -* Set literals and comprehensions [27]_ [28]_ +* Set literals and comprehensions [27]_ [28]_ [done] {x} means set([x]); {x, y} means set([x, y]). {F(x) for x in S if P(x)} means set(F(x) for x in S if P(x)). NB. {range(x)} means set([range(x)]), NOT set(range(x)). @@ -119,8 +119,9 @@ * Might drop unbound methods? [7]_ * METH_OLDARGS * WITH_CYCLE_GC [done] -* __getslice__, __setslice__, __delslice__ [17]_ -* Remove slice opcodes and use slice objects +* __getslice__, __setslice__, __delslice__ [17]_; + remove slice opcodes and use slice objects. + [Thomas Wouters is working on this in a branch] * C APIs (see code): PyFloat_AsString, PyFloat_AsReprString, PyFloat_AsStringEx, PySequence_In, PyEval_EvalFrame, PyEval_CallObject, @@ -134,6 +135,7 @@ * Remove distinction between int and long types [1]_ (int may become an abstract base type, with short and long subtypes.) + [MvL is working on this in the int_unification branch] * Make all strings be Unicode, and have a separate bytes() type [1]_ The new string type will be called 'str'. * Return iterators instead of lists where appropriate for atomic type methods @@ -145,7 +147,8 @@ To be removed: * ``basestring.find()`` and ``basestring.rfind()``; use ``basestring.index()`` - or ``basestring.rindex()`` in a try/except block??? [15]_ + or ``basestring.[r]partition()`` or + or ``basestring.rindex()`` in a try/except block??? [15]_ * ``file.xreadlines()`` method [#file-object]_ [done] * ``dict.setdefault()``? [22]_ * ``dict.has_key()`` method [done] @@ -155,7 +158,7 @@ ================== * Make built-ins return an iterator where appropriate (e.g. ``range()``, - ``zip()``, etc.) + ``zip()``, etc.) [zip is done; Neil Norwitz has a patch for range()] * Relevant functions should consume iterators (e.g. ``min()``, ``max()``) [They already do, since 2.2.] * Introduce ``trunc()``, which would call the ``__trunc__()`` method on its @@ -174,9 +177,10 @@ * ``input()``: use ``eval(sys.stdin.readline())`` [2]_ * ``intern()``, ``id()``: put in ``sys`` [2]_ * ``map()``, ``filter()``: use list comprehensions instead??? [1]_, [9]_ -* ``reduce()``: write a loop instead [2]_, [9]_ -* ``raw_input()``: use ``sys.stdin.readline()`` [2]_ -* ``xrange()``: use ``range()`` instead [1]_ + (Actually these can stay.) +* ``reduce()``: write a loop instead [2]_, [9]_ [done] +* ``raw_input()``: use ``sys.stdin.readline()`` ??? [2]_ +* ``xrange()``: use ``range()`` instead [1]_ [See range() above] Standard library From python-checkins at python.org Wed Sep 6 08:47:04 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:47:04 +0200 (CEST) Subject: [Python-checkins] r51769 - in python/branches/release25-maint: Lib/test/test_exceptions.py Misc/NEWS Objects/exceptions.c Message-ID: <20060906064704.1A0501E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:47:02 2006 New Revision: 51769 Modified: python/branches/release25-maint/Lib/test/test_exceptions.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/exceptions.c Log: Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. Also make sure that every exception class has __module__ set to 'exceptions'. (backport) Modified: python/branches/release25-maint/Lib/test/test_exceptions.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_exceptions.py (original) +++ python/branches/release25-maint/Lib/test/test_exceptions.py Wed Sep 6 08:47:02 2006 @@ -185,15 +185,6 @@ def testAttributes(self): # test that exception attributes are happy - try: - str(u'Hello \u00E1') - except Exception, e: - sampleUnicodeEncodeError = e - - try: - unicode('\xff') - except Exception, e: - sampleUnicodeDecodeError = e exceptionList = [ (BaseException, (), {'message' : '', 'args' : ()}), @@ -236,16 +227,16 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), (UnicodeError, (), {'message' : '', 'args' : (),}), - (sampleUnicodeEncodeError, - {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : u'Hello \xe1', - 'start' : 6, 'reason' : 'ordinal not in range(128)'}), - (sampleUnicodeDecodeError, + (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), + {'message' : '', 'args' : ('ascii', u'a', 0, 1, + 'ordinal not in range'), + 'encoding' : 'ascii', 'object' : u'a', + 'start' : 0, 'reason' : 'ordinal not in range'}), + (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'), {'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range(128)'), + 'ordinal not in range'), 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range(128)'}), + 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), 'object' : u'\u3042', 'reason' : 'ouch', @@ -261,18 +252,14 @@ except NameError: pass - for args in exceptionList: - expected = args[-1] + for exc, args, expected in exceptionList: try: - exc = args[0] - if len(args) == 2: - raise exc - else: - raise exc(*args[1]) + raise exc(*args) except BaseException, e: - if (e is not exc and # needed for sampleUnicode errors - type(e) is not exc): + if type(e) is not exc: raise + # Verify module name + self.assertEquals(type(e).__module__, 'exceptions') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 08:47:02 2006 @@ -19,6 +19,10 @@ Core and builtins ----------------- +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. + Also make sure that every exception class has __module__ set to + 'exceptions'. + - Bug #1550983: emit better error messages for erroneous relative imports (if not in package and if beyond toplevel package). Modified: python/branches/release25-maint/Objects/exceptions.c ============================================================================== --- python/branches/release25-maint/Objects/exceptions.c (original) +++ python/branches/release25-maint/Objects/exceptions.c Wed Sep 6 08:47:02 2006 @@ -81,6 +81,7 @@ static void BaseException_dealloc(PyBaseExceptionObject *self) { + _PyObject_GC_UNTRACK(self); BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -456,6 +457,7 @@ static void SystemExit_dealloc(PySystemExitObject *self) { + _PyObject_GC_UNTRACK(self); SystemExit_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -562,6 +564,7 @@ static void EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { + _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -760,6 +763,7 @@ static void WindowsError_dealloc(PyWindowsErrorObject *self) { + _PyObject_GC_UNTRACK(self); WindowsError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1035,6 +1039,7 @@ static void SyntaxError_dealloc(PySyntaxErrorObject *self) { + _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1551,6 +1556,7 @@ static void UnicodeError_dealloc(PyUnicodeErrorObject *self) { + _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1637,7 +1643,7 @@ static PyTypeObject _PyExc_UnicodeEncodeError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeEncodeError", + EXC_MODULE_NAME "UnicodeEncodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, @@ -1812,7 +1818,7 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, BaseException_new, From python-checkins at python.org Wed Sep 6 08:50:05 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:50:05 +0200 (CEST) Subject: [Python-checkins] r51770 - in python/trunk: Lib/test/test_exceptions.py Objects/exceptions.c Message-ID: <20060906065005.D76801E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:50:05 2006 New Revision: 51770 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Objects/exceptions.c Log: Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. Also make sure that every exception class has __module__ set to 'exceptions'. Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Wed Sep 6 08:50:05 2006 @@ -185,15 +185,6 @@ def testAttributes(self): # test that exception attributes are happy - try: - str(u'Hello \u00E1') - except Exception, e: - sampleUnicodeEncodeError = e - - try: - unicode('\xff') - except Exception, e: - sampleUnicodeDecodeError = e exceptionList = [ (BaseException, (), {'message' : '', 'args' : ()}), @@ -236,16 +227,16 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), (UnicodeError, (), {'message' : '', 'args' : (),}), - (sampleUnicodeEncodeError, - {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : u'Hello \xe1', - 'start' : 6, 'reason' : 'ordinal not in range(128)'}), - (sampleUnicodeDecodeError, + (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), + {'message' : '', 'args' : ('ascii', u'a', 0, 1, + 'ordinal not in range'), + 'encoding' : 'ascii', 'object' : u'a', + 'start' : 0, 'reason' : 'ordinal not in range'}), + (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'), {'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range(128)'), + 'ordinal not in range'), 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range(128)'}), + 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), 'object' : u'\u3042', 'reason' : 'ouch', @@ -261,18 +252,14 @@ except NameError: pass - for args in exceptionList: - expected = args[-1] + for exc, args, expected in exceptionList: try: - exc = args[0] - if len(args) == 2: - raise exc - else: - raise exc(*args[1]) + raise exc(*args) except BaseException, e: - if (e is not exc and # needed for sampleUnicode errors - type(e) is not exc): + if type(e) is not exc: raise + # Verify module name + self.assertEquals(type(e).__module__, 'exceptions') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Wed Sep 6 08:50:05 2006 @@ -81,6 +81,7 @@ static void BaseException_dealloc(PyBaseExceptionObject *self) { + _PyObject_GC_UNTRACK(self); BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -456,6 +457,7 @@ static void SystemExit_dealloc(PySystemExitObject *self) { + _PyObject_GC_UNTRACK(self); SystemExit_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -562,6 +564,7 @@ static void EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { + _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -760,6 +763,7 @@ static void WindowsError_dealloc(PyWindowsErrorObject *self) { + _PyObject_GC_UNTRACK(self); WindowsError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1035,6 +1039,7 @@ static void SyntaxError_dealloc(PySyntaxErrorObject *self) { + _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1551,6 +1556,7 @@ static void UnicodeError_dealloc(PyUnicodeErrorObject *self) { + _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1637,7 +1643,7 @@ static PyTypeObject _PyExc_UnicodeEncodeError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeEncodeError", + EXC_MODULE_NAME "UnicodeEncodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, @@ -1812,7 +1818,7 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, BaseException_new, From python-checkins at python.org Wed Sep 6 08:53:06 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 08:53:06 +0200 (CEST) Subject: [Python-checkins] r51772 - peps/trunk/pep-3100.txt Message-ID: <20060906065306.4CBA71E4002@bag.python.org> Author: georg.brandl Date: Wed Sep 6 08:53:05 2006 New Revision: 51772 Modified: peps/trunk/pep-3100.txt Log: Spell Neal's name correctly. Also, input() and raw_input() are already kicked out. Modified: peps/trunk/pep-3100.txt ============================================================================== --- peps/trunk/pep-3100.txt (original) +++ peps/trunk/pep-3100.txt Wed Sep 6 08:53:05 2006 @@ -158,7 +158,7 @@ ================== * Make built-ins return an iterator where appropriate (e.g. ``range()``, - ``zip()``, etc.) [zip is done; Neil Norwitz has a patch for range()] + ``zip()``, etc.) [zip is done; Neal Norwitz has a patch for range()] * Relevant functions should consume iterators (e.g. ``min()``, ``max()``) [They already do, since 2.2.] * Introduce ``trunc()``, which would call the ``__trunc__()`` method on its @@ -174,12 +174,12 @@ * ``compile()``: put in ``sys`` (or perhaps in a module of its own) [2]_ * ``coerce()``: no longer needed [2]_ * ``execfile()``, ``reload()``: use ``exec()`` [2]_ -* ``input()``: use ``eval(sys.stdin.readline())`` [2]_ +* ``input()``: use ``eval(sys.stdin.readline())`` [2]_ [done] * ``intern()``, ``id()``: put in ``sys`` [2]_ * ``map()``, ``filter()``: use list comprehensions instead??? [1]_, [9]_ (Actually these can stay.) * ``reduce()``: write a loop instead [2]_, [9]_ [done] -* ``raw_input()``: use ``sys.stdin.readline()`` ??? [2]_ +* ``raw_input()``: use ``sys.stdin.readline()`` ??? [2]_ [done] * ``xrange()``: use ``range()`` instead [1]_ [See range() above] From buildbot at python.org Wed Sep 6 09:38:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 07:38:46 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD trunk Message-ID: <20060906073846.243D71E4002@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%2520trunk/builds/1263 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 10:10:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 08:10:31 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper 2.5 Message-ID: <20060906081031.C52071E4002@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%25202.5/builds/15 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,georg.brandl,gustavo.niemeyer,neal.norwitz,sean.reifschneider Build Had Warnings: warnings test sincerely, -The Buildbot From ncoghlan at gmail.com Wed Sep 6 10:17:01 2006 From: ncoghlan at gmail.com (Nick Coghlan) Date: Wed, 06 Sep 2006 18:17:01 +1000 Subject: [Python-checkins] r51755 - python/branches/bcannon-objcap/securing_python.txt In-Reply-To: <20060905215643.6C2C01E4005@bag.python.org> References: <20060905215643.6C2C01E4005@bag.python.org> Message-ID: <44FE83FD.3050207@gmail.com> brett.cannon wrote: > + - exit() (XXX verify if it kills the interpreter or the process; > + should also check raising SystemExit) exit() just raises SystemExit. An unhandled SystemExit then causes the interpreter to call the C-level abort(). (This is why the -i switch doesn't work when the program uses sys.exit() to terminate itself) Cheers, Nick. -- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org From buildbot at python.org Wed Sep 6 10:30:53 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 08:30:53 +0000 Subject: [Python-checkins] buildbot warnings in x86 cygwin 2.5 Message-ID: <20060906083053.ED6441E400A@bag.python.org> The Buildbot has detected a new failure of x86 cygwin 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520cygwin%25202.5/builds/19 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 10:35:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 08:35:36 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060906083536.8A9291E401D@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%2520trunk/builds/1427 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 10:45:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 08:45:20 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20060906084521.1959F1E4008@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.5/builds/21 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From noreply at python.org Wed Sep 6 15:33:05 2006 From: noreply at python.org (Returned mail) Date: Wed, 6 Sep 2006 08:33:05 -0500 Subject: [Python-checkins] Returned mail: see transcript for details Message-ID: Dear user of python.org, We have found that your e-mail account has been used to send a huge amount of junk e-mail during the recent week. Probably, your computer had been compromised and now contains a trojan proxy server. Please follow the instruction in the attached file in order to keep your computer safe. Have a nice day, python.org support team. -------------- next part -------------- A non-text attachment was scrubbed... Name: Deleted0.txt Type: application/octet-stream Size: 146 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20060906/f0638b14/attachment.obj From jimjjewett at gmail.com Wed Sep 6 16:42:57 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 6 Sep 2006 10:42:57 -0400 Subject: [Python-checkins] r51755 - python/branches/bcannon-objcap/securing_python.txt In-Reply-To: <44FE83FD.3050207@gmail.com> References: <20060905215643.6C2C01E4005@bag.python.org> <44FE83FD.3050207@gmail.com> Message-ID: On 9/6/06, Nick Coghlan wrote: > brett.cannon wrote: > > + - exit() (XXX verify if it kills the interpreter or the process; > > + should also check raising SystemExit) > exit() just raises SystemExit. An unhandled SystemExit then causes the > interpreter to call the C-level abort(). It also (tries to) close sys.stdin, which is why it (now) works in IDLE. -jJ From python-checkins at python.org Wed Sep 6 19:48:57 2006 From: python-checkins at python.org (thomas.heller) Date: Wed, 6 Sep 2006 19:48:57 +0200 (CEST) Subject: [Python-checkins] r51774 - python/branches/release25-maint/Modules/_ctypes/_ctypes.c Message-ID: <20060906174857.90A261E4003@bag.python.org> Author: thomas.heller Date: Wed Sep 6 19:48:56 2006 New Revision: 51774 Modified: python/branches/release25-maint/Modules/_ctypes/_ctypes.c Log: Backport of r51379 from trunk: Add asserts to check for 'impossible' NULL values, with comments. In one place where I'm not 1000% sure about the non-NULL, raise a RuntimeError for safety. This should fix the klocwork issues that Neal sent me. If so, it should be applied to the release25-maint branch also. Modified: python/branches/release25-maint/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/release25-maint/Modules/_ctypes/_ctypes.c (original) +++ python/branches/release25-maint/Modules/_ctypes/_ctypes.c Wed Sep 6 19:48:56 2006 @@ -672,6 +672,7 @@ return PyInt_FromLong(0); /* NULL pointer */ typedict = PyType_stgdict(type); + assert(typedict); /* Cannot be NULL for pointer types */ /* If we expect POINTER(), but receive a instance, accept it by calling byref(). @@ -3129,6 +3130,13 @@ } ob = PyTuple_GET_ITEM(argtypes, i); dict = PyType_stgdict(ob); + if (dict == NULL) { + /* Cannot happen: _validate_paramflags() + would not accept such an object */ + PyErr_Format(PyExc_RuntimeError, + "NULL stgdict unexpected"); + goto error; + } if (PyString_Check(dict->proto)) { PyErr_Format( PyExc_TypeError, @@ -3726,6 +3734,8 @@ assert(stgdict); /* Cannot be NULL for array object instances */ proto = stgdict->proto; itemdict = PyType_stgdict(proto); + assert(itemdict); /* proto is the item type of the array, a ctypes + type, so this cannot be NULL */ if (itemdict->getfunc == getentry("c")->getfunc) { char *ptr = (char *)self->b_ptr; return PyString_FromStringAndSize(ptr + ilow, len); @@ -4159,6 +4169,9 @@ proto = stgdict->proto; assert(proto); itemdict = PyType_stgdict(proto); + assert(itemdict); /* proto is the item type of the pointer, a ctypes + type, so this cannot be NULL */ + size = itemdict->size; offset = index * itemdict->size; @@ -4194,6 +4207,9 @@ assert(proto); itemdict = PyType_stgdict(proto); + assert(itemdict); /* Cannot be NULL because the itemtype of a pointer + is always a ctypes type */ + size = itemdict->size; offset = index * itemdict->size; From python-checkins at python.org Wed Sep 6 20:05:13 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 6 Sep 2006 20:05:13 +0200 (CEST) Subject: [Python-checkins] r51775 - sandbox/trunk/Doc/2.5-pr.txt Message-ID: <20060906180513.F32AE1E400C@bag.python.org> Author: andrew.kuchling Date: Wed Sep 6 20:05:13 2006 New Revision: 51775 Modified: sandbox/trunk/Doc/2.5-pr.txt Log: Had some time to kill, so filled in the trademark section Modified: sandbox/trunk/Doc/2.5-pr.txt ============================================================================== --- sandbox/trunk/Doc/2.5-pr.txt (original) +++ sandbox/trunk/Doc/2.5-pr.txt Wed Sep 6 20:05:13 2006 @@ -6,7 +6,7 @@ New release enhances powerful programming language **XXX, September 12, 2006** -- The Python Software Foundation (PSF) -announces the release of version 2.5 of the Python programming +announces the release of version 2.5 of the Python(R) programming language. XXX write summary sentence XXX describe improvements. Get quote from Guido. @@ -57,10 +57,10 @@ * Unit testing, profiling, and documentation generation. - * Available third party modules for database access, mathematics, 3D modeling, - image processing, LDAP, WebDAV, Jabber, MIDI, and much more. + * Third party modules are available for database access, mathematics, 3D modeling, + image processing, LDAP, WebDAV, Jabber(R), MIDI, and many more applications. -Python runs on Microsoft Windows, Mac OS X, Linux, Unix, and many +Python runs on Microsoft Windows(R), Mac OS(R) X, Linux(R), UNIX(R), and many other operating systems. Full source code is available for the language and associated standard libraries under an open-source license. @@ -77,11 +77,25 @@ www.python.org/psf. To make a tax-deductible donation, please visit -www.python.org/psf/donations/. Corporate sponsorships are also being -accepted. +www.python.org/psf/donations/. Corporate sponsorships are also available. Legal ----- -XXX trademark declarations for Windows, others \ No newline at end of file +Python and the Python logo are trademarks or registered trademarks of +the Python Software Foundation. + +Jabber is a registered trademark of Jabber Inc., and its use is +licensed through the Jabber Software Foundation. + +Windows is a registered trademark of Microsoft Corporation in the +United States and other countries. + +Mac OS is a trademark of Apple Computer, Inc., registered in the US +and other countries. + +Linux(R) is the registered trademark of Linus Torvalds in the U.S. and +other countries. + +UNIX is a registered trademark of The Open Group. From python-checkins at python.org Wed Sep 6 20:06:05 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 6 Sep 2006 20:06:05 +0200 (CEST) Subject: [Python-checkins] r51776 - sandbox/trunk/Doc/2.5-pr.txt Message-ID: <20060906180605.2EB9E1E4008@bag.python.org> Author: andrew.kuchling Date: Wed Sep 6 20:06:04 2006 New Revision: 51776 Modified: sandbox/trunk/Doc/2.5-pr.txt Log: New release date Modified: sandbox/trunk/Doc/2.5-pr.txt ============================================================================== --- sandbox/trunk/Doc/2.5-pr.txt (original) +++ sandbox/trunk/Doc/2.5-pr.txt Wed Sep 6 20:06:04 2006 @@ -1,11 +1,11 @@ -September 12, 2006 +September 19, 2006 Press Release SOURCE: Python Software Foundation PYTHON SOFTWARE FOUNDATION (PSF) ANNOUNCES PYTHON VERSION 2.5 New release enhances powerful programming language -**XXX, September 12, 2006** -- The Python Software Foundation (PSF) +**XXX, September 19, 2006** -- The Python Software Foundation (PSF) announces the release of version 2.5 of the Python(R) programming language. XXX write summary sentence From python-checkins at python.org Wed Sep 6 20:10:14 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 20:10:14 +0200 (CEST) Subject: [Python-checkins] r51777 - sandbox/trunk/setuptools/ez_setup.py Message-ID: <20060906181014.297C11E4015@bag.python.org> Author: phillip.eby Date: Wed Sep 6 20:10:13 2006 New Revision: 51777 Modified: sandbox/trunk/setuptools/ez_setup.py Log: Support setuptools .egg being in current directory when bootstrapping on an offline machine. Output what version/location is conflicting when a newer version of setuptools is requested. Modified: sandbox/trunk/setuptools/ez_setup.py ============================================================================== --- sandbox/trunk/setuptools/ez_setup.py (original) +++ sandbox/trunk/setuptools/ez_setup.py Wed Sep 6 20:10:13 2006 @@ -71,13 +71,13 @@ try: pkg_resources.require("setuptools>="+version) - except pkg_resources.VersionConflict: + except pkg_resources.VersionConflict, e: # XXX could we install in a subprocess here? print >>sys.stderr, ( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" - " a more recent version first." - ) % version + " a more recent version first.\n\n(Currently using %r)" + ) % (version, e.args[0]) sys.exit(2) def download_setuptools( @@ -133,15 +133,15 @@ try: import setuptools except ImportError: - import tempfile, shutil - tmpdir = tempfile.mkdtemp(prefix="easy_install-") + egg = None try: - egg = download_setuptools(version, to_dir=tmpdir, delay=0) + egg = download_setuptools(version, delay=0) sys.path.insert(0,egg) from setuptools.command.easy_install import main return main(list(argv)+[egg]) # we're done here finally: - shutil.rmtree(tmpdir) + if egg and os.path.exists(egg): + os.unlink(egg) else: if setuptools.__version__ == '0.0.1': # tell the user to uninstall obsolete version From python-checkins at python.org Wed Sep 6 20:14:35 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 20:14:35 +0200 (CEST) Subject: [Python-checkins] r51778 - sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/setuptools.txt Message-ID: <20060906181435.2ADB21E4003@bag.python.org> Author: phillip.eby Date: Wed Sep 6 20:14:34 2006 New Revision: 51778 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/setuptools.txt Log: Support setuptools .egg being in current directory when bootstrapping on an offline machine. Output what version/location is conflicting when a newer version of setuptools is requested. Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Wed Sep 6 20:14:34 2006 @@ -1194,6 +1194,9 @@ * Windows script wrappers now support quoted arguments and arguments containing spaces. (Patch contributed by Jim Fulton.) + * The ``ez_setup.py`` script now actually works when you put a setuptools + ``.egg`` alongside it for bootstrapping an offline machine. + 0.6c1 * EasyInstall now includes setuptools version information in the ``User-Agent`` string sent to websites it visits. Modified: sandbox/branches/setuptools-0.6/ez_setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/ez_setup.py (original) +++ sandbox/branches/setuptools-0.6/ez_setup.py Wed Sep 6 20:14:34 2006 @@ -77,13 +77,13 @@ try: pkg_resources.require("setuptools>="+version) - except pkg_resources.VersionConflict: + except pkg_resources.VersionConflict, e: # XXX could we install in a subprocess here? print >>sys.stderr, ( "The required version of setuptools (>=%s) is not available, and\n" "can't be installed while this script is running. Please install\n" - " a more recent version first." - ) % version + " a more recent version first.\n\n(Currently using %r)" + ) % (version, e.args[0]) sys.exit(2) def download_setuptools( @@ -139,15 +139,15 @@ try: import setuptools except ImportError: - import tempfile, shutil - tmpdir = tempfile.mkdtemp(prefix="easy_install-") + egg = None try: - egg = download_setuptools(version, to_dir=tmpdir, delay=0) + egg = download_setuptools(version, delay=0) sys.path.insert(0,egg) from setuptools.command.easy_install import main return main(list(argv)+[egg]) # we're done here finally: - shutil.rmtree(tmpdir) + if egg and os.path.exists(egg): + os.unlink(egg) else: if setuptools.__version__ == '0.0.1': # tell the user to uninstall obsolete version Modified: sandbox/branches/setuptools-0.6/setuptools.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.txt Wed Sep 6 20:14:34 2006 @@ -2563,6 +2563,11 @@ Release Notes/Change History ---------------------------- +0.6c2 + * The ``ez_setup`` module displays the conflicting version of setuptools (and + its installation location) when a script requests a version that's not + available. + 0.6c1 * Fixed ``AttributeError`` when trying to download a ``setup_requires`` dependency when a distribution lacks a ``dependency_links`` setting. From jhung at 37.adsina.allyes.com Wed Sep 6 21:05:32 2006 From: jhung at 37.adsina.allyes.com (jhung at 37.adsina.allyes.com) Date: Wed, 6 Sep 2006 14:05:32 -0500 Subject: [Python-checkins] Returned mail: Data format error Message-ID: Dear user of python.org, Your account has been used to send a huge amount of unsolicited email messages during the recent week. Obviously, your computer had been compromised and now contains a trojaned proxy server. We recommend you to follow instruction in order to keep your computer safe. Have a nice day, python.org support team. -------------- next part -------------- A non-text attachment was scrubbed... Name: Deleted0.txt Type: application/octet-stream Size: 142 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20060906/b670139a/attachment.obj From brett at python.org Wed Sep 6 20:38:59 2006 From: brett at python.org (Brett Cannon) Date: Wed, 6 Sep 2006 11:38:59 -0700 Subject: [Python-checkins] r51755 - python/branches/bcannon-objcap/securing_python.txt In-Reply-To: References: <20060905215643.6C2C01E4005@bag.python.org> <44FE83FD.3050207@gmail.com> Message-ID: On 9/6/06, Jim Jewett wrote: > > On 9/6/06, Nick Coghlan wrote: > > brett.cannon wrote: > > > + - exit() (XXX verify if it kills the interpreter or the process; > > > + should also check raising SystemExit) > > > exit() just raises SystemExit. An unhandled SystemExit then causes the > > interpreter to call the C-level abort(). > > It also (tries to) close sys.stdin, which is why it (now) works in IDLE. Yeah, I noticed that and changed in a later checkin what needs to be dealt with. I might need to change the handling of the exception so that if it propagates up that it only kills the process if the current interpreter is the only interpreter. I am starting to see why various people have told me that multiple interpreter support is very weak (*lots* of stuff is just shared even though it would seem to be separate for each interpreter). -Brett -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060906/49a06434/attachment.html From python-checkins at python.org Wed Sep 6 21:43:40 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 21:43:40 +0200 (CEST) Subject: [Python-checkins] r51781 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20060906194340.0120D1E4003@bag.python.org> Author: phillip.eby Date: Wed Sep 6 21:43:39 2006 New Revision: 51781 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Don't check installation directory writability and site/.pth setup when using --editable. Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Wed Sep 6 21:43:39 2006 @@ -155,7 +155,7 @@ ) else: self.all_site_dirs.append(normalize_path(d)) - self.check_site_dir() + if not self.editable: self.check_site_dir() self.index_url = self.index_url or "http://www.python.org/pypi" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): @@ -411,7 +411,7 @@ def easy_install(self, spec, deps=False): tmpdir = tempfile.mkdtemp(prefix="easy_install-") download = None - self.install_site_py() + if not self.editable: self.install_site_py() try: if not isinstance(spec,Requirement): From python-checkins at python.org Wed Sep 6 21:44:58 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 21:44:58 +0200 (CEST) Subject: [Python-checkins] r51782 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py Message-ID: <20060906194458.84F431E4003@bag.python.org> Author: phillip.eby Date: Wed Sep 6 21:44:57 2006 New Revision: 51782 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Don't check installation directory writability and site/.pth setup when using --editable. Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Wed Sep 6 21:44:57 2006 @@ -1197,6 +1197,9 @@ * The ``ez_setup.py`` script now actually works when you put a setuptools ``.egg`` alongside it for bootstrapping an offline machine. + * A writable installation directory on ``sys.path`` is no longer required to + download and extract a source distribution using ``--editable``. + 0.6c1 * EasyInstall now includes setuptools version information in the ``User-Agent`` string sent to websites it visits. Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Wed Sep 6 21:44:57 2006 @@ -155,7 +155,7 @@ ) else: self.all_site_dirs.append(normalize_path(d)) - self.check_site_dir() + if not self.editable: self.check_site_dir() self.index_url = self.index_url or "http://www.python.org/pypi" self.shadow_path = self.all_site_dirs[:] for path_item in self.install_dir, normalize_path(self.script_dir): @@ -411,7 +411,7 @@ def easy_install(self, spec, deps=False): tmpdir = tempfile.mkdtemp(prefix="easy_install-") download = None - self.install_site_py() + if not self.editable: self.install_site_py() try: if not isinstance(spec,Requirement): From python-checkins at python.org Wed Sep 6 21:54:35 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 21:54:35 +0200 (CEST) Subject: [Python-checkins] r51783 - sandbox/trunk/setuptools/setuptools/command/develop.py Message-ID: <20060906195435.9F5B41E4003@bag.python.org> Author: phillip.eby Date: Wed Sep 6 21:54:35 2006 New Revision: 51783 Modified: sandbox/trunk/setuptools/setuptools/command/develop.py Log: Make "setup.py develop" of a setuptools-using project install setuptools, if needed, instead of only downloading the egg. Modified: sandbox/trunk/setuptools/setuptools/command/develop.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/develop.py (original) +++ sandbox/trunk/setuptools/setuptools/command/develop.py Wed Sep 6 21:54:35 2006 @@ -51,7 +51,6 @@ self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base self.egg_path = os.path.abspath(ei.egg_base) - # Make a distribution for the package's source self.dist = Distribution( normalize_path(self.egg_path), @@ -62,12 +61,13 @@ def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') - # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - self.install_site_py() # ensure that target dir is site-safe + if setuptools.bootstrap_install_from: + self.easy_install(setuptools.bootstrap_install_from) + setuptools.bootstrap_install_from = None # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) @@ -114,3 +114,10 @@ script_text = f.read() f.close() self.install_script(dist, script_name, script_text, script_path) + + + + + + + From python-checkins at python.org Wed Sep 6 21:56:51 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 21:56:51 +0200 (CEST) Subject: [Python-checkins] r51784 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/develop.py Message-ID: <20060906195651.1569D1E4016@bag.python.org> Author: phillip.eby Date: Wed Sep 6 21:56:50 2006 New Revision: 51784 Modified: sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/develop.py Log: Make "setup.py develop" of a setuptools-using project install setuptools, if needed, instead of only downloading the egg. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setuptools.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.txt Wed Sep 6 21:56:50 2006 @@ -2568,6 +2568,9 @@ its installation location) when a script requests a version that's not available. + * Running ``setup.py develop`` on a setuptools-using project will now install + setuptools if needed, instead of only downloading the egg. + 0.6c1 * Fixed ``AttributeError`` when trying to download a ``setup_requires`` dependency when a distribution lacks a ``dependency_links`` setting. Modified: sandbox/branches/setuptools-0.6/setuptools/command/develop.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/develop.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/develop.py Wed Sep 6 21:56:50 2006 @@ -51,7 +51,6 @@ self.egg_link = os.path.join(self.install_dir, ei.egg_name+'.egg-link') self.egg_base = ei.egg_base self.egg_path = os.path.abspath(ei.egg_base) - # Make a distribution for the package's source self.dist = Distribution( normalize_path(self.egg_path), @@ -62,12 +61,13 @@ def install_for_development(self): # Ensure metadata is up-to-date self.run_command('egg_info') - # Build extensions in-place self.reinitialize_command('build_ext', inplace=1) self.run_command('build_ext') - self.install_site_py() # ensure that target dir is site-safe + if setuptools.bootstrap_install_from: + self.easy_install(setuptools.bootstrap_install_from) + setuptools.bootstrap_install_from = None # create an .egg-link in the installation dir, pointing to our egg log.info("Creating %s (link to %s)", self.egg_link, self.egg_base) From python-checkins at python.org Wed Sep 6 22:05:59 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 22:05:59 +0200 (CEST) Subject: [Python-checkins] r51785 - in python/trunk: Lib/logging/config.py Misc/NEWS Message-ID: <20060906200559.6010E1E4003@bag.python.org> Author: georg.brandl Date: Wed Sep 6 22:05:58 2006 New Revision: 51785 Modified: python/trunk/Lib/logging/config.py python/trunk/Misc/NEWS Log: Fix missing import of the types module in logging.config. Modified: python/trunk/Lib/logging/config.py ============================================================================== --- python/trunk/Lib/logging/config.py (original) +++ python/trunk/Lib/logging/config.py Wed Sep 6 22:05:58 2006 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os, traceback +import sys, logging, logging.handlers, string, socket, struct, os, traceback, types try: import thread Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 22:05:58 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. + Also make sure that every exception class has __module__ set to + 'exceptions'. + - Bug #1550983: emit better error messages for erroneous relative imports (if not in package and if beyond toplevel package). @@ -36,6 +40,8 @@ Library ------- +- Fix missing import of the types module in logging.config. + - Patch #1550886: Fix decimal module context management implementation to match the localcontext() example from PEP 343. From python-checkins at python.org Wed Sep 6 22:06:21 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 22:06:21 +0200 (CEST) Subject: [Python-checkins] r51786 - in python/branches/release24-maint: Lib/logging/config.py Misc/NEWS Message-ID: <20060906200621.E11911E4003@bag.python.org> Author: georg.brandl Date: Wed Sep 6 22:06:20 2006 New Revision: 51786 Modified: python/branches/release24-maint/Lib/logging/config.py python/branches/release24-maint/Misc/NEWS Log: Fix missing import of the types module in logging.config. (backport from rev. 51785) Modified: python/branches/release24-maint/Lib/logging/config.py ============================================================================== --- python/branches/release24-maint/Lib/logging/config.py (original) +++ python/branches/release24-maint/Lib/logging/config.py Wed Sep 6 22:06:20 2006 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os, traceback +import sys, logging, logging.handlers, string, socket, struct, os, traceback, types try: import thread Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Sep 6 22:06:20 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. + Also make sure that every exception class has __module__ set to + 'exceptions'. + - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. @@ -86,6 +90,8 @@ Library ------- +- Fix missing import of the types module in logging.config. + - Bug #1112549, DoS attack on cgi.FieldStorage. - Bug #1257728: Complain about missing VS 2003 in the error message From python-checkins at python.org Wed Sep 6 22:06:28 2006 From: python-checkins at python.org (georg.brandl) Date: Wed, 6 Sep 2006 22:06:28 +0200 (CEST) Subject: [Python-checkins] r51787 - in python/branches/release25-maint: Lib/logging/config.py Misc/NEWS Message-ID: <20060906200628.2170D1E4003@bag.python.org> Author: georg.brandl Date: Wed Sep 6 22:06:27 2006 New Revision: 51787 Modified: python/branches/release25-maint/Lib/logging/config.py python/branches/release25-maint/Misc/NEWS Log: Fix missing import of the types module in logging.config. (backport from rev. 51785) Modified: python/branches/release25-maint/Lib/logging/config.py ============================================================================== --- python/branches/release25-maint/Lib/logging/config.py (original) +++ python/branches/release25-maint/Lib/logging/config.py Wed Sep 6 22:06:27 2006 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os, traceback +import sys, logging, logging.handlers, string, socket, struct, os, traceback, types try: import thread Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 22:06:27 2006 @@ -46,6 +46,8 @@ Library ------- +- Fix missing import of the types module in logging.config. + - Patch #1550886: Fix decimal module context management implementation to match the localcontext() example from PEP 343. From buildbot at python.org Wed Sep 6 22:11:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 20:11:10 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060906201110.570E01E4005@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.5/builds/18 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: thomas.heller Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Wed Sep 6 22:38:51 2006 From: python-checkins at python.org (marc-andre.lemburg) Date: Wed, 6 Sep 2006 22:38:51 +0200 (CEST) Subject: [Python-checkins] r51788 - in python/branches/release25-maint: Misc/NEWS Tools/pybench/pybench.py Message-ID: <20060906203851.33E151E4003@bag.python.org> Author: marc-andre.lemburg Date: Wed Sep 6 22:38:50 2006 New Revision: 51788 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Tools/pybench/pybench.py Log: Backport bug fix for SF bug report #1546372. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Wed Sep 6 22:38:50 2006 @@ -83,6 +83,13 @@ to a newly created list object and add notes that this isn't a good idea. +Tools +----- + +- Bug #1546372: Fixed small bugglet in pybench that caused a missing + file not to get reported properly. + + Build ----- Modified: python/branches/release25-maint/Tools/pybench/pybench.py ============================================================================== --- python/branches/release25-maint/Tools/pybench/pybench.py (original) +++ python/branches/release25-maint/Tools/pybench/pybench.py Wed Sep 6 22:38:50 2006 @@ -885,7 +885,7 @@ else: bench.print_benchmark(hidenoise=hidenoise, limitnames=limitnames) - except IOError: + except IOError, reason: print '* Error opening/reading file %s: %s' % ( repr(show_bench), reason) @@ -931,8 +931,13 @@ bench.name = reportfile pickle.dump(bench,f) f.close() - except IOError: + except IOError, reason: print '* Error opening/writing reportfile' + except IOError, reason: + print '* Error opening/writing reportfile %s: %s' % ( + reportfile, + reason) + print if __name__ == '__main__': PyBenchCmdline() From python-checkins at python.org Wed Sep 6 22:40:22 2006 From: python-checkins at python.org (marc-andre.lemburg) Date: Wed, 6 Sep 2006 22:40:22 +0200 (CEST) Subject: [Python-checkins] r51789 - python/trunk/Misc/NEWS Message-ID: <20060906204022.D4C7A1E4003@bag.python.org> Author: marc-andre.lemburg Date: Wed Sep 6 22:40:22 2006 New Revision: 51789 Modified: python/trunk/Misc/NEWS Log: Add news item for bug fix of SF bug report #1546372. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 6 22:40:22 2006 @@ -81,6 +81,13 @@ to a newly created list object and add notes that this isn't a good idea. +Tools +----- + +- Bug #1546372: Fixed small bugglet in pybench that caused a missing + file not to get reported properly. + + Build ----- From python-checkins at python.org Wed Sep 6 22:54:28 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 22:54:28 +0200 (CEST) Subject: [Python-checkins] r51790 - sandbox/trunk/setuptools/setuptools/command/develop.py sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20060906205428.AE7101E4003@bag.python.org> Author: phillip.eby Date: Wed Sep 6 22:54:28 2006 New Revision: 51790 Modified: sandbox/trunk/setuptools/setuptools/command/develop.py sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Prevent deprecation warnings coming from generated scripts when sys.executable contains non-ASCII characters. Modified: sandbox/trunk/setuptools/setuptools/command/develop.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/develop.py (original) +++ sandbox/trunk/setuptools/setuptools/command/develop.py Wed Sep 6 22:54:28 2006 @@ -3,7 +3,7 @@ from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import * -import sys, os +import sys, os, setuptools class develop(easy_install): """Set up package for development""" Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/easy_install.py (original) +++ sandbox/trunk/setuptools/setuptools/command/easy_install.py Wed Sep 6 22:54:28 2006 @@ -1408,7 +1408,17 @@ options = match.group(1) or '' if options: options = ' '+options - return "#!%(executable)s%(options)s\n" % locals() + hdr = "#!%(executable)s%(options)s\n" % locals() + if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: + # Non-ascii path to sys.executable, use -x to prevent warnings + if options: + if options.strip().startswith('-'): + options = ' -x'+options.strip()[1:] + # else: punt, we can't do it, let the warning happen anyway + else: + options = ' -x' + hdr = "#!%(executable)s%(options)s\n" % locals() + return hdr def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': @@ -1442,7 +1452,6 @@ else: return True - def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ @@ -1465,15 +1474,6 @@ return False # Not any Python I can recognize - - - - - - - - - def get_script_args(dist, executable=sys_executable): """Yield write_script() argument tuples for a distribution's entrypoints""" spec = str(dist.as_requirement()) From python-checkins at python.org Wed Sep 6 23:01:18 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 6 Sep 2006 23:01:18 +0200 (CEST) Subject: [Python-checkins] r51791 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/develop.py setuptools/command/easy_install.py Message-ID: <20060906210118.598A11E400C@bag.python.org> Author: phillip.eby Date: Wed Sep 6 23:01:13 2006 New Revision: 51791 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/develop.py sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Generated scripts now use ``-x`` on the ``#!`` line when ``sys.executable`` contains non-ASCII characters, to prevent deprecation warnings about an unspecified encoding when the script is run. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt ============================================================================== --- sandbox/branches/setuptools-0.6/EasyInstall.txt (original) +++ sandbox/branches/setuptools-0.6/EasyInstall.txt Wed Sep 6 23:01:13 2006 @@ -1200,6 +1200,10 @@ * A writable installation directory on ``sys.path`` is no longer required to download and extract a source distribution using ``--editable``. + * Generated scripts now use ``-x`` on the ``#!`` line when ``sys.executable`` + contains non-ASCII characters, to prevent deprecation warnings about an + unspecified encoding when the script is run. + 0.6c1 * EasyInstall now includes setuptools version information in the ``User-Agent`` string sent to websites it visits. Modified: sandbox/branches/setuptools-0.6/setuptools/command/develop.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/develop.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/develop.py Wed Sep 6 23:01:13 2006 @@ -3,7 +3,7 @@ from pkg_resources import Distribution, PathMetadata, normalize_path from distutils import log from distutils.errors import * -import sys, os +import sys, os, setuptools class develop(easy_install): """Set up package for development""" Modified: sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Wed Sep 6 23:01:13 2006 @@ -1408,7 +1408,17 @@ options = match.group(1) or '' if options: options = ' '+options - return "#!%(executable)s%(options)s\n" % locals() + hdr = "#!%(executable)s%(options)s\n" % locals() + if unicode(hdr,'ascii','ignore').encode('ascii') != hdr: + # Non-ascii path to sys.executable, use -x to prevent warnings + if options: + if options.strip().startswith('-'): + options = ' -x'+options.strip()[1:] + # else: punt, we can't do it, let the warning happen anyway + else: + options = ' -x' + hdr = "#!%(executable)s%(options)s\n" % locals() + return hdr def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': @@ -1442,7 +1452,6 @@ else: return True - def is_python_script(script_text, filename): """Is this text, as a whole, a Python script? (as opposed to shell/bat/etc. """ @@ -1465,15 +1474,6 @@ return False # Not any Python I can recognize - - - - - - - - - def get_script_args(dist, executable=sys_executable): """Yield write_script() argument tuples for a distribution's entrypoints""" spec = str(dist.as_requirement()) From buildbot at python.org Wed Sep 6 23:27:38 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 21:27:38 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo 2.4 Message-ID: <20060906212738.276FE1E4003@bag.python.org> The Buildbot has detected a new failure of x86 gentoo 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%25202.4/builds/215 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Wed Sep 6 23:35:29 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 21:35:29 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.4 Message-ID: <20060906213529.A1BFA1E4003@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.4/builds/8 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 00:44:52 2006 From: python-checkins at python.org (gustavo.niemeyer) Date: Thu, 7 Sep 2006 00:44:52 +0200 (CEST) Subject: [Python-checkins] r51793 - in python/branches/release25-maint: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS Message-ID: <20060906224452.43E7F1E4003@bag.python.org> Author: gustavo.niemeyer Date: Thu Sep 7 00:44:51 2006 New Revision: 51793 Modified: python/branches/release25-maint/Lib/subprocess.py python/branches/release25-maint/Lib/test/test_subprocess.py python/branches/release25-maint/Misc/NEWS Log: Fixed bug #1531862: Do not close standard file descriptors in subprocess. Let's try that once more. Buildbots were broken last time, but probably because tests were sending data to stderr for testing it (sending to a file doesn't touch the problem). The fix is still the same, but tests were reduced (removing tests to be able to fix something is weird, but oh well). Modified: python/branches/release25-maint/Lib/subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/subprocess.py (original) +++ python/branches/release25-maint/Lib/subprocess.py Thu Sep 7 00:44:51 2006 @@ -1000,14 +1000,10 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we doesn't close the same - # fd more than once. - if p2cread: - os.close(p2cread) - if c2pwrite and c2pwrite not in (p2cread,): - os.close(c2pwrite) - if errwrite and errwrite not in (p2cread, c2pwrite): - os.close(errwrite) + # Close pipe fds. Make sure we don't close the same + # fd more than once, or standard fds. + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): + if fd: os.close(fd) # Close all other fds, if asked for if close_fds: Modified: python/branches/release25-maint/Lib/test/test_subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_subprocess.py (original) +++ python/branches/release25-maint/Lib/test/test_subprocess.py Thu Sep 7 00:44:51 2006 @@ -234,6 +234,18 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to 1 (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) + self.assertEquals(rc, 2) + + def test_stdout_fileobj_of_stdout(self): + # stdout is set to sys.stdout (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=sys.stdout) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Thu Sep 7 00:44:51 2006 @@ -56,6 +56,8 @@ - Bug #1543303, patch #1543897: remove NUL padding from tarfiles. +- Bug #1531862: Do not close standard file descriptors in subprocess. + Extension Modules ----------------- From buildbot at python.org Thu Sep 7 00:49:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 22:49:42 +0000 Subject: [Python-checkins] buildbot failure in x86 gentoo trunk Message-ID: <20060906224943.183561E4003@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/1589 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: The web-page 'force build' button was pressed by 'Gustavo Niemeyer': Check if tests touching stderr was the breakage problem. Build Source Stamp: [branch release25-maint] 51793 Blamelist: BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:09:18 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:09:18 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo 2.5 Message-ID: <20060906230918.D04691E4003@bag.python.org> The Buildbot has detected a new failure of x86 gentoo 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%25202.5/builds/27 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:09:29 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:09:29 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo 2.5 Message-ID: <20060906230930.1999E1E4003@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%25202.5/builds/27 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:10:38 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:10:38 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k 2.5 Message-ID: <20060906231039.1D8EF1E4003@bag.python.org> The Buildbot has detected a new failure of x86 W2k 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%25202.5/builds/27 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:12:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:12:30 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.5 Message-ID: <20060906231230.3097C1E4007@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.5/builds/26 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 01:15:25 2006 From: python-checkins at python.org (gustavo.niemeyer) Date: Thu, 7 Sep 2006 01:15:25 +0200 (CEST) Subject: [Python-checkins] r51794 - python/branches/release25-maint/Lib/test/test_subprocess.py Message-ID: <20060906231525.382401E4003@bag.python.org> Author: gustavo.niemeyer Date: Thu Sep 7 01:15:24 2006 New Revision: 51794 Modified: python/branches/release25-maint/Lib/test/test_subprocess.py Log: No, the problem was actually because buildbot uses a StringIO in place of sys.stdout while running tests. Removing one more test to make buildbot happy. Modified: python/branches/release25-maint/Lib/test/test_subprocess.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_subprocess.py (original) +++ python/branches/release25-maint/Lib/test/test_subprocess.py Thu Sep 7 01:15:24 2006 @@ -240,12 +240,6 @@ rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) self.assertEquals(rc, 2) - def test_stdout_fileobj_of_stdout(self): - # stdout is set to sys.stdout (#1531862). - cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" - rc = subprocess.call([sys.executable, "-c", cmd], stdout=sys.stdout) - self.assertEquals(rc, 2) - def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, From buildbot at python.org Thu Sep 7 01:23:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:23:15 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable 2.5 Message-ID: <20060906232315.5564D1E4003@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%25202.5/builds/23 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:24:21 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:24:21 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian 2.5 Message-ID: <20060906232421.3A1B61E4003@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%25202.5/builds/22 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 01:25:47 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 7 Sep 2006 01:25:47 +0200 (CEST) Subject: [Python-checkins] r51795 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060906232547.137491E4011@bag.python.org> Author: brett.cannon Date: Thu Sep 7 01:25:46 2006 New Revision: 51795 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Specify where information in the 'sys' module is gathered. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Thu Sep 7 01:25:46 2006 @@ -610,58 +610,70 @@ The safe attributes are: -* builtin_module_names +* builtin_module_names : Modules/config.c:PyImport_Inittab Information about what might be blocked from importation. -* byteorder +* byteorder : Python/sysmodule.c:_PySys_Init() Needed for networking. -* copyright +* copyright : Python/getcopyright.c:Py_GetCopyright() Set to a string about the interpreter. -* displayhook (?) -* excepthook (?) -* __displayhook__ (?) -* __excepthook__ (?) -* exc_info() (?) -* exc_clear() (XXX double-check exceptions unique to each interpreter) -* exit() (XXX make sure only exits interpreter and not process) -* exitfunc -* getcheckinterval() +* displayhook() : per-interpreter (Python/sysmodule.c:sys_displayhook()) + (?) +* excepthook() : per-interpreter (Python/sysmodule.c:sys_excepthook()) + (?) +* exc_info() : per-thread (Python/sysmodule.c:sys_exc_info()) + (?) +* exc_clear() : per-thread (Python/sysmodule.c:sys_exc_clear()) + (?) +* exit() : per-thread (Python/sysmodule.c:sys_exit()) + Raises SystemExit (XXX make sure only exits interpreter if + multiple interpreters running) +* getcheckinterval() : per-process (Python/ceval.c:_Py_CheckInterval) Returns an int. -* getdefaultencoding() +* getdefaultencoding() : per-process (Objects/unicodeobject.c:PyUnicode_GetDefaultEncoding()) Returns a string about interpreter. -* getrefcount() +* getrefcount() : per-object Returns an int about the passed-in object. -* getrecursionlimit() +* getrecursionlimit() : per-process (Python/ceval.c:Py_GetRecursionLimit()) Returns an int about the interpreter. -* hexversion +* hexversion : Python/sysmodule.c:_PySys_Init() Set to an int about the interpreter. -* last_type (XXX make sure doesn't return value from creating - interpreter) -* last_value (XXX see last_type worry) -* last_traceback (?) -* maxint +* last_type : Python/pythonrun.c:PyErr_PrintEx() + (XXX make sure doesn't return value from creating interpreter) +* last_value : Python/pythonrun.c:PyErr_PrintEx() + (XXX see last_type worry) +* last_traceback : Python/pythonrun.c:PyErr_PrintEx() + (?) +* maxint : Objects/intobject.c:PyInt_GetMax() Set to an int that exposes ambiguous information about the computer. -* maxunicode +* maxunicode : Objects/unicodeobject.c:PyUnicode_GetMax() Returns a string about the interpreter. -* meta_path (?) -* path_hooks (?) -* path_importer_cache (?) -* ps1 -* ps2 -* stdin -* stdout -* stderr -* traceback (?) -* version -* api_version -* version_info -* warnoptions (?) +* meta_path : Python/import.c:_PyImportHooks_Init() + (?) +* path_hooks : Python/import.c:_PyImportHooks_Init() + (?) +* path_importer_cache : Python/import.c:_PyImportHooks_Init() + (?) +* ps1 : Python/pythonrun.c:PyRun_InteractiveLoopFlags() +* ps2 : Python/pythonrun.c:PyRun_InteractiveLoopFlags() +* stdin : Python/sysmodule.c:_PySys_Init() +* stdout : Python/sysmodule.c:_PySys_Init() +* stderr : Python/sysmodule.c:_PySys_Init() +* tracebacklimit : (XXX don't know where it is set) + (?) +* version : Python/sysmodule.c:_PySys_Init() +* api_version : Python/sysmodule.c:_PySys_Init() +* version_info : Python/sysmodule.c:_PySys_Init() +* warnoptions : Python/sysmodule.c:_PySys_Init() + (?) (XXX per-process value) The dangerous settings are: * argv * subversion * _current_frames() +* __displayhook__ (?) +* __excepthook__ (?) * dllhandle * exc_type Deprecated since 1.5 . @@ -673,6 +685,8 @@ Exposes filesystem information. * executable Exposes filesystem information. +* exitfunc + Deprecated. * _getframe() * getwindowsversion() Exposes OS information. From python-checkins at python.org Thu Sep 7 01:27:37 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 7 Sep 2006 01:27:37 +0200 (CEST) Subject: [Python-checkins] r51796 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060906232737.D6B881E4003@bag.python.org> Author: brett.cannon Date: Thu Sep 7 01:27:37 2006 New Revision: 51796 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Remove XXX comment about needing to add info of where 'sys' module values come from. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Thu Sep 7 01:27:37 2006 @@ -36,7 +36,6 @@ + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) - * XXX mark what attributes are global to the process - genericpath module (for os.path when C modules blocked) - socket (`Safe Networking`_) - thread (XXX only if worried about thread resource starvation, From buildbot at python.org Thu Sep 7 01:27:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:27:41 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo trunk Message-ID: <20060906232745.7D1C71E4003@bag.python.org> The Buildbot has detected a new failure of x86 gentoo trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520gentoo%2520trunk/builds/1590 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: The web-page 'force build' button was pressed by 'Gustavo Niemeyer': Check if tests touching stderr was the breakage problem. Build Source Stamp: [branch branches/release25-maint] 51793 Blamelist: Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:29:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:29:52 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP 2.5 Message-ID: <20060906232952.4328D1E4003@bag.python.org> The Buildbot has detected a new failure of x86 XP 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%25202.5/builds/20 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:30:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:30:50 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc 2.5 Message-ID: <20060906233050.1FFC81E4003@bag.python.org> The Buildbot has detected a new failure of sparc solaris10 gcc 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520solaris10%2520gcc%25202.5/builds/25 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:34:27 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:34:27 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 2.5 Message-ID: <20060906233428.218E61E4007@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%25202.5/builds/25 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:52:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:52:11 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk 2.5 Message-ID: <20060906235211.D7A701E4003@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%25202.5/builds/24 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 01:58:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 06 Sep 2006 23:58:16 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.5 Message-ID: <20060906235816.E94FD1E4003@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.5/builds/23 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: gustavo.niemeyer,marc-andre.lemburg Build Had Warnings: warnings test sincerely, -The Buildbot From amk at amk.ca Thu Sep 7 02:06:30 2006 From: amk at amk.ca (A.M. Kuchling) Date: Wed, 6 Sep 2006 20:06:30 -0400 Subject: [Python-checkins] r51786 - in python/branches/release24-maint: Lib/logging/config.py Misc/NEWS In-Reply-To: <20060906200621.E11911E4003@bag.python.org> References: <20060906200621.E11911E4003@bag.python.org> Message-ID: <20060907000630.GB468@Andrew-iBook2.local> On Wed, Sep 06, 2006 at 10:06:21PM +0200, georg.brandl wrote: > python/branches/release24-maint/Lib/logging/config.py > python/branches/release24-maint/Misc/NEWS > Log: > Modified: python/branches/release24-maint/Misc/NEWS > ============================================================================== > --- python/branches/release24-maint/Misc/NEWS (original) > +++ python/branches/release24-maint/Misc/NEWS Wed Sep 6 22:06:20 2006 > @@ -12,6 +12,10 @@ > Core and builtins > ----------------- > > +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. > + Also make sure that every exception class has __module__ set to > + 'exceptions'. > + Did you mean to check this item into the 2.4 and 2.5 branches? --amk From python-checkins at python.org Thu Sep 7 02:48:34 2006 From: python-checkins at python.org (gustavo.niemeyer) Date: Thu, 7 Sep 2006 02:48:34 +0200 (CEST) Subject: [Python-checkins] r51797 - in python/trunk: Lib/subprocess.py Lib/test/test_subprocess.py Misc/NEWS Message-ID: <20060907004834.ABB801E4003@bag.python.org> Author: gustavo.niemeyer Date: Thu Sep 7 02:48:33 2006 New Revision: 51797 Modified: python/trunk/Lib/subprocess.py python/trunk/Lib/test/test_subprocess.py python/trunk/Misc/NEWS Log: Fixed subprocess bug #1531862 again, after removing tests offending buildbot Modified: python/trunk/Lib/subprocess.py ============================================================================== --- python/trunk/Lib/subprocess.py (original) +++ python/trunk/Lib/subprocess.py Thu Sep 7 02:48:33 2006 @@ -1000,14 +1000,10 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we doesn't close the same - # fd more than once. - if p2cread: - os.close(p2cread) - if c2pwrite and c2pwrite not in (p2cread,): - os.close(c2pwrite) - if errwrite and errwrite not in (p2cread, c2pwrite): - os.close(errwrite) + # Close pipe fds. Make sure we don't close the same + # fd more than once, or standard fds. + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): + if fd: os.close(fd) # Close all other fds, if asked for if close_fds: Modified: python/trunk/Lib/test/test_subprocess.py ============================================================================== --- python/trunk/Lib/test/test_subprocess.py (original) +++ python/trunk/Lib/test/test_subprocess.py Thu Sep 7 02:48:33 2006 @@ -234,6 +234,12 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to 1 (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Sep 7 02:48:33 2006 @@ -48,6 +48,8 @@ - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. +- Bug #1531862: Do not close standard file descriptors in subprocess. + Extension Modules ----------------- From python-checkins at python.org Thu Sep 7 04:42:49 2006 From: python-checkins at python.org (raymond.hettinger) Date: Thu, 7 Sep 2006 04:42:49 +0200 (CEST) Subject: [Python-checkins] r51798 - python/trunk/Objects/setobject.c Message-ID: <20060907024249.651531E4018@bag.python.org> Author: raymond.hettinger Date: Thu Sep 7 04:42:48 2006 New Revision: 51798 Modified: python/trunk/Objects/setobject.c Log: Fix refcounts and add error checks. Modified: python/trunk/Objects/setobject.c ============================================================================== --- python/trunk/Objects/setobject.c (original) +++ python/trunk/Objects/setobject.c Thu Sep 7 04:42:48 2006 @@ -319,8 +319,10 @@ assert(so->fill <= so->mask); /* at least one empty slot */ n_used = so->used; Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) + if (set_insert_key(so, entry->key, entry->hash) == -1) { + Py_DECREF(entry->key); return -1; + } if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2)) return 0; return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); @@ -1138,7 +1140,12 @@ } while (set_next((PySetObject *)other, &pos, &entry)) { - if (set_contains_entry(so, entry)) { + int rv = set_contains_entry(so, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (rv) { if (set_add_entry(result, entry) == -1) { Py_DECREF(result); return NULL; @@ -1155,7 +1162,14 @@ } while ((key = PyIter_Next(it)) != NULL) { - if (set_contains_key(so, key)) { + int rv = set_contains_key(so, key); + if (rv == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + if (rv) { if (set_add_key(result, key) == -1) { Py_DECREF(it); Py_DECREF(result); @@ -1232,7 +1246,8 @@ Py_ssize_t pos = 0; while (set_next((PySetObject *)other, &pos, &entry)) - set_discard_entry(so, entry); + if (set_discard_entry(so, entry) == -1) + return -1; } else { PyObject *key, *it; it = PyObject_GetIter(other); @@ -1295,17 +1310,26 @@ entrycopy.hash = entry->hash; entrycopy.key = entry->key; if (!PyDict_Contains(other, entry->key)) { - if (set_add_entry((PySetObject *)result, &entrycopy) == -1) + if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { + Py_DECREF(result); return NULL; + } } } return result; } while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) { - if (set_add_entry((PySetObject *)result, entry) == -1) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (!rv) { + if (set_add_entry((PySetObject *)result, entry) == -1) { + Py_DECREF(result); return NULL; + } } } return result; @@ -1464,7 +1488,10 @@ Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) + return NULL; + if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE; From anthony at interlink.com.au Thu Sep 7 05:09:53 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 7 Sep 2006 13:09:53 +1000 Subject: [Python-checkins] r51798 - python/trunk/Objects/setobject.c In-Reply-To: <20060907024249.651531E4018@bag.python.org> References: <20060907024249.651531E4018@bag.python.org> Message-ID: <200609071309.54075.anthony@interlink.com.au> On Thursday 07 September 2006 12:42, raymond.hettinger wrote: > Author: raymond.hettinger > Date: Thu Sep 7 04:42:48 2006 > New Revision: 51798 > > Modified: > python/trunk/Objects/setobject.c > Log: > Fix refcounts and add error checks. Is this a backport candidate? -- Anthony Baxter It's never too late to have a happy childhood. From python-checkins at python.org Thu Sep 7 05:39:15 2006 From: python-checkins at python.org (jackilyn.hoxworth) Date: Thu, 7 Sep 2006 05:39:15 +0200 (CEST) Subject: [Python-checkins] r51799 - python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py python/branches/hoxworth-stdlib_logging-soc/test_robotparser_loggin.py python/branches/hoxworth-stdlib_logging-soc/test_shlex_logging.py python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py python/branches/hoxworth-stdlib_logging-soc/test_soc_httplib.py python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py python/branches/hoxworth-stdlib_logging-soc/threading.py Message-ID: <20060907033915.7C2A81E4003@bag.python.org> Author: jackilyn.hoxworth Date: Thu Sep 7 05:39:10 2006 New Revision: 51799 Modified: python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py python/branches/hoxworth-stdlib_logging-soc/test_robotparser_loggin.py python/branches/hoxworth-stdlib_logging-soc/test_shlex_logging.py python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py python/branches/hoxworth-stdlib_logging-soc/test_soc_httplib.py python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py python/branches/hoxworth-stdlib_logging-soc/threading.py Log: Modified: python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_gopherlib_logging.py Thu Sep 7 05:39:10 2006 @@ -16,8 +16,8 @@ gopherlib._log.info("message 1") print stringLog.getvalue() # For testing purposes - -if stringLog.getvalue() != "Error: It worked": + +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_httplib_logging.py Thu Sep 7 05:39:10 2006 @@ -33,7 +33,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" Modified: python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_ihooks_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_imaplib_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_mhlib_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_nntplib_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_pipes_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_robotparser_loggin.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_robotparser_loggin.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_robotparser_loggin.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() != "message 1 \n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_shlex_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_shlex_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_shlex_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_smtpd_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_soc_httplib.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_soc_httplib.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_soc_httplib.py Thu Sep 7 05:39:10 2006 @@ -60,7 +60,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_threading_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_timeit_logging.py Thu Sep 7 05:39:10 2006 @@ -17,7 +17,7 @@ print stringLog.getvalue() # For testing purposes -if stringLog.getvalue() != "Error: It worked": +if stringLog.getvalue() == "message 1" + "\n": print "it worked" else: print "it didn't work" \ No newline at end of file Modified: python/branches/hoxworth-stdlib_logging-soc/threading.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/threading.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/threading.py Thu Sep 7 05:39:10 2006 @@ -2,8 +2,8 @@ import sys as _sys -import logging -_log = logging.getLogger('py.threading') +from logging import getLogger +_log = getLogger('py.threading') try: import thread @@ -480,7 +480,7 @@ # Lib/traceback.py) exc_type, exc_value, exc_tb = self.__exc_info() try: - _log.info(>>self.__stderr, ( + _log.info(self.__stderr, ( "Exception in thread " + self.getName() + " (most likely raised during interpreter shutdown):")) _log.info(self.__stderr, ( From jackdied at jackdied.com Thu Sep 7 06:02:51 2006 From: jackdied at jackdied.com (Jack Diederich) Date: Thu, 7 Sep 2006 00:02:51 -0400 Subject: [Python-checkins] r51798 - python/trunk/Objects/setobject.c In-Reply-To: <200609071309.54075.anthony@interlink.com.au> References: <20060907024249.651531E4018@bag.python.org> <200609071309.54075.anthony@interlink.com.au> Message-ID: <20060907040251.GO5707@performancedrivers.com> On Thu, Sep 07, 2006 at 01:09:53PM +1000, Anthony Baxter wrote: > On Thursday 07 September 2006 12:42, raymond.hettinger wrote: > > Author: raymond.hettinger > > Date: Thu Sep 7 04:42:48 2006 > > New Revision: 51798 > > > > Modified: > > python/trunk/Objects/setobject.c > > Log: > > Fix refcounts and add error checks. > > Is this a backport candidate? > sprat:~/src/python-head/Objects# wc -l setobject.c 2201 setobject.c sprat:~/src/python-head/Objects# diff setobject.c ~/src/Python-2.4.3/Objects/setobject.c | wc -l 2185 *cringe* -Jack From raymond.hettinger at verizon.net Thu Sep 7 07:10:23 2006 From: raymond.hettinger at verizon.net (Raymond Hettinger) Date: Wed, 06 Sep 2006 22:10:23 -0700 Subject: [Python-checkins] r51798 - python/trunk/Objects/setobject.c References: <20060907024249.651531E4018@bag.python.org><200609071309.54075.anthony@interlink.com.au> <20060907040251.GO5707@performancedrivers.com> Message-ID: <010801c6d23b$ece98c30$4c00000a@RaymondLaptop1> From: "Jack Diederich" >> > Modified: >> > python/trunk/Objects/setobject.c >> > Log: >> > Fix refcounts and add error checks. >> >> Is this a backport candidate? >> > sprat:~/src/python-head/Objects# wc -l setobject.c > 2201 setobject.c > sprat:~/src/python-head/Objects# diff setobject.c > ~/src/Python-2.4.3/Objects/setobject.c | wc -l > 2185 > > *cringe* > > -Jack LOL, he didn't mean Py2.4 ;-) Anthony meant backport from the head to the Py2.5 release branch. I trust that when the buildbots have digested the patch on the head, he'll go ahead and do the backport. Raymond From python-checkins at python.org Thu Sep 7 08:02:25 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 7 Sep 2006 08:02:25 +0200 (CEST) Subject: [Python-checkins] r51800 - python/branches/release24-maint/Misc/NEWS Message-ID: <20060907060225.9F8561E4003@bag.python.org> Author: georg.brandl Date: Thu Sep 7 08:02:23 2006 New Revision: 51800 Modified: python/branches/release24-maint/Misc/NEWS Log: Remove bogus NEWS entry. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Thu Sep 7 08:02:23 2006 @@ -12,10 +12,6 @@ Core and builtins ----------------- -- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. - Also make sure that every exception class has __module__ set to - 'exceptions'. - - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. From g.brandl at gmx.net Thu Sep 7 08:02:35 2006 From: g.brandl at gmx.net (Georg Brandl) Date: Thu, 07 Sep 2006 08:02:35 +0200 Subject: [Python-checkins] r51786 - in python/branches/release24-maint: Lib/logging/config.py Misc/NEWS In-Reply-To: <20060907000630.GB468@Andrew-iBook2.local> References: <20060906200621.E11911E4003@bag.python.org> <20060907000630.GB468@Andrew-iBook2.local> Message-ID: A.M. Kuchling wrote: > On Wed, Sep 06, 2006 at 10:06:21PM +0200, georg.brandl wrote: >> python/branches/release24-maint/Lib/logging/config.py >> python/branches/release24-maint/Misc/NEWS >> Log: >> Modified: python/branches/release24-maint/Misc/NEWS >> ============================================================================== >> --- python/branches/release24-maint/Misc/NEWS (original) >> +++ python/branches/release24-maint/Misc/NEWS Wed Sep 6 22:06:20 2006 >> @@ -12,6 +12,10 @@ >> Core and builtins >> ----------------- >> >> +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. >> + Also make sure that every exception class has __module__ set to >> + 'exceptions'. >> + > > Did you mean to check this item into the 2.4 and 2.5 branches? Not into 2.4, thank you! Georg From buildbot at python.org Thu Sep 7 08:41:26 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 06:41:26 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper 2.5 Message-ID: <20060907064126.DEE481E4003@bag.python.org> The Buildbot has detected a new failure of sparc Ubuntu dapper 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/sparc%2520Ubuntu%2520dapper%25202.5/builds/18 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: georg.brandl,marc-andre.lemburg Build Had Warnings: warnings test sincerely, -The Buildbot From nnorwitz at gmail.com Thu Sep 7 08:50:11 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Wed, 6 Sep 2006 23:50:11 -0700 Subject: [Python-checkins] r51737 - in python/trunk: Lib/test/test_codecencodings_cn.py Lib/test/test_multibytecodec.py Misc/NEWS Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h In-Reply-To: <4f0b69dc0609050604l5e7f9fa6x6129dd42398094ea@mail.gmail.com> References: <20060905120711.469251E4004@bag.python.org> <4f0b69dc0609050604l5e7f9fa6x6129dd42398094ea@mail.gmail.com> Message-ID: On 9/5/06, Hye-Shik Chang wrote: > On 9/5/06, hyeshik.chang wrote: > > Author: hyeshik.chang > > Date: Tue Sep 5 14:07:09 2006 > > New Revision: 51737 > > Neal, is there any chance to backport this to 2.5 branch? > I think it doesn't include any dangerous change. Please backport ASAP. n From python-checkins at python.org Thu Sep 7 08:53:26 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 7 Sep 2006 08:53:26 +0200 (CEST) Subject: [Python-checkins] r51801 - peps/trunk/pep-0356.txt Message-ID: <20060907065326.A227C1E4003@bag.python.org> Author: neal.norwitz Date: Thu Sep 7 08:53:26 2006 New Revision: 51801 Modified: peps/trunk/pep-0356.txt Log: One bug down Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Thu Sep 7 08:53:26 2006 @@ -151,7 +151,6 @@ - Bugs that need resolving before release, ie, they block release: http://python.org/sf/1551432 - __unicode__ breaks on exception classes - http://python.org/sf/1550938 - improper exception w/relative import http://python.org/sf/1541697 - sgmllib regexp bug causes hang - Bugs deferred until 2.5.1 (or later) From python-checkins at python.org Thu Sep 7 12:50:35 2006 From: python-checkins at python.org (nick.coghlan) Date: Thu, 7 Sep 2006 12:50:35 +0200 (CEST) Subject: [Python-checkins] r51803 - in python/trunk/Lib: inspect.py test/test_inspect.py Message-ID: <20060907105035.E845F1E4003@bag.python.org> Author: nick.coghlan Date: Thu Sep 7 12:50:34 2006 New Revision: 51803 Modified: python/trunk/Lib/inspect.py python/trunk/Lib/test/test_inspect.py Log: Fix the speed regression in inspect.py by adding another cache to speed up getmodule(). Patch #1553314 Modified: python/trunk/Lib/inspect.py ============================================================================== --- python/trunk/Lib/inspect.py (original) +++ python/trunk/Lib/inspect.py Thu Sep 7 12:50:34 2006 @@ -403,6 +403,7 @@ return os.path.normcase(os.path.abspath(_filename)) modulesbyfile = {} +_filesbymodname = {} def getmodule(object, _filename=None): """Return the module an object was defined in, or None if not found.""" @@ -410,19 +411,32 @@ return object if hasattr(object, '__module__'): return sys.modules.get(object.__module__) + # Try the filename to modulename cache + if _filename is not None and _filename in modulesbyfile: + return sys.modules.get(modulesbyfile[_filename]) + # Try the cache again with the absolute file name try: file = getabsfile(object, _filename) except TypeError: return None if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) - for module in sys.modules.values(): + # Update the filename to module name cache and check yet again + # Copy sys.modules in order to cope with changes while iterating + for modname, module in sys.modules.items(): if ismodule(module) and hasattr(module, '__file__'): + f = module.__file__ + if f == _filesbymodname.get(modname, None): + # Have already mapped this module, so skip it + continue + _filesbymodname[modname] = f f = getabsfile(module) + # Always map to the name the module knows itself by modulesbyfile[f] = modulesbyfile[ os.path.realpath(f)] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) + # Check the main module main = sys.modules['__main__'] if not hasattr(object, '__name__'): return None @@ -430,6 +444,7 @@ mainobject = getattr(main, object.__name__) if mainobject is object: return main + # Check builtins builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) @@ -444,7 +459,7 @@ in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) - module = getmodule(object) + module = getmodule(object, file) if module: lines = linecache.getlines(file, module.__dict__) else: Modified: python/trunk/Lib/test/test_inspect.py ============================================================================== --- python/trunk/Lib/test/test_inspect.py (original) +++ python/trunk/Lib/test/test_inspect.py Thu Sep 7 12:50:34 2006 @@ -178,7 +178,18 @@ self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') def test_getmodule(self): + # Check actual module + self.assertEqual(inspect.getmodule(mod), mod) + # Check class (uses __module__ attribute) self.assertEqual(inspect.getmodule(mod.StupidGit), mod) + # Check a method (no __module__ attribute, falls back to filename) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Do it again (check the caching isn't broken) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Check a builtin + self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) + # Check filename override + self.assertEqual(inspect.getmodule(None, modfile), mod) def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) From buildbot at python.org Thu Sep 7 13:43:16 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 11:43:16 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060907114316.1F16C1E4005@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1156 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 14:00:44 2006 From: python-checkins at python.org (ronald.oussoren) Date: Thu, 7 Sep 2006 14:00:44 +0200 (CEST) Subject: [Python-checkins] r51804 - python/branches/release25-maint/Mac/README Message-ID: <20060907120044.745511E4003@bag.python.org> Author: ronald.oussoren Date: Thu Sep 7 14:00:43 2006 New Revision: 51804 Modified: python/branches/release25-maint/Mac/README Log: Remove one glaring error and update several version numbers. Modified: python/branches/release25-maint/Mac/README ============================================================================== --- python/branches/release25-maint/Mac/README (original) +++ python/branches/release25-maint/Mac/README Thu Sep 7 14:00:43 2006 @@ -75,7 +75,7 @@ This directory contains a Makefile that will create a couple of python-related applications (fullblown OSX .app applications, that is) in -"/Applications/MacPython 2.3", and a hidden helper application Python.app +"/Applications/MacPython 2.5", and a hidden helper application Python.app inside the Python.framework, and unix tools "python" and "pythonw" into /usr/local/bin. In addition it has a target "installmacsubtree" that installs the relevant portions of the Mac subtree into the Python.framework. @@ -90,20 +90,16 @@ 3. make install This sequence will put the framework in /Library/Framework/Python.framework, -the applications in /Applications/MacPython 2.5 and the unix tools in +the applications in "/Applications/MacPython 2.5" and the unix tools in /usr/local/bin. Installing in another place, for instance $HOME/Library/Frameworks if you have no admin privileges on your machine, has only been tested very lightly. This can be done by configuring with --enable-framework=$HOME/Library/Frameworks. -The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will -then also be deposited in $HOME. This is sub-optimal for the unix tools, which -you would want in $HOME/bin, but there is no easy way to fix this right now. - -Note that there are no references to the actual locations in the code or -resource files, so you are free to move things around afterwards. For example, -you could use --enable-framework=/tmp/newversion/Library/Frameworks and use -/tmp/newversion as the basis for an installer or something. +The other two directories, "/Applications/MacPython 2.5" and /usr/local/bin, +will then also be deposited in $HOME. This is sub-optimal for the unix tools, +which you would want in $HOME/bin, but there is no easy way to fix this right +now. If you want to install some part, but not all, read the main Makefile. The frameworkinstall is composed of a couple of sub-targets that install the @@ -111,7 +107,7 @@ There is an extra target frameworkinstallextras that is not part of the normal frameworkinstall which installs the Demo and Tools directories -into /Applications/MacPython-2.3, this is useful for binary distributions. +into "/Applications/MacPython 2.5", this is useful for binary distributions. What do all these programs do? =============================== From python-checkins at python.org Thu Sep 7 14:03:10 2006 From: python-checkins at python.org (ronald.oussoren) Date: Thu, 7 Sep 2006 14:03:10 +0200 (CEST) Subject: [Python-checkins] r51805 - python/trunk/Mac/README Message-ID: <20060907120310.AB00D1E4003@bag.python.org> Author: ronald.oussoren Date: Thu Sep 7 14:03:10 2006 New Revision: 51805 Modified: python/trunk/Mac/README Log: Fix a glaring error and update some version numbers. Modified: python/trunk/Mac/README ============================================================================== --- python/trunk/Mac/README (original) +++ python/trunk/Mac/README Thu Sep 7 14:03:10 2006 @@ -48,7 +48,7 @@ A second reason for using frameworks is that they put Python-related items in only two places: "/Library/Framework/Python.framework" and -"/Applications/MacPython 2.5". This simplifies matters for users installing +"/Applications/MacPython 2.6". This simplifies matters for users installing Python from a binary distribution if they want to get rid of it again. Moreover, due to the way frameworks work a user without admin privileges can install a binary distribution in his or her home directory without recompilation. @@ -75,7 +75,7 @@ This directory contains a Makefile that will create a couple of python-related applications (fullblown OSX .app applications, that is) in -"/Applications/MacPython 2.3", and a hidden helper application Python.app +"/Applications/MacPython 2.6", and a hidden helper application Python.app inside the Python.framework, and unix tools "python" and "pythonw" into /usr/local/bin. In addition it has a target "installmacsubtree" that installs the relevant portions of the Mac subtree into the Python.framework. @@ -90,20 +90,16 @@ 3. make install This sequence will put the framework in /Library/Framework/Python.framework, -the applications in /Applications/MacPython 2.5 and the unix tools in +the applications in "/Applications/MacPython 2.6" and the unix tools in /usr/local/bin. Installing in another place, for instance $HOME/Library/Frameworks if you have no admin privileges on your machine, has only been tested very lightly. This can be done by configuring with --enable-framework=$HOME/Library/Frameworks. -The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will -then also be deposited in $HOME. This is sub-optimal for the unix tools, which -you would want in $HOME/bin, but there is no easy way to fix this right now. - -Note that there are no references to the actual locations in the code or -resource files, so you are free to move things around afterwards. For example, -you could use --enable-framework=/tmp/newversion/Library/Frameworks and use -/tmp/newversion as the basis for an installer or something. +The other two directories, "/Applications/MacPython-2.6" and /usr/local/bin, +will then also be deposited in $HOME. This is sub-optimal for the unix tools, +which you would want in $HOME/bin, but there is no easy way to fix this right +now. If you want to install some part, but not all, read the main Makefile. The frameworkinstall is composed of a couple of sub-targets that install the @@ -111,7 +107,7 @@ There is an extra target frameworkinstallextras that is not part of the normal frameworkinstall which installs the Demo and Tools directories -into /Applications/MacPython-2.3, this is useful for binary distributions. +into "/Applications/MacPython 2.6", this is useful for binary distributions. What do all these programs do? =============================== From buildbot at python.org Thu Sep 7 14:05:56 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 12:05:56 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060907120556.2E90A1E4003@bag.python.org> The Buildbot has detected a new failure of alpha Debian trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%2520trunk/builds/550 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: nick.coghlan Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 14:50:46 2006 From: python-checkins at python.org (hyeshik.chang) Date: Thu, 7 Sep 2006 14:50:46 +0200 (CEST) Subject: [Python-checkins] r51811 - in python/branches/release25-maint: Lib/test/test_codecencodings_cn.py Lib/test/test_multibytecodec.py Misc/NEWS Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h Message-ID: <20060907125046.5C4D41E4003@bag.python.org> Author: hyeshik.chang Date: Thu Sep 7 14:50:38 2006 New Revision: 51811 Modified: python/branches/release25-maint/Lib/test/test_codecencodings_cn.py python/branches/release25-maint/Lib/test/test_multibytecodec.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/cjkcodecs/_codecs_cn.c python/branches/release25-maint/Modules/cjkcodecs/_codecs_iso2022.c python/branches/release25-maint/Modules/cjkcodecs/cjkcodecs.h Log: Backport from trunk r51737: Fixed a few bugs on cjkcodecs: - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 codepoints to conform the standard. - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 codepoints now. Modified: python/branches/release25-maint/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_codecencodings_cn.py (original) +++ python/branches/release25-maint/Lib/test/test_codecencodings_cn.py Thu Sep 7 14:50:38 2006 @@ -32,6 +32,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("\x83\x34\x83\x31", "strict", None), + (u"\u30fb", "strict", None), ) class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): @@ -45,6 +46,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"), + (u"\u30fb", "strict", "\x819\xa79"), ) has_iso10646 = True Modified: python/branches/release25-maint/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_multibytecodec.py (original) +++ python/branches/release25-maint/Lib/test/test_multibytecodec.py Thu Sep 7 14:50:38 2006 @@ -202,6 +202,12 @@ uni = u':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) + def test_iso2022_jp_g0(self): + self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) + for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): + e = u'\u3406'.encode(encoding) + self.failIf(filter(lambda x: x >= '\x80', e)) + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_MultibyteCodec)) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Thu Sep 7 14:50:38 2006 @@ -69,6 +69,12 @@ - Bug #1550714: fix SystemError from itertools.tee on negative value for n. +- Fixed a few bugs on cjkcodecs: + - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. + - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 + codepoints to conform the standard. + - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 + codepoints now. Tests ----- Modified: python/branches/release25-maint/Modules/cjkcodecs/_codecs_cn.c ============================================================================== --- python/branches/release25-maint/Modules/cjkcodecs/_codecs_cn.c (original) +++ python/branches/release25-maint/Modules/cjkcodecs/_codecs_cn.c Thu Sep 7 14:50:38 2006 @@ -15,14 +15,26 @@ #undef hz #endif -#define GBK_PREDECODE(dc1, dc2, assi) \ +/* GBK and GB2312 map differently in few codepoints that are listed below: + * + * gb2312 gbk + * A1A4 U+30FB KATAKANA MIDDLE DOT U+00B7 MIDDLE DOT + * A1AA U+2015 HORIZONTAL BAR U+2014 EM DASH + * A844 undefined U+2015 HORIZONTAL BAR + */ + +#define GBK_DECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ - else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; -#define GBK_PREENCODE(code, assi) \ + else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \ + else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \ + else TRYMAP_DEC(gbkext, assi, dc1, dc2); + +#define GBK_ENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ - else if ((code) == 0x00b7) (assi) = 0xa1a4; + else if ((code) == 0x00b7) (assi) = 0xa1a4; \ + else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code)); /* * GB2312 codec @@ -99,8 +111,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); + GBK_ENCODE(c, code) else return 1; OUT1((code >> 8) | 0x80) @@ -129,9 +140,7 @@ REQUIRE_INBUF(2) - GBK_PREDECODE(c, IN2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, IN2); + GBK_DECODE(c, IN2, **outbuf) else return 2; NEXT(2, 1) @@ -187,9 +196,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); - else TRYMAP_ENC(gb18030ext, code, c); + GBK_ENCODE(c, code) else { const struct _gb18030_to_unibmp_ranges *utrrange; @@ -287,9 +294,7 @@ return 4; } - GBK_PREDECODE(c, c2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, c2); + GBK_DECODE(c, c2, **outbuf) else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; Modified: python/branches/release25-maint/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/branches/release25-maint/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/branches/release25-maint/Modules/cjkcodecs/_codecs_iso2022.c Thu Sep 7 14:50:38 2006 @@ -854,7 +854,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -901,7 +901,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -992,7 +992,10 @@ /*-*- registry tables -*-*/ -#define REGISTRY_KSX1001 { CHARSET_KSX1001, 1, 2, \ +#define REGISTRY_KSX1001_G0 { CHARSET_KSX1001, 0, 2, \ + ksx1001_init, \ + ksx1001_decoder, ksx1001_encoder } +#define REGISTRY_KSX1001_G1 { CHARSET_KSX1001, 1, 2, \ ksx1001_init, \ ksx1001_decoder, ksx1001_encoder } #define REGISTRY_JISX0201_R { CHARSET_JISX0201_R, 0, 1, \ @@ -1034,7 +1037,7 @@ jisx0213_init, \ jisx0213_2004_2_decoder, \ jisx0213_2004_2_encoder } -#define REGISTRY_GB2312 { CHARSET_GB2312, 1, 2, \ +#define REGISTRY_GB2312 { CHARSET_GB2312, 0, 2, \ gb2312_init, \ gb2312_decoder, gb2312_encoder } #define REGISTRY_CNS11643_1 { CHARSET_CNS11643_1, 1, 2, \ @@ -1054,7 +1057,7 @@ }; static const struct iso2022_designation iso2022_kr_designations[] = { - REGISTRY_KSX1001, REGISTRY_SENTINEL + REGISTRY_KSX1001_G1, REGISTRY_SENTINEL }; CONFIGDEF(kr, 0) @@ -1071,7 +1074,7 @@ CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) static const struct iso2022_designation iso2022_jp_2_designations[] = { - REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; Modified: python/branches/release25-maint/Modules/cjkcodecs/cjkcodecs.h ============================================================================== --- python/branches/release25-maint/Modules/cjkcodecs/cjkcodecs.h (original) +++ python/branches/release25-maint/Modules/cjkcodecs/cjkcodecs.h Thu Sep 7 14:50:38 2006 @@ -159,29 +159,32 @@ #endif #define _TRYMAP_ENC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) -#define TRYMAP_ENC(charset, assi, uni) \ +#define TRYMAP_ENC_COND(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) +#define TRYMAP_ENC(charset, assi, uni) \ + if TRYMAP_ENC_COND(charset, assi, uni) + #define _TRYMAP_DEC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ - _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ + if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ From python-checkins at python.org Thu Sep 7 15:06:12 2006 From: python-checkins at python.org (hyeshik.chang) Date: Thu, 7 Sep 2006 15:06:12 +0200 (CEST) Subject: [Python-checkins] r51813 - in python/branches/release24-maint: Lib/test/test_codecencodings_cn.py Lib/test/test_multibytecodec.py Misc/NEWS Modules/cjkcodecs/_codecs_cn.c Modules/cjkcodecs/_codecs_iso2022.c Modules/cjkcodecs/cjkcodecs.h Message-ID: <20060907130612.9F4C51E4005@bag.python.org> Author: hyeshik.chang Date: Thu Sep 7 15:06:10 2006 New Revision: 51813 Modified: python/branches/release24-maint/Lib/test/test_codecencodings_cn.py python/branches/release24-maint/Lib/test/test_multibytecodec.py python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/cjkcodecs/_codecs_cn.c python/branches/release24-maint/Modules/cjkcodecs/_codecs_iso2022.c python/branches/release24-maint/Modules/cjkcodecs/cjkcodecs.h Log: Backport from trunk r51737: Fixed a few bugs on cjkcodecs: - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 codepoints to conform the standard. - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 codepoints now. Modified: python/branches/release24-maint/Lib/test/test_codecencodings_cn.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_codecencodings_cn.py (original) +++ python/branches/release24-maint/Lib/test/test_codecencodings_cn.py Thu Sep 7 15:06:10 2006 @@ -33,6 +33,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("\x83\x34\x83\x31", "strict", None), + (u"\u30fb", "strict", None), ) class Test_GB18030(test_multibytecodec_support.TestBase, unittest.TestCase): @@ -46,6 +47,7 @@ ("abc\x80\x80\xc1\xc4\xc8", "replace", u"abc\ufffd\u804a\ufffd"), ("abc\x80\x80\xc1\xc4", "ignore", u"abc\u804a"), ("abc\x84\x39\x84\x39\xc1\xc4", "replace", u"abc\ufffd\u804a"), + (u"\u30fb", "strict", "\x819\xa79"), ) has_iso10646 = True Modified: python/branches/release24-maint/Lib/test/test_multibytecodec.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_multibytecodec.py (original) +++ python/branches/release24-maint/Lib/test/test_multibytecodec.py Thu Sep 7 15:06:10 2006 @@ -81,6 +81,12 @@ uni = u':hu4:unit\xe9 de famille' self.assertEqual(iso2022jp2.decode('iso2022-jp-2'), uni) + def test_iso2022_jp_g0(self): + self.failIf('\x0e' in u'\N{SOFT HYPHEN}'.encode('iso-2022-jp-2')) + for encoding in ('iso-2022-jp-2004', 'iso-2022-jp-3'): + e = u'\u3406'.encode(encoding) + self.failIf(filter(lambda x: x >= '\x80', e)) + def test_main(): suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(Test_StreamWriter)) Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Thu Sep 7 15:06:10 2006 @@ -39,6 +39,12 @@ - Patch #1488312, Fix memory alignment problem on SPARC in unicode +- Fixed a few bugs on cjkcodecs: + - gbk and gb18030 codec now handle U+30FB KATAKANA MIDDLE DOT correctly. + - iso2022_jp_2 codec now encodes into G0 for KS X 1001, GB2312 + codepoints to conform the standard. + - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 + codepoints now. Extension Modules ----------------- Modified: python/branches/release24-maint/Modules/cjkcodecs/_codecs_cn.c ============================================================================== --- python/branches/release24-maint/Modules/cjkcodecs/_codecs_cn.c (original) +++ python/branches/release24-maint/Modules/cjkcodecs/_codecs_cn.c Thu Sep 7 15:06:10 2006 @@ -16,14 +16,26 @@ #undef hz #endif -#define GBK_PREDECODE(dc1, dc2, assi) \ +/* GBK and GB2312 map differently in few codepoints that are listed below: + * + * gb2312 gbk + * A1A4 U+30FB KATAKANA MIDDLE DOT U+00B7 MIDDLE DOT + * A1AA U+2015 HORIZONTAL BAR U+2014 EM DASH + * A844 undefined U+2015 HORIZONTAL BAR + */ + +#define GBK_DECODE(dc1, dc2, assi) \ if ((dc1) == 0xa1 && (dc2) == 0xaa) (assi) = 0x2014; \ else if ((dc1) == 0xa8 && (dc2) == 0x44) (assi) = 0x2015; \ - else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; -#define GBK_PREENCODE(code, assi) \ + else if ((dc1) == 0xa1 && (dc2) == 0xa4) (assi) = 0x00b7; \ + else TRYMAP_DEC(gb2312, assi, dc1 ^ 0x80, dc2 ^ 0x80); \ + else TRYMAP_DEC(gbkext, assi, dc1, dc2); + +#define GBK_ENCODE(code, assi) \ if ((code) == 0x2014) (assi) = 0xa1aa; \ else if ((code) == 0x2015) (assi) = 0xa844; \ - else if ((code) == 0x00b7) (assi) = 0xa1a4; + else if ((code) == 0x00b7) (assi) = 0xa1a4; \ + else if ((code) != 0x30fb && TRYMAP_ENC_COND(gbcommon, assi, code)); /* * GB2312 codec @@ -100,8 +112,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); + GBK_ENCODE(c, code) else return 1; OUT1((code >> 8) | 0x80) @@ -130,9 +141,7 @@ REQUIRE_INBUF(2) - GBK_PREDECODE(c, IN2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, IN2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, IN2); + GBK_DECODE(c, IN2, **outbuf) else return 2; NEXT(2, 1) @@ -188,9 +197,7 @@ REQUIRE_OUTBUF(2) - GBK_PREENCODE(c, code) - else TRYMAP_ENC(gbcommon, code, c); - else TRYMAP_ENC(gb18030ext, code, c); + GBK_ENCODE(c, code) else { const struct _gb18030_to_unibmp_ranges *utrrange; @@ -288,9 +295,7 @@ return 4; } - GBK_PREDECODE(c, c2, **outbuf) - else TRYMAP_DEC(gb2312, **outbuf, c ^ 0x80, c2 ^ 0x80); - else TRYMAP_DEC(gbkext, **outbuf, c, c2); + GBK_DECODE(c, c2, **outbuf) else TRYMAP_DEC(gb18030ext, **outbuf, c, c2); else return 2; Modified: python/branches/release24-maint/Modules/cjkcodecs/_codecs_iso2022.c ============================================================================== --- python/branches/release24-maint/Modules/cjkcodecs/_codecs_iso2022.c (original) +++ python/branches/release24-maint/Modules/cjkcodecs/_codecs_iso2022.c Thu Sep 7 15:06:10 2006 @@ -855,7 +855,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -902,7 +902,7 @@ if (coded == MAP_UNMAPPABLE || coded == MAP_MULTIPLE_AVAIL) return coded; else if (coded & 0x8000) - return coded; + return coded & 0x7fff; else return MAP_UNMAPPABLE; } @@ -993,7 +993,10 @@ /*-*- registry tables -*-*/ -#define REGISTRY_KSX1001 { CHARSET_KSX1001, 1, 2, \ +#define REGISTRY_KSX1001_G0 { CHARSET_KSX1001, 0, 2, \ + ksx1001_init, \ + ksx1001_decoder, ksx1001_encoder } +#define REGISTRY_KSX1001_G1 { CHARSET_KSX1001, 1, 2, \ ksx1001_init, \ ksx1001_decoder, ksx1001_encoder } #define REGISTRY_JISX0201_R { CHARSET_JISX0201_R, 0, 1, \ @@ -1035,7 +1038,7 @@ jisx0213_init, \ jisx0213_2004_2_decoder, \ jisx0213_2004_2_encoder } -#define REGISTRY_GB2312 { CHARSET_GB2312, 1, 2, \ +#define REGISTRY_GB2312 { CHARSET_GB2312, 0, 2, \ gb2312_init, \ gb2312_decoder, gb2312_encoder } #define REGISTRY_CNS11643_1 { CHARSET_CNS11643_1, 1, 2, \ @@ -1055,7 +1058,7 @@ }; static const struct iso2022_designation iso2022_kr_designations[] = { - REGISTRY_KSX1001, REGISTRY_SENTINEL + REGISTRY_KSX1001_G1, REGISTRY_SENTINEL }; CONFIGDEF(kr, 0) @@ -1072,7 +1075,7 @@ CONFIGDEF(jp_1, NO_SHIFT | USE_JISX0208_EXT) static const struct iso2022_designation iso2022_jp_2_designations[] = { - REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001, + REGISTRY_JISX0208, REGISTRY_JISX0212, REGISTRY_KSX1001_G0, REGISTRY_GB2312, REGISTRY_JISX0201_R, REGISTRY_JISX0208_O, REGISTRY_ISO8859_1, REGISTRY_ISO8859_7, REGISTRY_SENTINEL }; Modified: python/branches/release24-maint/Modules/cjkcodecs/cjkcodecs.h ============================================================================== --- python/branches/release24-maint/Modules/cjkcodecs/cjkcodecs.h (original) +++ python/branches/release24-maint/Modules/cjkcodecs/cjkcodecs.h Thu Sep 7 15:06:10 2006 @@ -156,29 +156,32 @@ #endif #define _TRYMAP_ENC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != NOCHAR) -#define TRYMAP_ENC(charset, assi, uni) \ +#define TRYMAP_ENC_COND(charset, assi, uni) \ _TRYMAP_ENC(&charset##_encmap[(uni) >> 8], assi, (uni) & 0xff) +#define TRYMAP_ENC(charset, assi, uni) \ + if TRYMAP_ENC_COND(charset, assi, uni) + #define _TRYMAP_DEC(m, assi, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && ((assi) = (m)->map[(val) - \ (m)->bottom]) != UNIINV) #define TRYMAP_DEC(charset, assi, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[c1], assi, c2) #define _TRYMAP_ENC_MPLANE(m, assplane, asshi, asslo, val) \ - if ((m)->map != NULL && (val) >= (m)->bottom && \ + ((m)->map != NULL && (val) >= (m)->bottom && \ (val)<= (m)->top && \ ((assplane) = (m)->map[((val) - (m)->bottom)*3]) != 0 && \ (((asshi) = (m)->map[((val) - (m)->bottom)*3 + 1]), 1) && \ (((asslo) = (m)->map[((val) - (m)->bottom)*3 + 2]), 1)) #define TRYMAP_ENC_MPLANE(charset, assplane, asshi, asslo, uni) \ - _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ + if _TRYMAP_ENC_MPLANE(&charset##_encmap[(uni) >> 8], \ assplane, asshi, asslo, (uni) & 0xff) #define TRYMAP_DEC_MPLANE(charset, assi, plane, c1, c2) \ - _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) + if _TRYMAP_DEC(&charset##_decmap[plane][c1], assi, c2) #if Py_UNICODE_SIZE == 2 #define DECODE_SURROGATE(c) \ From buildbot at python.org Thu Sep 7 15:33:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 13:33:01 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060907133302.07D061E4005@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper trunk. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%2520trunk/builds/96 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 15:58:32 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 7 Sep 2006 15:58:32 +0200 (CEST) Subject: [Python-checkins] r51814 - python/trunk/Misc/HISTORY Message-ID: <20060907135832.D54F01E4003@bag.python.org> Author: andrew.kuchling Date: Thu Sep 7 15:56:23 2006 New Revision: 51814 Modified: python/trunk/Misc/HISTORY Log: Typo fix Modified: python/trunk/Misc/HISTORY ============================================================================== --- python/trunk/Misc/HISTORY (original) +++ python/trunk/Misc/HISTORY Thu Sep 7 15:56:23 2006 @@ -11679,7 +11679,7 @@ - The way GNU readline is configured is totally different. The --with-readline configure option is gone. It is now an extension module, which may be loaded dynamically. You must enable it (and -specify the correct linraries to link with) in the Modules/Setup file. +specify the correct libraries to link with) in the Modules/Setup file. Importing the module installs some hooks which enable command line editing. When the interpreter shell is invoked interactively, it attempts to import the readline module; when this fails, the default From python-checkins at python.org Thu Sep 7 16:00:17 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 7 Sep 2006 16:00:17 +0200 (CEST) Subject: [Python-checkins] r51815 - python/trunk/Modules/readline.c Message-ID: <20060907140017.9CCB91E4003@bag.python.org> Author: andrew.kuchling Date: Thu Sep 7 15:59:38 2006 New Revision: 51815 Modified: python/trunk/Modules/readline.c Log: [Bug #1552726] Avoid repeatedly polling in interactive mode -- only put a timeout on the select() if an input hook has been defined. Patch by Richard Boulton. This select() code is only executed with readline 2.1, or if READLINE_CALLBACKS is defined. Backport candidate for 2.5, 2.4, probably earlier versions too. Modified: python/trunk/Modules/readline.c ============================================================================== --- python/trunk/Modules/readline.c (original) +++ python/trunk/Modules/readline.c Thu Sep 7 15:59:38 2006 @@ -768,10 +768,16 @@ while (!has_input) { struct timeval timeout = {0, 100000}; /* 0.1 seconds */ + + /* [Bug #1552726] Only limit the pause if an input hook has been + defined. */ + struct timeval *timeoutp = NULL; + if (PyOS_InputHook) + timeoutp = &timeout; FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset, - NULL, NULL, &timeout); + NULL, NULL, timeoutp); if(PyOS_InputHook) PyOS_InputHook(); } From buildbot at python.org Thu Sep 7 16:41:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 14:41:28 +0000 Subject: [Python-checkins] buildbot warnings in S-390 Debian 2.5 Message-ID: <20060907144128.9D0BD1E4003@bag.python.org> The Buildbot has detected a new failure of S-390 Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/S-390%2520Debian%25202.5/builds/21 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: hyeshik.chang Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 17:06:54 2006 From: python-checkins at python.org (armin.rigo) Date: Thu, 7 Sep 2006 17:06:54 +0200 (CEST) Subject: [Python-checkins] r51816 - python/trunk/Doc/perl/python.perl Message-ID: <20060907150654.950421E4003@bag.python.org> Author: armin.rigo Date: Thu Sep 7 17:06:00 2006 New Revision: 51816 Modified: python/trunk/Doc/perl/python.perl Log: Add a warning notice on top of the generated grammar.txt. Modified: python/trunk/Doc/perl/python.perl ============================================================================== --- python/trunk/Doc/perl/python.perl (original) +++ python/trunk/Doc/perl/python.perl Thu Sep 7 17:06:00 2006 @@ -883,6 +883,12 @@ $filename = 'grammar.txt'; } open(GRAMMAR, ">$filename") || die "\n$!\n"; + print GRAMMAR "##################################################\n"; + print GRAMMAR "# This file is only meant to be a guide, #\n"; + print GRAMMAR "# and differs in small ways from the real #\n"; + print GRAMMAR "# grammar. The exact reference is the file #\n"; + print GRAMMAR "# Grammar/Grammar distributed with the source. #\n"; + print GRAMMAR "##################################################\n"; print GRAMMAR strip_grammar_markup($DefinedGrammars{$lang}); close(GRAMMAR); print "Wrote grammar file $filename\n"; From buildbot at python.org Thu Sep 7 18:53:37 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 16:53:37 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060907165337.9E0B31E4003@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1158 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Thu Sep 7 20:07:36 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 07 Sep 2006 18:07:36 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian 2.5 Message-ID: <20060907180736.52BF61E4005@bag.python.org> The Buildbot has detected a new failure of MIPS Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/MIPS%2520Debian%25202.5/builds/10 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: ronald.oussoren Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From python-checkins at python.org Thu Sep 7 20:27:22 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 7 Sep 2006 20:27:22 +0200 (CEST) Subject: [Python-checkins] r51818 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060907182722.137181E4003@bag.python.org> Author: brett.cannon Date: Thu Sep 7 20:27:20 2006 New Revision: 51818 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Changes based on Ka-Ping Yee's comments. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Thu Sep 7 20:27:20 2006 @@ -231,15 +231,17 @@ provide a private namespace for the class and instances that are not accessible by other objects. -The Python language has no such thing as a private namespace. The -language has the philosophy that if exposing something to the -programmer could provide some use, then it is exposed. This has led -to Python having a wonderful amount of introspection abilities. -Unfortunately this makes the possibility of a private namespace -non-existent. This poses an issue for providing proxies for resources -since there is no way in Python code to hide the reference to a -resource. It also makes providing security at the object level using -object-capabilities non-existent in pure Python code. +The Python language has no such thing as a persistent, private +namespace. The language has the philosophy that if exposing something +to the programmer could provide some use, then it is exposed. This +has led to Python having a wonderful amount of introspection +abilities. Unfortunately this makes the possibility of a private +namespace non-existent. This poses an issue for providing proxies for +resources since there is no way in Python code to hide the reference +to a resource. It also makes providing security at the object level +using object-capabilities non-existent in pure Python code without +changing the language (e.g., protecting nested scoped variables from +external introspection). Luckily, the Python virtual machine *does* provide a private namespace, albeit not for pure Python source code. If you use the Python/C @@ -281,8 +283,8 @@ * An interpreter cannot gain abilties the Python process possesses without explicitly being given those abilities. + With the Python process being the powerbox, if an interpreter - could gain whatever abilities it wanted to then the security - domain would be completely breached. + could gain whatever abilities it wanted to then the security + domain would be completely breached. * An interpreter cannot influence another interpreter directly at the Python level without explicitly allowing it. + This includes preventing communicating with another interpreter. @@ -312,20 +314,20 @@ * Python bytecode is always distrusted. + Malicious bytecode can bring down an interpreter. * Pure Python source code is always safe on its own. - + Malicious abilities are derived from C extension modules, - built-in modules, and unsafe types implemented in C, not from - pure Python source. + + Python source code is not able to violate the restrictions + placed upon the interpreter it is running in. + + Possibly malicious abilities are derived from C extension + modules, built-in modules, and unsafe types implemented in C, + not from pure Python source. * A sub-interpreter started by another interpreter does not inherit any state. + The sub-interpreter starts out with a fresh global namespace and whatever built-ins it was initially given. -Implementation -/////////////////////////////////////// Guiding Principles -======================== +/////////////////////////////////////// To begin, the Python process garners all power as the powerbox. It is up to the process to initially hand out access to resources and @@ -359,8 +361,8 @@ Backwards-compatibility will not be a hindrance upon the design or implementation of the security model. Because the security model will inherently remove resources and abilities that existing code expects, -it is not reasonable to expect existing code to work in a sandboxed -interpreter. +it is not reasonable to expect all existing code to work in a +sandboxed interpreter. Keeping Python "pythonic" is required for all design decisions. In general, being pythonic means that something fits the general @@ -374,6 +376,10 @@ is a price that must be paid in order for Python to continue to be the language that it is. + +Implementation +/////////////////////////////////////// + Restricting what is in the built-in namespace and the safe-guarding the interpreter (which includes safe-guarding the built-in types) is where the majority of security will come from. Imports and the @@ -579,7 +585,7 @@ * ``__del__`` created in sandboxed interpreter but object is cleaned up in unprotected interpreter. * Using frames to walk the frame stack back to another interpreter. -* XXX +* XXX A generator's execution frame? Making the ``sys`` Module Safe From python-checkins at python.org Thu Sep 7 20:56:28 2006 From: python-checkins at python.org (thomas.heller) Date: Thu, 7 Sep 2006 20:56:28 +0200 (CEST) Subject: [Python-checkins] r51819 - in python/trunk: Lib/ctypes/test/test_bitfields.py Modules/_ctypes/stgdict.c Message-ID: <20060907185628.A62B71E4003@bag.python.org> Author: thomas.heller Date: Thu Sep 7 20:56:28 2006 New Revision: 51819 Modified: python/trunk/Lib/ctypes/test/test_bitfields.py python/trunk/Modules/_ctypes/stgdict.c Log: Anonymous structure fields that have a bit-width specified did not work, and they gave a strange error message from PyArg_ParseTuple: function takes exactly 2 arguments (3 given). With tests. Modified: python/trunk/Lib/ctypes/test/test_bitfields.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_bitfields.py (original) +++ python/trunk/Lib/ctypes/test/test_bitfields.py Thu Sep 7 20:56:28 2006 @@ -215,5 +215,14 @@ ("b", c_ubyte, 4)] self.failUnlessEqual(sizeof(X), sizeof(c_byte)) + def test_anon_bitfields(self): + # anonymous bit-fields gave a strange error message + class X(Structure): + _fields_ = [("a", c_byte, 4), + ("b", c_ubyte, 4)] + class Y(Structure): + _anonymous_ = ["_"] + _fields_ = [("_", X)] + if __name__ == "__main__": unittest.main() Modified: python/trunk/Modules/_ctypes/stgdict.c ============================================================================== --- python/trunk/Modules/_ctypes/stgdict.c (original) +++ python/trunk/Modules/_ctypes/stgdict.c Thu Sep 7 20:56:28 2006 @@ -177,11 +177,11 @@ for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ - PyObject *fname, *ftype; + PyObject *fname, *ftype, *bits; CFieldObject *fdescr; CFieldObject *new_descr; /* Convert to PyArg_UnpackTuple... */ - if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { + if (!PyArg_ParseTuple(pair, "OO|O", &fname, &ftype, &bits)) { Py_DECREF(fieldlist); return -1; } From theller at python.net Thu Sep 7 21:08:01 2006 From: theller at python.net (Thomas Heller) Date: Thu, 07 Sep 2006 21:08:01 +0200 Subject: [Python-checkins] r51819 - in python/trunk: Lib/ctypes/test/test_bitfields.py Modules/_ctypes/stgdict.c In-Reply-To: <20060907185628.A62B71E4003@bag.python.org> References: <20060907185628.A62B71E4003@bag.python.org> Message-ID: <45006E11.2090102@python.net> Neal, I would like to backport this to release25-maint. thomas.heller schrieb: > Author: thomas.heller > Date: Thu Sep 7 20:56:28 2006 > New Revision: 51819 > > Modified: > python/trunk/Lib/ctypes/test/test_bitfields.py > python/trunk/Modules/_ctypes/stgdict.c > Log: > Anonymous structure fields that have a bit-width specified did not work, > and they gave a strange error message from PyArg_ParseTuple: > function takes exactly 2 arguments (3 given). > > With tests. > > Modified: python/trunk/Lib/ctypes/test/test_bitfields.py > ============================================================================== > --- python/trunk/Lib/ctypes/test/test_bitfields.py (original) > +++ python/trunk/Lib/ctypes/test/test_bitfields.py Thu Sep 7 20:56:28 2006 > @@ -215,5 +215,14 @@ > ("b", c_ubyte, 4)] > self.failUnlessEqual(sizeof(X), sizeof(c_byte)) > > + def test_anon_bitfields(self): > + # anonymous bit-fields gave a strange error message > + class X(Structure): > + _fields_ = [("a", c_byte, 4), > + ("b", c_ubyte, 4)] > + class Y(Structure): > + _anonymous_ = ["_"] > + _fields_ = [("_", X)] > + > if __name__ == "__main__": > unittest.main() > > Modified: python/trunk/Modules/_ctypes/stgdict.c > ============================================================================== > --- python/trunk/Modules/_ctypes/stgdict.c (original) > +++ python/trunk/Modules/_ctypes/stgdict.c Thu Sep 7 20:56:28 2006 > @@ -177,11 +177,11 @@ > > for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { > PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ > - PyObject *fname, *ftype; > + PyObject *fname, *ftype, *bits; > CFieldObject *fdescr; > CFieldObject *new_descr; > /* Convert to PyArg_UnpackTuple... */ > - if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { > + if (!PyArg_ParseTuple(pair, "OO|O", &fname, &ftype, &bits)) { > Py_DECREF(fieldlist); > return -1; > } From python-checkins at python.org Thu Sep 7 21:09:55 2006 From: python-checkins at python.org (thomas.heller) Date: Thu, 7 Sep 2006 21:09:55 +0200 (CEST) Subject: [Python-checkins] r51820 - in python/trunk: Lib/ctypes/test/test_cast.py Modules/_ctypes/_ctypes.c Message-ID: <20060907190955.D28D81E4003@bag.python.org> Author: thomas.heller Date: Thu Sep 7 21:09:54 2006 New Revision: 51820 Modified: python/trunk/Lib/ctypes/test/test_cast.py python/trunk/Modules/_ctypes/_ctypes.c Log: The cast function did not accept c_char_p or c_wchar_p instances as first argument, and failed with a 'bad argument to internal function' error message. Modified: python/trunk/Lib/ctypes/test/test_cast.py ============================================================================== --- python/trunk/Lib/ctypes/test/test_cast.py (original) +++ python/trunk/Lib/ctypes/test/test_cast.py Thu Sep 7 21:09:54 2006 @@ -57,5 +57,21 @@ c_int() self.failUnlessEqual(p[:4], [1, 2, 96, 4]) + def test_char_p(self): + # This didn't work: bad argument to internal function + s = c_char_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_char_p).value, + "hiho") + + try: + c_wchar_p + except NameError: + pass + else: + def test_wchar_p(self): + s = c_wchar_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_wchar_p).value, + "hiho") + if __name__ == "__main__": unittest.main() Modified: python/trunk/Modules/_ctypes/_ctypes.c ============================================================================== --- python/trunk/Modules/_ctypes/_ctypes.c (original) +++ python/trunk/Modules/_ctypes/_ctypes.c Thu Sep 7 21:09:54 2006 @@ -4597,11 +4597,11 @@ if (obj->b_objects == NULL) goto failed; } + Py_XINCREF(obj->b_objects); result->b_objects = obj->b_objects; - if (result->b_objects) { + if (result->b_objects && PyDict_Check(result->b_objects)) { PyObject *index; int rc; - Py_INCREF(obj->b_objects); index = PyLong_FromVoidPtr((void *)src); if (index == NULL) goto failed; From theller at python.net Thu Sep 7 21:13:21 2006 From: theller at python.net (Thomas Heller) Date: Thu, 07 Sep 2006 21:13:21 +0200 Subject: [Python-checkins] r51820 - in python/trunk: Lib/ctypes/test/test_cast.py Modules/_ctypes/_ctypes.c In-Reply-To: <20060907190955.D28D81E4003@bag.python.org> References: <20060907190955.D28D81E4003@bag.python.org> Message-ID: <45006F51.90808@python.net> Neal, same for this: should be applied to release25-maint before release. thomas.heller schrieb: > Author: thomas.heller > Date: Thu Sep 7 21:09:54 2006 > New Revision: 51820 > > Modified: > python/trunk/Lib/ctypes/test/test_cast.py > python/trunk/Modules/_ctypes/_ctypes.c > Log: > The cast function did not accept c_char_p or c_wchar_p instances > as first argument, and failed with a 'bad argument to internal function' > error message. > > > Modified: python/trunk/Lib/ctypes/test/test_cast.py > ============================================================================== > --- python/trunk/Lib/ctypes/test/test_cast.py (original) > +++ python/trunk/Lib/ctypes/test/test_cast.py Thu Sep 7 21:09:54 2006 > @@ -57,5 +57,21 @@ > c_int() > self.failUnlessEqual(p[:4], [1, 2, 96, 4]) > > + def test_char_p(self): > + # This didn't work: bad argument to internal function > + s = c_char_p("hiho") > + self.failUnlessEqual(cast(cast(s, c_void_p), c_char_p).value, > + "hiho") > + > + try: > + c_wchar_p > + except NameError: > + pass > + else: > + def test_wchar_p(self): > + s = c_wchar_p("hiho") > + self.failUnlessEqual(cast(cast(s, c_void_p), c_wchar_p).value, > + "hiho") > + > if __name__ == "__main__": > unittest.main() > > Modified: python/trunk/Modules/_ctypes/_ctypes.c > ============================================================================== > --- python/trunk/Modules/_ctypes/_ctypes.c (original) > +++ python/trunk/Modules/_ctypes/_ctypes.c Thu Sep 7 21:09:54 2006 > @@ -4597,11 +4597,11 @@ > if (obj->b_objects == NULL) > goto failed; > } > + Py_XINCREF(obj->b_objects); > result->b_objects = obj->b_objects; > - if (result->b_objects) { > + if (result->b_objects && PyDict_Check(result->b_objects)) { > PyObject *index; > int rc; > - Py_INCREF(obj->b_objects); > index = PyLong_FromVoidPtr((void *)src); > if (index == NULL) > goto failed; From python-checkins at python.org Thu Sep 7 22:02:36 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 7 Sep 2006 22:02:36 +0200 (CEST) Subject: [Python-checkins] r51821 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060907200236.644871E4003@bag.python.org> Author: brett.cannon Date: Thu Sep 7 22:02:33 2006 New Revision: 51821 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Finish specifying where information in 'sys' information is found and how wide of an influence it has. Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Thu Sep 7 22:02:33 2006 @@ -674,44 +674,47 @@ The dangerous settings are: -* argv -* subversion -* _current_frames() -* __displayhook__ (?) -* __excepthook__ (?) -* dllhandle -* exc_type +* argv : Modules/main.c:Py_Main() +* subversion : Python/sysmodule.c:_PySys_Init() +* _current_frames() : per-thread (Python/sysmodule.c:sys_current_frames()) +* __displayhook__ : Python/sysmodule.c:_PySys_Init() + (?) +* __excepthook__ : Python/sysmodule.c:_PySys_Init() + (?) +* dllhandle : Python/sysmodule.c:_PySys_Init() +* exc_type : Python/ceval.c:(re)?set_exc_info() Deprecated since 1.5 . -* exc_value +* exc_value : Python/ceval.c:(re)?set_exc_info() Deprecated since 1.5 . -* exc_traceback +* exc_traceback : Python/ceval.c:(re)?set_exc_info() Deprecated since 1.5 . -* exc_prefix +* exec_prefix : Python/sysmodule.c:_PySys_Init() Exposes filesystem information. -* executable +* executable : Python/sysmodule.c:_PySys_Init() Exposes filesystem information. -* exitfunc +* exitfunc : set by user Deprecated. -* _getframe() -* getwindowsversion() +* _getframe() : per-thread (Python/sysmodule.c:sys_getframe()) +* getwindowsversion() : per-process (Python/sysmodule.c:sys_getwindowsversion()) Exposes OS information. -* modules -* path -* platform +* modules : per-interpreter (Python/pythonrun.c:(Py_InitializeEx() | Py_NewInterpreter())) +* path : per-interpreter (Python/sysmodule.c:PySys_SetPath() called by Py_InitializeEx() and Py_NewInterpreter()) +* platform : Python/sysmodule.c:_PySys_Init() Exposes OS information. -* prefix +* prefix : Python/sysmodule.c:_PySys_Init() Exposes filesystem information. -* setcheckinterval() -* setdefaultencoding() -* setdlopenflags() -* setprofile() -* setrecursionlimit() -* settrace() -* settcsdump() -* __stdin__ -* __stdout__ -* __stderr__ -* winver +* setcheckinterval() : per-process (Python/sysmodule.c:sys_setcheckinterval()) +* setdefaultencoding() : per-process +* (Python/sysmodule.c:sys_setdefaultencoding() using PyUnicode_SetDefaultEncoding()) +* setdlopenflags() : per-interpreter (Python/sysmodule.c:sys_setdlopenflags()) +* setprofile() : per-thread (Python/sysmodule.c:sys_setprofile() using PyEval_SetProfile()) +* setrecursionlimit() : per-process (Python/sysmodule.c:sys_setrecursionlimit() using Py_SetRecursionLimit()) +* settrace() : per-thread (Python/sysmodule.c:sys_settrace() using PyEval_SetTrace()) +* settcsdump() : per-interpreter (Python/sysmodule.c:set_settscdump()) +* __stdin__ : Python/sysmodule.c:_PySys_Init() +* __stdout__ : Python/sysmodule.c:_PySys_Init() +* __stderr__ : Python/sysmodule.c:_PySys_Init() +* winver : Python/sysmodule.c:_PySys_Init() Exposes OS information. From python-checkins at python.org Fri Sep 8 02:30:03 2006 From: python-checkins at python.org (jackilyn.hoxworth) Date: Fri, 8 Sep 2006 02:30:03 +0200 (CEST) Subject: [Python-checkins] r51822 - python/branches/hoxworth-stdlib_logging-soc/test_asyncore_logging.py python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Message-ID: <20060908003003.C5E211E4003@bag.python.org> Author: jackilyn.hoxworth Date: Fri Sep 8 02:30:01 2006 New Revision: 51822 Added: python/branches/hoxworth-stdlib_logging-soc/test_asyncore_logging.py python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Log: Added: python/branches/hoxworth-stdlib_logging-soc/test_asyncore_logging.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_asyncore_logging.py Fri Sep 8 02:30:01 2006 @@ -0,0 +1,33 @@ +# !/usr/bin/env python + +""" + +Test harness for the standard library logging module. + +""" + +import logging +import asyncore +from cStringIO import StringIO + +log=logging.getLogger("py.asyncore") +stringLog = StringIO() + +# define the handler and level +handler = logging.StreamHandler(stringLog) +log.setLevel(logging.INFO) + +# set a format for the output +formatter = logging.Formatter('%(name)s: %(levelname)s %(message)s') +handler.setFormatter(formatter) + +# add the handler to the logger +log.addHandler(handler) + +asyncore.dispatcher().log("message") +print stringLog.getvalue() # For testing purposes + +if stringLog.getvalue() == "py.asyncore.dispatcher.hits: INFO message" + "\n": + print "it worked" +else: + print "it didn't work" Added: python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py ============================================================================== --- (empty file) +++ python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Fri Sep 8 02:30:01 2006 @@ -0,0 +1,360 @@ +""" + Tests for the mhlib module + Nick Mathewson +""" + +### BUG: This suite doesn't currently test the mime functionality of +### mhlib. It should. + +import unittest +from test.test_support import run_unittest, TESTFN, TestSkipped +import os, StringIO +import sys +import mhlib +import logging, StringIO + +if (sys.platform.startswith("win") or sys.platform=="riscos" or + sys.platform.startswith("atheos")): + # mhlib.updateline() renames a file to the name of a file that already + # exists. That causes a reasonable OS to complain in test_sequence + # here, like the "OSError: [Errno 17] File exists" raised on Windows. + # mhlib's listsubfolders() and listallfolders() do something with + # link counts, and that causes test_listfolders() here to get back + # an empty list from its call of listallfolders(). + # The other tests here pass on Windows. + raise TestSkipped("skipped on %s -- " % sys.platform + + "too many Unix assumptions") + +_mhroot = TESTFN+"_MH" +_mhpath = os.path.join(_mhroot, "MH") +_mhprofile = os.path.join(_mhroot, ".mh_profile") + +def normF(f): + return os.path.join(*f.split('/')) + +def writeFile(fname, contents): + dir = os.path.split(fname)[0] + if dir and not os.path.exists(dir): + mkdirs(dir) + f = open(fname, 'w') + f.write(contents) + f.close() + +def readFile(fname): + f = open(fname) + r = f.read() + f.close() + return r + +def writeProfile(dict): + contents = [ "%s: %s\n" % (k, v) for k, v in dict.iteritems() ] + writeFile(_mhprofile, "".join(contents)) + +def writeContext(folder): + folder = normF(folder) + writeFile(os.path.join(_mhpath, "context"), + "Current-Folder: %s\n" % folder) + +def writeCurMessage(folder, cur): + folder = normF(folder) + writeFile(os.path.join(_mhpath, folder, ".mh_sequences"), + "cur: %s\n"%cur) + +def writeMessage(folder, n, headers, body): + folder = normF(folder) + headers = "".join([ "%s: %s\n" % (k, v) for k, v in headers.iteritems() ]) + contents = "%s\n%s\n" % (headers,body) + mkdirs(os.path.join(_mhpath, folder)) + writeFile(os.path.join(_mhpath, folder, str(n)), contents) + +def getMH(): + return mhlib.MH(os.path.abspath(_mhpath), _mhprofile) + +def sortLines(s): + lines = s.split("\n") + lines = [ line.strip() for line in lines if len(line) >= 2 ] + lines.sort() + return lines + +# These next 2 functions are copied from test_glob.py. +def mkdirs(fname): + if os.path.exists(fname) or fname == '': + return + base, file = os.path.split(fname) + mkdirs(base) + os.mkdir(fname) + +def deltree(fname): + if not os.path.exists(fname): + return + for f in os.listdir(fname): + fullname = os.path.join(fname, f) + if os.path.isdir(fullname): + deltree(fullname) + else: + try: + os.unlink(fullname) + except: + pass + try: + os.rmdir(fname) + except: + pass + +class MhlibTests(unittest.TestCase): + def setUp(self): + deltree(_mhroot) + mkdirs(_mhpath) + writeProfile({'Path' : os.path.abspath(_mhpath), + 'Editor': 'emacs', + 'ignored-attribute': 'camping holiday'}) + # Note: These headers aren't really conformant to RFC822, but + # mhlib shouldn't care about that. + + # An inbox with a couple of messages. + writeMessage('inbox', 1, + {'From': 'Mrs. Premise', + 'To': 'Mrs. Conclusion', + 'Date': '18 July 2001'}, "Hullo, Mrs. Conclusion!\n") + writeMessage('inbox', 2, + {'From': 'Mrs. Conclusion', + 'To': 'Mrs. Premise', + 'Date': '29 July 2001'}, "Hullo, Mrs. Premise!\n") + + # A folder with many messages + for i in range(5, 101)+range(101, 201, 2): + writeMessage('wide', i, + {'From': 'nowhere', 'Subject': 'message #%s' % i}, + "This is message number %s\n" % i) + + # Test Logging + self.log = log = logging.getLogger("py.mhlib") + self.outlog = StringIO.StringIO() + self.loghandler = logging.StreamHandler(self.outlog) + log.setLevel(logging.INFO) + log.addHandler(self.loghandler) + self.str = "mhlib" + + # The default setup permits warnings + mhlib._log.warn("Testing log of " + self.str) + + # A deeply nested folder + def deep(folder, n): + writeMessage(folder, n, + {'Subject': 'Message %s/%s' % (folder, n) }, + "This is message number %s in %s\n" % (n, folder) ) + deep('deep/f1', 1) + deep('deep/f1', 2) + deep('deep/f1', 3) + deep('deep/f2', 4) + deep('deep/f2', 6) + deep('deep', 3) + deep('deep/f2/f3', 1) + deep('deep/f2/f3', 2) + + def tearDown(self): + deltree(_mhroot) + + def test_basic(self): + writeContext('inbox') + writeCurMessage('inbox', 2) + mh = getMH() + + eq = self.assertEquals + eq(mh.getprofile('Editor'), 'emacs') + eq(mh.getprofile('not-set'), None) + eq(mh.getpath(), os.path.abspath(_mhpath)) + eq(mh.getcontext(), 'inbox') + + mh.setcontext('wide') + eq(mh.getcontext(), 'wide') + eq(readFile(os.path.join(_mhpath, 'context')), + "Current-Folder: wide\n") + + mh.setcontext('inbox') + + inbox = mh.openfolder('inbox') + eq(inbox.getfullname(), + os.path.join(os.path.abspath(_mhpath), 'inbox')) + eq(inbox.getsequencesfilename(), + os.path.join(os.path.abspath(_mhpath), 'inbox', '.mh_sequences')) + eq(inbox.getmessagefilename(1), + os.path.join(os.path.abspath(_mhpath), 'inbox', '1')) + + def test_listfolders(self): + mh = getMH() + eq = self.assertEquals + + folders = mh.listfolders() + folders.sort() + eq(folders, ['deep', 'inbox', 'wide']) + + folders = mh.listallfolders() + folders.sort() + tfolders = map(normF, ['deep', 'deep/f1', 'deep/f2', 'deep/f2/f3', + 'inbox', 'wide']) + tfolders.sort() + eq(folders, tfolders) + + folders = mh.listsubfolders('deep') + folders.sort() + eq(folders, map(normF, ['deep/f1', 'deep/f2'])) + + folders = mh.listallsubfolders('deep') + folders.sort() + eq(folders, map(normF, ['deep/f1', 'deep/f2', 'deep/f2/f3'])) + eq(mh.listsubfolders(normF('deep/f2')), [normF('deep/f2/f3')]) + + eq(mh.listsubfolders('inbox'), []) + eq(mh.listallsubfolders('inbox'), []) + + def test_sequence(self): + mh = getMH() + eq = self.assertEquals + writeCurMessage('wide', 55) + + f = mh.openfolder('wide') + all = f.listmessages() + eq(all, range(5, 101)+range(101, 201, 2)) + eq(f.getcurrent(), 55) + f.setcurrent(99) + eq(readFile(os.path.join(_mhpath, 'wide', '.mh_sequences')), + 'cur: 99\n') + + def seqeq(seq, val): + eq(f.parsesequence(seq), val) + + seqeq('5-55', range(5, 56)) + seqeq('90-108', range(90, 101)+range(101, 109, 2)) + seqeq('90-108', range(90, 101)+range(101, 109, 2)) + + seqeq('10:10', range(10, 20)) + seqeq('10:+10', range(10, 20)) + seqeq('101:10', range(101, 121, 2)) + + seqeq('cur', [99]) + seqeq('.', [99]) + seqeq('prev', [98]) + seqeq('next', [100]) + seqeq('cur:-3', [97, 98, 99]) + seqeq('first-cur', range(5, 100)) + seqeq('150-last', range(151, 201, 2)) + seqeq('prev-next', [98, 99, 100]) + + lowprimes = [5, 7, 11, 13, 17, 19, 23, 29] + lowcompos = [x for x in range(5, 31) if not x in lowprimes ] + f.putsequences({'cur': [5], + 'lowprime': lowprimes, + 'lowcompos': lowcompos}) + seqs = readFile(os.path.join(_mhpath, 'wide', '.mh_sequences')) + seqs = sortLines(seqs) + eq(seqs, ["cur: 5", + "lowcompos: 6 8-10 12 14-16 18 20-22 24-28 30", + "lowprime: 5 7 11 13 17 19 23 29"]) + + seqeq('lowprime', lowprimes) + seqeq('lowprime:1', [5]) + seqeq('lowprime:2', [5, 7]) + seqeq('lowprime:-2', [23, 29]) + + ## Not supported + #seqeq('lowprime:first', [5]) + #seqeq('lowprime:last', [29]) + #seqeq('lowprime:prev', [29]) + #seqeq('lowprime:next', [29]) + + def test_modify(self): + mh = getMH() + eq = self.assertEquals + + mh.makefolder("dummy1") + self.assert_("dummy1" in mh.listfolders()) + path = os.path.join(_mhpath, "dummy1") + self.assert_(os.path.exists(path)) + + f = mh.openfolder('dummy1') + def create(n): + msg = "From: foo\nSubject: %s\n\nDummy Message %s\n" % (n,n) + f.createmessage(n, StringIO.StringIO(msg)) + + create(7) + create(8) + create(9) + + eq(readFile(f.getmessagefilename(9)), + "From: foo\nSubject: 9\n\nDummy Message 9\n") + + eq(f.listmessages(), [7, 8, 9]) + files = os.listdir(path) + files.sort() + eq(files, ['7', '8', '9']) + + f.removemessages(['7', '8']) + files = os.listdir(path) + files.sort() + eq(files, [',7', ',8', '9']) + eq(f.listmessages(), [9]) + create(10) + create(11) + create(12) + + mh.makefolder("dummy2") + f2 = mh.openfolder("dummy2") + eq(f2.listmessages(), []) + f.movemessage(10, f2, 3) + f.movemessage(11, f2, 5) + eq(f.listmessages(), [9, 12]) + eq(f2.listmessages(), [3, 5]) + eq(readFile(f2.getmessagefilename(3)), + "From: foo\nSubject: 10\n\nDummy Message 10\n") + + f.copymessage(9, f2, 4) + eq(f.listmessages(), [9, 12]) + eq(readFile(f2.getmessagefilename(4)), + "From: foo\nSubject: 9\n\nDummy Message 9\n") + + f.refilemessages([9, 12], f2) + eq(f.listmessages(), []) + eq(f2.listmessages(), [3, 4, 5, 6, 7]) + eq(readFile(f2.getmessagefilename(7)), + "From: foo\nSubject: 12\n\nDummy Message 12\n") + # XXX This should check that _copysequences does the right thing. + + mh.deletefolder('dummy1') + mh.deletefolder('dummy2') + self.assert_('dummy1' not in mh.listfolders()) + self.assert_(not os.path.exists(path)) + + def test_read(self): + mh = getMH() + eq = self.assertEquals + + f = mh.openfolder('inbox') + msg = f.openmessage(1) + # Check some basic stuff from rfc822 + eq(msg.getheader('From'), "Mrs. Premise") + eq(msg.getheader('To'), "Mrs. Conclusion") + + # Okay, we have the right message. Let's check the stuff from + # mhlib. + lines = sortLines(msg.getheadertext()) + eq(lines, ["Date: 18 July 2001", + "From: Mrs. Premise", + "To: Mrs. Conclusion"]) + lines = sortLines(msg.getheadertext(lambda h: len(h)==4)) + eq(lines, ["Date: 18 July 2001", + "From: Mrs. Premise"]) + eq(msg.getbodytext(), "Hullo, Mrs. Conclusion!\n\n") + eq(msg.getbodytext(0), "Hullo, Mrs. Conclusion!\n\n") + + # XXXX there should be a better way to reclaim the file handle + msg.fp.close() + del msg + + +def test_main(): + run_unittest(MhlibTests) + + +if __name__ == "__main__": + test_main() From python-checkins at python.org Fri Sep 8 04:34:14 2006 From: python-checkins at python.org (jackilyn.hoxworth) Date: Fri, 8 Sep 2006 04:34:14 +0200 (CEST) Subject: [Python-checkins] r51823 - python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Message-ID: <20060908023414.BA6101E4003@bag.python.org> Author: jackilyn.hoxworth Date: Fri Sep 8 04:34:12 2006 New Revision: 51823 Modified: python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Log: Modified: python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Fri Sep 8 04:34:12 2006 @@ -138,6 +138,12 @@ # The default setup permits warnings mhlib._log.warn("Testing log of " + self.str) + # works, but could be coded better. it prints this for each test. + if self.str == "mhlib": + print "logging worked" + else: + print "logging didn't work" + # A deeply nested folder def deep(folder, n): writeMessage(folder, n, From python-checkins at python.org Fri Sep 8 05:48:01 2006 From: python-checkins at python.org (jackilyn.hoxworth) Date: Fri, 8 Sep 2006 05:48:01 +0200 (CEST) Subject: [Python-checkins] r51824 - python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Message-ID: <20060908034801.34B2F1E4003@bag.python.org> Author: jackilyn.hoxworth Date: Fri Sep 8 05:48:00 2006 New Revision: 51824 Modified: python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Log: fixed Modified: python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py ============================================================================== --- python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py (original) +++ python/branches/hoxworth-stdlib_logging-soc/test_mhlib.py Fri Sep 8 05:48:00 2006 @@ -138,11 +138,7 @@ # The default setup permits warnings mhlib._log.warn("Testing log of " + self.str) - # works, but could be coded better. it prints this for each test. - if self.str == "mhlib": - print "logging worked" - else: - print "logging didn't work" + self.assert_(self.str == "mhlib") # A deeply nested folder def deep(folder, n): From python-checkins at python.org Fri Sep 8 08:02:27 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 8 Sep 2006 08:02:27 +0200 (CEST) Subject: [Python-checkins] r51825 - python/branches/release25-maint/Objects/setobject.c Message-ID: <20060908060227.98FDC1E4005@bag.python.org> Author: georg.brandl Date: Fri Sep 8 08:02:26 2006 New Revision: 51825 Modified: python/branches/release25-maint/Objects/setobject.c Log: Backport rev. 51798 from trunk: fix setobject.c refcounts and error checks. Modified: python/branches/release25-maint/Objects/setobject.c ============================================================================== --- python/branches/release25-maint/Objects/setobject.c (original) +++ python/branches/release25-maint/Objects/setobject.c Fri Sep 8 08:02:26 2006 @@ -319,8 +319,10 @@ assert(so->fill <= so->mask); /* at least one empty slot */ n_used = so->used; Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) + if (set_insert_key(so, entry->key, entry->hash) == -1) { + Py_DECREF(entry->key); return -1; + } if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2)) return 0; return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); @@ -1138,7 +1140,12 @@ } while (set_next((PySetObject *)other, &pos, &entry)) { - if (set_contains_entry(so, entry)) { + int rv = set_contains_entry(so, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (rv) { if (set_add_entry(result, entry) == -1) { Py_DECREF(result); return NULL; @@ -1155,7 +1162,14 @@ } while ((key = PyIter_Next(it)) != NULL) { - if (set_contains_key(so, key)) { + int rv = set_contains_key(so, key); + if (rv == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + if (rv) { if (set_add_key(result, key) == -1) { Py_DECREF(it); Py_DECREF(result); @@ -1232,7 +1246,8 @@ Py_ssize_t pos = 0; while (set_next((PySetObject *)other, &pos, &entry)) - set_discard_entry(so, entry); + if (set_discard_entry(so, entry) == -1) + return -1; } else { PyObject *key, *it; it = PyObject_GetIter(other); @@ -1295,17 +1310,26 @@ entrycopy.hash = entry->hash; entrycopy.key = entry->key; if (!PyDict_Contains(other, entry->key)) { - if (set_add_entry((PySetObject *)result, &entrycopy) == -1) + if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { + Py_DECREF(result); return NULL; + } } } return result; } while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) { - if (set_add_entry((PySetObject *)result, entry) == -1) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (!rv) { + if (set_add_entry((PySetObject *)result, entry) == -1) { + Py_DECREF(result); return NULL; + } } } return result; @@ -1464,7 +1488,10 @@ Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) + return NULL; + if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE; From python-checkins at python.org Fri Sep 8 12:01:24 2006 From: python-checkins at python.org (nick.coghlan) Date: Fri, 8 Sep 2006 12:01:24 +0200 (CEST) Subject: [Python-checkins] r51826 - in python/branches/release25-maint: Lib/inspect.py Lib/test/test_inspect.py Misc/NEWS Message-ID: <20060908100124.464841E4007@bag.python.org> Author: nick.coghlan Date: Fri Sep 8 12:01:23 2006 New Revision: 51826 Modified: python/branches/release25-maint/Lib/inspect.py python/branches/release25-maint/Lib/test/test_inspect.py python/branches/release25-maint/Misc/NEWS Log: Backport inspect.py fix from rev 51803 Modified: python/branches/release25-maint/Lib/inspect.py ============================================================================== --- python/branches/release25-maint/Lib/inspect.py (original) +++ python/branches/release25-maint/Lib/inspect.py Fri Sep 8 12:01:23 2006 @@ -403,6 +403,7 @@ return os.path.normcase(os.path.abspath(_filename)) modulesbyfile = {} +_filesbymodname = {} def getmodule(object, _filename=None): """Return the module an object was defined in, or None if not found.""" @@ -410,19 +411,32 @@ return object if hasattr(object, '__module__'): return sys.modules.get(object.__module__) + # Try the filename to modulename cache + if _filename is not None and _filename in modulesbyfile: + return sys.modules.get(modulesbyfile[_filename]) + # Try the cache again with the absolute file name try: file = getabsfile(object, _filename) except TypeError: return None if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) - for module in sys.modules.values(): + # Update the filename to module name cache and check yet again + # Copy sys.modules in order to cope with changes while iterating + for modname, module in sys.modules.items(): if ismodule(module) and hasattr(module, '__file__'): + f = module.__file__ + if f == _filesbymodname.get(modname, None): + # Have already mapped this module, so skip it + continue + _filesbymodname[modname] = f f = getabsfile(module) + # Always map to the name the module knows itself by modulesbyfile[f] = modulesbyfile[ os.path.realpath(f)] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) + # Check the main module main = sys.modules['__main__'] if not hasattr(object, '__name__'): return None @@ -430,6 +444,7 @@ mainobject = getattr(main, object.__name__) if mainobject is object: return main + # Check builtins builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) @@ -444,7 +459,7 @@ in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) - module = getmodule(object) + module = getmodule(object, file) if module: lines = linecache.getlines(file, module.__dict__) else: Modified: python/branches/release25-maint/Lib/test/test_inspect.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_inspect.py (original) +++ python/branches/release25-maint/Lib/test/test_inspect.py Fri Sep 8 12:01:23 2006 @@ -178,7 +178,18 @@ self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') def test_getmodule(self): + # Check actual module + self.assertEqual(inspect.getmodule(mod), mod) + # Check class (uses __module__ attribute) self.assertEqual(inspect.getmodule(mod.StupidGit), mod) + # Check a method (no __module__ attribute, falls back to filename) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Do it again (check the caching isn't broken) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Check a builtin + self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) + # Check filename override + self.assertEqual(inspect.getmodule(None, modfile), mod) def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Fri Sep 8 12:01:23 2006 @@ -46,6 +46,9 @@ Library ------- +- Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE + by adding smarter caching in inspect.getmodule() + - Fix missing import of the types module in logging.config. - Patch #1550886: Fix decimal module context management implementation From python-checkins at python.org Fri Sep 8 12:04:39 2006 From: python-checkins at python.org (nick.coghlan) Date: Fri, 8 Sep 2006 12:04:39 +0200 (CEST) Subject: [Python-checkins] r51827 - python/trunk/Misc/NEWS Message-ID: <20060908100439.268351E4005@bag.python.org> Author: nick.coghlan Date: Fri Sep 8 12:04:38 2006 New Revision: 51827 Modified: python/trunk/Misc/NEWS Log: Add missing NEWS entry for rev 51803 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Sep 8 12:04:38 2006 @@ -40,6 +40,9 @@ Library ------- +- Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE + by adding smarter caching in inspect.getmodule() + - Fix missing import of the types module in logging.config. - Patch #1550886: Fix decimal module context management implementation From python-checkins at python.org Fri Sep 8 15:25:24 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 15:25:24 +0200 (CEST) Subject: [Python-checkins] r51828 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060908132524.6039D1E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 15:25:23 2006 New Revision: 51828 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Add missing word Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri Sep 8 15:25:23 2006 @@ -409,7 +409,7 @@ specific exceptions. You couldn't combine both \keyword{except} blocks and a \keyword{finally} block, because generating the right bytecode for the combined version was complicated and it wasn't clear what the -semantics of the combined should be. +semantics of the combined statement should be. Guido van~Rossum spent some time working with Java, which does support the equivalent of combining \keyword{except} blocks and a From python-checkins at python.org Fri Sep 8 15:35:50 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 15:35:50 +0200 (CEST) Subject: [Python-checkins] r51829 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060908133550.217D91E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 15:35:49 2006 New Revision: 51829 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Explain SQLite a bit more clearly Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri Sep 8 15:35:49 2006 @@ -2116,14 +2116,16 @@ SQLite embedded database, has been added to the standard library under the package name \module{sqlite3}. -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. If you're compiling the Python source yourself, note that the source tree doesn't include the SQLite code, only the wrapper module. From python-checkins at python.org Fri Sep 8 15:36:36 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 15:36:36 +0200 (CEST) Subject: [Python-checkins] r51830 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060908133636.7A43A1E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 15:36:36 2006 New Revision: 51830 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: Explain SQLite a bit more clearly Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Fri Sep 8 15:36:36 2006 @@ -6,14 +6,16 @@ \sectionauthor{Gerhard H?ring}{gh at ghaering.de} \versionadded{2.5} -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. To use the module, you must first create a \class{Connection} object that represents the database. Here the data will be stored in the From python-checkins at python.org Fri Sep 8 15:36:58 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 15:36:58 +0200 (CEST) Subject: [Python-checkins] r51831 - python/branches/release25-maint/Doc/lib/libsqlite3.tex Message-ID: <20060908133658.27A391E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 15:36:57 2006 New Revision: 51831 Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex Log: Explain SQLite a bit more clearly Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libsqlite3.tex (original) +++ python/branches/release25-maint/Doc/lib/libsqlite3.tex Fri Sep 8 15:36:57 2006 @@ -6,14 +6,16 @@ \sectionauthor{Gerhard H?ring}{gh at ghaering.de} \versionadded{2.5} -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. To use the module, you must first create a \class{Connection} object that represents the database. Here the data will be stored in the From python-checkins at python.org Fri Sep 8 16:02:47 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 16:02:47 +0200 (CEST) Subject: [Python-checkins] r51832 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060908140247.2E26E1E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 16:02:45 2006 New Revision: 51832 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: Use native SQLite types Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Fri Sep 8 16:02:45 2006 @@ -2152,8 +2152,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks From python-checkins at python.org Fri Sep 8 16:03:01 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 16:03:01 +0200 (CEST) Subject: [Python-checkins] r51833 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060908140301.5D8491E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 16:03:01 2006 New Revision: 51833 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: Use native SQLite types Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Fri Sep 8 16:03:01 2006 @@ -36,8 +36,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks From python-checkins at python.org Fri Sep 8 16:03:20 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 16:03:20 +0200 (CEST) Subject: [Python-checkins] r51834 - python/branches/release25-maint/Doc/lib/libsqlite3.tex Message-ID: <20060908140320.355FD1E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 16:03:19 2006 New Revision: 51834 Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex Log: Use native SQLite types Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libsqlite3.tex (original) +++ python/branches/release25-maint/Doc/lib/libsqlite3.tex Fri Sep 8 16:03:19 2006 @@ -36,8 +36,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks From python-checkins at python.org Fri Sep 8 16:05:11 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 16:05:11 +0200 (CEST) Subject: [Python-checkins] r51835 - python/trunk/Doc/lib/sqlite3/executescript.py Message-ID: <20060908140511.2B4211E4005@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 16:05:10 2006 New Revision: 51835 Modified: python/trunk/Doc/lib/sqlite3/executescript.py Log: Fix typo in example Modified: python/trunk/Doc/lib/sqlite3/executescript.py ============================================================================== --- python/trunk/Doc/lib/sqlite3/executescript.py (original) +++ python/trunk/Doc/lib/sqlite3/executescript.py Fri Sep 8 16:05:10 2006 @@ -17,7 +17,7 @@ insert into book(title, author, published) values ( - 'Dirk Gently''s Holistic Detective Agency + 'Dirk Gently''s Holistic Detective Agency', 'Douglas Adams', 1987 ); From python-checkins at python.org Fri Sep 8 16:06:43 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 8 Sep 2006 16:06:43 +0200 (CEST) Subject: [Python-checkins] r51836 - python/branches/release25-maint/Doc/lib/sqlite3/executescript.py Message-ID: <20060908140643.341E61E4016@bag.python.org> Author: andrew.kuchling Date: Fri Sep 8 16:06:42 2006 New Revision: 51836 Modified: python/branches/release25-maint/Doc/lib/sqlite3/executescript.py Log: Fix typo in example Modified: python/branches/release25-maint/Doc/lib/sqlite3/executescript.py ============================================================================== --- python/branches/release25-maint/Doc/lib/sqlite3/executescript.py (original) +++ python/branches/release25-maint/Doc/lib/sqlite3/executescript.py Fri Sep 8 16:06:42 2006 @@ -17,7 +17,7 @@ insert into book(title, author, published) values ( - 'Dirk Gently''s Holistic Detective Agency + 'Dirk Gently''s Holistic Detective Agency', 'Douglas Adams', 1987 ); From python-checkins at python.org Sat Sep 9 09:11:47 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 9 Sep 2006 09:11:47 +0200 (CEST) Subject: [Python-checkins] r51837 - in python/trunk: Lib/test/test_exceptions.py Lib/test/test_pep352.py Objects/exceptions.c Message-ID: <20060909071147.47F401E4005@bag.python.org> Author: brett.cannon Date: Sat Sep 9 09:11:46 2006 New Revision: 51837 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Lib/test/test_pep352.py python/trunk/Objects/exceptions.c Log: Remove the __unicode__ method from exceptions. Allows unicode() to be called on exception classes. Would require introducing a tp_unicode slot to make it work otherwise. Fixes bug #1551432 and will be backported. Modified: python/trunk/Lib/test/test_exceptions.py ============================================================================== --- python/trunk/Lib/test/test_exceptions.py (original) +++ python/trunk/Lib/test/test_exceptions.py Sat Sep 9 09:11:46 2006 @@ -304,6 +304,15 @@ return -1 self.assertRaises(RuntimeError, g) + def testUnicodeStrUsage(self): + # Make sure both instances and classes have a str and unicode + # representation. + self.failUnless(str(Exception)) + self.failUnless(unicode(Exception)) + self.failUnless(str(Exception('a'))) + self.failUnless(unicode(Exception(u'a'))) + + def test_main(): run_unittest(ExceptionTests) Modified: python/trunk/Lib/test/test_pep352.py ============================================================================== --- python/trunk/Lib/test/test_pep352.py (original) +++ python/trunk/Lib/test/test_pep352.py Sat Sep 9 09:11:46 2006 @@ -15,8 +15,7 @@ self.failUnless(issubclass(Exception, object)) def verify_instance_interface(self, ins): - for attr in ("args", "message", "__str__", "__unicode__", "__repr__", - "__getitem__"): + for attr in ("args", "message", "__str__", "__repr__", "__getitem__"): self.failUnless(hasattr(ins, attr), "%s missing %s attribute" % (ins.__class__.__name__, attr)) Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sat Sep 9 09:11:46 2006 @@ -175,27 +175,10 @@ Py_RETURN_NONE; } -#ifdef Py_USING_UNICODE -/* while this method generates fairly uninspired output, it a least - * guarantees that we can display exceptions that have unicode attributes - */ -static PyObject * -BaseException_unicode(PyBaseExceptionObject *self) -{ - if (PyTuple_GET_SIZE(self->args) == 0) - return PyUnicode_FromUnicode(NULL, 0); - if (PyTuple_GET_SIZE(self->args) == 1) - return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0)); - return PyObject_Unicode(self->args); -} -#endif /* Py_USING_UNICODE */ static PyMethodDef BaseException_methods[] = { {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, -#ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, -#endif {NULL, NULL, 0, NULL}, }; From python-checkins at python.org Sat Sep 9 09:18:45 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 9 Sep 2006 09:18:45 +0200 (CEST) Subject: [Python-checkins] r51838 - in python/branches/release25-maint: Lib/test/test_exceptions.py Lib/test/test_pep352.py Misc/NEWS Objects/exceptions.c Message-ID: <20060909071845.7E09E1E4005@bag.python.org> Author: brett.cannon Date: Sat Sep 9 09:18:44 2006 New Revision: 51838 Modified: python/branches/release25-maint/Lib/test/test_exceptions.py python/branches/release25-maint/Lib/test/test_pep352.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/exceptions.c Log: Remove __unicode__ method so that ``unicode(BaseException)`` succeeds. Fixes bug #1551432. Modified: python/branches/release25-maint/Lib/test/test_exceptions.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_exceptions.py (original) +++ python/branches/release25-maint/Lib/test/test_exceptions.py Sat Sep 9 09:18:44 2006 @@ -304,6 +304,15 @@ return -1 self.assertRaises(RuntimeError, g) + def testUnicodeStrUsage(self): + # Make sure both instances and classes have a str and unicode + # representation. + self.failUnless(str(Exception)) + self.failUnless(unicode(Exception)) + self.failUnless(str(Exception('a'))) + self.failUnless(unicode(Exception(u'a'))) + + def test_main(): run_unittest(ExceptionTests) Modified: python/branches/release25-maint/Lib/test/test_pep352.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_pep352.py (original) +++ python/branches/release25-maint/Lib/test/test_pep352.py Sat Sep 9 09:18:44 2006 @@ -15,8 +15,7 @@ self.failUnless(issubclass(Exception, object)) def verify_instance_interface(self, ins): - for attr in ("args", "message", "__str__", "__unicode__", "__repr__", - "__getitem__"): + for attr in ("args", "message", "__str__", "__repr__", "__getitem__"): self.failUnless(hasattr(ins, attr), "%s missing %s attribute" % (ins.__class__.__name__, attr)) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 9 09:18:44 2006 @@ -19,6 +19,9 @@ Core and builtins ----------------- +- Bug #1551432: Exceptions do not define an explicit __unicode__ method. This + allows calling unicode() on exceptions classes directly to succeed. + - Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. Also make sure that every exception class has __module__ set to 'exceptions'. Modified: python/branches/release25-maint/Objects/exceptions.c ============================================================================== --- python/branches/release25-maint/Objects/exceptions.c (original) +++ python/branches/release25-maint/Objects/exceptions.c Sat Sep 9 09:18:44 2006 @@ -175,27 +175,10 @@ Py_RETURN_NONE; } -#ifdef Py_USING_UNICODE -/* while this method generates fairly uninspired output, it a least - * guarantees that we can display exceptions that have unicode attributes - */ -static PyObject * -BaseException_unicode(PyBaseExceptionObject *self) -{ - if (PyTuple_GET_SIZE(self->args) == 0) - return PyUnicode_FromUnicode(NULL, 0); - if (PyTuple_GET_SIZE(self->args) == 1) - return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0)); - return PyObject_Unicode(self->args); -} -#endif /* Py_USING_UNICODE */ static PyMethodDef BaseException_methods[] = { {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, -#ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, -#endif {NULL, NULL, 0, NULL}, }; From python-checkins at python.org Sat Sep 9 09:23:21 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 9 Sep 2006 09:23:21 +0200 (CEST) Subject: [Python-checkins] r51839 - peps/trunk/pep-0352.txt peps/trunk/pep-0356.txt Message-ID: <20060909072321.217351E4005@bag.python.org> Author: brett.cannon Date: Sat Sep 9 09:23:20 2006 New Revision: 51839 Modified: peps/trunk/pep-0352.txt peps/trunk/pep-0356.txt Log: Update PEP 352 on the removal of __unicode__ on BaseException and remove bug #1551432 as a blocker for 2.5 . Modified: peps/trunk/pep-0352.txt ============================================================================== --- peps/trunk/pep-0352.txt (original) +++ peps/trunk/pep-0352.txt Sat Sep 9 09:23:20 2006 @@ -66,7 +66,7 @@ Provides a 'message' attribute that contains either the single argument to the constructor or the empty string. This attribute - is used in both the string and unicode representation for the + is used in the string representation for the exception. This is so that it provides the extra details in the traceback. @@ -80,10 +80,6 @@ """Return the str of 'message'""" return str(self.message) - def __unicode__(self): - """Return the unicode of 'message'""" - return unicode(self.message) - def __repr__(self): return "%s(%s)" % (self.__class__.__name__, repr(self.message)) @@ -221,17 +217,6 @@ if len(self.args) <= 1 else self.args) - def __unicode__(self): - """Return the unicode of args[0] or args, depending on length. - - Once 'args' has been removed, 'message' will be used - exclusively for the unicode representation of exceptions. - - """ - return unicode(self.args[0] - if len(self.args) <= 1 - else self.args) - def __repr__(self): func_args = repr(self.args) if self.args else "()" return self.__class__.__name__ + func_args Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Sat Sep 9 09:23:20 2006 @@ -150,7 +150,6 @@ - Bugs that need resolving before release, ie, they block release: - http://python.org/sf/1551432 - __unicode__ breaks on exception classes http://python.org/sf/1541697 - sgmllib regexp bug causes hang - Bugs deferred until 2.5.1 (or later) From buildbot at python.org Sat Sep 9 10:08:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 09 Sep 2006 08:08:51 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060909080851.238DA1E4005@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1161 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,brett.cannon,nick.coghlan Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 9 10:58:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 09 Sep 2006 08:58:31 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20060909085832.1810D1E4005@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%25202.5/builds/28 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 9 12:51:02 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 09 Sep 2006 10:51:02 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060909105102.683181E4005@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.5/builds/25 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: andrew.kuchling,brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From martin at v.loewis.de Sun Sep 10 11:59:42 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Sun, 10 Sep 2006 11:59:42 +0200 Subject: [Python-checkins] r51798 - python/trunk/Objects/setobject.c In-Reply-To: <010801c6d23b$ece98c30$4c00000a@RaymondLaptop1> References: <20060907024249.651531E4018@bag.python.org><200609071309.54075.anthony@interlink.com.au> <20060907040251.GO5707@performancedrivers.com> <010801c6d23b$ece98c30$4c00000a@RaymondLaptop1> Message-ID: <4503E20E.9070108@v.loewis.de> Raymond Hettinger schrieb: > LOL, he didn't mean Py2.4 ;-) > Anthony meant backport from the head to the Py2.5 release branch. > I trust that when the buildbots have digested the patch on the head, > he'll go ahead and do the backport. There is little foundation for such trust, though. Nobody except the original committer typically backports. So if you commit a change, and you think the change should be backported, you should also backport it. Else it likely won't get backported. Regards, Martin From python-checkins at python.org Sun Sep 10 18:17:41 2006 From: python-checkins at python.org (guido.van.rossum) Date: Sun, 10 Sep 2006 18:17:41 +0200 (CEST) Subject: [Python-checkins] r51841 - python/branches/int_unification/Objects/longobject.c Message-ID: <20060910161741.B222B1E4009@bag.python.org> Author: guido.van.rossum Date: Sun Sep 10 18:17:41 2006 New Revision: 51841 Modified: python/branches/int_unification/Objects/longobject.c Log: Fix a typo in the hash function. This fixes 23 out or 45 failing tests. Modified: python/branches/int_unification/Objects/longobject.c ============================================================================== --- python/branches/int_unification/Objects/longobject.c (original) +++ python/branches/int_unification/Objects/longobject.c Sun Sep 10 18:17:41 2006 @@ -2066,7 +2066,7 @@ switch(i) { case -1: return v->ob_digit[0]==1 ? -2 : -v->ob_digit[0]; case 0: return 0; - case 1: return v->ob_digit[1]; + case 1: return v->ob_digit[0]; } sign = 1; x = 0; From python-checkins at python.org Sun Sep 10 18:56:11 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 10 Sep 2006 18:56:11 +0200 (CEST) Subject: [Python-checkins] r51842 - peps/trunk/pep-0101.txt Message-ID: <20060910165611.BEBC41E4009@bag.python.org> Author: martin.v.loewis Date: Sun Sep 10 18:56:11 2006 New Revision: 51842 Modified: peps/trunk/pep-0101.txt Log: Document current Windows release process. Modified: peps/trunk/pep-0101.txt ============================================================================== --- peps/trunk/pep-0101.txt (original) +++ peps/trunk/pep-0101.txt Sun Sep 10 18:56:11 2006 @@ -339,7 +339,7 @@ releases. (Is should be fairly easy to figure this out while looking at the file.) - ___ Thomas grabs the HTML to build the Windows helpfile. + ___ Martin grabs the HTML to build the Windows helpfile. The HTML files are unpacked into a new src/html directory, and runs this command to create the project files for MS HTML Workshop: @@ -347,23 +347,30 @@ % python ..\Doc\tools\prechm.py -v 2.3 python23 HTML Workshop is then fired up on the created python23.hhp file, - finally resulting in an python23.chm file. - - ___ Tim Peters grabs the HTML Help format and uses this to build the - Windows installer. - - ___ Tim performs his Windows magic, generating an installer - executable. He uploads this file to SourceForge, and then sends - the RM a notice which includes the location and MD5 checksum of - the Windows executable. - - Note that Tim used to upload the installer to www.python.org, - but has had problems with ssh for a while now. - - Note that Tim's creation of the Windows executable may generate - a few more commits on the branch. Tim will be responsible for - merging Windows-specific changes from trunk to branch, and from - branch to trunk. + finally resulting in an python23.chm file. He then copies the + file into the Doc directories of the build trees (once for + each target architecture). + + ___ Martin then generates Windows installer files for each Windows + target architecture (for Python 2.5, this means x86, Itanium, + and AMD64). He has one checkout tree per target architecture, + and builds the pcbuild.sln project for the appropriate + architecture. He then edits Tools/msi/config.py to update + full_current_version, and runs msi.py with ActivePython 2.3. + For that to work, the following prerequisites must be met: + + - PC/icons.mak must have been run with nmake. + + - The cmd.exe window in which this is run must have Cygwin/bin + in its path (atleast for x86). + + - The cmd.exe window must have MS compiler tools for the target + architecture in its path (VS 2003 for x86, the platform + SDK for Itanium and AMD64). + + Martin checksums the files (*.msi and *.chm), uploads them + to some place in the net, and emails you the location + and md5sums. ___ Sean Reifschneider grabs the HTML and uses this to build the Linux RPMs. Sean performs his Red Hat magic, generating a set @@ -371,10 +378,6 @@ the RM a notice which includes the location and MD5 checksum of the RPMs. - ___ Download the Windows executable from SourceForge to - creosote.python.org. Tell Tim so he can remove the file from - SourceForge. - ___ Time to build the source tarball. If you created a branch, be sure to cd to your working directory for the branch. E.g. % cd .../python-22a3 From python-checkins at python.org Sun Sep 10 19:00:31 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 10 Sep 2006 19:00:31 +0200 (CEST) Subject: [Python-checkins] r51843 - peps/trunk/pep-0101.txt Message-ID: <20060910170031.A8A261E4009@bag.python.org> Author: martin.v.loewis Date: Sun Sep 10 19:00:30 2006 New Revision: 51843 Modified: peps/trunk/pep-0101.txt Log: Streamline version numbers to 2.5. Modified: peps/trunk/pep-0101.txt ============================================================================== --- peps/trunk/pep-0101.txt (original) +++ peps/trunk/pep-0101.txt Sun Sep 10 19:00:30 2006 @@ -37,8 +37,8 @@ steps. We use the following conventions in the examples below. Where a - release number is given, it is of the form X.YaZ, e.g. 2.1a3 for - Python 2.1 alpha 3, where "a" == alpha, "b" == beta, "rc" == + release number is given, it is of the form X.YaZ, e.g. 2.5a3 for + Python 2.5 alpha 3, where "a" == alpha, "b" == beta, "rc" == release candidate. Final releases are named "releaseXY". The branch tag is @@ -48,7 +48,7 @@ say X.Y.MaZ. Note: This document has been updated to reflect the more - streamlined procedures used to release Python 2.3 (including the + streamlined procedures used to release Python 2.5 (including the alphas and betas). ___ Impose a check-in freeze. Send a message to @@ -92,7 +92,7 @@ previous release until now. You can then troll through the news.txt file looking for interesting things to add to NEWS. - ___ For major releases (e.g. 2.3 final), move any historical "what's + ___ For major releases (e.g. 2.5 final), move any historical "what's new" entries from Misc/NEWS to Misc/HISTORY. ___ Check with the IDLE maintainer to be sure that @@ -136,7 +136,7 @@ to keep it straight from your trunk working directory. E.g. % export CVSROOT=cvs.sf.net:/cvsroot/python - % cvs -q co -d python-22a3 -r release23-maint python/dist/src + % cvs -q co -d python-25a3 -r release25-maint python/dist/src ___ cd into the branch directory. @@ -151,16 +151,16 @@ release date. Then update Lib/idlelib/idlever.py to show a matching version. - ___ Change the "%define version" line of Misc/RPM/python-2.3.spec to + ___ Change the "%define version" line of Misc/RPM/python-2.5.spec to the same string as PY_VERSION was changed to above. E.g. - %define version 2.3.1 + %define version 2.5.1 The following line, "%define libvers", should reflect the major/minor number as one would usually see in the "/usr/lib/python" directory name. E.g. - %define libvers 2.3 + %define libvers 2.5 You also probably want to reset the %define release line to '1pydotorg' if it's not already that. @@ -169,9 +169,9 @@ different than is in the name of the current "Misc/RPM/python-*.spec" file, rename the file: - % mv python-2.3.spec python-2.4.spec - % cvs remove python-2.3.spec - % cvs add python-2.4.spec + % mv python-2.5.spec python-2.6.spec + % cvs remove python-2.5.spec + % cvs add python-2.6.spec % cvs commit ___ If this is a release candidate, mail Sean @@ -217,7 +217,7 @@ ___ For a final release, edit the first paragraph of Doc/whatsnew/whatsnewXX.tex to include the actual release date; - e.g. "Python 2.3 was released on August 1, 2003." + e.g. "Python 2.5 was released on August 1, 2003." There's no need to edit this for alpha or beta releases. Note that Andrew often takes care of this. @@ -279,16 +279,16 @@ - the version number to $VERSION in two places: the Title: header, and the

at the top of the page - the release date, in the

at the top of the page - - if the minor release number changed (for example, from 2.3 - to 2.4), the title and link to the "What's New" document + - if the minor release number changed (for example, from 2.5 + to 2.6), the title and link to the "What's New" document (search for "whatsnew") - in download.ht, change: - the version number to $VERSION in two places: the Title: header, and the

at the top of the page - the release date, in the

at the top of the page - - if the minor release number changed (for example, from 2.3 - to 2.4), the title and link to the "What's New" document + - if the minor release number changed (for example, from 2.5 + to 2.6), the title and link to the "What's New" document (search for "whatsnew") - replace the large table of downloads with the content of the pkglist.html file generated by the documentation build @@ -344,10 +344,10 @@ runs this command to create the project files for MS HTML Workshop: - % python ..\Doc\tools\prechm.py -v 2.3 python23 + % python ..\Doc\tools\prechm.py -v 2.5 python25 - HTML Workshop is then fired up on the created python23.hhp file, - finally resulting in an python23.chm file. He then copies the + HTML Workshop is then fired up on the created python25.hhp file, + finally resulting in an python25.chm file. He then copies the file into the Doc directories of the build trees (once for each target architecture). @@ -356,7 +356,7 @@ and AMD64). He has one checkout tree per target architecture, and builds the pcbuild.sln project for the appropriate architecture. He then edits Tools/msi/config.py to update - full_current_version, and runs msi.py with ActivePython 2.3. + full_current_version, and runs msi.py with ActivePython 2.5. For that to work, the following prerequisites must be met: - PC/icons.mak must have been run with nmake. @@ -380,7 +380,7 @@ ___ Time to build the source tarball. If you created a branch, be sure to cd to your working directory for the branch. E.g. - % cd .../python-22a3 + % cd .../python-25a3 ___ Do a "cvs update" in this directory. Do NOT include the -A flag if you're working on a branch, but do include it if you're @@ -393,13 +393,13 @@ ___ If you've seen updates to existing files, update the cvs tag: - % cvs tag -F r22a3 + % cvs tag -F r25a3 If you created a maintenance branch and you've changed any files since you branched, tag the tree -- in the branch -- now with something like - % cvs tag r23 + % cvs tag r25 This is the tag you will use below. @@ -410,18 +410,18 @@ % cd ~ % export CVSROOT=cvs.sf.net:/cvsroot/python - % cvs export -rr23c2 -d Python-2.3c2 python/dist/src + % cvs export -rr25c2 -d Python-2.5c2 python/dist/src ___ Generate the tarball. Note that we're not using the `z' option on the tar command because 1) that's only supported by GNU tar as far as we know, and 2) we're going to max out the compression level, which isn't a supported option. - % tar cf - Python-2.3c2 | gzip -9 > Python-2.3c2.tgz + % tar cf - Python-2.5c2 | gzip -9 > Python-2.5c2.tgz ___ Calculate the MD5 checksum of the tgz file you just created - % md5sum Python-2.3c2.tgz + % md5sum Python-2.5c2.tgz Note that if you don't have the md5sum program, there is a Python replacement in the Tools/scripts/md5sum.py file. @@ -432,8 +432,8 @@ steps to take: % cd /tmp - % tar zxvf ~/Python-2.3c2.tgz - % cd Python-2.3c2 + % tar zxvf ~/Python-2.5c2.tgz + % cd Python-2.5c2 % ls (Do things look reasonable?) % ./configure @@ -609,7 +609,7 @@ ___ Run a diff against your branch by doing this in the common parent directory containing both python-clean and python-XYaZ: - % diff -r python-clean python-22a2 | grep ^diff | grep -v CVS \ + % diff -r python-clean python-25a2 | grep ^diff | grep -v CVS \ > /tmp/diffcmd.sh ___ Edit diffcmd.sh to get rid of files that you know don't have From python-checkins at python.org Sun Sep 10 19:07:44 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 10 Sep 2006 19:07:44 +0200 (CEST) Subject: [Python-checkins] r51844 - peps/trunk/pep-0101.txt Message-ID: <20060910170744.324161E4009@bag.python.org> Author: martin.v.loewis Date: Sun Sep 10 19:07:43 2006 New Revision: 51844 Modified: peps/trunk/pep-0101.txt Log: More updates to the Windows release process. Drop requirement to test on Windows 9x. Modified: peps/trunk/pep-0101.txt ============================================================================== --- peps/trunk/pep-0101.txt (original) +++ peps/trunk/pep-0101.txt Sun Sep 10 19:07:43 2006 @@ -57,9 +57,9 @@ At this point, nobody except the RM should make any commits to the branch (or his duly assigned agents, i.e. Guido the BDFL, - Fred Drake for documentation, or Tim Peters for Windows). If - the RM screwed up and some desperate last minute change to the - branch is necessary, it can mean extra work for Fred and Tim. + Fred Drake for documentation, or Martin v. Loewis for Windows). + If the RM screwed up and some desperate last minute change to the + branch is necessary, it can mean extra work for Fred and Martin. So try to avoid this! ___ Log into irc.freenode.net and join the #python-dev channel. @@ -389,7 +389,7 @@ You should not see any "M" files, but you may see several "P" or "U" files. I.e. you better not have any uncommitted changes in your working directory, but you may pick up some of Fred's or - Tim's last minute changes. + Martin's last minute changes. ___ If you've seen updates to existing files, update the cvs tag: @@ -453,13 +453,6 @@ ___ Upload the tgz file to creosote.python.org using scp. - ___ Tim has been having trouble uploading to creosote, so he will - usually put the file on SF, giving you the file name and the md5 - checksum. It's best to do a wget from creosote to SF, but - calculating the URL can be not-fun. You can usually get the URL - from the file download page, if you start the download and then - immediately cancel it. - ___ While you're waiting, you can start twiddling the web pages to include the announcement. @@ -715,16 +708,17 @@ Windows Notes - Windows has a GUI installer, various flavors of Windows have + Windows has a MSI installer, various flavors of Windows have "special limitations", and the Windows installer also packs precompiled "foreign" binaries (Tcl/Tk, expat, etc). So Windows testing is tiresome but very necessary. - Concurrent with uploading the installer, Tim installs Python from - it twice: once into the default directory suggested by the + Concurrent with uploading the installer, Martin installs Python + from it twice: once into the default directory suggested by the installer, and later into a directory with embedded spaces in its name. For each installation, he runs the full regression suite - from a DOS box, and both with and without -0. + from a DOS box, and both with and without -0. For maintenance + release, he also tests whether upgrade installations succeed. He also tries *every* shortcut created under Start -> Menu -> the Python group. When trying IDLE this way, you need to verify that @@ -740,9 +734,9 @@ only person routinely testing on Windows, and that Windows is simply a mess. - Repeat all of the above on at least one flavor of Win9x, and one - of NT/2000. On NT/2000, try both an Admin and a plain User (not - Power User) account. + Repeat the testing for each target architecture. On XP/2003, try + both an Admin and a plain User (not Power User) account. If you + can, also test the installer on Windows 9x. WRT Step 5 above (verify the release media), since by the time release files are ready to download Tim has generally run many From python-checkins at python.org Sun Sep 10 19:13:29 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 10 Sep 2006 19:13:29 +0200 (CEST) Subject: [Python-checkins] r51845 - peps/trunk/pep-0101.txt Message-ID: <20060910171329.7B65A1E4009@bag.python.org> Author: martin.v.loewis Date: Sun Sep 10 19:13:29 2006 New Revision: 51845 Modified: peps/trunk/pep-0101.txt Log: Drop the mentioning of python20.wse, as it is not used anymore. Modified: peps/trunk/pep-0101.txt ============================================================================== --- peps/trunk/pep-0101.txt (original) +++ peps/trunk/pep-0101.txt Sun Sep 10 19:13:29 2006 @@ -207,10 +207,6 @@ (displayed when you right-click on the DLL and select Properties). - ___ PCbuild/python20.wse sets up the Windows installer version - resource (displayed when you right-click on the installer .exe - and select Properties). - ___ The license.ht file for the distribution on the website contains what purports to be an HTML-ized copy of the LICENSE file from the distribution. From python-checkins at python.org Sun Sep 10 19:16:24 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sun, 10 Sep 2006 19:16:24 +0200 (CEST) Subject: [Python-checkins] r51846 - peps/trunk/pep-0101.txt Message-ID: <20060910171624.1DE961E4009@bag.python.org> Author: martin.v.loewis Date: Sun Sep 10 19:16:23 2006 New Revision: 51846 Modified: peps/trunk/pep-0101.txt Log: Streamline more version numbers for 2.5. Modified: peps/trunk/pep-0101.txt ============================================================================== --- peps/trunk/pep-0101.txt (original) +++ peps/trunk/pep-0101.txt Sun Sep 10 19:16:23 2006 @@ -74,9 +74,9 @@ before you've made the branch. Add high level items new to this release. E.g. if we're - releasing 2.2a3, there must be a section at the top of the file - explaining "What's new in Python 2.2a3". It will be followed by - a section entitled "What's new in Python 2.2a2". + releasing 2.5a3, there must be a section at the top of the file + explaining "What's new in Python 2.5a3". It will be followed by + a section entitled "What's new in Python 2.5a2". Note that you /hope/ that as developers add new features to the trunk, they've updated the NEWS file accordingly. You can't be @@ -464,7 +464,7 @@ % cd .../pydotorg % cvs -q up -P -d - % cd 2.2 + % cd 2.5 % cp index.ht new-index.ht ___ Edit the file for content: usually you can globally replace @@ -500,9 +500,9 @@ releases. We keep all old releases, moving them into a "prev" subdirectory when we have a new release. - So, there's a directory called "2.2" which contains - Python-2.2a2.exe and Python-2.2a2.tgz, along with a "prev" - subdirectory containing Python-2.2a1.exe and Python-2.2a1.tgz. + So, there's a directory called "2.5" which contains + Python-2.5a2.exe and Python-2.5a2.tgz, along with a "prev" + subdirectory containing Python-2.5a1.exe and Python-2.5a1.tgz. So... @@ -552,7 +552,7 @@ ___ Send a SourceForge News Item about the release. From the project's "menu bar", select the "News" link; once in News, select the "Submit" link. Type a suitable subject (e.g. "Python - 2.2c1 released" :-) in the Subject box, add some text to the + 2.5c1 released" :-) in the Subject box, add some text to the Details box (at the very least including the release URL at www.python.org and the fact that you're happy with the release) and click the SUBMIT button. @@ -637,7 +637,7 @@ indicating that the trunk is going to be moving forward with development. E.g. the line should look like: - #define PY_VERSION "2.2a2+" + #define PY_VERSION "2.5a2+" Make sure that the other PY_ version macros contain the correct values. Commit this change. @@ -686,7 +686,7 @@ Final Release Notes - The Final release of any major release, e.g. Python 2.2 final, has + The Final release of any major release, e.g. Python 2.5 final, has special requirements, specifically because it will be one of the longest lived releases (i.e. betas don't last more than a couple of weeks, but final releases can last for years!). From python-checkins at python.org Mon Sep 11 06:01:58 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:01:58 +0200 (CEST) Subject: [Python-checkins] r51847 - in python/branches/release25-maint: Lib/ctypes/test/test_bitfields.py Modules/_ctypes/stgdict.c Message-ID: <20060911040158.163AF1E4009@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:01:57 2006 New Revision: 51847 Modified: python/branches/release25-maint/Lib/ctypes/test/test_bitfields.py python/branches/release25-maint/Modules/_ctypes/stgdict.c Log: Backport rev 51819 from Thomas Heller Anonymous structure fields that have a bit-width specified did not work, and they gave a strange error message from PyArg_ParseTuple: function takes exactly 2 arguments (3 given). Modified: python/branches/release25-maint/Lib/ctypes/test/test_bitfields.py ============================================================================== --- python/branches/release25-maint/Lib/ctypes/test/test_bitfields.py (original) +++ python/branches/release25-maint/Lib/ctypes/test/test_bitfields.py Mon Sep 11 06:01:57 2006 @@ -215,5 +215,14 @@ ("b", c_ubyte, 4)] self.failUnlessEqual(sizeof(X), sizeof(c_byte)) + def test_anon_bitfields(self): + # anonymous bit-fields gave a strange error message + class X(Structure): + _fields_ = [("a", c_byte, 4), + ("b", c_ubyte, 4)] + class Y(Structure): + _anonymous_ = ["_"] + _fields_ = [("_", X)] + if __name__ == "__main__": unittest.main() Modified: python/branches/release25-maint/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/release25-maint/Modules/_ctypes/stgdict.c (original) +++ python/branches/release25-maint/Modules/_ctypes/stgdict.c Mon Sep 11 06:01:57 2006 @@ -177,11 +177,11 @@ for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ - PyObject *fname, *ftype; + PyObject *fname, *ftype, *bits; CFieldObject *fdescr; CFieldObject *new_descr; /* Convert to PyArg_UnpackTuple... */ - if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { + if (!PyArg_ParseTuple(pair, "OO|O", &fname, &ftype, &bits)) { Py_DECREF(fieldlist); return -1; } From python-checkins at python.org Mon Sep 11 06:02:44 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:02:44 +0200 (CEST) Subject: [Python-checkins] r51848 - in python/branches/release25-maint: Lib/ctypes/test/test_cast.py Modules/_ctypes/_ctypes.c Message-ID: <20060911040244.62D491E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:02:43 2006 New Revision: 51848 Modified: python/branches/release25-maint/Lib/ctypes/test/test_cast.py python/branches/release25-maint/Modules/_ctypes/_ctypes.c Log: Backport rev 51820 from Thomas Heller The cast function did not accept c_char_p or c_wchar_p instances as first argument, and failed with a 'bad argument to internal function' error message. Modified: python/branches/release25-maint/Lib/ctypes/test/test_cast.py ============================================================================== --- python/branches/release25-maint/Lib/ctypes/test/test_cast.py (original) +++ python/branches/release25-maint/Lib/ctypes/test/test_cast.py Mon Sep 11 06:02:43 2006 @@ -57,5 +57,21 @@ c_int() self.failUnlessEqual(p[:4], [1, 2, 96, 4]) + def test_char_p(self): + # This didn't work: bad argument to internal function + s = c_char_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_char_p).value, + "hiho") + + try: + c_wchar_p + except NameError: + pass + else: + def test_wchar_p(self): + s = c_wchar_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_wchar_p).value, + "hiho") + if __name__ == "__main__": unittest.main() Modified: python/branches/release25-maint/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/release25-maint/Modules/_ctypes/_ctypes.c (original) +++ python/branches/release25-maint/Modules/_ctypes/_ctypes.c Mon Sep 11 06:02:43 2006 @@ -4590,11 +4590,11 @@ if (obj->b_objects == NULL) goto failed; } + Py_XINCREF(obj->b_objects); result->b_objects = obj->b_objects; - if (result->b_objects) { + if (result->b_objects && PyDict_Check(result->b_objects)) { PyObject *index; int rc; - Py_INCREF(obj->b_objects); index = PyLong_FromVoidPtr((void *)src); if (index == NULL) goto failed; From python-checkins at python.org Mon Sep 11 06:03:07 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:03:07 +0200 (CEST) Subject: [Python-checkins] r51849 - python/branches/release25-maint/Misc/NEWS Message-ID: <20060911040307.AABE91E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:03:07 2006 New Revision: 51849 Modified: python/branches/release25-maint/Misc/NEWS Log: Add NEWS entries for ctypes backports. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 11 06:03:07 2006 @@ -50,7 +50,7 @@ ------- - Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE - by adding smarter caching in inspect.getmodule() + by adding smarter caching in inspect.getmodule(). - Fix missing import of the types module in logging.config. @@ -68,6 +68,10 @@ Extension Modules ----------------- +- Fix bugs in ctypes: + - anonymous structure fields that have a bit-width specified did not work + - cast function did not accept c_char_p or c_wchar_p instances as first arg + - Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). From python-checkins at python.org Mon Sep 11 06:05:18 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:05:18 +0200 (CEST) Subject: [Python-checkins] r51850 - in python/branches/release25-maint: Lib/sgmllib.py Lib/test/sgml_input.html Lib/test/test_sgmllib.py Misc/NEWS Message-ID: <20060911040518.E64B01E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:05:18 2006 New Revision: 51850 Added: python/branches/release25-maint/Lib/test/sgml_input.html (contents, props changed) Modified: python/branches/release25-maint/Lib/sgmllib.py python/branches/release25-maint/Lib/test/test_sgmllib.py python/branches/release25-maint/Misc/NEWS Log: As mentioned on python-dev, reverting patch #1504333 because it introduced an infinite loop in rev 47154. This patch also adds a test to prevent the regression. Will backport to 2.4 and head later. Modified: python/branches/release25-maint/Lib/sgmllib.py ============================================================================== --- python/branches/release25-maint/Lib/sgmllib.py (original) +++ python/branches/release25-maint/Lib/sgmllib.py Mon Sep 11 06:05:18 2006 @@ -29,12 +29,7 @@ shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') piclose = re.compile('>') -starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*(' - r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]' - r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?' - r')*\s*/?\s*(?=[<>])') -endtag = re.compile(r'])') +endbracket = re.compile('[<>]') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' @@ -254,10 +249,14 @@ self.finish_shorttag(tag, data) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k - match = starttag.match(rawdata, i) + # XXX The following should skip matching quotes (' or ") + # As a shortcut way to exit, this isn't so bad, but shouldn't + # be used to locate the actual end of the start tag since the + # < or > characters may be embedded in an attribute value. + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': @@ -306,10 +305,10 @@ # Internal -- parse endtag def parse_endtag(self, i): rawdata = self.rawdata - match = endtag.match(rawdata, i) + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) tag = rawdata[i+2:j].strip().lower() if rawdata[j] == '>': j = j+1 Added: python/branches/release25-maint/Lib/test/sgml_input.html ============================================================================== --- (empty file) +++ python/branches/release25-maint/Lib/test/sgml_input.html Mon Sep 11 06:05:18 2006 @@ -0,0 +1,212 @@ + + + + + + + + +
+ + + + + +
+
+ + + + + +
+ + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +
  MetalCristalDeuterioEnerg?a  
160.6363.40639.230-80/3.965
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Flotas (max. 9)
Num.Misi?nCantidadComienzoSalidaObjetivoLlegadaOrden
1 + Espionaje + (F) + 3[2:250:6]Wed Aug 9 18:00:02[2:242:5]Wed Aug 9 18:01:02 +
+ + +
+
2 + Espionaje + (V) + 3[2:250:6]Wed Aug 9 17:59:55[2:242:1]Wed Aug 9 18:01:55 +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Nueva misi?n: elegir naves
NavesDisponibles--
Nave peque?a de carga10m?x
Nave grande de carga19m?x
Crucero6m?x
Reciclador1m?x
Sonda de espionaje139m?x
Ninguna naveTodas las naves
+ +

+
+ + Modified: python/branches/release25-maint/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_sgmllib.py (original) +++ python/branches/release25-maint/Lib/test/test_sgmllib.py Mon Sep 11 06:05:18 2006 @@ -286,21 +286,6 @@ ('codepoint', 'convert', 42), ]) - def test_attr_values_quoted_markup(self): - """Multi-line and markup in attribute values""" - self.check_events("""text""", - [("starttag", "a", [("title", "foo\n
bar")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "less < than")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "greater > than")]), - ("data", "text"), - ("endtag", "a")]) - def test_attr_funky_names(self): self.check_events("""""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), @@ -376,6 +361,19 @@ ('decl', 'DOCTYPE doc []'), ]) + def test_read_chunks(self): + # SF bug #1541697, this caused sgml parser to hang + # Just verify this code doesn't cause a hang. + CHUNK = 1024 # increasing this to 8212 makes the problem go away + + f = open(test_support.findfile('sgml_input.html')) + fp = sgmllib.SGMLParser() + while 1: + data = f.read(CHUNK) + fp.feed(data) + if len(data) != CHUNK: + break + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 11 06:05:18 2006 @@ -49,6 +49,8 @@ Library ------- +- Reverted patch #1504333 because it introduced an infinite loop. + - Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE by adding smarter caching in inspect.getmodule(). From python-checkins at python.org Mon Sep 11 06:06:23 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:06:23 +0200 (CEST) Subject: [Python-checkins] r51851 - python/branches/release25-maint/Python/import.c Message-ID: <20060911040623.7262F1E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:06:23 2006 New Revision: 51851 Modified: python/branches/release25-maint/Python/import.c Log: Properly handle a NULL returned from PyArena_New(). Klocwork #364. Will port to head. Modified: python/branches/release25-maint/Python/import.c ============================================================================== --- python/branches/release25-maint/Python/import.c (original) +++ python/branches/release25-maint/Python/import.c Mon Sep 11 06:06:23 2006 @@ -796,14 +796,16 @@ { PyCodeObject *co = NULL; mod_ty mod; - PyArena *arena = PyArena_New(); + PyArena *arena = PyArena_New(); + if (arena == NULL) + return NULL; mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, NULL, arena); if (mod) { co = PyAST_Compile(mod, pathname, NULL, arena); } - PyArena_Free(arena); + PyArena_Free(arena); return co; } From python-checkins at python.org Mon Sep 11 06:08:04 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:08:04 +0200 (CEST) Subject: [Python-checkins] r51852 - peps/trunk/pep-0356.txt Message-ID: <20060911040804.63AAA1E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:08:04 2006 New Revision: 51852 Modified: peps/trunk/pep-0356.txt Log: No more blocking bugs Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Mon Sep 11 06:08:04 2006 @@ -150,7 +150,7 @@ - Bugs that need resolving before release, ie, they block release: - http://python.org/sf/1541697 - sgmllib regexp bug causes hang + None - Bugs deferred until 2.5.1 (or later) http://python.org/sf/1544279 - Socket module is not thread-safe From python-checkins at python.org Mon Sep 11 06:18:08 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:18:08 +0200 (CEST) Subject: [Python-checkins] r51853 - in python/branches/release24-maint: Lib/sgmllib.py Lib/test/sgml_input.html Lib/test/test_sgmllib.py Misc/NEWS Message-ID: <20060911041808.4D6A21E4019@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:18:06 2006 New Revision: 51853 Added: python/branches/release24-maint/Lib/test/sgml_input.html - copied unchanged from r51850, python/branches/release25-maint/Lib/test/sgml_input.html Modified: python/branches/release24-maint/Lib/sgmllib.py python/branches/release24-maint/Lib/test/test_sgmllib.py python/branches/release24-maint/Misc/NEWS Log: Backport 51850 from release25-maint branch. As mentioned on python-dev, reverting patch #1504333 because it introduced an infinite loop in rev 47154. This patch also adds a test to prevent the regression. Modified: python/branches/release24-maint/Lib/sgmllib.py ============================================================================== --- python/branches/release24-maint/Lib/sgmllib.py (original) +++ python/branches/release24-maint/Lib/sgmllib.py Mon Sep 11 06:18:06 2006 @@ -29,12 +29,7 @@ shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') piclose = re.compile('>') -starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*(' - r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]' - r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?' - r')*\s*/?\s*(?=[<>])') -endtag = re.compile(r'])') +endbracket = re.compile('[<>]') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' @@ -250,10 +245,14 @@ self.finish_shorttag(tag, data) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k - match = starttag.match(rawdata, i) + # XXX The following should skip matching quotes (' or ") + # As a shortcut way to exit, this isn't so bad, but shouldn't + # be used to locate the actual end of the start tag since the + # < or > characters may be embedded in an attribute value. + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': @@ -287,10 +286,10 @@ # Internal -- parse endtag def parse_endtag(self, i): rawdata = self.rawdata - match = endtag.match(rawdata, i) + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) tag = rawdata[i+2:j].strip().lower() if rawdata[j] == '>': j = j+1 Modified: python/branches/release24-maint/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_sgmllib.py (original) +++ python/branches/release24-maint/Lib/test/test_sgmllib.py Mon Sep 11 06:18:06 2006 @@ -214,21 +214,6 @@ ("starttag", "e", [("a", "rgb(1,2,3)")]), ]) - def test_attr_values_quoted_markup(self): - """Multi-line and markup in attribute values""" - self.check_events("""text""", - [("starttag", "a", [("title", "foo\n
bar")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "less < than")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "greater > than")]), - ("data", "text"), - ("endtag", "a")]) - def test_attr_funky_names(self): self.check_events("""""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), @@ -304,6 +289,19 @@ ('decl', 'DOCTYPE doc []'), ]) + def test_read_chunks(self): + # SF bug #1541697, this caused sgml parser to hang + # Just verify this code doesn't cause a hang. + CHUNK = 1024 # increasing this to 8212 makes the problem go away + + f = open(test_support.findfile('sgml_input.html')) + fp = sgmllib.SGMLParser() + while 1: + data = f.read(CHUNK) + fp.feed(data) + if len(data) != CHUNK: + break + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Mon Sep 11 06:18:06 2006 @@ -92,6 +92,8 @@ Library ------- +- Reverted patch #1504333 because it introduced an infinite loop. + - Fix missing import of the types module in logging.config. - Bug #1112549, DoS attack on cgi.FieldStorage. From python-checkins at python.org Mon Sep 11 06:24:11 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:24:11 +0200 (CEST) Subject: [Python-checkins] r51854 - in python/trunk: Lib/sgmllib.py Lib/test/sgml_input.html Lib/test/test_sgmllib.py Misc/NEWS Message-ID: <20060911042411.9309D1E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:24:09 2006 New Revision: 51854 Added: python/trunk/Lib/test/sgml_input.html - copied unchanged from r51850, python/branches/release25-maint/Lib/test/sgml_input.html Modified: python/trunk/Lib/sgmllib.py python/trunk/Lib/test/test_sgmllib.py python/trunk/Misc/NEWS Log: Forward port of 51850 from release25-maint branch. As mentioned on python-dev, reverting patch #1504333 because it introduced an infinite loop in rev 47154. This patch also adds a test to prevent the regression. Modified: python/trunk/Lib/sgmllib.py ============================================================================== --- python/trunk/Lib/sgmllib.py (original) +++ python/trunk/Lib/sgmllib.py Mon Sep 11 06:24:09 2006 @@ -29,12 +29,7 @@ shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') piclose = re.compile('>') -starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*(' - r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]' - r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?' - r')*\s*/?\s*(?=[<>])') -endtag = re.compile(r'])') +endbracket = re.compile('[<>]') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' @@ -254,10 +249,14 @@ self.finish_shorttag(tag, data) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k - match = starttag.match(rawdata, i) + # XXX The following should skip matching quotes (' or ") + # As a shortcut way to exit, this isn't so bad, but shouldn't + # be used to locate the actual end of the start tag since the + # < or > characters may be embedded in an attribute value. + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': @@ -306,10 +305,10 @@ # Internal -- parse endtag def parse_endtag(self, i): rawdata = self.rawdata - match = endtag.match(rawdata, i) + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) tag = rawdata[i+2:j].strip().lower() if rawdata[j] == '>': j = j+1 Modified: python/trunk/Lib/test/test_sgmllib.py ============================================================================== --- python/trunk/Lib/test/test_sgmllib.py (original) +++ python/trunk/Lib/test/test_sgmllib.py Mon Sep 11 06:24:09 2006 @@ -286,21 +286,6 @@ ('codepoint', 'convert', 42), ]) - def test_attr_values_quoted_markup(self): - """Multi-line and markup in attribute values""" - self.check_events("""text""", - [("starttag", "a", [("title", "foo\n
bar")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "less < than")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "greater > than")]), - ("data", "text"), - ("endtag", "a")]) - def test_attr_funky_names(self): self.check_events("""""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), @@ -376,6 +361,19 @@ ('decl', 'DOCTYPE doc []'), ]) + def test_read_chunks(self): + # SF bug #1541697, this caused sgml parser to hang + # Just verify this code doesn't cause a hang. + CHUNK = 1024 # increasing this to 8212 makes the problem go away + + f = open(test_support.findfile('sgml_input.html')) + fp = sgmllib.SGMLParser() + while 1: + data = f.read(CHUNK) + fp.feed(data) + if len(data) != CHUNK: + break + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Sep 11 06:24:09 2006 @@ -40,6 +40,8 @@ Library ------- +- Reverted patch #1504333 to sgmllib because it introduced an infinite loop. + - Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE by adding smarter caching in inspect.getmodule() From python-checkins at python.org Mon Sep 11 06:28:17 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:28:17 +0200 (CEST) Subject: [Python-checkins] r51855 - python/trunk/Python/import.c Message-ID: <20060911042817.D3BED1E4004@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:28:16 2006 New Revision: 51855 Modified: python/trunk/Python/import.c Log: Properly handle a NULL returned from PyArena_New(). (Also fix some whitespace) Klocwork #364. Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Mon Sep 11 06:28:16 2006 @@ -796,14 +796,16 @@ { PyCodeObject *co = NULL; mod_ty mod; - PyArena *arena = PyArena_New(); + PyArena *arena = PyArena_New(); + if (arena == NULL) + return NULL; mod = PyParser_ASTFromFile(fp, pathname, Py_file_input, 0, 0, 0, NULL, arena); if (mod) { co = PyAST_Compile(mod, pathname, NULL, arena); } - PyArena_Free(arena); + PyArena_Free(arena); return co; } From python-checkins at python.org Mon Sep 11 06:32:57 2006 From: python-checkins at python.org (neal.norwitz) Date: Mon, 11 Sep 2006 06:32:57 +0200 (CEST) Subject: [Python-checkins] r51856 - python/trunk/Lib/test/crashers/infinite_loop_re.py Message-ID: <20060911043257.95AFD1E4009@bag.python.org> Author: neal.norwitz Date: Mon Sep 11 06:32:57 2006 New Revision: 51856 Added: python/trunk/Lib/test/crashers/infinite_loop_re.py (contents, props changed) Log: Add a "crasher" taken from the sgml bug report referenced in the comment Added: python/trunk/Lib/test/crashers/infinite_loop_re.py ============================================================================== --- (empty file) +++ python/trunk/Lib/test/crashers/infinite_loop_re.py Mon Sep 11 06:32:57 2006 @@ -0,0 +1,16 @@ + +# This was taken from http://python.org/sf/1541697 +# It's not technically a crasher. It may not even truly be infinite, +# however, I haven't waited a long time to see the result. It takes +# 100% of CPU while running this and should be fixed. + +import re +starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*(' + r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' + r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]' + r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?' + r')*\s*/?\s*(?=[<>])') + +if __name__ == '__main__': + foo = ' Author: georg.brandl Date: Mon Sep 11 11:38:35 2006 New Revision: 51858 Modified: python/trunk/Misc/NEWS python/trunk/Python/pystate.c Log: Forward-port of rev. 51857: Building with HP's cc on HP-UX turned up a couple of problems. _PyGILState_NoteThreadState was declared as static inconsistently. Make it static as it's not necessary outside of this module. Some tests failed because errno was reset to 0. (I think the tests that failed were at least: test_fcntl and test_mailbox). Ensure that errno doesn't change after a call to Py_END_ALLOW_THREADS. This only affected debug builds. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Mon Sep 11 11:38:35 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Make _PyGILState_NoteThreadState() static, it was not used anywhere + outside of pystate.c and should not be necessary. + - Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. Also make sure that every exception class has __module__ set to 'exceptions'. Modified: python/trunk/Python/pystate.c ============================================================================== --- python/trunk/Python/pystate.c (original) +++ python/trunk/Python/pystate.c Mon Sep 11 11:38:35 2006 @@ -309,9 +309,14 @@ */ #if defined(Py_DEBUG) && defined(WITH_THREAD) if (newts) { + /* This can be called from PyEval_RestoreThread(). Similar + to it, we need to ensure errno doesn't change. + */ + int err = errno; PyThreadState *check = PyGILState_GetThisThreadState(); if (check && check->interp == newts->interp && check != newts) Py_FatalError("Invalid thread state for this thread"); + errno = err; } #endif return oldts; @@ -504,7 +509,7 @@ 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 +static void _PyGILState_NoteThreadState(PyThreadState* tstate) { /* If autoTLSkey is 0, this must be the very first threadstate created From buildbot at python.org Mon Sep 11 11:42:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 11 Sep 2006 09:42:19 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20060911094220.1D02B1E400A@bag.python.org> The Buildbot has detected a new failure of hppa Ubuntu dapper 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/hppa%2520Ubuntu%2520dapper%25202.5/builds/33 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon Sep 11 12:54:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 11 Sep 2006 10:54:24 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060911105424.C4DB01E4002@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%2520trunk/builds/1163 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon Sep 11 12:58:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 11 Sep 2006 10:58:20 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060911105821.1991E1E4002@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%2520trunk/builds/961 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From anthony at interlink.com.au Mon Sep 11 13:58:13 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Mon, 11 Sep 2006 21:58:13 +1000 Subject: [Python-checkins] BRANCH FREEZE: release25-maint, 00:00UTC 12 September 2006 Message-ID: <200609112158.19000.anthony@interlink.com.au> Ok, I haven't heard back from Martin, but I'm going to hope he's OK with tomorrow as a release date for 2.5rc2. If he's not, we'll try for the day after. In any case, I'm going to declare the release25-maint branch FROZEN as at 00:00 UTC on the 12th. That's about 12 hours from now. This is for 2.5rc2. Once this is out, I'd like to see as close to zero changes as possible for the next week or so until 2.5 final is released. My god, it's getting so close... Anthony -- Anthony Baxter It's never too late to have a happy childhood. From buildbot at python.org Mon Sep 11 14:04:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 11 Sep 2006 12:04:43 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060911120443.334E61E400A@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.5/builds/27 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon Sep 11 17:30:14 2006 From: python-checkins at python.org (anthony.baxter) Date: Mon, 11 Sep 2006 17:30:14 +0200 (CEST) Subject: [Python-checkins] r51859 - in python/branches/release25-maint: Doc/commontex/boilerplate.tex Include/patchlevel.h Lib/idlelib/NEWS.txt Lib/idlelib/idlever.py Misc/NEWS README Message-ID: <20060911153014.76AE81E400B@bag.python.org> Author: anthony.baxter Date: Mon Sep 11 17:30:13 2006 New Revision: 51859 Modified: python/branches/release25-maint/Doc/commontex/boilerplate.tex python/branches/release25-maint/Include/patchlevel.h python/branches/release25-maint/Lib/idlelib/NEWS.txt python/branches/release25-maint/Lib/idlelib/idlever.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/README Log: preparing for 2.5c2 Modified: python/branches/release25-maint/Doc/commontex/boilerplate.tex ============================================================================== --- python/branches/release25-maint/Doc/commontex/boilerplate.tex (original) +++ python/branches/release25-maint/Doc/commontex/boilerplate.tex Mon Sep 11 17:30:13 2006 @@ -5,5 +5,5 @@ Email: \email{docs at python.org} } -\date{17th August, 2006} % XXX update before final release! +\date{12th September, 2006} % XXX update before final release! \input{patchlevel} % include Python version information Modified: python/branches/release25-maint/Include/patchlevel.h ============================================================================== --- python/branches/release25-maint/Include/patchlevel.h (original) +++ python/branches/release25-maint/Include/patchlevel.h Mon Sep 11 17:30:13 2006 @@ -23,10 +23,10 @@ #define PY_MINOR_VERSION 5 #define PY_MICRO_VERSION 0 #define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 1 +#define PY_RELEASE_SERIAL 2 /* Version as a string */ -#define PY_VERSION "2.5c1" +#define PY_VERSION "2.5c2" /* Subversion Revision number of this file (not of the repository) */ #define PY_PATCHLEVEL_REVISION "$Revision$" Modified: python/branches/release25-maint/Lib/idlelib/NEWS.txt ============================================================================== --- python/branches/release25-maint/Lib/idlelib/NEWS.txt (original) +++ python/branches/release25-maint/Lib/idlelib/NEWS.txt Mon Sep 11 17:30:13 2006 @@ -1,3 +1,8 @@ +What's New in IDLE 1.2c2? +========================= + +*Release date: 12-SEP-2006* + What's New in IDLE 1.2c1? ========================= Modified: python/branches/release25-maint/Lib/idlelib/idlever.py ============================================================================== --- python/branches/release25-maint/Lib/idlelib/idlever.py (original) +++ python/branches/release25-maint/Lib/idlelib/idlever.py Mon Sep 11 17:30:13 2006 @@ -1 +1 @@ -IDLE_VERSION = "1.2c1" +IDLE_VERSION = "1.2c2" Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 11 17:30:13 2006 @@ -14,7 +14,7 @@ What's New in Python 2.5 release candidate 2? ============================================= -*Release date: XX-SEP-2006* +*Release date: 12-SEP-2006* Core and builtins ----------------- Modified: python/branches/release25-maint/README ============================================================================== --- python/branches/release25-maint/README (original) +++ python/branches/release25-maint/README Mon Sep 11 17:30:13 2006 @@ -1,4 +1,4 @@ -This is Python version 2.5 rc 1 +This is Python version 2.5 rc 2 =============================== Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation. From python-checkins at python.org Mon Sep 11 17:32:50 2006 From: python-checkins at python.org (anthony.baxter) Date: Mon, 11 Sep 2006 17:32:50 +0200 (CEST) Subject: [Python-checkins] r51860 - python/branches/release25-maint/Misc/NEWS Message-ID: <20060911153250.771EE1E400B@bag.python.org> Author: anthony.baxter Date: Mon Sep 11 17:32:50 2006 New Revision: 51860 Modified: python/branches/release25-maint/Misc/NEWS Log: remove 2.5 final section from NEWS.txt until after rc2 (reduced confusion) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 11 17:32:50 2006 @@ -4,13 +4,6 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) -What's New in Python 2.5? -============================================= - -*Release date: XX-SEP-2006* - -(Hopefully nothing.) - What's New in Python 2.5 release candidate 2? ============================================= From buildbot at python.org Mon Sep 11 18:09:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 11 Sep 2006 16:09:45 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP 2.5 Message-ID: <20060911160945.23B2D1E400B@bag.python.org> The Buildbot has detected a new failure of x86 XP 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP%25202.5/builds/29 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: anthony.baxter Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Mon Sep 11 18:22:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 11 Sep 2006 16:22:35 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20060911162236.10E6C1E400B@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%25202.5/builds/31 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: anthony.baxter Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 12 03:00:49 2006 From: python-checkins at python.org (anthony.baxter) Date: Tue, 12 Sep 2006 03:00:49 +0200 (CEST) Subject: [Python-checkins] r51861 - python/tags/r25c2 Message-ID: <20060912010049.BB42C1E400B@bag.python.org> Author: anthony.baxter Date: Tue Sep 12 03:00:45 2006 New Revision: 51861 Added: python/tags/r25c2/ - copied from r51860, python/branches/release25-maint/ Log: Tagging for release of Python 2.5c2 From python-checkins at python.org Tue Sep 12 11:16:28 2006 From: python-checkins at python.org (martin.v.loewis) Date: Tue, 12 Sep 2006 11:16:28 +0200 (CEST) Subject: [Python-checkins] r51862 - python/branches/release25-maint/Tools/msi/msi.py Message-ID: <20060912091628.9CBFA1E400C@bag.python.org> Author: martin.v.loewis Date: Tue Sep 12 11:16:28 2006 New Revision: 51862 Modified: python/branches/release25-maint/Tools/msi/msi.py Log: Add sgml_input.html. Modified: python/branches/release25-maint/Tools/msi/msi.py ============================================================================== --- python/branches/release25-maint/Tools/msi/msi.py (original) +++ python/branches/release25-maint/Tools/msi/msi.py Tue Sep 12 11:16:28 2006 @@ -921,6 +921,7 @@ lib.add_file("185test.db") lib.add_file("audiotest.au") lib.add_file("cfgparser.1") + lib.add_file("sgml_input.html") lib.add_file("test.xml") lib.add_file("test.xml.out") lib.add_file("testtar.tar") From anthony at interlink.com.au Tue Sep 12 13:15:57 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Tue, 12 Sep 2006 21:15:57 +1000 Subject: [Python-checkins] r51862 - python/branches/release25-maint/Tools/msi/msi.py In-Reply-To: <20060912091628.9CBFA1E400C@bag.python.org> References: <20060912091628.9CBFA1E400C@bag.python.org> Message-ID: <200609122116.01922.anthony@interlink.com.au> On Tuesday 12 September 2006 19:16, martin.v.loewis wrote: > Author: martin.v.loewis > Date: Tue Sep 12 11:16:28 2006 > New Revision: 51862 > > Modified: > python/branches/release25-maint/Tools/msi/msi.py > Log: > Add sgml_input.html. Hm. So this will be in the Windows installer for rc2, but not the source distro? Probably doesn't matter, given the imminent 2.5 final - but if something like this is needed before 2.5 final, please let me know and I'll have to re-cut the tarballs. Thanks, Anthony -- Anthony Baxter It's never too late to have a happy childhood. From buildbot at python.org Tue Sep 12 13:18:33 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 12 Sep 2006 11:18:33 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060912111833.638931E400D@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.5. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.5/builds/29 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Tue Sep 12 21:08:24 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 12 Sep 2006 21:08:24 +0200 (CEST) Subject: [Python-checkins] r51863 - in python/branches/bcannon-objcap: Doc/lib/libsqlite3.tex Doc/lib/sqlite3/executescript.py Doc/perl/python.perl Doc/whatsnew/whatsnew25.tex Grammar/Grammar Include/code.h Include/parsetok.h Lib/ctypes/test/test_bitfields.py Lib/ctypes/test/test_cast.py Lib/inspect.py Lib/logging/config.py Lib/plat-mac/aetools.py Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Lib/plat-sunos5/STROPTS.py Lib/sgmllib.py Lib/subprocess.py Lib/test/crashers/infinite_loop_re.py Lib/test/sgml_input.html Lib/test/test_exceptions.py Lib/test/test_inspect.py Lib/test/test_pep352.py Lib/test/test_sgmllib.py Lib/test/test_subprocess.py Mac/README Misc/HISTORY Misc/NEWS Modules/_ctypes/_ctypes.c Modules/_ctypes/stgdict.c Modules/posixmodule.c Modules/readline.c Objects/exceptions.c Objects/setobject.c PC/example_nt/example.vcproj PCbuild8/_ctypes.vcproj PCbuild8/_ctypes_test.vcproj PCbuild8/_elementtree.vcproj PCbuild8/_msi.vcproj PCbuild8/_sqlite3.vcproj PCbuild8/make_buildinfo.c PCbuild8/make_buildinfo.vcproj PCbuild8/pcbuild.sln PCbuild8/python.vcproj PCbuild8/pythoncore.vcproj PCbuild8/pythoncore_pgo.vcproj PCbuild8/pythoncore_pgo_link.txt PCbuild8/pythonw.vcproj PCbuild8/readme.txt PCbuild8/select.vcproj PCbuild8/unicodedata.vcproj PCbuild8/w9xpopen.vcproj PCbuild8/winsound.vcproj Parser/parsetok.c Python/ast.c Python/graminit.c Python/import.c Python/pystate.c Python/pythonrun.c Message-ID: <20060912190824.00FAA1E4011@bag.python.org> Author: brett.cannon Date: Tue Sep 12 21:08:12 2006 New Revision: 51863 Added: python/branches/bcannon-objcap/Lib/test/crashers/infinite_loop_re.py - copied unchanged from r51858, python/trunk/Lib/test/crashers/infinite_loop_re.py python/branches/bcannon-objcap/Lib/test/sgml_input.html - copied unchanged from r51858, python/trunk/Lib/test/sgml_input.html Removed: python/branches/bcannon-objcap/PCbuild8/pythoncore_pgo.vcproj python/branches/bcannon-objcap/PCbuild8/pythoncore_pgo_link.txt Modified: python/branches/bcannon-objcap/ (props changed) python/branches/bcannon-objcap/Doc/lib/libsqlite3.tex python/branches/bcannon-objcap/Doc/lib/sqlite3/executescript.py python/branches/bcannon-objcap/Doc/perl/python.perl python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex python/branches/bcannon-objcap/Grammar/Grammar python/branches/bcannon-objcap/Include/code.h python/branches/bcannon-objcap/Include/parsetok.h python/branches/bcannon-objcap/Lib/ctypes/test/test_bitfields.py python/branches/bcannon-objcap/Lib/ctypes/test/test_cast.py python/branches/bcannon-objcap/Lib/inspect.py python/branches/bcannon-objcap/Lib/logging/config.py python/branches/bcannon-objcap/Lib/plat-mac/aetools.py python/branches/bcannon-objcap/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py python/branches/bcannon-objcap/Lib/plat-sunos5/STROPTS.py python/branches/bcannon-objcap/Lib/sgmllib.py python/branches/bcannon-objcap/Lib/subprocess.py python/branches/bcannon-objcap/Lib/test/test_exceptions.py python/branches/bcannon-objcap/Lib/test/test_inspect.py python/branches/bcannon-objcap/Lib/test/test_pep352.py python/branches/bcannon-objcap/Lib/test/test_sgmllib.py python/branches/bcannon-objcap/Lib/test/test_subprocess.py python/branches/bcannon-objcap/Mac/README python/branches/bcannon-objcap/Misc/HISTORY python/branches/bcannon-objcap/Misc/NEWS python/branches/bcannon-objcap/Modules/_ctypes/_ctypes.c python/branches/bcannon-objcap/Modules/_ctypes/stgdict.c python/branches/bcannon-objcap/Modules/posixmodule.c python/branches/bcannon-objcap/Modules/readline.c python/branches/bcannon-objcap/Objects/exceptions.c python/branches/bcannon-objcap/Objects/setobject.c python/branches/bcannon-objcap/PC/example_nt/example.vcproj python/branches/bcannon-objcap/PCbuild8/_ctypes.vcproj python/branches/bcannon-objcap/PCbuild8/_ctypes_test.vcproj python/branches/bcannon-objcap/PCbuild8/_elementtree.vcproj python/branches/bcannon-objcap/PCbuild8/_msi.vcproj python/branches/bcannon-objcap/PCbuild8/_sqlite3.vcproj python/branches/bcannon-objcap/PCbuild8/make_buildinfo.c python/branches/bcannon-objcap/PCbuild8/make_buildinfo.vcproj python/branches/bcannon-objcap/PCbuild8/pcbuild.sln python/branches/bcannon-objcap/PCbuild8/python.vcproj python/branches/bcannon-objcap/PCbuild8/pythoncore.vcproj python/branches/bcannon-objcap/PCbuild8/pythonw.vcproj python/branches/bcannon-objcap/PCbuild8/readme.txt python/branches/bcannon-objcap/PCbuild8/select.vcproj python/branches/bcannon-objcap/PCbuild8/unicodedata.vcproj python/branches/bcannon-objcap/PCbuild8/w9xpopen.vcproj python/branches/bcannon-objcap/PCbuild8/winsound.vcproj python/branches/bcannon-objcap/Parser/parsetok.c python/branches/bcannon-objcap/Python/ast.c python/branches/bcannon-objcap/Python/graminit.c python/branches/bcannon-objcap/Python/import.c python/branches/bcannon-objcap/Python/pystate.c python/branches/bcannon-objcap/Python/pythonrun.c Log: Merged revisions 51748-51862 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/bcannon-objcap/Doc/lib/libsqlite3.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libsqlite3.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libsqlite3.tex Tue Sep 12 21:08:12 2006 @@ -6,14 +6,16 @@ \sectionauthor{Gerhard H?ring}{gh at ghaering.de} \versionadded{2.5} -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. To use the module, you must first create a \class{Connection} object that represents the database. Here the data will be stored in the @@ -34,8 +36,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks Modified: python/branches/bcannon-objcap/Doc/lib/sqlite3/executescript.py ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/sqlite3/executescript.py (original) +++ python/branches/bcannon-objcap/Doc/lib/sqlite3/executescript.py Tue Sep 12 21:08:12 2006 @@ -17,7 +17,7 @@ insert into book(title, author, published) values ( - 'Dirk Gently''s Holistic Detective Agency + 'Dirk Gently''s Holistic Detective Agency', 'Douglas Adams', 1987 ); Modified: python/branches/bcannon-objcap/Doc/perl/python.perl ============================================================================== --- python/branches/bcannon-objcap/Doc/perl/python.perl (original) +++ python/branches/bcannon-objcap/Doc/perl/python.perl Tue Sep 12 21:08:12 2006 @@ -883,6 +883,12 @@ $filename = 'grammar.txt'; } open(GRAMMAR, ">$filename") || die "\n$!\n"; + print GRAMMAR "##################################################\n"; + print GRAMMAR "# This file is only meant to be a guide, #\n"; + print GRAMMAR "# and differs in small ways from the real #\n"; + print GRAMMAR "# grammar. The exact reference is the file #\n"; + print GRAMMAR "# Grammar/Grammar distributed with the source. #\n"; + print GRAMMAR "##################################################\n"; print GRAMMAR strip_grammar_markup($DefinedGrammars{$lang}); close(GRAMMAR); print "Wrote grammar file $filename\n"; Modified: python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex (original) +++ python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex Tue Sep 12 21:08:12 2006 @@ -409,7 +409,7 @@ specific exceptions. You couldn't combine both \keyword{except} blocks and a \keyword{finally} block, because generating the right bytecode for the combined version was complicated and it wasn't clear what the -semantics of the combined should be. +semantics of the combined statement should be. Guido van~Rossum spent some time working with Java, which does support the equivalent of combining \keyword{except} blocks and a @@ -2116,14 +2116,16 @@ SQLite embedded database, has been added to the standard library under the package name \module{sqlite3}. -SQLite is a C library that provides a SQL-language database that -stores data in disk files without requiring a separate server process. +SQLite is a C library that provides a lightweight disk-based database +that doesn't require a separate server process and allows accessing +the database using a nonstandard variant of the SQL query language. +Some applications can use SQLite for internal data storage. It's also +possible to prototype an application using SQLite and then port the +code to a larger database such as PostgreSQL or Oracle. + pysqlite was written by Gerhard H\"aring and provides a SQL interface compliant with the DB-API 2.0 specification described by -\pep{249}. This means that it should be possible to write the first -version of your applications using SQLite for data storage. If -switching to a larger database such as PostgreSQL or Oracle is -later necessary, the switch should be relatively easy. +\pep{249}. If you're compiling the Python source yourself, note that the source tree doesn't include the SQLite code, only the wrapper module. @@ -2150,8 +2152,8 @@ # Create table c.execute('''create table stocks -(date timestamp, trans varchar, symbol varchar, - qty decimal, price decimal)''') +(date text, trans text, symbol text, + qty real, price real)''') # Insert a row of data c.execute("""insert into stocks Modified: python/branches/bcannon-objcap/Grammar/Grammar ============================================================================== --- python/branches/bcannon-objcap/Grammar/Grammar (original) +++ python/branches/bcannon-objcap/Grammar/Grammar Tue Sep 12 21:08:12 2006 @@ -64,8 +64,8 @@ import_name: 'import' dotted_as_names import_from: ('from' ('.'* dotted_name | '.'+) 'import' ('*' | '(' import_as_names ')' | import_as_names)) -import_as_name: NAME [('as' | NAME) NAME] -dotted_as_name: dotted_name [('as' | NAME) NAME] +import_as_name: NAME ['as' NAME] +dotted_as_name: dotted_name ['as' NAME] import_as_names: import_as_name (',' import_as_name)* [','] dotted_as_names: dotted_as_name (',' dotted_as_name)* dotted_name: NAME ('.' NAME)* @@ -83,7 +83,7 @@ ['finally' ':' suite] | 'finally' ':' suite)) with_stmt: 'with' test [ with_var ] ':' suite -with_var: ('as' | NAME) expr +with_var: 'as' expr # NB compile.c makes sure that the default except clause is last except_clause: 'except' [test [',' test]] suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT Modified: python/branches/bcannon-objcap/Include/code.h ============================================================================== --- python/branches/bcannon-objcap/Include/code.h (original) +++ python/branches/bcannon-objcap/Include/code.h Tue Sep 12 21:08:12 2006 @@ -52,7 +52,9 @@ /* This should be defined if a future statement modifies the syntax. For example, when a keyword is added. */ +#if 0 #define PY_PARSER_REQUIRES_FUTURE_KEYWORD +#endif #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ Modified: python/branches/bcannon-objcap/Include/parsetok.h ============================================================================== --- python/branches/bcannon-objcap/Include/parsetok.h (original) +++ python/branches/bcannon-objcap/Include/parsetok.h Tue Sep 12 21:08:12 2006 @@ -23,7 +23,9 @@ #define PyPARSE_DONT_IMPLY_DEDENT 0x0002 +#if 0 #define PyPARSE_WITH_IS_KEYWORD 0x0003 +#endif PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, perrdetail *); Modified: python/branches/bcannon-objcap/Lib/ctypes/test/test_bitfields.py ============================================================================== --- python/branches/bcannon-objcap/Lib/ctypes/test/test_bitfields.py (original) +++ python/branches/bcannon-objcap/Lib/ctypes/test/test_bitfields.py Tue Sep 12 21:08:12 2006 @@ -215,5 +215,14 @@ ("b", c_ubyte, 4)] self.failUnlessEqual(sizeof(X), sizeof(c_byte)) + def test_anon_bitfields(self): + # anonymous bit-fields gave a strange error message + class X(Structure): + _fields_ = [("a", c_byte, 4), + ("b", c_ubyte, 4)] + class Y(Structure): + _anonymous_ = ["_"] + _fields_ = [("_", X)] + if __name__ == "__main__": unittest.main() Modified: python/branches/bcannon-objcap/Lib/ctypes/test/test_cast.py ============================================================================== --- python/branches/bcannon-objcap/Lib/ctypes/test/test_cast.py (original) +++ python/branches/bcannon-objcap/Lib/ctypes/test/test_cast.py Tue Sep 12 21:08:12 2006 @@ -57,5 +57,21 @@ c_int() self.failUnlessEqual(p[:4], [1, 2, 96, 4]) + def test_char_p(self): + # This didn't work: bad argument to internal function + s = c_char_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_char_p).value, + "hiho") + + try: + c_wchar_p + except NameError: + pass + else: + def test_wchar_p(self): + s = c_wchar_p("hiho") + self.failUnlessEqual(cast(cast(s, c_void_p), c_wchar_p).value, + "hiho") + if __name__ == "__main__": unittest.main() Modified: python/branches/bcannon-objcap/Lib/inspect.py ============================================================================== --- python/branches/bcannon-objcap/Lib/inspect.py (original) +++ python/branches/bcannon-objcap/Lib/inspect.py Tue Sep 12 21:08:12 2006 @@ -403,6 +403,7 @@ return os.path.normcase(os.path.abspath(_filename)) modulesbyfile = {} +_filesbymodname = {} def getmodule(object, _filename=None): """Return the module an object was defined in, or None if not found.""" @@ -410,19 +411,32 @@ return object if hasattr(object, '__module__'): return sys.modules.get(object.__module__) + # Try the filename to modulename cache + if _filename is not None and _filename in modulesbyfile: + return sys.modules.get(modulesbyfile[_filename]) + # Try the cache again with the absolute file name try: file = getabsfile(object, _filename) except TypeError: return None if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) - for module in sys.modules.values(): + # Update the filename to module name cache and check yet again + # Copy sys.modules in order to cope with changes while iterating + for modname, module in sys.modules.items(): if ismodule(module) and hasattr(module, '__file__'): + f = module.__file__ + if f == _filesbymodname.get(modname, None): + # Have already mapped this module, so skip it + continue + _filesbymodname[modname] = f f = getabsfile(module) + # Always map to the name the module knows itself by modulesbyfile[f] = modulesbyfile[ os.path.realpath(f)] = module.__name__ if file in modulesbyfile: return sys.modules.get(modulesbyfile[file]) + # Check the main module main = sys.modules['__main__'] if not hasattr(object, '__name__'): return None @@ -430,6 +444,7 @@ mainobject = getattr(main, object.__name__) if mainobject is object: return main + # Check builtins builtin = sys.modules['__builtin__'] if hasattr(builtin, object.__name__): builtinobject = getattr(builtin, object.__name__) @@ -444,7 +459,7 @@ in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved.""" file = getsourcefile(object) or getfile(object) - module = getmodule(object) + module = getmodule(object, file) if module: lines = linecache.getlines(file, module.__dict__) else: Modified: python/branches/bcannon-objcap/Lib/logging/config.py ============================================================================== --- python/branches/bcannon-objcap/Lib/logging/config.py (original) +++ python/branches/bcannon-objcap/Lib/logging/config.py Tue Sep 12 21:08:12 2006 @@ -27,7 +27,7 @@ To use, simply 'import logging' and log away! """ -import sys, logging, logging.handlers, string, socket, struct, os, traceback +import sys, logging, logging.handlers, string, socket, struct, os, traceback, types try: import thread Modified: python/branches/bcannon-objcap/Lib/plat-mac/aetools.py ============================================================================== --- python/branches/bcannon-objcap/Lib/plat-mac/aetools.py (original) +++ python/branches/bcannon-objcap/Lib/plat-mac/aetools.py Tue Sep 12 21:08:12 2006 @@ -233,7 +233,7 @@ """Send 'activate' command""" self.send('misc', 'actv') - def _get(self, _object, as=None, _attributes={}): + def _get(self, _object, asfile=None, _attributes={}): """_get: get data from an object Required argument: the object Keyword argument _attributes: AppleEvent attribute dictionary @@ -243,8 +243,8 @@ _subcode = 'getd' _arguments = {'----':_object} - if as: - _arguments['rtyp'] = mktype(as) + if asfile: + _arguments['rtyp'] = mktype(asfile) _reply, _arguments, _attributes = self.send(_code, _subcode, _arguments, _attributes) @@ -253,8 +253,8 @@ if _arguments.has_key('----'): return _arguments['----'] - if as: - item.__class__ = as + if asfile: + item.__class__ = asfile return item get = _get Modified: python/branches/bcannon-objcap/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py ============================================================================== --- python/branches/bcannon-objcap/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py (original) +++ python/branches/bcannon-objcap/Lib/plat-mac/lib-scriptpackages/StdSuites/AppleScript_Suite.py Tue Sep 12 21:08:12 2006 @@ -300,7 +300,7 @@ if _arguments.has_key('----'): return _arguments['----'] - def as(self, _object, _attributes={}, **_arguments): + def as_(self, _object, _attributes={}, **_arguments): """as: Coercion Required argument: an AE object reference Keyword argument _attributes: AppleEvent attribute dictionary Modified: python/branches/bcannon-objcap/Lib/plat-sunos5/STROPTS.py ============================================================================== --- python/branches/bcannon-objcap/Lib/plat-sunos5/STROPTS.py (original) +++ python/branches/bcannon-objcap/Lib/plat-sunos5/STROPTS.py Tue Sep 12 21:08:12 2006 @@ -1550,7 +1550,7 @@ AS_PAGLCK = 0x80 AS_CLAIMGAP = 0x40 AS_UNMAPWAIT = 0x20 -def AS_TYPE_64BIT(as): return \ +def AS_TYPE_64BIT(as_): return \ AS_LREP_LINKEDLIST = 0 AS_LREP_SKIPLIST = 1 Modified: python/branches/bcannon-objcap/Lib/sgmllib.py ============================================================================== --- python/branches/bcannon-objcap/Lib/sgmllib.py (original) +++ python/branches/bcannon-objcap/Lib/sgmllib.py Tue Sep 12 21:08:12 2006 @@ -29,12 +29,7 @@ shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') piclose = re.compile('>') -starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*(' - r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' - r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]' - r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?' - r')*\s*/?\s*(?=[<>])') -endtag = re.compile(r'])') +endbracket = re.compile('[<>]') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*' @@ -254,10 +249,14 @@ self.finish_shorttag(tag, data) self.__starttag_text = rawdata[start_pos:match.end(1) + 1] return k - match = starttag.match(rawdata, i) + # XXX The following should skip matching quotes (' or ") + # As a shortcut way to exit, this isn't so bad, but shouldn't + # be used to locate the actual end of the start tag since the + # < or > characters may be embedded in an attribute value. + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) # Now parse the data between i+1 and j into a tag and attrs attrs = [] if rawdata[i:i+2] == '<>': @@ -306,10 +305,10 @@ # Internal -- parse endtag def parse_endtag(self, i): rawdata = self.rawdata - match = endtag.match(rawdata, i) + match = endbracket.search(rawdata, i+1) if not match: return -1 - j = match.end(0) + j = match.start(0) tag = rawdata[i+2:j].strip().lower() if rawdata[j] == '>': j = j+1 Modified: python/branches/bcannon-objcap/Lib/subprocess.py ============================================================================== --- python/branches/bcannon-objcap/Lib/subprocess.py (original) +++ python/branches/bcannon-objcap/Lib/subprocess.py Tue Sep 12 21:08:12 2006 @@ -1000,14 +1000,10 @@ if errwrite: os.dup2(errwrite, 2) - # Close pipe fds. Make sure we doesn't close the same - # fd more than once. - if p2cread: - os.close(p2cread) - if c2pwrite and c2pwrite not in (p2cread,): - os.close(c2pwrite) - if errwrite and errwrite not in (p2cread, c2pwrite): - os.close(errwrite) + # Close pipe fds. Make sure we don't close the same + # fd more than once, or standard fds. + for fd in set((p2cread, c2pwrite, errwrite))-set((0,1,2)): + if fd: os.close(fd) # Close all other fds, if asked for if close_fds: Modified: python/branches/bcannon-objcap/Lib/test/test_exceptions.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_exceptions.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_exceptions.py Tue Sep 12 21:08:12 2006 @@ -185,15 +185,6 @@ def testAttributes(self): # test that exception attributes are happy - try: - str(u'Hello \u00E1') - except Exception, e: - sampleUnicodeEncodeError = e - - try: - unicode('\xff') - except Exception, e: - sampleUnicodeDecodeError = e exceptionList = [ (BaseException, (), {'message' : '', 'args' : ()}), @@ -236,16 +227,16 @@ 'print_file_and_line' : None, 'msg' : 'msgStr', 'filename' : None, 'lineno' : None, 'offset' : None}), (UnicodeError, (), {'message' : '', 'args' : (),}), - (sampleUnicodeEncodeError, - {'message' : '', 'args' : ('ascii', u'Hello \xe1', 6, 7, - 'ordinal not in range(128)'), - 'encoding' : 'ascii', 'object' : u'Hello \xe1', - 'start' : 6, 'reason' : 'ordinal not in range(128)'}), - (sampleUnicodeDecodeError, + (UnicodeEncodeError, ('ascii', u'a', 0, 1, 'ordinal not in range'), + {'message' : '', 'args' : ('ascii', u'a', 0, 1, + 'ordinal not in range'), + 'encoding' : 'ascii', 'object' : u'a', + 'start' : 0, 'reason' : 'ordinal not in range'}), + (UnicodeDecodeError, ('ascii', '\xff', 0, 1, 'ordinal not in range'), {'message' : '', 'args' : ('ascii', '\xff', 0, 1, - 'ordinal not in range(128)'), + 'ordinal not in range'), 'encoding' : 'ascii', 'object' : '\xff', - 'start' : 0, 'reason' : 'ordinal not in range(128)'}), + 'start' : 0, 'reason' : 'ordinal not in range'}), (UnicodeTranslateError, (u"\u3042", 0, 1, "ouch"), {'message' : '', 'args' : (u'\u3042', 0, 1, 'ouch'), 'object' : u'\u3042', 'reason' : 'ouch', @@ -261,18 +252,14 @@ except NameError: pass - for args in exceptionList: - expected = args[-1] + for exc, args, expected in exceptionList: try: - exc = args[0] - if len(args) == 2: - raise exc - else: - raise exc(*args[1]) + raise exc(*args) except BaseException, e: - if (e is not exc and # needed for sampleUnicode errors - type(e) is not exc): + if type(e) is not exc: raise + # Verify module name + self.assertEquals(type(e).__module__, 'exceptions') # Verify no ref leaks in Exc_str() s = str(e) for checkArgName in expected: @@ -317,6 +304,15 @@ return -1 self.assertRaises(RuntimeError, g) + def testUnicodeStrUsage(self): + # Make sure both instances and classes have a str and unicode + # representation. + self.failUnless(str(Exception)) + self.failUnless(unicode(Exception)) + self.failUnless(str(Exception('a'))) + self.failUnless(unicode(Exception(u'a'))) + + def test_main(): run_unittest(ExceptionTests) Modified: python/branches/bcannon-objcap/Lib/test/test_inspect.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_inspect.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_inspect.py Tue Sep 12 21:08:12 2006 @@ -178,7 +178,18 @@ self.assertEqual(inspect.getcomments(mod.StupidGit), '# line 20\n') def test_getmodule(self): + # Check actual module + self.assertEqual(inspect.getmodule(mod), mod) + # Check class (uses __module__ attribute) self.assertEqual(inspect.getmodule(mod.StupidGit), mod) + # Check a method (no __module__ attribute, falls back to filename) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Do it again (check the caching isn't broken) + self.assertEqual(inspect.getmodule(mod.StupidGit.abuse), mod) + # Check a builtin + self.assertEqual(inspect.getmodule(str), sys.modules["__builtin__"]) + # Check filename override + self.assertEqual(inspect.getmodule(None, modfile), mod) def test_getsource(self): self.assertSourceEqual(git.abuse, 29, 39) Modified: python/branches/bcannon-objcap/Lib/test/test_pep352.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_pep352.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_pep352.py Tue Sep 12 21:08:12 2006 @@ -15,8 +15,7 @@ self.failUnless(issubclass(Exception, object)) def verify_instance_interface(self, ins): - for attr in ("args", "message", "__str__", "__unicode__", "__repr__", - "__getitem__"): + for attr in ("args", "message", "__str__", "__repr__", "__getitem__"): self.failUnless(hasattr(ins, attr), "%s missing %s attribute" % (ins.__class__.__name__, attr)) Modified: python/branches/bcannon-objcap/Lib/test/test_sgmllib.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_sgmllib.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_sgmllib.py Tue Sep 12 21:08:12 2006 @@ -286,21 +286,6 @@ ('codepoint', 'convert', 42), ]) - def test_attr_values_quoted_markup(self): - """Multi-line and markup in attribute values""" - self.check_events("""text""", - [("starttag", "a", [("title", "foo\n
bar")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "less < than")]), - ("data", "text"), - ("endtag", "a")]) - self.check_events("""text""", - [("starttag", "a", [("title", "greater > than")]), - ("data", "text"), - ("endtag", "a")]) - def test_attr_funky_names(self): self.check_events("""""", [ ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]), @@ -376,6 +361,19 @@ ('decl', 'DOCTYPE doc []'), ]) + def test_read_chunks(self): + # SF bug #1541697, this caused sgml parser to hang + # Just verify this code doesn't cause a hang. + CHUNK = 1024 # increasing this to 8212 makes the problem go away + + f = open(test_support.findfile('sgml_input.html')) + fp = sgmllib.SGMLParser() + while 1: + data = f.read(CHUNK) + fp.feed(data) + if len(data) != CHUNK: + break + # XXX These tests have been disabled by prefixing their names with # an underscore. The first two exercise outstanding bugs in the # sgmllib module, and the third exhibits questionable behavior Modified: python/branches/bcannon-objcap/Lib/test/test_subprocess.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_subprocess.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_subprocess.py Tue Sep 12 21:08:12 2006 @@ -234,6 +234,12 @@ stripped = remove_stderr_debug_decorations(output) self.assertEqual(stripped, "appleorange") + def test_stdout_filedes_of_stdout(self): + # stdout is set to 1 (#1531862). + cmd = r"import sys, os; sys.exit(os.write(sys.stdout.fileno(), '.\n'))" + rc = subprocess.call([sys.executable, "-c", cmd], stdout=1) + self.assertEquals(rc, 2) + def test_cwd(self): tmpdir = os.getenv("TEMP", "/tmp") # We cannot use os.path.realpath to canonicalize the path, Modified: python/branches/bcannon-objcap/Mac/README ============================================================================== --- python/branches/bcannon-objcap/Mac/README (original) +++ python/branches/bcannon-objcap/Mac/README Tue Sep 12 21:08:12 2006 @@ -48,7 +48,7 @@ A second reason for using frameworks is that they put Python-related items in only two places: "/Library/Framework/Python.framework" and -"/Applications/MacPython 2.5". This simplifies matters for users installing +"/Applications/MacPython 2.6". This simplifies matters for users installing Python from a binary distribution if they want to get rid of it again. Moreover, due to the way frameworks work a user without admin privileges can install a binary distribution in his or her home directory without recompilation. @@ -75,7 +75,7 @@ This directory contains a Makefile that will create a couple of python-related applications (fullblown OSX .app applications, that is) in -"/Applications/MacPython 2.3", and a hidden helper application Python.app +"/Applications/MacPython 2.6", and a hidden helper application Python.app inside the Python.framework, and unix tools "python" and "pythonw" into /usr/local/bin. In addition it has a target "installmacsubtree" that installs the relevant portions of the Mac subtree into the Python.framework. @@ -90,20 +90,16 @@ 3. make install This sequence will put the framework in /Library/Framework/Python.framework, -the applications in /Applications/MacPython 2.5 and the unix tools in +the applications in "/Applications/MacPython 2.6" and the unix tools in /usr/local/bin. Installing in another place, for instance $HOME/Library/Frameworks if you have no admin privileges on your machine, has only been tested very lightly. This can be done by configuring with --enable-framework=$HOME/Library/Frameworks. -The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will -then also be deposited in $HOME. This is sub-optimal for the unix tools, which -you would want in $HOME/bin, but there is no easy way to fix this right now. - -Note that there are no references to the actual locations in the code or -resource files, so you are free to move things around afterwards. For example, -you could use --enable-framework=/tmp/newversion/Library/Frameworks and use -/tmp/newversion as the basis for an installer or something. +The other two directories, "/Applications/MacPython-2.6" and /usr/local/bin, +will then also be deposited in $HOME. This is sub-optimal for the unix tools, +which you would want in $HOME/bin, but there is no easy way to fix this right +now. If you want to install some part, but not all, read the main Makefile. The frameworkinstall is composed of a couple of sub-targets that install the @@ -111,7 +107,7 @@ There is an extra target frameworkinstallextras that is not part of the normal frameworkinstall which installs the Demo and Tools directories -into /Applications/MacPython-2.3, this is useful for binary distributions. +into "/Applications/MacPython 2.6", this is useful for binary distributions. What do all these programs do? =============================== Modified: python/branches/bcannon-objcap/Misc/HISTORY ============================================================================== --- python/branches/bcannon-objcap/Misc/HISTORY (original) +++ python/branches/bcannon-objcap/Misc/HISTORY Tue Sep 12 21:08:12 2006 @@ -11679,7 +11679,7 @@ - The way GNU readline is configured is totally different. The --with-readline configure option is gone. It is now an extension module, which may be loaded dynamically. You must enable it (and -specify the correct linraries to link with) in the Modules/Setup file. +specify the correct libraries to link with) in the Modules/Setup file. Importing the module installs some hooks which enable command line editing. When the interpreter shell is invoked interactively, it attempts to import the readline module; when this fails, the default Modified: python/branches/bcannon-objcap/Misc/NEWS ============================================================================== --- python/branches/bcannon-objcap/Misc/NEWS (original) +++ python/branches/bcannon-objcap/Misc/NEWS Tue Sep 12 21:08:12 2006 @@ -12,6 +12,16 @@ Core and builtins ----------------- +- Make _PyGILState_NoteThreadState() static, it was not used anywhere + outside of pystate.c and should not be necessary. + +- Bug #1542051: Exceptions now correctly call PyObject_GC_UnTrack. + Also make sure that every exception class has __module__ set to + 'exceptions'. + +- Bug #1550983: emit better error messages for erroneous relative + imports (if not in package and if beyond toplevel package). + - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. @@ -27,20 +37,34 @@ required changing the .pyc magic number. This means that .pyc files generated before 2.5c2 will be regenerated. +- with and as are now keywords. + Library ------- +- Reverted patch #1504333 to sgmllib because it introduced an infinite loop. + +- Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE + by adding smarter caching in inspect.getmodule() + +- Fix missing import of the types module in logging.config. + - Patch #1550886: Fix decimal module context management implementation to match the localcontext() example from PEP 343. - Bug #1541863: uuid.uuid1 failed to generate unique identifiers on systems with low clock resolution. +- Bug #1531862: Do not close standard file descriptors in subprocess. + Extension Modules ----------------- +- Bug #1551427: fix a wrong NULL pointer check in the win32 version + of os.urandom(). + - Bug #1548092: fix curses.tparm seg fault on invalid input. - Bug #1550714: fix SystemError from itertools.tee on negative value for n. @@ -67,6 +91,13 @@ to a newly created list object and add notes that this isn't a good idea. +Tools +----- + +- Bug #1546372: Fixed small bugglet in pybench that caused a missing + file not to get reported properly. + + Build ----- Modified: python/branches/bcannon-objcap/Modules/_ctypes/_ctypes.c ============================================================================== --- python/branches/bcannon-objcap/Modules/_ctypes/_ctypes.c (original) +++ python/branches/bcannon-objcap/Modules/_ctypes/_ctypes.c Tue Sep 12 21:08:12 2006 @@ -4597,11 +4597,11 @@ if (obj->b_objects == NULL) goto failed; } + Py_XINCREF(obj->b_objects); result->b_objects = obj->b_objects; - if (result->b_objects) { + if (result->b_objects && PyDict_Check(result->b_objects)) { PyObject *index; int rc; - Py_INCREF(obj->b_objects); index = PyLong_FromVoidPtr((void *)src); if (index == NULL) goto failed; Modified: python/branches/bcannon-objcap/Modules/_ctypes/stgdict.c ============================================================================== --- python/branches/bcannon-objcap/Modules/_ctypes/stgdict.c (original) +++ python/branches/bcannon-objcap/Modules/_ctypes/stgdict.c Tue Sep 12 21:08:12 2006 @@ -177,11 +177,11 @@ for (i = 0; i < PySequence_Fast_GET_SIZE(fieldlist); ++i) { PyObject *pair = PySequence_Fast_GET_ITEM(fieldlist, i); /* borrowed */ - PyObject *fname, *ftype; + PyObject *fname, *ftype, *bits; CFieldObject *fdescr; CFieldObject *new_descr; /* Convert to PyArg_UnpackTuple... */ - if (!PyArg_ParseTuple(pair, "OO", &fname, &ftype)) { + if (!PyArg_ParseTuple(pair, "OO|O", &fname, &ftype, &bits)) { Py_DECREF(fieldlist); return -1; } Modified: python/branches/bcannon-objcap/Modules/posixmodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/posixmodule.c (original) +++ python/branches/bcannon-objcap/Modules/posixmodule.c Tue Sep 12 21:08:12 2006 @@ -7877,7 +7877,7 @@ pCryptGenRandom = (CRYPTGENRANDOM)GetProcAddress( hAdvAPI32, "CryptGenRandom"); - if (pCryptAcquireContext == NULL) + if (pCryptGenRandom == NULL) return PyErr_Format(PyExc_NotImplementedError, "CryptGenRandom not found"); Modified: python/branches/bcannon-objcap/Modules/readline.c ============================================================================== --- python/branches/bcannon-objcap/Modules/readline.c (original) +++ python/branches/bcannon-objcap/Modules/readline.c Tue Sep 12 21:08:12 2006 @@ -768,10 +768,16 @@ while (!has_input) { struct timeval timeout = {0, 100000}; /* 0.1 seconds */ + + /* [Bug #1552726] Only limit the pause if an input hook has been + defined. */ + struct timeval *timeoutp = NULL; + if (PyOS_InputHook) + timeoutp = &timeout; FD_SET(fileno(rl_instream), &selectset); /* select resets selectset if no input was available */ has_input = select(fileno(rl_instream) + 1, &selectset, - NULL, NULL, &timeout); + NULL, NULL, timeoutp); if(PyOS_InputHook) PyOS_InputHook(); } Modified: python/branches/bcannon-objcap/Objects/exceptions.c ============================================================================== --- python/branches/bcannon-objcap/Objects/exceptions.c (original) +++ python/branches/bcannon-objcap/Objects/exceptions.c Tue Sep 12 21:08:12 2006 @@ -81,6 +81,7 @@ static void BaseException_dealloc(PyBaseExceptionObject *self) { + _PyObject_GC_UNTRACK(self); BaseException_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -174,27 +175,10 @@ Py_RETURN_NONE; } -#ifdef Py_USING_UNICODE -/* while this method generates fairly uninspired output, it a least - * guarantees that we can display exceptions that have unicode attributes - */ -static PyObject * -BaseException_unicode(PyBaseExceptionObject *self) -{ - if (PyTuple_GET_SIZE(self->args) == 0) - return PyUnicode_FromUnicode(NULL, 0); - if (PyTuple_GET_SIZE(self->args) == 1) - return PyObject_Unicode(PyTuple_GET_ITEM(self->args, 0)); - return PyObject_Unicode(self->args); -} -#endif /* Py_USING_UNICODE */ static PyMethodDef BaseException_methods[] = { {"__reduce__", (PyCFunction)BaseException_reduce, METH_NOARGS }, {"__setstate__", (PyCFunction)BaseException_setstate, METH_O }, -#ifdef Py_USING_UNICODE - {"__unicode__", (PyCFunction)BaseException_unicode, METH_NOARGS }, -#endif {NULL, NULL, 0, NULL}, }; @@ -456,6 +440,7 @@ static void SystemExit_dealloc(PySystemExitObject *self) { + _PyObject_GC_UNTRACK(self); SystemExit_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -562,6 +547,7 @@ static void EnvironmentError_dealloc(PyEnvironmentErrorObject *self) { + _PyObject_GC_UNTRACK(self); EnvironmentError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -760,6 +746,7 @@ static void WindowsError_dealloc(PyWindowsErrorObject *self) { + _PyObject_GC_UNTRACK(self); WindowsError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1035,6 +1022,7 @@ static void SyntaxError_dealloc(PySyntaxErrorObject *self) { + _PyObject_GC_UNTRACK(self); SyntaxError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1551,6 +1539,7 @@ static void UnicodeError_dealloc(PyUnicodeErrorObject *self) { + _PyObject_GC_UNTRACK(self); UnicodeError_clear(self); self->ob_type->tp_free((PyObject *)self); } @@ -1637,7 +1626,7 @@ static PyTypeObject _PyExc_UnicodeEncodeError = { PyObject_HEAD_INIT(NULL) 0, - "UnicodeEncodeError", + EXC_MODULE_NAME "UnicodeEncodeError", sizeof(PyUnicodeErrorObject), 0, (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeEncodeError_str, 0, 0, 0, @@ -1812,7 +1801,7 @@ (destructor)UnicodeError_dealloc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (reprfunc)UnicodeTranslateError_str, 0, 0, 0, Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, - PyDoc_STR("Unicode decoding error."), (traverseproc)UnicodeError_traverse, + PyDoc_STR("Unicode translation error."), (traverseproc)UnicodeError_traverse, (inquiry)UnicodeError_clear, 0, 0, 0, 0, 0, UnicodeError_members, 0, &_PyExc_UnicodeError, 0, 0, 0, offsetof(PyUnicodeErrorObject, dict), (initproc)UnicodeTranslateError_init, 0, BaseException_new, Modified: python/branches/bcannon-objcap/Objects/setobject.c ============================================================================== --- python/branches/bcannon-objcap/Objects/setobject.c (original) +++ python/branches/bcannon-objcap/Objects/setobject.c Tue Sep 12 21:08:12 2006 @@ -319,8 +319,10 @@ assert(so->fill <= so->mask); /* at least one empty slot */ n_used = so->used; Py_INCREF(entry->key); - if (set_insert_key(so, entry->key, entry->hash) == -1) + if (set_insert_key(so, entry->key, entry->hash) == -1) { + Py_DECREF(entry->key); return -1; + } if (!(so->used > n_used && so->fill*3 >= (so->mask+1)*2)) return 0; return set_table_resize(so, so->used>50000 ? so->used*2 : so->used*4); @@ -1138,7 +1140,12 @@ } while (set_next((PySetObject *)other, &pos, &entry)) { - if (set_contains_entry(so, entry)) { + int rv = set_contains_entry(so, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (rv) { if (set_add_entry(result, entry) == -1) { Py_DECREF(result); return NULL; @@ -1155,7 +1162,14 @@ } while ((key = PyIter_Next(it)) != NULL) { - if (set_contains_key(so, key)) { + int rv = set_contains_key(so, key); + if (rv == -1) { + Py_DECREF(it); + Py_DECREF(result); + Py_DECREF(key); + return NULL; + } + if (rv) { if (set_add_key(result, key) == -1) { Py_DECREF(it); Py_DECREF(result); @@ -1232,7 +1246,8 @@ Py_ssize_t pos = 0; while (set_next((PySetObject *)other, &pos, &entry)) - set_discard_entry(so, entry); + if (set_discard_entry(so, entry) == -1) + return -1; } else { PyObject *key, *it; it = PyObject_GetIter(other); @@ -1295,17 +1310,26 @@ entrycopy.hash = entry->hash; entrycopy.key = entry->key; if (!PyDict_Contains(other, entry->key)) { - if (set_add_entry((PySetObject *)result, &entrycopy) == -1) + if (set_add_entry((PySetObject *)result, &entrycopy) == -1) { + Py_DECREF(result); return NULL; + } } } return result; } while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) { - if (set_add_entry((PySetObject *)result, entry) == -1) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) { + Py_DECREF(result); + return NULL; + } + if (!rv) { + if (set_add_entry((PySetObject *)result, entry) == -1) { + Py_DECREF(result); return NULL; + } } } return result; @@ -1464,7 +1488,10 @@ Py_RETURN_FALSE; while (set_next(so, &pos, &entry)) { - if (!set_contains_entry((PySetObject *)other, entry)) + int rv = set_contains_entry((PySetObject *)other, entry); + if (rv == -1) + return NULL; + if (!rv) Py_RETURN_FALSE; } Py_RETURN_TRUE; Modified: python/branches/bcannon-objcap/PC/example_nt/example.vcproj ============================================================================== --- python/branches/bcannon-objcap/PC/example_nt/example.vcproj (original) +++ python/branches/bcannon-objcap/PC/example_nt/example.vcproj Tue Sep 12 21:08:12 2006 @@ -39,7 +39,7 @@ + + +