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 @@ + + + @@ -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/branches/bcannon-objcap/PCbuild8/make_buildinfo.vcproj ============================================================================== --- python/branches/bcannon-objcap/PCbuild8/make_buildinfo.vcproj (original) +++ python/branches/bcannon-objcap/PCbuild8/make_buildinfo.vcproj Tue Sep 12 21:08: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/branches/bcannon-objcap/PCbuild8/pcbuild.sln ============================================================================== --- python/branches/bcannon-objcap/PCbuild8/pcbuild.sln (original) +++ python/branches/bcannon-objcap/PCbuild8/pcbuild.sln Tue Sep 12 21:08: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/branches/bcannon-objcap/PCbuild8/python.vcproj ============================================================================== --- python/branches/bcannon-objcap/PCbuild8/python.vcproj (original) +++ python/branches/bcannon-objcap/PCbuild8/python.vcproj Tue Sep 12 21:08: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/branches/bcannon-objcap/PCbuild8/pythoncore_pgo.vcproj ============================================================================== --- /python/branches/bcannon-objcap/PCbuild8/pythoncore_pgo.vcproj Tue Sep 12 21:08:12 2006 +++ (empty file) @@ -1,781 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Deleted: /python/branches/bcannon-objcap/PCbuild8/pythoncore_pgo_link.txt ============================================================================== --- /python/branches/bcannon-objcap/PCbuild8/pythoncore_pgo_link.txt Tue Sep 12 21:08: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/branches/bcannon-objcap/PCbuild8/pythonw.vcproj ============================================================================== --- python/branches/bcannon-objcap/PCbuild8/pythonw.vcproj (original) +++ python/branches/bcannon-objcap/PCbuild8/pythonw.vcproj Tue Sep 12 21:08: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/branches/bcannon-objcap/PCbuild8/winsound.vcproj ============================================================================== --- python/branches/bcannon-objcap/PCbuild8/winsound.vcproj (original) +++ python/branches/bcannon-objcap/PCbuild8/winsound.vcproj Tue Sep 12 21:08:12 2006 @@ -4,19 +4,23 @@ Version="8,00" Name="winsound" ProjectGUID="{51F35FAE-FB92-4B2C-9187-1542C065AD77}" + RootNamespace="winsound" > + 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/branches/bcannon-objcap/Python/graminit.c ============================================================================== --- python/branches/bcannon-objcap/Python/graminit.c (original) +++ python/branches/bcannon-objcap/Python/graminit.c Tue Sep 12 21:08:12 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/branches/bcannon-objcap/Python/import.c ============================================================================== --- python/branches/bcannon-objcap/Python/import.c (original) +++ python/branches/bcannon-objcap/Python/import.c Tue Sep 12 21:08:12 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; } @@ -2114,7 +2116,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 +2135,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'; Modified: python/branches/bcannon-objcap/Python/pystate.c ============================================================================== --- python/branches/bcannon-objcap/Python/pystate.c (original) +++ python/branches/bcannon-objcap/Python/pystate.c Tue Sep 12 21:08:12 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 Modified: python/branches/bcannon-objcap/Python/pythonrun.c ============================================================================== --- python/branches/bcannon-objcap/Python/pythonrun.c (original) +++ python/branches/bcannon-objcap/Python/pythonrun.c Tue Sep 12 21:08:12 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 Tue Sep 12 21:11:28 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 12 Sep 2006 21:11:28 +0200 (CEST) Subject: [Python-checkins] r51864 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060912191128.1DCA91E400F@bag.python.org> Author: brett.cannon Date: Tue Sep 12 21:11:27 2006 New Revision: 51864 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Mark what is critical to get roughly matching security levels as JavaScript. 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 12 21:11:27 2006 @@ -25,15 +25,15 @@ * Remove object.__subclasses__ (`Mutable Shared State`_) [done] + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) - open() - - __import__() / PEP 302 importer (`Imports`_) + - __import__() / PEP 302 importer (`Imports`_) - execfile() * Force to go through open() + Prevents opening unauthorized files. + Prevents using as a way to probe filesystem. - - exit() + - exit() * XXX verify that raising SystemExit in a sub-interpreter only - exits that sub-interpreter and not the process. -+ Filesystem path hiding (`Filesystem Information`_) + exits that sub-interpreter and not the process. ++ Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) - genericpath module (for os.path when C modules blocked) @@ -41,7 +41,7 @@ - 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 ++ Create sandboxed interpreter stdlib module - Be able to specify built-ins - Set 'sys' module settings - API From python-checkins at python.org Tue Sep 12 21:49:20 2006 From: python-checkins at python.org (martin.v.loewis) Date: Tue, 12 Sep 2006 21:49:20 +0200 (CEST) Subject: [Python-checkins] r51865 - python/trunk/Tools/msi/msi.py Message-ID: <20060912194920.D4D241E4015@bag.python.org> Author: martin.v.loewis Date: Tue Sep 12 21:49:20 2006 New Revision: 51865 Modified: python/trunk/Tools/msi/msi.py Log: Forward-port 51862: Add sgml_input.html. Modified: python/trunk/Tools/msi/msi.py ============================================================================== --- python/trunk/Tools/msi/msi.py (original) +++ python/trunk/Tools/msi/msi.py Tue Sep 12 21:49:20 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 martin at v.loewis.de Tue Sep 12 22:00:14 2006 From: martin at v.loewis.de (=?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=) Date: Tue, 12 Sep 2006 22:00:14 +0200 Subject: [Python-checkins] r51862 - python/branches/release25-maint/Tools/msi/msi.py In-Reply-To: <200609122116.01922.anthony@interlink.com.au> References: <20060912091628.9CBFA1E400C@bag.python.org> <200609122116.01922.anthony@interlink.com.au> Message-ID: <450711CE.8040201@v.loewis.de> Anthony Baxter schrieb: >> 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? Correct. Actually, msi.py is not distributed in the Windows installer either, but the file (sgml_input.html) got included so that the test case passes when run from an installed version. > 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. I've committed it to the trunk, so it should show up automatically in the 2.5 release. It doesn't have to be in 2.5c2, IMO. If you wonder how this all happened: Neal added sgml_input.html after c1, but didn't edit msi.py to make it included on Windows. I found out after running the test suite on the installed version, edited msi.py, and rebuilt the installer. I personally don't think that there needs a NEWS entry for it, given that there is already Neal's NEWS entry for the entire change. If somebebody think there should be a NEWS entry for the addition of the file to msi.py, please let me know whether it should go into the 2.5c2 or the 2.5 section. Regards, Martin From python-checkins at python.org Tue Sep 12 22:50:23 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 12 Sep 2006 22:50:23 +0200 (CEST) Subject: [Python-checkins] r51866 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060912205023.A35211E4014@bag.python.org> Author: andrew.kuchling Date: Tue Sep 12 22:50:23 2006 New Revision: 51866 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: Markup typo fix Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Tue Sep 12 22:50:23 2006 @@ -197,7 +197,7 @@ \verbatiminput{sqlite3/complete_statement.py} \end{funcdesc} -\begin{funcdesc}{}enable_callback_tracebacks{flag} +\begin{funcdesc}{enable_callback_tracebacks}{flag} By default you will not get any tracebacks in user-defined functions, aggregates, converters, authorizer callbacks etc. If you want to debug them, you can call this function with \var{flag} as True. Afterwards, you will get From python-checkins at python.org Tue Sep 12 23:09:04 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 12 Sep 2006 23:09:04 +0200 (CEST) Subject: [Python-checkins] r51867 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060912210904.D480F1E400D@bag.python.org> Author: andrew.kuchling Date: Tue Sep 12 23:09:02 2006 New Revision: 51867 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: Some editing, markup fixes Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Tue Sep 12 23:09:02 2006 @@ -464,20 +464,19 @@ \lineii{BLOB}{buffer} \end{tableii} -The type system of the \module{sqlite3} module is extensible in both ways: you can store +The type system of the \module{sqlite3} module is extensible in two ways: you can store additional Python types in a SQLite database via object adaptation, and you can let the \module{sqlite3} module convert SQLite types to different Python types via converters. \subsubsection{Using adapters to store additional Python types in SQLite databases} -Like described before, SQLite supports only a limited set of types natively. To +As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must \strong{adapt} them to one of the sqlite3 -module's supported types for SQLite. So, one of NoneType, int, long, float, +module's supported types for SQLite: one of NoneType, int, long, float, str, unicode, buffer. -The \module{sqlite3} module uses the Python object adaptation, like described in PEP 246 -for this. The protocol to use is \class{PrepareProtocol}. +The \module{sqlite3} module uses Python object adaptation, as described in \pep{246} for this. The protocol to use is \class{PrepareProtocol}. There are two ways to enable the \module{sqlite3} module to adapt a custom Python type to one of the supported ones. @@ -493,8 +492,8 @@ self.x, self.y = x, y \end{verbatim} -Now you want to store the point in a single SQLite column. You'll have to -choose one of the supported types first that you use to represent the point in. +Now you want to store the point in a single SQLite column. First you'll have to +choose one of the supported types first to be used for representing the point. Let's just use str and separate the coordinates using a semicolon. Then you need to give your class a method \code{__conform__(self, protocol)} which must return the converted value. The parameter \var{protocol} will be @@ -507,13 +506,13 @@ The other possibility is to create a function that converts the type to the string representation and register the function with \method{register_adapter}. - \verbatiminput{sqlite3/adapter_point_2.py} - \begin{notice} The type/class to adapt must be a new-style class, i. e. it must have \class{object} as one of its bases. \end{notice} + \verbatiminput{sqlite3/adapter_point_2.py} + The \module{sqlite3} module has two default adapters for Python's built-in \class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we want to store \class{datetime.datetime} objects not in ISO representation, @@ -523,16 +522,17 @@ \subsubsection{Converting SQLite values to custom Python types} -Now that's all nice and dandy that you can send custom Python types to SQLite. +Writing an adapter lets you send custom Python types to SQLite. But to make it really useful we need to make the Python to SQLite to Python -roundtrip work. +roundtrip work. Enter converters. -Let's go back to the Point class. We stored the x and y coordinates separated -via semicolons as strings in SQLite. +Let's go back to the \class{Point} class. We stored the x and y +coordinates separated via semicolons as strings in SQLite. -Let's first define a converter function that accepts the string as a parameter and constructs a Point object from it. +First, we'll define a converter function that accepts the string as a +parameter and constructs a \class{Point} object from it. \begin{notice} Converter functions \strong{always} get called with a string, no matter @@ -558,11 +558,12 @@ \item Explicitly via the column name \end{itemize} -Both ways are described at \ref{sqlite3-Module-Contents} in the text explaining -the constants \constant{PARSE_DECLTYPES} and \constant{PARSE_COlNAMES}. +Both ways are described in section~\ref{sqlite3-Module-Contents}, in +the text explaining the constants \constant{PARSE_DECLTYPES} and +\constant{PARSE_COLNAMES}. -The following example illustrates both ways. +The following example illustrates both approaches. \verbatiminput{sqlite3/converter_point.py} @@ -571,8 +572,8 @@ There are default adapters for the date and datetime types in the datetime module. They will be sent as ISO dates/ISO timestamps to SQLite. -The default converters are registered under the name "date" for datetime.date -and under the name "timestamp" for datetime.datetime. +The default converters are registered under the name "date" for \class{datetime.date} +and under the name "timestamp" for \class{datetime.datetime}. This way, you can use date/timestamps from Python without any additional fiddling in most cases. The format of the adapters is also compatible with the @@ -584,12 +585,12 @@ \subsection{Controlling Transactions \label{sqlite3-Controlling-Transactions}} -By default, the \module{sqlite3} module opens transactions implicitly before a DML -statement (INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly -before a non-DML, non-DQL statement (i. e. anything other than +By default, the \module{sqlite3} module opens transactions implicitly before a Data Modification Language (DML) +statement (i.e. INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly +before a non-DML, non-query statement (i. e. anything other than SELECT/INSERT/UPDATE/DELETE/REPLACE). -So if you are within a transaction, and issue a command like \code{CREATE TABLE +So if you are within a transaction and issue a command like \code{CREATE TABLE ...}, \code{VACUUM}, \code{PRAGMA}, the \module{sqlite3} module will commit implicitly before executing that command. There are two reasons for doing that. The first is that some of these commands don't work within transactions. The other reason From python-checkins at python.org Tue Sep 12 23:21:52 2006 From: python-checkins at python.org (andrew.kuchling) Date: Tue, 12 Sep 2006 23:21:52 +0200 (CEST) Subject: [Python-checkins] r51868 - python/trunk/Doc/lib/libsqlite3.tex Message-ID: <20060912212152.023051E400D@bag.python.org> Author: andrew.kuchling Date: Tue Sep 12 23:21:51 2006 New Revision: 51868 Modified: python/trunk/Doc/lib/libsqlite3.tex Log: More wordsmithing Modified: python/trunk/Doc/lib/libsqlite3.tex ============================================================================== --- python/trunk/Doc/lib/libsqlite3.tex (original) +++ python/trunk/Doc/lib/libsqlite3.tex Tue Sep 12 23:21:51 2006 @@ -146,8 +146,8 @@ wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds). -For the \var{isolation_level} parameter, please see \member{isolation_level} -\ref{sqlite3-Connection-IsolationLevel} property of \class{Connection} objects. +For the \var{isolation_level} parameter, please see the \member{isolation_level} +property of \class{Connection} objects in section~\ref{sqlite3-Connection-IsolationLevel}. SQLite natively supports only the types TEXT, INTEGER, FLOAT, BLOB and NULL. If you want to use other types, like you have to add support for them yourself. @@ -212,13 +212,14 @@ \label{sqlite3-Connection-IsolationLevel} \begin{memberdesc}{isolation_level} Get or set the current isolation level. None for autocommit mode or one of - "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See Controlling Transactions - \ref{sqlite3-Controlling-Transactions} for a more detailed explanation. + "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See ``Controlling Transactions'', + section~\ref{sqlite3-Controlling-Transactions}, for a more detailed explanation. \end{memberdesc} \begin{methoddesc}{cursor}{\optional{cursorClass}} The cursor method accepts a single optional parameter \var{cursorClass}. - This is a custom cursor class which must extend \class{sqlite3.Cursor}. + If supplied, this must be a custom cursor class that extends + \class{sqlite3.Cursor}. \end{methoddesc} \begin{methoddesc}{execute}{sql, \optional{parameters}} @@ -244,7 +245,7 @@ Creates a user-defined function that you can later use from within SQL statements under the function name \var{name}. \var{num_params} is the number of parameters the function accepts, and \var{func} is a Python callable that is -called as SQL function. +called as the SQL function. The function can return any of the types supported by SQLite: unicode, str, int, long, float, buffer and None. @@ -274,7 +275,7 @@ Creates a collation with the specified \var{name} and \var{callable}. The callable will be passed two string arguments. It should return -1 if the first -is ordered lower than the second, 0 if they are ordered equal and 1 and if the +is ordered lower than the second, 0 if they are ordered equal and 1 if the first is ordered higher than the second. Note that this controls sorting (ORDER BY in SQL) so your comparisons don't affect other SQL operations. @@ -323,20 +324,21 @@ \begin{memberdesc}{row_factory} You can change this attribute to a callable that accepts the cursor and - the original row as tuple and will return the real result row. This - way, you can implement more advanced ways of returning results, like - ones that can also access columns by name. + the original row as a tuple and will return the real result row. This + way, you can implement more advanced ways of returning results, such + as returning an object that can also access columns by name. Example: \verbatiminput{sqlite3/row_factory.py} - If the standard tuple types don't suffice for you, and you want name-based + If returning a tuple doesn't suffice and you want name-based access to columns, you should consider setting \member{row_factory} to the - highly-optimized sqlite3.Row type. It provides both + highly-optimized \class{sqlite3.Row} type. \class{Row} provides both index-based and case-insensitive name-based access to columns with almost - no memory overhead. Much better than your own custom dictionary-based - approach or even a db_row based solution. + no memory overhead. It will probably be better than your own custom + dictionary-based approach or even a db_row based solution. + % XXX what's a db_row-based solution? \end{memberdesc} \begin{memberdesc}{text_factory} @@ -350,7 +352,7 @@ attribute to \constant{sqlite3.OptimizedUnicode}. You can also set it to any other callable that accepts a single bytestring - parameter and returns the result object. + parameter and returns the resulting object. See the following example code for illustration: @@ -358,7 +360,7 @@ \end{memberdesc} \begin{memberdesc}{total_changes} - Returns the total number of database rows that have be modified, inserted, + Returns the total number of database rows that have been modified, inserted, or deleted since the database connection was opened. \end{memberdesc} @@ -385,9 +387,9 @@ \verbatiminput{sqlite3/execute_2.py} - \method{execute} will only execute a single SQL statement. If you try to + \method{execute()} will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a Warning. Use - \method{executescript} if want to execute multiple SQL statements with one + \method{executescript()} if you want to execute multiple SQL statements with one call. \end{methoddesc} @@ -395,7 +397,7 @@ \begin{methoddesc}{executemany}{sql, seq_of_parameters} Executes a SQL command against all parameter sequences or mappings found in the sequence \var{sql}. The \module{sqlite3} module also allows -to use an iterator yielding parameters instead of a sequence. +using an iterator yielding parameters instead of a sequence. \verbatiminput{sqlite3/executemany_1.py} @@ -407,7 +409,7 @@ \begin{methoddesc}{executescript}{sql_script} This is a nonstandard convenience method for executing multiple SQL statements -at once. It issues a COMMIT statement before, then executes the SQL script it +at once. It issues a COMMIT statement first, then executes the SQL script it gets as a parameter. \var{sql_script} can be a bytestring or a Unicode string. @@ -558,8 +560,8 @@ \item Explicitly via the column name \end{itemize} -Both ways are described in section~\ref{sqlite3-Module-Contents}, in -the text explaining the constants \constant{PARSE_DECLTYPES} and +Both ways are described in ``Module Constants'', section~\ref{sqlite3-Module-Contents}, in +the entries for the constants \constant{PARSE_DECLTYPES} and \constant{PARSE_COLNAMES}. @@ -619,17 +621,17 @@ Using the nonstandard \method{execute}, \method{executemany} and \method{executescript} methods of the \class{Connection} object, your code can -be written more concisely, because you don't have to create the - often -superfluous \class{Cursor} objects explicitly. Instead, the \class{Cursor} +be written more concisely because you don't have to create the (often +superfluous) \class{Cursor} objects explicitly. Instead, the \class{Cursor} objects are created implicitly and these shortcut methods return the cursor -objects. This way, you can for example execute a SELECT statement and iterate +objects. This way, you can execute a SELECT statement and iterate over it directly using only a single call on the \class{Connection} object. \verbatiminput{sqlite3/shortcut_methods.py} \subsubsection{Accessing columns by name instead of by index} -One cool feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class +One useful feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class designed to be used as a row factory. Rows wrapped with this class can be accessed both by index (like tuples) and From buildbot at python.org Tue Sep 12 23:35:49 2006 From: buildbot at python.org (buildbot at python.org) Date: Tue, 12 Sep 2006 21:35:49 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060912213549.827471E400D@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/557 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 14 02:43:50 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Sep 2006 02:43:50 +0200 (CEST) Subject: [Python-checkins] r51874 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060914004350.ED1691E4003@bag.python.org> Author: brett.cannon Date: Thu Sep 14 02:43:50 2006 New Revision: 51874 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Add note about worry of passing a raised exception from a created interpreter to the caller. 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 14 02:43:50 2006 @@ -47,6 +47,13 @@ - API * Python * C + - Securely handle exceptions being raised in sub-interpreter + * Raise InterpreterException w/ string for the exception type + and a sanitized string for message? + * If type is exact of an exception in namespace, recreate, + otherwise make an instance of InterpreterException? + * Need to watch out for malicious __str__() instances that + could do something nasty. Introduction From python-checkins at python.org Thu Sep 14 02:45:40 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Sep 2006 02:45:40 +0200 (CEST) Subject: [Python-checkins] r51875 - in python/branches/bcannon-objcap: Include/interpreter.h Lib/test/test_interpreter.py Modules/interpretermodule.c securing_python.txt setup.py Message-ID: <20060914004540.978151E4003@bag.python.org> Author: brett.cannon Date: Thu Sep 14 02:45:39 2006 New Revision: 51875 Added: python/branches/bcannon-objcap/Include/interpreter.h (contents, props changed) python/branches/bcannon-objcap/Lib/test/test_interpreter.py (contents, props changed) python/branches/bcannon-objcap/Modules/interpretermodule.c (contents, props changed) Modified: python/branches/bcannon-objcap/securing_python.txt python/branches/bcannon-objcap/setup.py Log: Add beginnings of an interpreter module. Added: python/branches/bcannon-objcap/Include/interpreter.h ============================================================================== --- (empty file) +++ python/branches/bcannon-objcap/Include/interpreter.h Thu Sep 14 02:45:39 2006 @@ -0,0 +1,24 @@ +/* + interpreter.h +*/ + +#ifndef HAVE_INTERPRETER_H +#define HAVE_INTERPRETER_H + +#ifdef __cpluspus +extern "C" { +#endif + +typedef struct +{ + PyObject_HEAD; + PyThreadState *tstate; /* Main thread state for interpreter */ + PyInterpreterState *istate; /* Interpreter state; for convenience to avoid + going through thread state every time. */ +} PyInterpreterObject; + +#ifdef __cplusplus +} +#endif + +#endif /* !HAVE_INTERPRETER_H */ Added: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- (empty file) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Thu Sep 14 02:45:39 2006 @@ -0,0 +1,110 @@ +"""XXX +""" +import interpreter + +import unittest +from test import test_support +import sys +import __builtin__ + +simple_stmt = """ +while True: + 2 + 3 + break +""" + +class BaseInterpTests(unittest.TestCase): + + def setUp(self): + """Create a new interpreter.""" + + self.interp = interpreter.Interpreter() + + +class BasicInterpreterTests(BaseInterpTests): + + def test_basic_expression(self): + # Make sure that execucuting a simple expression does not die. + self.interp.execute('2 + 3') + + def test_basic_statement(self): + # Make sure executing a statement does not die. + self.interp.execute(simple_stmt) + + +class BuiltinsTests(BaseInterpTests): + + """Test interpreter.Interpreter().builtins .""" + + def test_get(self): + # Test the getting of 'builtins'. + builtins = self.interp.builtins + self.failUnless(isinstance(builtins, dict)) + self.failUnless('object' in builtins) + + def test_set(self): + # Make sure setting 'builtins' can be done and has proper type + # checking. + self.interp.builtins = {} + self.failUnlessRaises(TypeError, setattr, self.interp, 'builtins', []) + + def test_effect(self): + # Make sure that setting 'builtin's actually affects the built-in + # namespace. + self.interp.builtins['msg'] = "hello" + self.interp.execute("msg") + self.interp.execute("import __builtin__; __builtin__.__dict__['test1'] = 'test1'") + self.failUnless('test1' in self.interp.builtins) + del self.interp.builtins['object'] + #self.failUnlessRaises(XXX, interp.execute, 'object') + + def test_copied(self): + # Make sure built-ins are unique per interpreter. + self.failUnless(self.interp.builtins is not __builtin__.__dict__) + + try: + __builtin__.__dict__['test1'] = 'test1' + self.failUnless('test1' not in self.interp.builtins) + finally: + del __builtin__.__dict__['test1'] + self.interp.builtins['test2'] = 'test2' + self.failUnless('test2' not in __builtin__.__dict__) + + +class ModulesTests(BaseInterpTests): + + """Test interpreter.Interpreter().modules .""" + + def test_get(self): + # Make sure a dict is returned. + modules = self.interp.modules + self.failUnless(isinstance(modules, dict)) + + def test_set(self): + # Make sure setting 'modules' can be done and has proper type checking. + self.interp.modules = {} + self.failUnlessRaises(TypeError, setattr, self.interp.modules, []) + + def test_effect(self): + # Make sure mutating 'modules' has proper result. + # XXX Insert value in 'module', have sub-interpreter set into + # __builtin__, and check that same object. + pass + + def test_fresh(self): + # Make sure that import Python modules are new instances. + import token + self.interp.execute("import token") + self.failUnless(self.interp.modules['token'] is not token) + + +def test_main(): + test_support.run_unittest( + BasicInterpreterTests, + BuiltinsTests, + ModulesTests, + ) + + +if __name__ == '__main__': + test_main() Added: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- (empty file) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Thu Sep 14 02:45:39 2006 @@ -0,0 +1,254 @@ +#include "Python.h" +#include "interpreter.h" + +#define PyInterpreter_GET_INTERP(interp) \ + (((PyInterpreterObject *)interp)->istate) + +/* + Destroy the interpreter and dealloc memory. +*/ +static void +interpreter_dealloc(PyObject *self) +{ + PyThreadState *new_tstate = NULL; + PyThreadState *cur_tstate = NULL; + + /* To destory an interpreter using Py_EndInterpreter() it must be the + currently running interpreter. This means you must temporariy make the + created interpreter the running interpreter again, destroy it, and then + swap back to the interpreter that created the interpreter in the first + place. */ + new_tstate = ((PyInterpreterObject *)self)->tstate; + cur_tstate = PyThreadState_Swap(new_tstate); + + Py_EndInterpreter(new_tstate); + PyEval_RestoreThread(cur_tstate); + + self->ob_type->tp_free(self); +} + +/* + Create a new interpreter. +*/ +static PyObject * +interpreter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) +{ + PyInterpreterObject *self; + PyThreadState *cur_tstate; + + self = (PyInterpreterObject *)type->tp_alloc(type, 0); + if (self == NULL) + return NULL; + + /* Creating a new interpreter swaps out the current one. */ + cur_tstate = PyThreadState_GET(); + + if (Py_NewInterpreter() == NULL) { + Py_DECREF(self); + /* XXX Exception best exception to use here? */ + PyErr_SetString(PyExc_Exception, "sub-interpreter creation failed"); + return NULL; + } + + self->tstate = PyThreadState_Swap(cur_tstate); + if (self->tstate == NULL) { + Py_DECREF(self); + PyErr_SetString(PyExc_Exception, "sub-interpreter swap failed"); + return NULL; + } + self->istate = (self->tstate)->interp; + + return (PyObject *)self; +} + +/* + Execute Python source code in the interpreter. +*/ +static PyObject * +interpreter_exec(PyObject *self, PyObject *arg) +{ + PyInterpreterObject *interp_self = (PyInterpreterObject *)self; + const char *str_arg = NULL; + PyThreadState* cur_tstate = NULL; + int result = 0; + + if (!PyString_Check(arg)) { + PyErr_SetString(PyExc_TypeError, "argument must be a string"); + return NULL; + } + + str_arg = PyString_AsString(arg); + if (!str_arg) + return NULL; + + cur_tstate = PyThreadState_Swap(interp_self->tstate); + + result = PyRun_SimpleString(str_arg); + if (result < 0) { + PyErr_Clear(); + } + + PyThreadState_Swap(cur_tstate); + + if (result < 0) { + PyErr_SetString(PyExc_Exception, + "exception during execution in interpreter."); + return NULL; + } + + Py_RETURN_NONE; +} + +static PyMethodDef interpreter_methods[] = { + {"execute", interpreter_exec, METH_O, + "Execute the passed-in string in the interpreter"}, + {NULL} +}; + + +/* + Getter for 'builtins'. +*/ +static PyObject * +interpreter_get_builtins(PyObject *self, void *optional) +{ + PyObject *builtins = PyInterpreter_GET_INTERP(self)->builtins; + + Py_INCREF(builtins); + return builtins; +} + +/* + Setter for 'builtins'. +*/ +static int +interpreter_set_builtins(PyObject *self, PyObject *arg, void *optional) +{ + PyObject *old_builtins = PyInterpreter_GET_INTERP(self)->builtins; + + if (!PyDict_CheckExact(arg)) { + PyErr_SetString(PyExc_TypeError, + "'builtins' must be set to a dict"); + return -1; + } + + Py_INCREF(arg); + Py_XDECREF(old_builtins); + PyInterpreter_GET_INTERP(self)->builtins = arg; + + return 0; +} + +/* + Getter for 'modules'. +*/ +static PyObject * +interpreter_get_modules(PyObject *self, void *optional) +{ + PyObject *modules = PyInterpreter_GET_INTERP(self)->modules; + + Py_INCREF(modules); + return modules; +} + +/* + Setter for 'modules'. +*/ +static int +interpreter_set_modules(PyObject *self, PyObject *arg, void *optional) +{ + PyObject *old_modules = PyInterpreter_GET_INTERP(self)->modules; + + if (!PyDict_CheckExact(arg)) { + PyErr_SetString(PyExc_TypeError, + "'modules' must be set to a dict"); + return -1; + } + + Py_INCREF(arg); + Py_XDECREF(old_modules); + PyInterpreter_GET_INTERP(self)->modules = arg; + + return 0; +} + + +static PyGetSetDef interpreter_getset[] = { + {"builtins", interpreter_get_builtins, interpreter_set_builtins, + "The built-ins dict for the interpreter.", NULL}, + /*{"sys_dict", XXX, XXX, "The modules dict for 'sys'.", NULL},*/ + {"modules", interpreter_get_modules, interpreter_set_modules, + "The dict used for sys.modules.", NULL}, + {NULL} +}; + + +PyDoc_STRVAR(interpreter_type_doc, +"XXX\n\ +\n\ +XXX"); + +PyTypeObject PyInterpreter_Type = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "interpreterInterpreter", /* tp_name */ + sizeof(PyInterpreterObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + interpreter_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE, /* tp_flags */ + interpreter_type_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + interpreter_methods, /* tp_methods */ + 0, /* tp_members */ + interpreter_getset, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + interpreter_new, /* tp_new */ + 0, /* tp_free */ + 0, /* tp_is_gc */ +}; + + +PyMODINIT_FUNC +initinterpreter(void) +{ + PyObject *module; + + module = Py_InitModule3("interpreter", NULL, + "Create other Python interpreters to execute code within."); + if (module == NULL) + return; + + Py_INCREF(&PyInterpreter_Type); + if (PyType_Ready(&PyInterpreter_Type) < 0) + return; + + if (PyModule_AddObject(module, "Interpreter", + (PyObject *)&PyInterpreter_Type) < 0) + return; +} 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 14 02:45:39 2006 @@ -44,6 +44,7 @@ + Create sandboxed interpreter stdlib module - Be able to specify built-ins - Set 'sys' module settings + - Set 'sys.modules' - API * Python * C Modified: python/branches/bcannon-objcap/setup.py ============================================================================== --- python/branches/bcannon-objcap/setup.py (original) +++ python/branches/bcannon-objcap/setup.py Thu Sep 14 02:45:39 2006 @@ -367,6 +367,8 @@ libraries=math_libs) ) exts.append( Extension('datetime', ['datetimemodule.c', 'timemodule.c'], libraries=math_libs) ) + # interpreter instantiation + exts.append( Extension('interpreter', ['interpretermodule.c']) ) # random number generator implemented in C exts.append( Extension("_random", ["_randommodule.c"]) ) # fast iterator tools implemented in C From anthony at interlink.com.au Thu Sep 14 02:58:08 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 14 Sep 2006 10:58:08 +1000 Subject: [Python-checkins] release is done, but release25-maint branch remains near-frozen Message-ID: <200609141058.13625.anthony@interlink.com.au> Ok - we're looking at a final release in 7 days time. I really, really, really don't want to have to cut an rc3, so unless it's a seriously critical brown-paper-bag bug, let's hold off on the checkins. Documentation, I don't mind so much - particularly any formatting errors. -- Anthony Baxter It's never too late to have a happy childhood. From python-checkins at python.org Thu Sep 14 07:05:43 2006 From: python-checkins at python.org (georg.brandl) Date: Thu, 14 Sep 2006 07:05:43 +0200 (CEST) Subject: [Python-checkins] r51876 - python/branches/release25-maint/Doc/lib/libsqlite3.tex Message-ID: <20060914050543.61B351E400F@bag.python.org> Author: georg.brandl Date: Thu Sep 14 07:05:42 2006 New Revision: 51876 Modified: python/branches/release25-maint/Doc/lib/libsqlite3.tex Log: Backport rev 51866-51868 from trunk (sqlite3 documentation fixes). 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 Thu Sep 14 07:05:42 2006 @@ -146,8 +146,8 @@ wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds). -For the \var{isolation_level} parameter, please see \member{isolation_level} -\ref{sqlite3-Connection-IsolationLevel} property of \class{Connection} objects. +For the \var{isolation_level} parameter, please see the \member{isolation_level} +property of \class{Connection} objects in section~\ref{sqlite3-Connection-IsolationLevel}. SQLite natively supports only the types TEXT, INTEGER, FLOAT, BLOB and NULL. If you want to use other types, like you have to add support for them yourself. @@ -197,7 +197,7 @@ \verbatiminput{sqlite3/complete_statement.py} \end{funcdesc} -\begin{funcdesc}{}enable_callback_tracebacks{flag} +\begin{funcdesc}{enable_callback_tracebacks}{flag} By default you will not get any tracebacks in user-defined functions, aggregates, converters, authorizer callbacks etc. If you want to debug them, you can call this function with \var{flag} as True. Afterwards, you will get @@ -212,13 +212,14 @@ \label{sqlite3-Connection-IsolationLevel} \begin{memberdesc}{isolation_level} Get or set the current isolation level. None for autocommit mode or one of - "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See Controlling Transactions - \ref{sqlite3-Controlling-Transactions} for a more detailed explanation. + "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See ``Controlling Transactions'', + section~\ref{sqlite3-Controlling-Transactions}, for a more detailed explanation. \end{memberdesc} \begin{methoddesc}{cursor}{\optional{cursorClass}} The cursor method accepts a single optional parameter \var{cursorClass}. - This is a custom cursor class which must extend \class{sqlite3.Cursor}. + If supplied, this must be a custom cursor class that extends + \class{sqlite3.Cursor}. \end{methoddesc} \begin{methoddesc}{execute}{sql, \optional{parameters}} @@ -244,7 +245,7 @@ Creates a user-defined function that you can later use from within SQL statements under the function name \var{name}. \var{num_params} is the number of parameters the function accepts, and \var{func} is a Python callable that is -called as SQL function. +called as the SQL function. The function can return any of the types supported by SQLite: unicode, str, int, long, float, buffer and None. @@ -274,7 +275,7 @@ Creates a collation with the specified \var{name} and \var{callable}. The callable will be passed two string arguments. It should return -1 if the first -is ordered lower than the second, 0 if they are ordered equal and 1 and if the +is ordered lower than the second, 0 if they are ordered equal and 1 if the first is ordered higher than the second. Note that this controls sorting (ORDER BY in SQL) so your comparisons don't affect other SQL operations. @@ -323,20 +324,21 @@ \begin{memberdesc}{row_factory} You can change this attribute to a callable that accepts the cursor and - the original row as tuple and will return the real result row. This - way, you can implement more advanced ways of returning results, like - ones that can also access columns by name. + the original row as a tuple and will return the real result row. This + way, you can implement more advanced ways of returning results, such + as returning an object that can also access columns by name. Example: \verbatiminput{sqlite3/row_factory.py} - If the standard tuple types don't suffice for you, and you want name-based + If returning a tuple doesn't suffice and you want name-based access to columns, you should consider setting \member{row_factory} to the - highly-optimized sqlite3.Row type. It provides both + highly-optimized \class{sqlite3.Row} type. \class{Row} provides both index-based and case-insensitive name-based access to columns with almost - no memory overhead. Much better than your own custom dictionary-based - approach or even a db_row based solution. + no memory overhead. It will probably be better than your own custom + dictionary-based approach or even a db_row based solution. + % XXX what's a db_row-based solution? \end{memberdesc} \begin{memberdesc}{text_factory} @@ -350,7 +352,7 @@ attribute to \constant{sqlite3.OptimizedUnicode}. You can also set it to any other callable that accepts a single bytestring - parameter and returns the result object. + parameter and returns the resulting object. See the following example code for illustration: @@ -358,7 +360,7 @@ \end{memberdesc} \begin{memberdesc}{total_changes} - Returns the total number of database rows that have be modified, inserted, + Returns the total number of database rows that have been modified, inserted, or deleted since the database connection was opened. \end{memberdesc} @@ -385,9 +387,9 @@ \verbatiminput{sqlite3/execute_2.py} - \method{execute} will only execute a single SQL statement. If you try to + \method{execute()} will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a Warning. Use - \method{executescript} if want to execute multiple SQL statements with one + \method{executescript()} if you want to execute multiple SQL statements with one call. \end{methoddesc} @@ -395,7 +397,7 @@ \begin{methoddesc}{executemany}{sql, seq_of_parameters} Executes a SQL command against all parameter sequences or mappings found in the sequence \var{sql}. The \module{sqlite3} module also allows -to use an iterator yielding parameters instead of a sequence. +using an iterator yielding parameters instead of a sequence. \verbatiminput{sqlite3/executemany_1.py} @@ -407,7 +409,7 @@ \begin{methoddesc}{executescript}{sql_script} This is a nonstandard convenience method for executing multiple SQL statements -at once. It issues a COMMIT statement before, then executes the SQL script it +at once. It issues a COMMIT statement first, then executes the SQL script it gets as a parameter. \var{sql_script} can be a bytestring or a Unicode string. @@ -464,20 +466,19 @@ \lineii{BLOB}{buffer} \end{tableii} -The type system of the \module{sqlite3} module is extensible in both ways: you can store +The type system of the \module{sqlite3} module is extensible in two ways: you can store additional Python types in a SQLite database via object adaptation, and you can let the \module{sqlite3} module convert SQLite types to different Python types via converters. \subsubsection{Using adapters to store additional Python types in SQLite databases} -Like described before, SQLite supports only a limited set of types natively. To +As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must \strong{adapt} them to one of the sqlite3 -module's supported types for SQLite. So, one of NoneType, int, long, float, +module's supported types for SQLite: one of NoneType, int, long, float, str, unicode, buffer. -The \module{sqlite3} module uses the Python object adaptation, like described in PEP 246 -for this. The protocol to use is \class{PrepareProtocol}. +The \module{sqlite3} module uses Python object adaptation, as described in \pep{246} for this. The protocol to use is \class{PrepareProtocol}. There are two ways to enable the \module{sqlite3} module to adapt a custom Python type to one of the supported ones. @@ -493,8 +494,8 @@ self.x, self.y = x, y \end{verbatim} -Now you want to store the point in a single SQLite column. You'll have to -choose one of the supported types first that you use to represent the point in. +Now you want to store the point in a single SQLite column. First you'll have to +choose one of the supported types first to be used for representing the point. Let's just use str and separate the coordinates using a semicolon. Then you need to give your class a method \code{__conform__(self, protocol)} which must return the converted value. The parameter \var{protocol} will be @@ -507,13 +508,13 @@ The other possibility is to create a function that converts the type to the string representation and register the function with \method{register_adapter}. - \verbatiminput{sqlite3/adapter_point_2.py} - \begin{notice} The type/class to adapt must be a new-style class, i. e. it must have \class{object} as one of its bases. \end{notice} + \verbatiminput{sqlite3/adapter_point_2.py} + The \module{sqlite3} module has two default adapters for Python's built-in \class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we want to store \class{datetime.datetime} objects not in ISO representation, @@ -523,16 +524,17 @@ \subsubsection{Converting SQLite values to custom Python types} -Now that's all nice and dandy that you can send custom Python types to SQLite. +Writing an adapter lets you send custom Python types to SQLite. But to make it really useful we need to make the Python to SQLite to Python -roundtrip work. +roundtrip work. Enter converters. -Let's go back to the Point class. We stored the x and y coordinates separated -via semicolons as strings in SQLite. +Let's go back to the \class{Point} class. We stored the x and y +coordinates separated via semicolons as strings in SQLite. -Let's first define a converter function that accepts the string as a parameter and constructs a Point object from it. +First, we'll define a converter function that accepts the string as a +parameter and constructs a \class{Point} object from it. \begin{notice} Converter functions \strong{always} get called with a string, no matter @@ -558,11 +560,12 @@ \item Explicitly via the column name \end{itemize} -Both ways are described at \ref{sqlite3-Module-Contents} in the text explaining -the constants \constant{PARSE_DECLTYPES} and \constant{PARSE_COlNAMES}. +Both ways are described in ``Module Constants'', section~\ref{sqlite3-Module-Contents}, in +the entries for the constants \constant{PARSE_DECLTYPES} and +\constant{PARSE_COLNAMES}. -The following example illustrates both ways. +The following example illustrates both approaches. \verbatiminput{sqlite3/converter_point.py} @@ -571,8 +574,8 @@ There are default adapters for the date and datetime types in the datetime module. They will be sent as ISO dates/ISO timestamps to SQLite. -The default converters are registered under the name "date" for datetime.date -and under the name "timestamp" for datetime.datetime. +The default converters are registered under the name "date" for \class{datetime.date} +and under the name "timestamp" for \class{datetime.datetime}. This way, you can use date/timestamps from Python without any additional fiddling in most cases. The format of the adapters is also compatible with the @@ -584,12 +587,12 @@ \subsection{Controlling Transactions \label{sqlite3-Controlling-Transactions}} -By default, the \module{sqlite3} module opens transactions implicitly before a DML -statement (INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly -before a non-DML, non-DQL statement (i. e. anything other than +By default, the \module{sqlite3} module opens transactions implicitly before a Data Modification Language (DML) +statement (i.e. INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly +before a non-DML, non-query statement (i. e. anything other than SELECT/INSERT/UPDATE/DELETE/REPLACE). -So if you are within a transaction, and issue a command like \code{CREATE TABLE +So if you are within a transaction and issue a command like \code{CREATE TABLE ...}, \code{VACUUM}, \code{PRAGMA}, the \module{sqlite3} module will commit implicitly before executing that command. There are two reasons for doing that. The first is that some of these commands don't work within transactions. The other reason @@ -618,17 +621,17 @@ Using the nonstandard \method{execute}, \method{executemany} and \method{executescript} methods of the \class{Connection} object, your code can -be written more concisely, because you don't have to create the - often -superfluous \class{Cursor} objects explicitly. Instead, the \class{Cursor} +be written more concisely because you don't have to create the (often +superfluous) \class{Cursor} objects explicitly. Instead, the \class{Cursor} objects are created implicitly and these shortcut methods return the cursor -objects. This way, you can for example execute a SELECT statement and iterate +objects. This way, you can execute a SELECT statement and iterate over it directly using only a single call on the \class{Connection} object. \verbatiminput{sqlite3/shortcut_methods.py} \subsubsection{Accessing columns by name instead of by index} -One cool feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class +One useful feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class designed to be used as a row factory. Rows wrapped with this class can be accessed both by index (like tuples) and From python-checkins at python.org Thu Sep 14 13:22:18 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 14 Sep 2006 13:22:18 +0200 (CEST) Subject: [Python-checkins] r51877 - python/trunk/Modules/main.c Message-ID: <20060914112218.8B8511E400E@bag.python.org> Author: andrew.kuchling Date: Thu Sep 14 13:22:18 2006 New Revision: 51877 Modified: python/trunk/Modules/main.c Log: Make --help mention that -v can be supplied multiple times Modified: python/trunk/Modules/main.c ============================================================================== --- python/trunk/Modules/main.c (original) +++ python/trunk/Modules/main.c Thu Sep 14 13:22:18 2006 @@ -78,6 +78,7 @@ static char *usage_3 = "\ see man page for details on internal buffering relating to '-u'\n\ -v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ + (can be supplied multiple times to increase verbosity)\n\ -V : print the Python version number and exit (also --version)\n\ -W arg : warning control (arg is action:message:category:module:lineno)\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ From python-checkins at python.org Thu Sep 14 13:28:51 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 14 Sep 2006 13:28:51 +0200 (CEST) Subject: [Python-checkins] r51878 - python/trunk/Modules/main.c Message-ID: <20060914112851.132051E400E@bag.python.org> Author: andrew.kuchling Date: Thu Sep 14 13:28:50 2006 New Revision: 51878 Modified: python/trunk/Modules/main.c Log: Rewrite help message to remove some of the parentheticals. (There were a lot of them.) Modified: python/trunk/Modules/main.c ============================================================================== --- python/trunk/Modules/main.c (original) +++ python/trunk/Modules/main.c Thu Sep 14 13:28:50 2006 @@ -60,33 +60,33 @@ static char *usage_1 = "\ Options and arguments (and corresponding environment variables):\n\ -c cmd : program passed in as string (terminates option list)\n\ --d : debug output from parser (also PYTHONDEBUG=x)\n\ +-d : debug output from parser; also PYTHONDEBUG=x\n\ -E : ignore environment variables (such as PYTHONPATH)\n\ -h : print this help message and exit (also --help)\n\ --i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\ - and force prompts, even if stdin does not appear to be a terminal\n\ +-i : inspect interactively after running script; forces a prompt even\n\ + if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\ "; static char *usage_2 = "\ -m mod : run library module as a script (terminates option list)\n\ --O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\ +-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\ -S : don't imply 'import site' on initialization\n\ -t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ --u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ +-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n\ "; static char *usage_3 = "\ see man page for details on internal buffering relating to '-u'\n\ --v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ - (can be supplied multiple times to increase verbosity)\n\ +-v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ + can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ --W arg : warning control (arg is action:message:category:module:lineno)\n\ +-W arg : warning control; arg is action:message:category:module:lineno\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ file : program read from script file\n\ - : program read from stdin (default; interactive mode if a tty)\n\ "; static char *usage_4 = "\ -arg ...: arguments passed to program in sys.argv[1:]\n\ +arg ...: arguments passed to program in sys.argv[1:]\n\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ From buildbot at python.org Thu Sep 14 13:28:55 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 14 Sep 2006 11:28:55 +0000 Subject: [Python-checkins] buildbot failure in sparc Ubuntu dapper trunk Message-ID: <20060914112855.357EF1E400E@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/699 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Thu Sep 14 18:16:46 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 14 Sep 2006 16:16:46 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060914161646.2AC361E400F@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/559 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 python-checkins at python.org Thu Sep 14 22:53:01 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Sep 2006 22:53:01 +0200 (CEST) Subject: [Python-checkins] r51879 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060914205301.E35061E4005@bag.python.org> Author: brett.cannon Date: Thu Sep 14 22:53:01 2006 New Revision: 51879 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Add mention of adding interpreter module. Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Thu Sep 14 22:53:01 2006 @@ -20,3 +20,9 @@ * rev. 51392: Introduce objcap module to hold removed functions/methods. Begin with moving object.__subclasses__(). + + +Extension Modules +----------------- + +* rev. 51875: Introduced the interpreter module. From python-checkins at python.org Thu Sep 14 22:54:08 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Sep 2006 22:54:08 +0200 (CEST) Subject: [Python-checkins] r51880 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py Modules/interpretermodule.c securing_python.txt Message-ID: <20060914205408.4EB121E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 14 22:54:07 2006 New Revision: 51880 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/Modules/interpretermodule.c python/branches/bcannon-objcap/securing_python.txt Log: Add access to the 'sys' module's data dict. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Thu Sep 14 22:54:07 2006 @@ -1,5 +1,3 @@ -"""XXX -""" import interpreter import unittest @@ -13,6 +11,14 @@ break """ +test_sys_changed = """ +import sys +if sys.version == 'test': + to_return.append(True) +else: + to_return.append(False) +""" + class BaseInterpTests(unittest.TestCase): def setUp(self): @@ -98,11 +104,50 @@ self.failUnless(self.interp.modules['token'] is not token) +class SysDictTests(BaseInterpTests): + + """Test interpreter.Interpreter().sys_dict .""" + + def test_get(self): + # Make sure a dict is returned. + sys_dict = self.interp.sys_dict + self.failUnless(isinstance(sys_dict, dict)) + self.failUnless('version' in sys_dict) + + def test_set(self): + # Make sure sys_dict can be set to a new dict. + sys_dict_copy = self.interp.sys_dict.copy() + self.interp.sys_dict = sys_dict_copy + self.failUnlessRaises(TypeError, setattr, self.interp, 'sys_dict', []) + + def test_effect(self): + # Changes to the dict should be reflected in the interpreter. + sys_dict = self.interp.sys_dict + sys_dict['version'] = 'test' + interp_return = [] + self.interp.builtins['to_return'] = interp_return + self.interp.execute(test_sys_changed) + self.failUnless(interp_return[0]) + + def test_copied(self): + # sys_dict should be unique per interpreter (including mutable data + # structures). + sys_dict = self.interp.sys_dict + sys_dict['version'] = 'test' + self.failUnless(sys.version != 'test') + # XXX check mutable data structures + sys_dict.setdefault('argv', []).append('test') + self.failUnless(sys.argv[-1] != 'test') + sys_dict['path'].append('test') + self.failUnless(sys.path[-1] != 'test') + + def test_main(): test_support.run_unittest( BasicInterpreterTests, BuiltinsTests, ModulesTests, + SysDictTests, ) Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Thu Sep 14 22:54:07 2006 @@ -133,7 +133,7 @@ } Py_INCREF(arg); - Py_XDECREF(old_builtins); + Py_DECREF(old_builtins); PyInterpreter_GET_INTERP(self)->builtins = arg; return 0; @@ -166,17 +166,51 @@ } Py_INCREF(arg); - Py_XDECREF(old_modules); + Py_DECREF(old_modules); PyInterpreter_GET_INTERP(self)->modules = arg; return 0; } +/* + Getter for 'sys_dict'. +*/ +static PyObject * +interpreter_get_sys_dict(PyObject *self, void *optional) +{ + PyObject *sys_dict = PyInterpreter_GET_INTERP(self)->sysdict; + + Py_INCREF(sys_dict); + return sys_dict; +} + +/* + Setter for 'sys_dict'. +*/ +static int +interpreter_set_sys_dict(PyObject *self, PyObject *arg, void *optional) +{ + PyObject *old_sys_dict = PyInterpreter_GET_INTERP(self)->sysdict; + + if (!PyDict_Check(arg)) { + PyErr_SetString(PyExc_TypeError, + "'sys_dict' must be set to a dict"); + return -1; + } + + Py_INCREF(arg); + Py_DECREF(old_sys_dict); + PyInterpreter_GET_INTERP(self)->sysdict = arg; + + return 0; +} + static PyGetSetDef interpreter_getset[] = { {"builtins", interpreter_get_builtins, interpreter_set_builtins, "The built-ins dict for the interpreter.", NULL}, - /*{"sys_dict", XXX, XXX, "The modules dict for 'sys'.", NULL},*/ + {"sys_dict", interpreter_get_sys_dict, interpreter_set_sys_dict, + "The modules dict for 'sys'.", NULL}, {"modules", interpreter_get_modules, interpreter_set_modules, "The dict used for sys.modules.", NULL}, {NULL} 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 14 22:54:07 2006 @@ -31,8 +31,8 @@ + 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. + * Have SystemExit exit the process only if no other + interpreters are running. + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) @@ -42,9 +42,9 @@ 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 - - Set 'sys.modules' + - Be able to specify built-ins [done] + - Set 'sys' module settings [done] + - Set 'sys.modules' [done] - API * Python * C From python-checkins at python.org Thu Sep 14 22:55:35 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Sep 2006 22:55:35 +0200 (CEST) Subject: [Python-checkins] r51881 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060914205535.7AF6B1E4005@bag.python.org> Author: brett.cannon Date: Thu Sep 14 22:55:35 2006 New Revision: 51881 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Add mention of sys_dict attribute on Interpreter objects. Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Thu Sep 14 22:55:35 2006 @@ -25,4 +25,6 @@ Extension Modules ----------------- +* rev. 51880: Add access to the 'sys' modules data dict to Interpreter objects. + * rev. 51875: Introduced the interpreter module. From python-checkins at python.org Thu Sep 14 23:21:23 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 14 Sep 2006 23:21:23 +0200 (CEST) Subject: [Python-checkins] r51882 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060914212123.684051E4005@bag.python.org> Author: brett.cannon Date: Thu Sep 14 23:21:22 2006 New Revision: 51882 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Add some notes of issues that exist currently with the interpreter module. 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 14 23:21:22 2006 @@ -26,6 +26,7 @@ + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) - open() - __import__() / PEP 302 importer (`Imports`_) + * Make sure importing built-in modules can be blocked. - execfile() * Force to go through open() + Prevents opening unauthorized files. @@ -55,6 +56,11 @@ otherwise make an instance of InterpreterException? * Need to watch out for malicious __str__() instances that could do something nasty. + - Be able to clear exceptions in the interpreter to allow reuse + * Raise an exception if the interpreter is used while an + exception is still set. + * Provide a function to clear any set exeception. ++ Tear out old restricted mode code. Introduction From python-checkins at python.org Fri Sep 15 02:34:19 2006 From: python-checkins at python.org (ka-ping.yee) Date: Fri, 15 Sep 2006 02:34:19 +0200 (CEST) Subject: [Python-checkins] r51883 - python/trunk/Doc/lib/libuuid.tex Message-ID: <20060915003419.BC2FE1E400F@bag.python.org> Author: ka-ping.yee Date: Fri Sep 15 02:34:19 2006 New Revision: 51883 Modified: python/trunk/Doc/lib/libuuid.tex Log: Fix grammar errors and improve clarity. Modified: python/trunk/Doc/lib/libuuid.tex ============================================================================== --- python/trunk/Doc/lib/libuuid.tex (original) +++ python/trunk/Doc/lib/libuuid.tex Fri Sep 15 02:34:19 2006 @@ -95,10 +95,10 @@ \begin{memberdesc}{variant} The UUID variant, which determines the internal layout of the UUID. -This will be an integer equal to one of the constants +This will be one of the integer constants \constant{RESERVED_NCS}, \constant{RFC_4122}, \constant{RESERVED_MICROSOFT}, or -\constant{RESERVED_FUTURE}). +\constant{RESERVED_FUTURE}. \end{memberdesc} \begin{memberdesc}{version} @@ -106,7 +106,7 @@ when the variant is \constant{RFC_4122}). \end{memberdesc} -The \module{uuid} module defines the following functions +The \module{uuid} module defines the following functions: \begin{funcdesc}{getnode}{} Get the hardware address as a 48-bit positive integer. The first time this @@ -129,11 +129,8 @@ \index{uuid1} \begin{funcdesc}{uuid3}{namespace, name} -Generate a UUID based upon a MD5 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the MD5 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid3} @@ -143,31 +140,32 @@ \index{uuid4} \begin{funcdesc}{uuid5}{namespace, name} -Generate a UUID based upon a SHA-1 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the SHA-1 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid5} -The \module{uuid} module defines the following namespace constants +The \module{uuid} module defines the following namespace identifiers for use with \function{uuid3()} or \function{uuid5()}. \begin{datadesc}{NAMESPACE_DNS} -Fully-qualified domain name namespace UUID. +When this namespace is specified, +the \var{name} string is a fully-qualified domain name. \end{datadesc} \begin{datadesc}{NAMESPACE_URL} -URL namespace UUID. +When this namespace is specified, +the \var{name} string is a URL. \end{datadesc} \begin{datadesc}{NAMESPACE_OID} -ISO OID namespace UUID. +When this namespace is specified, +the \var{name} string is an ISO OID. \end{datadesc} \begin{datadesc}{NAMESPACE_X500} -X.500 DN namespace UUID. +When this namespace is specified, +the \var{name} string is an X.500 DN in DER or a text output format. \end{datadesc} The \module{uuid} module defines the following constants @@ -178,11 +176,11 @@ \end{datadesc} \begin{datadesc}{RFC_4122} -Uses UUID layout specified in \rfc{4122}. +Specifies the UUID layout given in \rfc{4122}. \end{datadesc} \begin{datadesc}{RESERVED_MICROSOFT} -Reserved for Microsoft backward compatibility. +Reserved for Microsoft compatibility. \end{datadesc} \begin{datadesc}{RESERVED_FUTURE} @@ -192,12 +190,13 @@ \begin{seealso} \seerfc{4122}{A Universally Unique IDentifier (UUID) URN Namespace}{ - This specifies a Uniform Resource Name namespace for UUIDs.} +This specification defines a Uniform Resource Name namespace for UUIDs, +the internal format of UUIDs, and methods of generating UUIDs.} \end{seealso} \subsection{Example \label{uuid-example}} -Here is a typical usage: +Here are some examples of typical usage of the \module{uuid} module: \begin{verbatim} >>> import uuid From python-checkins at python.org Fri Sep 15 07:20:57 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 15 Sep 2006 07:20:57 +0200 (CEST) Subject: [Python-checkins] r51884 - python/branches/release25-maint/Doc/lib/libetree.tex Message-ID: <20060915052057.7421D1E4006@bag.python.org> Author: georg.brandl Date: Fri Sep 15 07:20:57 2006 New Revision: 51884 Modified: python/branches/release25-maint/Doc/lib/libetree.tex Log: Correct elementtree module index entry. (backport) Modified: python/branches/release25-maint/Doc/lib/libetree.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libetree.tex (original) +++ python/branches/release25-maint/Doc/lib/libetree.tex Fri Sep 15 07:20:57 2006 @@ -1,5 +1,5 @@ \section{\module{elementtree} --- The xml.etree.ElementTree Module} -\declaremodule{standard}{elementtree} +\declaremodule{standard}{xml.etree.elementtree} \moduleauthor{Fredrik Lundh}{fredrik at pythonware.com} \modulesynopsis{This module provides implementations of the Element and ElementTree types, plus support classes. From python-checkins at python.org Fri Sep 15 07:22:24 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 15 Sep 2006 07:22:24 +0200 (CEST) Subject: [Python-checkins] r51885 - python/trunk/Doc/lib/libetree.tex Message-ID: <20060915052224.DA8C31E4005@bag.python.org> Author: georg.brandl Date: Fri Sep 15 07:22:24 2006 New Revision: 51885 Modified: python/trunk/Doc/lib/libetree.tex Log: Correct elementtree module index entry. Modified: python/trunk/Doc/lib/libetree.tex ============================================================================== --- python/trunk/Doc/lib/libetree.tex (original) +++ python/trunk/Doc/lib/libetree.tex Fri Sep 15 07:22:24 2006 @@ -1,5 +1,5 @@ \section{\module{elementtree} --- The xml.etree.ElementTree Module} -\declaremodule{standard}{elementtree} +\declaremodule{standard}{xml.etree.elementtree} \moduleauthor{Fredrik Lundh}{fredrik at pythonware.com} \modulesynopsis{This module provides implementations of the Element and ElementTree types, plus support classes. From python-checkins at python.org Fri Sep 15 07:26:17 2006 From: python-checkins at python.org (georg.brandl) Date: Fri, 15 Sep 2006 07:26:17 +0200 (CEST) Subject: [Python-checkins] r51886 - python/branches/release25-maint/Doc/lib/libuuid.tex Message-ID: <20060915052617.8E7F91E4005@bag.python.org> Author: georg.brandl Date: Fri Sep 15 07:26:17 2006 New Revision: 51886 Modified: python/branches/release25-maint/Doc/lib/libuuid.tex Log: Backport uuid doc cleanup from rev. 51883. Modified: python/branches/release25-maint/Doc/lib/libuuid.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libuuid.tex (original) +++ python/branches/release25-maint/Doc/lib/libuuid.tex Fri Sep 15 07:26:17 2006 @@ -95,10 +95,10 @@ \begin{memberdesc}{variant} The UUID variant, which determines the internal layout of the UUID. -This will be an integer equal to one of the constants +This will be one of the integer constants \constant{RESERVED_NCS}, \constant{RFC_4122}, \constant{RESERVED_MICROSOFT}, or -\constant{RESERVED_FUTURE}). +\constant{RESERVED_FUTURE}. \end{memberdesc} \begin{memberdesc}{version} @@ -106,7 +106,7 @@ when the variant is \constant{RFC_4122}). \end{memberdesc} -The \module{uuid} module defines the following functions +The \module{uuid} module defines the following functions: \begin{funcdesc}{getnode}{} Get the hardware address as a 48-bit positive integer. The first time this @@ -129,11 +129,8 @@ \index{uuid1} \begin{funcdesc}{uuid3}{namespace, name} -Generate a UUID based upon a MD5 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the MD5 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid3} @@ -143,31 +140,32 @@ \index{uuid4} \begin{funcdesc}{uuid5}{namespace, name} -Generate a UUID based upon a SHA-1 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the SHA-1 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid5} -The \module{uuid} module defines the following namespace constants +The \module{uuid} module defines the following namespace identifiers for use with \function{uuid3()} or \function{uuid5()}. \begin{datadesc}{NAMESPACE_DNS} -Fully-qualified domain name namespace UUID. +When this namespace is specified, +the \var{name} string is a fully-qualified domain name. \end{datadesc} \begin{datadesc}{NAMESPACE_URL} -URL namespace UUID. +When this namespace is specified, +the \var{name} string is a URL. \end{datadesc} \begin{datadesc}{NAMESPACE_OID} -ISO OID namespace UUID. +When this namespace is specified, +the \var{name} string is an ISO OID. \end{datadesc} \begin{datadesc}{NAMESPACE_X500} -X.500 DN namespace UUID. +When this namespace is specified, +the \var{name} string is an X.500 DN in DER or a text output format. \end{datadesc} The \module{uuid} module defines the following constants @@ -178,11 +176,11 @@ \end{datadesc} \begin{datadesc}{RFC_4122} -Uses UUID layout specified in \rfc{4122}. +Specifies the UUID layout given in \rfc{4122}. \end{datadesc} \begin{datadesc}{RESERVED_MICROSOFT} -Reserved for Microsoft backward compatibility. +Reserved for Microsoft compatibility. \end{datadesc} \begin{datadesc}{RESERVED_FUTURE} @@ -192,12 +190,13 @@ \begin{seealso} \seerfc{4122}{A Universally Unique IDentifier (UUID) URN Namespace}{ - This specifies a Uniform Resource Name namespace for UUIDs.} +This specification defines a Uniform Resource Name namespace for UUIDs, +the internal format of UUIDs, and methods of generating UUIDs.} \end{seealso} \subsection{Example \label{uuid-example}} -Here is a typical usage: +Here are some examples of typical usage of the \module{uuid} module: \begin{verbatim} >>> import uuid From python-checkins at python.org Fri Sep 15 08:05:59 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 15 Sep 2006 08:05:59 +0200 (CEST) Subject: [Python-checkins] r51887 - peps/trunk/pep-0356.txt Message-ID: <20060915060559.C64A61E4005@bag.python.org> Author: neal.norwitz Date: Fri Sep 15 08:05:59 2006 New Revision: 51887 Modified: peps/trunk/pep-0356.txt Log: rc2 is out Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Fri Sep 15 08:05:59 2006 @@ -39,7 +39,7 @@ beta 2: July 11, 2006 [completed] beta 3: August 3, 2006 [completed] rc 1: August 17, 2006 [completed] - rc 2: September 12, 2006 [planned] + rc 2: September 12, 2006 [completed] final: September 19, 2006 [planned] From python-checkins at python.org Fri Sep 15 16:14:56 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 15 Sep 2006 16:14:56 +0200 (CEST) Subject: [Python-checkins] r51888 - python/branches/release25-maint/Doc/lib/libetree.tex Message-ID: <20060915141456.A63A11E4005@bag.python.org> Author: fred.drake Date: Fri Sep 15 16:14:55 2006 New Revision: 51888 Modified: python/branches/release25-maint/Doc/lib/libetree.tex Log: - fix module name in links in formatted documentation - minor markup cleanup Modified: python/branches/release25-maint/Doc/lib/libetree.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libetree.tex (original) +++ python/branches/release25-maint/Doc/lib/libetree.tex Fri Sep 15 16:14:55 2006 @@ -1,45 +1,34 @@ -\section{\module{elementtree} --- The xml.etree.ElementTree Module} -\declaremodule{standard}{xml.etree.elementtree} +\section{\module{xml.etree.ElementTree} --- The ElementTree XML API} +\declaremodule{standard}{xml.etree.ElementTree} \moduleauthor{Fredrik Lundh}{fredrik at pythonware.com} -\modulesynopsis{This module provides implementations -of the Element and ElementTree types, plus support classes. +\modulesynopsis{Implementation of the ElementTree API.} -A C version of this API is available as xml.etree.cElementTree.} \versionadded{2.5} - -\subsection{Overview\label{elementtree-overview}} - The Element type is a flexible container object, designed to store hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary. Each element has a number of properties associated with it: -\begin{itemize} -\item {} -a tag which is a string identifying what kind of data -this element represents (the element type, in other words). - -\item {} -a number of attributes, stored in a Python dictionary. - -\item {} -a text string. - -\item {} -an optional tail string. - -\item {} -a number of child elements, stored in a Python sequence +\begin{itemize} + \item a tag which is a string identifying what kind of data + this element represents (the element type, in other words). + \item a number of attributes, stored in a Python dictionary. + \item a text string. + \item an optional tail string. + \item a number of child elements, stored in a Python sequence \end{itemize} To create an element instance, use the Element or SubElement factory functions. -The ElementTree class can be used to wrap an element +The \class{ElementTree} class can be used to wrap an element structure, and convert it from and to XML. +A C implementation of this API is available as +\module{xml.etree.cElementTree}. + \subsection{Functions\label{elementtree-functions}} From python-checkins at python.org Fri Sep 15 17:18:05 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 15 Sep 2006 17:18:05 +0200 (CEST) Subject: [Python-checkins] r51889 - python/trunk/Doc/lib/libetree.tex Message-ID: <20060915151805.1062D1E4006@bag.python.org> Author: fred.drake Date: Fri Sep 15 17:18:04 2006 New Revision: 51889 Modified: python/trunk/Doc/lib/libetree.tex Log: - fix module name in links in formatted documentation - minor markup cleanup (forward-ported from release25-maint revision 51888) Modified: python/trunk/Doc/lib/libetree.tex ============================================================================== --- python/trunk/Doc/lib/libetree.tex (original) +++ python/trunk/Doc/lib/libetree.tex Fri Sep 15 17:18:04 2006 @@ -1,45 +1,34 @@ -\section{\module{elementtree} --- The xml.etree.ElementTree Module} -\declaremodule{standard}{xml.etree.elementtree} +\section{\module{xml.etree.ElementTree} --- The ElementTree XML API} +\declaremodule{standard}{xml.etree.ElementTree} \moduleauthor{Fredrik Lundh}{fredrik at pythonware.com} -\modulesynopsis{This module provides implementations -of the Element and ElementTree types, plus support classes. +\modulesynopsis{Implementation of the ElementTree API.} -A C version of this API is available as xml.etree.cElementTree.} \versionadded{2.5} - -\subsection{Overview\label{elementtree-overview}} - The Element type is a flexible container object, designed to store hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary. Each element has a number of properties associated with it: -\begin{itemize} -\item {} -a tag which is a string identifying what kind of data -this element represents (the element type, in other words). - -\item {} -a number of attributes, stored in a Python dictionary. - -\item {} -a text string. - -\item {} -an optional tail string. - -\item {} -a number of child elements, stored in a Python sequence +\begin{itemize} + \item a tag which is a string identifying what kind of data + this element represents (the element type, in other words). + \item a number of attributes, stored in a Python dictionary. + \item a text string. + \item an optional tail string. + \item a number of child elements, stored in a Python sequence \end{itemize} To create an element instance, use the Element or SubElement factory functions. -The ElementTree class can be used to wrap an element +The \class{ElementTree} class can be used to wrap an element structure, and convert it from and to XML. +A C implementation of this API is available as +\module{xml.etree.cElementTree}. + \subsection{Functions\label{elementtree-functions}} From python-checkins at python.org Fri Sep 15 18:10:31 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 15 Sep 2006 18:10:31 +0200 (CEST) Subject: [Python-checkins] r51890 - python/branches/release25-maint/Doc/lib/libpyexpat.tex Message-ID: <20060915161031.546101E4005@bag.python.org> Author: fred.drake Date: Fri Sep 15 18:10:25 2006 New Revision: 51890 Modified: python/branches/release25-maint/Doc/lib/libpyexpat.tex Log: revise explanation of returns_unicode to reflect bool values and to include the default value Modified: python/branches/release25-maint/Doc/lib/libpyexpat.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libpyexpat.tex (original) +++ python/branches/release25-maint/Doc/lib/libpyexpat.tex Fri Sep 15 18:10:25 2006 @@ -216,9 +216,10 @@ \begin{memberdesc}[xmlparser]{returns_unicode} If this attribute is set to a non-zero integer, the handler functions -will be passed Unicode strings. If \member{returns_unicode} is 0, -8-bit strings containing UTF-8 encoded data will be passed to the -handlers. +will be passed Unicode strings. If \member{returns_unicode} is +\constant{False}, 8-bit strings containing UTF-8 encoded data will be +passed to the handlers. This is \constant{True} by default when +Python is built with Unicode support. \versionchanged[Can be changed at any time to affect the result type]{1.6} \end{memberdesc} From python-checkins at python.org Fri Sep 15 18:11:27 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 15 Sep 2006 18:11:27 +0200 (CEST) Subject: [Python-checkins] r51891 - python/trunk/Doc/lib/libpyexpat.tex Message-ID: <20060915161127.5F7821E4005@bag.python.org> Author: fred.drake Date: Fri Sep 15 18:11:27 2006 New Revision: 51891 Modified: python/trunk/Doc/lib/libpyexpat.tex Log: revise explanation of returns_unicode to reflect bool values and to include the default value (merged from release25-maint revision 51890) Modified: python/trunk/Doc/lib/libpyexpat.tex ============================================================================== --- python/trunk/Doc/lib/libpyexpat.tex (original) +++ python/trunk/Doc/lib/libpyexpat.tex Fri Sep 15 18:11:27 2006 @@ -216,9 +216,10 @@ \begin{memberdesc}[xmlparser]{returns_unicode} If this attribute is set to a non-zero integer, the handler functions -will be passed Unicode strings. If \member{returns_unicode} is 0, -8-bit strings containing UTF-8 encoded data will be passed to the -handlers. +will be passed Unicode strings. If \member{returns_unicode} is +\constant{False}, 8-bit strings containing UTF-8 encoded data will be +passed to the handlers. This is \constant{True} by default when +Python is built with Unicode support. \versionchanged[Can be changed at any time to affect the result type]{1.6} \end{memberdesc} From python-checkins at python.org Fri Sep 15 20:49:42 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 15 Sep 2006 20:49:42 +0200 (CEST) Subject: [Python-checkins] r51892 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060915184942.7577B1E4005@bag.python.org> Author: brett.cannon Date: Fri Sep 15 20:49:41 2006 New Revision: 51892 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Add notes about issue with setting built-ins to a new dict and another possible place __del__ could be a problem. 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 15 20:49:41 2006 @@ -43,9 +43,13 @@ interrupt_main() not per-interpreter, and stack_size() can be dangerous) + Create sandboxed interpreter stdlib module - - Be able to specify built-ins [done] - - Set 'sys' module settings [done] - - Set 'sys.modules' [done] + - Be able to specify built-ins + * XXX frames cache built-ins, so setting to a new dict does + not get propagated; need to either change ability to assign + to built-ins or add functions that allow to set and delete + keys individually. + - Set 'sys' module settings + - Set 'sys.modules' - API * Python * C @@ -598,6 +602,9 @@ * ``__del__`` created in sandboxed interpreter but object is cleaned up in unprotected interpreter. + - XXX Watch out for objects being set in __builtin__.__dict__ and + thus not cleaned up until the interpreter object is deleted and + thus possibly executed in the creator's environment! * Using frames to walk the frame stack back to another interpreter. * XXX A generator's execution frame? From python-checkins at python.org Sat Sep 16 06:00:43 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 16 Sep 2006 06:00:43 +0200 (CEST) Subject: [Python-checkins] r51896 - python/branches/bcannon-objcap/Lib/test/security python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Message-ID: <20060916040043.77F4E1E4017@bag.python.org> Author: brett.cannon Date: Sat Sep 16 06:00:41 2006 New Revision: 51896 Added: python/branches/bcannon-objcap/Lib/test/security/ python/branches/bcannon-objcap/Lib/test/security/evil__del__.py (contents, props changed) Log: Add a test directory that contains proof-of-concept security breach attempts. These scripts should obviously not succeed (if they do then security is broken). Basically any possible way that security could be circumvented should be put in here as a at-large test. Obviously, at some point, a more structured test for each worry should be developed, but this works for now and allows people to add more ways they think people might try to circumvent security. Added: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py ============================================================================== --- (empty file) +++ python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Sat Sep 16 06:00:41 2006 @@ -0,0 +1,64 @@ +evil_str = r""" +import __builtin__ +import sys + +class Evil(object): + + builtin = __builtin__.__dict__ + stdout = sys.stdout + NameError = NameError + BaseException = BaseException + + def __init__(self, num): + self.num = num + + def __del__(self): + if 'open' in self.builtin: + self.stdout.write('(%s) First Evil!\n' % self.num) + else: + self.stdout.write("(%s) First Good!\n" % self.num) + self.stdout.flush() + + try: + temp = open + except self.NameError: + self.stdout.write("(%s) Second Good!\n" % self.num) + except self.BaseException, exc: + self.stdout.write("Unexpected exception: %r\n" % exc) + else: + self.stdout.write("(%s) Second Evil!\n" % self.num) + finally: + self.stdout.flush() + +# Deletion in own scope. +Evil(0) + +# Cleanup of interpreter. +__builtin__.__dict__['evil1'] = Evil(1) +# Explicitly deleted in calling interpreter. +__builtin__.__dict__['evil2'] = Evil(2) +# Implicit deletion during teardown of calling interpreter. +__builtin__.__dict__['evil3'] = Evil(3) +""" + +import interpreter +import __builtin__ + + +interp = interpreter.Interpreter() +print 'Same builtins?:', ('no' if id(__builtin__.__dict__) != + id(interp.builtins) else 'yes') +del interp.builtins['open'] +print 'Running interpreter ...' +interp.execute(evil_str) + +evil2 = interp.builtins['evil2'] +evil3 = interp.builtins['evil3'] + +print 'Deleting interpreter ...' +del interp + +print 'Explicitly deleting locally ...' +del evil2 + +print 'Implicit deletion locally from interpreter teardown ...' From python-checkins at python.org Sat Sep 16 19:36:38 2006 From: python-checkins at python.org (martin.v.loewis) Date: Sat, 16 Sep 2006 19:36:38 +0200 (CEST) Subject: [Python-checkins] r51897 - in python/trunk: Misc/NEWS Modules/resource.c Message-ID: <20060916173638.5E28E1E4004@bag.python.org> Author: martin.v.loewis Date: Sat Sep 16 19:36:37 2006 New Revision: 51897 Modified: python/trunk/Misc/NEWS python/trunk/Modules/resource.c Log: Patch #1557515: Add RLIMIT_SBSIZE. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 16 19:36:37 2006 @@ -62,6 +62,8 @@ Extension Modules ----------------- +- RLIMIT_SBSIZE was added to the resource module where available. + - Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). Modified: python/trunk/Modules/resource.c ============================================================================== --- python/trunk/Modules/resource.c (original) +++ python/trunk/Modules/resource.c Sat Sep 16 19:36:37 2006 @@ -298,6 +298,10 @@ PyModule_AddIntConstant(m, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK); #endif +#ifdef RLIMIT_SBSIZE + PyModule_AddIntConstant(m, "RLIMIT_SBSIZE", RLIMIT_SBSIZE); +#endif + #ifdef RUSAGE_SELF PyModule_AddIntConstant(m, "RUSAGE_SELF", RUSAGE_SELF); #endif From neal at metaslash.com Sat Sep 16 23:09:38 2006 From: neal at metaslash.com (Neal Norwitz) Date: Sat, 16 Sep 2006 17:09:38 -0400 Subject: [Python-checkins] Python Regression Test Failures refleak (1) Message-ID: <20060916210938.GA12070@python.psfb.org> test_cmd_line leaked [0, 0, -17] references test_threadsignals leaked [0, 0, -8] references From python-checkins at python.org Sun Sep 17 17:53:00 2006 From: python-checkins at python.org (phillip.eby) Date: Sun, 17 Sep 2006 17:53:00 +0200 (CEST) Subject: [Python-checkins] r51898 - in sandbox/branches/setuptools-0.6: ez_setup.py release.sh setup.py setuptools/__init__.py version.dat Message-ID: <20060917155300.36A611E4002@bag.python.org> Author: phillip.eby Date: Sun Sep 17 17:52:59 2006 New Revision: 51898 Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/__init__.py sandbox/branches/setuptools-0.6/version.dat Log: Bump revision to start work on 0.6c3 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 Sun Sep 17 17:52:59 2006 @@ -14,7 +14,7 @@ This file can also be run as a script to install or upgrade setuptools. """ import sys -DEFAULT_VERSION = "0.6c2" +DEFAULT_VERSION = "0.6c3" DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { @@ -28,6 +28,8 @@ 'setuptools-0.6b4-py2.4.egg': '4cb2a185d228dacffb2d17f103b3b1c4', 'setuptools-0.6c1-py2.3.egg': 'b3f2b5539d65cb7f74ad79127f1a908c', 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', + 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', + 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', } import sys, os Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Sun Sep 17 17:52:59 2006 @@ -7,7 +7,7 @@ # If your initials aren't PJE, don't run it. :) # -export VERSION="0.6c2" +export VERSION="0.6c3" wpython setup.py -q release source && \ cpython setup.py -q release binary && \ Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Sun Sep 17 17:52:59 2006 @@ -19,7 +19,7 @@ d = {}; execfile(convert_path('setuptools/command/__init__.py'), d) SETUP_COMMANDS = d['__all__'] -VERSION = "0.6c2" +VERSION = "0.6c3" from setuptools import setup, find_packages import sys scripts = [] Modified: sandbox/branches/setuptools-0.6/setuptools/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/__init__.py Sun Sep 17 17:52:59 2006 @@ -7,7 +7,7 @@ from distutils.util import convert_path import os.path -__version__ = '0.6c2' +__version__ = '0.6c3' __all__ = [ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'find_packages' Modified: sandbox/branches/setuptools-0.6/version.dat ============================================================================== --- sandbox/branches/setuptools-0.6/version.dat (original) +++ sandbox/branches/setuptools-0.6/version.dat Sun Sep 17 17:52:59 2006 @@ -1,6 +1,6 @@ [setuptools] status = 'release candidate' major = 0 -build = 2 +build = 3 minor = 6 From python-checkins at python.org Sun Sep 17 18:18:55 2006 From: python-checkins at python.org (phillip.eby) Date: Sun, 17 Sep 2006 18:18:55 +0200 (CEST) Subject: [Python-checkins] r51899 - sandbox/trunk/setuptools/setuptools/command/egg_info.py sandbox/trunk/setuptools/setuptools/command/sdist.py Message-ID: <20060917161855.83DAE1E4002@bag.python.org> Author: phillip.eby Date: Sun Sep 17 18:18:54 2006 New Revision: 51899 Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py sandbox/trunk/setuptools/setuptools/command/sdist.py Log: Support svn 1.4 working copy format Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/egg_info.py (original) +++ sandbox/trunk/setuptools/setuptools/command/egg_info.py Sun Sep 17 18:18:54 2006 @@ -181,10 +181,33 @@ import time; version += time.strftime("-%Y%m%d") return version + + + + + + + + + + + + + + + + + + + + + + def get_svn_revision(self): revision = 0 urlre = re.compile('url="([^"]+)"') revre = re.compile('committed-rev="(\d+)"') + for base,dirs,files in os.walk(os.curdir): if '.svn' not in dirs: dirs[:] = [] @@ -193,16 +216,34 @@ f = open(os.path.join(base,'.svn','entries')) data = f.read() f.close() - dirurl = urlre.search(data).group(1) # get repository URL + + if data.startswith('8'): + data = map(str.splitlines,data.split('\n\x0c\n')) + del data[0][0] # get rid of the '8' + dirurl = data[0][3] + localrev = max([int(d[9]) for d in data if len(d)>9]) + elif data.startswith(']+deleted="true")', re.I) + +def entries_finder(dirname, filename): + f = open(filename,'rU') + data = f.read() + f.close() + if data.startswith('8'): # subversion 1.4 + for record in map(str.splitlines, data.split('\n\x0c\n')[1:]): + if not record or len(record)>=6 and record[5]=="delete": + continue # skip deleted + yield joinpath(dirname, record[0]) + elif data.startswith(']+deleted="true")', re.I), - unescape - ) - ), + (convert_path('.svn/entries'), entries_finder), (convert_path('.svn/dir-props'), externals_finder), + (convert_path('.svn/dir-prop-base'), externals_finder), # svn 1.4 ] @@ -106,21 +121,6 @@ - - - - - - - - - - - - - - - class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" From python-checkins at python.org Sun Sep 17 18:20:48 2006 From: python-checkins at python.org (phillip.eby) Date: Sun, 17 Sep 2006 18:20:48 +0200 (CEST) Subject: [Python-checkins] r51900 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/egg_info.py setuptools/command/sdist.py Message-ID: <20060917162048.429B81E4002@bag.python.org> Author: phillip.eby Date: Sun Sep 17 18:20:47 2006 New Revision: 51900 Modified: sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py sandbox/branches/setuptools-0.6/setuptools/command/sdist.py Log: Support svn 1.4 working copy format (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 Sun Sep 17 18:20:47 2006 @@ -2563,6 +2563,9 @@ Release Notes/Change History ---------------------------- +0.6c3 + * Fixed breakages caused by Subversion 1.4's new "working copy" format + 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 Modified: sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py Sun Sep 17 18:20:47 2006 @@ -181,10 +181,33 @@ import time; version += time.strftime("-%Y%m%d") return version + + + + + + + + + + + + + + + + + + + + + + def get_svn_revision(self): revision = 0 urlre = re.compile('url="([^"]+)"') revre = re.compile('committed-rev="(\d+)"') + for base,dirs,files in os.walk(os.curdir): if '.svn' not in dirs: dirs[:] = [] @@ -193,16 +216,34 @@ f = open(os.path.join(base,'.svn','entries')) data = f.read() f.close() - dirurl = urlre.search(data).group(1) # get repository URL + + if data.startswith('8'): + data = map(str.splitlines,data.split('\n\x0c\n')) + del data[0][0] # get rid of the '8' + dirurl = data[0][3] + localrev = max([int(d[9]) for d in data if len(d)>9]) + elif data.startswith(']+deleted="true")', re.I) + +def entries_finder(dirname, filename): + f = open(filename,'rU') + data = f.read() + f.close() + if data.startswith('8'): # subversion 1.4 + for record in map(str.splitlines, data.split('\n\x0c\n')[1:]): + if not record or len(record)>=6 and record[5]=="delete": + continue # skip deleted + yield joinpath(dirname, record[0]) + elif data.startswith(']+deleted="true")', re.I), - unescape - ) - ), + (convert_path('.svn/entries'), entries_finder), (convert_path('.svn/dir-props'), externals_finder), + (convert_path('.svn/dir-prop-base'), externals_finder), # svn 1.4 ] @@ -106,21 +121,6 @@ - - - - - - - - - - - - - - - class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" From python-checkins at python.org Sun Sep 17 20:06:25 2006 From: python-checkins at python.org (brett.cannon) Date: Sun, 17 Sep 2006 20:06:25 +0200 (CEST) Subject: [Python-checkins] r51901 - python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Message-ID: <20060917180625.2190C1E4002@bag.python.org> Author: brett.cannon Date: Sun Sep 17 20:06:24 2006 New Revision: 51901 Modified: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Log: Another attempt to get at open() through the use of an evil __del__() method. So far been unable to craft one that uses another interpreter's scope to resolve the built-in namespace. Modified: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/security/evil__del__.py (original) +++ python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Sun Sep 17 20:06:24 2006 @@ -8,6 +8,9 @@ stdout = sys.stdout NameError = NameError BaseException = BaseException + ImportError = ImportError + KeyError = KeyError + TypeError = TypeError def __init__(self, num): self.num = num @@ -29,9 +32,23 @@ self.stdout.write("(%s) Second Evil!\n" % self.num) finally: self.stdout.flush() + try: + import __builtin__ + temp = __builtin__.__dict__['open'] + except self.ImportError: + self.stdout.write("(%s) Third Good!\n" % self.num) + except self.KeyError: + self.stdout.write("(%s) Third Good!\n" % self.num) + except self.TypeError: + self.stdout.write("(%s) Third Good!\n" % self.num) + except self.BaseException, exc: + self.stdout.write("Unexpected exception (2): %r\n" % exc) + finally: + self.stdout.flush() + # Deletion in own scope. -Evil(0) +temp = Evil(0) # Cleanup of interpreter. __builtin__.__dict__['evil1'] = Evil(1) @@ -43,12 +60,16 @@ import interpreter import __builtin__ +import gc interp = interpreter.Interpreter() print 'Same builtins?:', ('no' if id(__builtin__.__dict__) != id(interp.builtins) else 'yes') del interp.builtins['open'] +gc.collect() +if 'open' not in __builtin__.__dict__: + print "'open()' missing!" print 'Running interpreter ...' interp.execute(evil_str) @@ -57,8 +78,10 @@ print 'Deleting interpreter ...' del interp +gc.collect() print 'Explicitly deleting locally ...' del evil2 +gc.collect() print 'Implicit deletion locally from interpreter teardown ...' From python-checkins at python.org Sun Sep 17 20:40:15 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 17 Sep 2006 20:40:15 +0200 (CEST) Subject: [Python-checkins] r51902 - in python/branches/release25-maint/Mac: BuildScript/build-installer.py Tools/fixapplepython23.py Message-ID: <20060917184015.CCAFB1E4011@bag.python.org> Author: ronald.oussoren Date: Sun Sep 17 20:40:15 2006 New Revision: 51902 Modified: python/branches/release25-maint/Mac/BuildScript/build-installer.py python/branches/release25-maint/Mac/Tools/fixapplepython23.py Log: Workaround for bug #1558983 There is an issue with custom icons on directories in the 2.5c2 installer, don't set a custom icon on "/Applications/MacPython 2.5" for now. Also make sure that the installer doesn't crap out when the Makefile in the system's python installation has other customizations than we expect. Modified: python/branches/release25-maint/Mac/BuildScript/build-installer.py ============================================================================== --- python/branches/release25-maint/Mac/BuildScript/build-installer.py (original) +++ python/branches/release25-maint/Mac/BuildScript/build-installer.py Sun Sep 17 20:40:15 2006 @@ -945,6 +945,10 @@ ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) if isDirectory: + # There is a problem with getting this into the pax(1) archive, + # just ignore directory icons for now. + return + tmpPath = os.path.join(filePath, "Icon\r") if not os.path.exists(tmpPath): fp = open(tmpPath, 'w') Modified: python/branches/release25-maint/Mac/Tools/fixapplepython23.py ============================================================================== --- python/branches/release25-maint/Mac/Tools/fixapplepython23.py (original) +++ python/branches/release25-maint/Mac/Tools/fixapplepython23.py Sun Sep 17 20:40:15 2006 @@ -123,7 +123,8 @@ makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) - sys.exit(rv) + #sys.exit(rv) + sys.exit(0) if __name__ == '__main__': main() From python-checkins at python.org Sun Sep 17 20:42:54 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 17 Sep 2006 20:42:54 +0200 (CEST) Subject: [Python-checkins] r51903 - in python/trunk/Mac: BuildScript/build-installer.py Tools/fixapplepython23.py Message-ID: <20060917184254.102351E4005@bag.python.org> Author: ronald.oussoren Date: Sun Sep 17 20:42:53 2006 New Revision: 51903 Modified: python/trunk/Mac/BuildScript/build-installer.py python/trunk/Mac/Tools/fixapplepython23.py Log: Port of revision 51902 in release25-maint to the trunk Modified: python/trunk/Mac/BuildScript/build-installer.py ============================================================================== --- python/trunk/Mac/BuildScript/build-installer.py (original) +++ python/trunk/Mac/BuildScript/build-installer.py Sun Sep 17 20:42:53 2006 @@ -945,6 +945,7 @@ ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) if isDirectory: + return tmpPath = os.path.join(filePath, "Icon\r") if not os.path.exists(tmpPath): fp = open(tmpPath, 'w') Modified: python/trunk/Mac/Tools/fixapplepython23.py ============================================================================== --- python/trunk/Mac/Tools/fixapplepython23.py (original) +++ python/trunk/Mac/Tools/fixapplepython23.py Sun Sep 17 20:42:53 2006 @@ -123,7 +123,8 @@ makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) - sys.exit(rv) + #sys.exit(rv) + sys.exit(0) if __name__ == '__main__': main() From python-checkins at python.org Sun Sep 17 21:23:28 2006 From: python-checkins at python.org (ronald.oussoren) Date: Sun, 17 Sep 2006 21:23:28 +0200 (CEST) Subject: [Python-checkins] r51904 - python/trunk/Mac/Makefile.in Message-ID: <20060917192328.603331E4002@bag.python.org> Author: ronald.oussoren Date: Sun Sep 17 21:23:27 2006 New Revision: 51904 Modified: python/trunk/Mac/Makefile.in Log: Tweak Mac/Makefile in to ensure that pythonw gets rebuild when the major version of python changes (2.5 -> 2.6). Bug #1552935. Modified: python/trunk/Mac/Makefile.in ============================================================================== --- python/trunk/Mac/Makefile.in (original) +++ python/trunk/Mac/Makefile.in Sun Sep 17 21:23:27 2006 @@ -101,7 +101,7 @@ fi -pythonw: $(srcdir)/Tools/pythonw.c +pythonw: $(srcdir)/Tools/pythonw.c Makefile $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \ -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"' @@ -249,3 +249,6 @@ rm pythonw cd PythonLauncher && make clean cd IDLE && make clean + +Makefile: $(srcdir)/Makefile.in ../config.status + cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status From buildbot at python.org Sun Sep 17 22:28:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 17 Sep 2006 20:28:43 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060917202843.B1B681E4002@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/1168 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 anthony at interlink.com.au Mon Sep 18 06:40:43 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Mon, 18 Sep 2006 14:40:43 +1000 Subject: [Python-checkins] BRANCH FREEZE/IMMINENT RELEASE: Python 2.5 (final). 2006-09-19, 00:00UTC Message-ID: <200609181440.46961.anthony@interlink.com.au> Ok, time to bring down the hammer. The release25-maint branch is absolutely frozen to everyone but the release team from 00:00UTC, Tuesday 19th September. That's just under 20 hours from now. This is for Python 2.5 FINAL, so anyone who breaks this release will make me very, very sad. Based on the last few releases, I'd expect the release process to take around 18 hours (timezones are a swine). Anthony -- Anthony Baxter It's never too late to have a happy childhood. From python-checkins at python.org Mon Sep 18 08:00:52 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 18 Sep 2006 08:00:52 +0200 (CEST) Subject: [Python-checkins] r51905 - python/branches/release25-maint/README Message-ID: <20060918060052.C3AD51E4005@bag.python.org> Author: martin.v.loewis Date: Mon Sep 18 08:00:52 2006 New Revision: 51905 Modified: python/branches/release25-maint/README Log: Discourage using GCC 4.2 for Python. Modified: python/branches/release25-maint/README ============================================================================== --- python/branches/release25-maint/README (original) +++ python/branches/release25-maint/README Mon Sep 18 08:00:52 2006 @@ -276,6 +276,14 @@ submit a documentation bug report to SourceForge (see Bug Reports above) so we can remove them!) +GCC 4.2: There is a known incompatibility between Python and GCC, + where GCC 4.2 takes an interpretation of C different from + prior GCC releases, in an area where C has undefined behaviour + (namely, integer arithmetic involving -sys.maxint-1). + As a consequence, compiling Python with GCC 4.2 is not + recommend. It is likely that this problem will be resolved + in future Python releases. + Unix platforms: If your vendor still ships (and you still use) Berkeley DB 1.85 you will need to edit Modules/Setup to build the bsddb185 module and add a line to sitecustomize.py which makes it the From python-checkins at python.org Mon Sep 18 08:23:07 2006 From: python-checkins at python.org (martin.v.loewis) Date: Mon, 18 Sep 2006 08:23:07 +0200 (CEST) Subject: [Python-checkins] r51906 - python/branches/release25-maint/README Message-ID: <20060918062307.1E3AE1E4005@bag.python.org> Author: martin.v.loewis Date: Mon Sep 18 08:23:06 2006 New Revision: 51906 Modified: python/branches/release25-maint/README Log: Mention that GCC 4.1 is also affected, and that adding -fwrapv helps. Modified: python/branches/release25-maint/README ============================================================================== --- python/branches/release25-maint/README (original) +++ python/branches/release25-maint/README Mon Sep 18 08:23:06 2006 @@ -276,13 +276,16 @@ submit a documentation bug report to SourceForge (see Bug Reports above) so we can remove them!) +GCC 4.1, GCC 4.2: There is a known incompatibility between Python and GCC, - where GCC 4.2 takes an interpretation of C different from + where GCC 4.1 takes an interpretation of C different from prior GCC releases, in an area where C has undefined behaviour (namely, integer arithmetic involving -sys.maxint-1). - As a consequence, compiling Python with GCC 4.2 is not + As a consequence, compiling Python with GCC 4.1/4.2 is not recommend. It is likely that this problem will be resolved - in future Python releases. + in future Python releases. As a work-around, it seems that + adding -fwrapv to the compiler option restores the earlier + GCC behaviour. Unix platforms: If your vendor still ships (and you still use) Berkeley DB 1.85 you will need to edit Modules/Setup to build the bsddb185 From python-checkins at python.org Mon Sep 18 08:46:00 2006 From: python-checkins at python.org (anthony.baxter) Date: Mon, 18 Sep 2006 08:46:00 +0200 (CEST) Subject: [Python-checkins] r51907 - python/branches/release25-maint/README Message-ID: <20060918064600.232E91E4005@bag.python.org> Author: anthony.baxter Date: Mon Sep 18 08:45:59 2006 New Revision: 51907 Modified: python/branches/release25-maint/README Log: better wording Modified: python/branches/release25-maint/README ============================================================================== --- python/branches/release25-maint/README (original) +++ python/branches/release25-maint/README Mon Sep 18 08:45:59 2006 @@ -278,13 +278,15 @@ GCC 4.1, GCC 4.2: There is a known incompatibility between Python and GCC, - where GCC 4.1 takes an interpretation of C different from - prior GCC releases, in an area where C has undefined behaviour - (namely, integer arithmetic involving -sys.maxint-1). + where GCC 4.1 and later uses an interpretation of C + different to earlier GCC releases in an area where the C + specification has undefined behaviour (namely, integer arithmetic + involving -sys.maxint-1). + As a consequence, compiling Python with GCC 4.1/4.2 is not - recommend. It is likely that this problem will be resolved + recommended. It is likely that this problem will be resolved in future Python releases. As a work-around, it seems that - adding -fwrapv to the compiler option restores the earlier + adding -fwrapv to the compiler options restores the earlier GCC behaviour. Unix platforms: If your vendor still ships (and you still use) Berkeley DB @@ -604,7 +606,7 @@ You may also want to try the configure option "--enable-universalsdk" which builds Python as a universal binary with support for the - i386 and PPC architetures. This requires Xcode 2.1 or later to build. + i386 and PPC architectures. This requires Xcode 2.1 or later to build. See Mac/OSX/README for more information on framework and universal builds. From python-checkins at python.org Mon Sep 18 08:51:52 2006 From: python-checkins at python.org (anthony.baxter) Date: Mon, 18 Sep 2006 08:51:52 +0200 (CEST) Subject: [Python-checkins] r51908 - in python/branches/release25-maint: Doc/commontex/boilerplate.tex Include/patchlevel.h Lib/idlelib/NEWS.txt Lib/idlelib/idlever.py Misc/NEWS Misc/RPM/python-2.5.spec README Message-ID: <20060918065152.422381E4006@bag.python.org> Author: anthony.baxter Date: Mon Sep 18 08:51:50 2006 New Revision: 51908 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/Misc/RPM/python-2.5.spec python/branches/release25-maint/README Log: Preparing for 2.5 final. (damn, it's nice to see the line #define PY_VERSION "2.5" in patchlevel.h) 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 18 08:51:50 2006 @@ -5,5 +5,5 @@ Email: \email{docs at python.org} } -\date{12th September, 2006} % XXX update before final release! +\date{19th 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 18 08:51:50 2006 @@ -22,11 +22,11 @@ #define PY_MAJOR_VERSION 2 #define PY_MINOR_VERSION 5 #define PY_MICRO_VERSION 0 -#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_GAMMA -#define PY_RELEASE_SERIAL 2 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 /* Version as a string */ -#define PY_VERSION "2.5c2" +#define PY_VERSION "2.5" /* 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 18 08:51:50 2006 @@ -1,3 +1,8 @@ +What's New in IDLE 1.2? +======================= + +*Release date: 19-SEP-2006* + What's New in IDLE 1.2c2? ========================= 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 18 08:51:50 2006 @@ -1 +1 @@ -IDLE_VERSION = "1.2c2" +IDLE_VERSION = "1.2" Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 18 08:51:50 2006 @@ -4,6 +4,13 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.5 (final) +================================ + +*Release date: 19-SEP-2006* + +No changes since release candidate 2. + What's New in Python 2.5 release candidate 2? ============================================= 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 Mon Sep 18 08:51:50 2006 @@ -33,7 +33,7 @@ ################################# %define name python -%define version 2.5c2 +%define version 2.5 %define libvers 2.5 %define release 1pydotorg %define __prefix /usr Modified: python/branches/release25-maint/README ============================================================================== --- python/branches/release25-maint/README (original) +++ python/branches/release25-maint/README Mon Sep 18 08:51:50 2006 @@ -1,5 +1,5 @@ -This is Python version 2.5 rc 2 -=============================== +This is Python version 2.5 +========================== Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation. All rights reserved. From buildbot at python.org Mon Sep 18 10:03:20 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Sep 2006 08:03:20 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20060918080320.804B51E4005@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/35 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: anthony.baxter,martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From neal at metaslash.com Mon Sep 18 11:36:42 2006 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 18 Sep 2006 05:36:42 -0400 Subject: [Python-checkins] Python Regression Test Failures all (1) Message-ID: <20060918093642.GA27388@python.psfb.org> test_grammar test_opcodes test_operations test_builtin test_exceptions test_types test_MimeWriter test_StringIO test___all__ test___future__ test__locale test_aepack test_aepack skipped -- No module named aepack test_al test_al skipped -- No module named al test_anydbm test_applesingle test_applesingle skipped -- No module named macostools test_array test_ast test_asynchat test_atexit test_audioop test_augassign test_base64 test_bastion test_bigaddrspace test_bigmem test_binascii test_binhex test_binop test_bisect test_bool test_bsddb test_bsddb185 test_bsddb185 skipped -- No module named bsddb185 test_bsddb3 Exception in thread reader 3: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.6/threading.py", line 460, in __bootstrap self.run() File "/tmp/python-test/local/lib/python2.6/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.6/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/tmp/python-test/local/lib/python2.6/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') Exception in thread reader 0: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.6/threading.py", line 460, in __bootstrap self.run() File "/tmp/python-test/local/lib/python2.6/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.6/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/tmp/python-test/local/lib/python2.6/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') Exception in thread reader 2: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.6/threading.py", line 460, in __bootstrap self.run() File "/tmp/python-test/local/lib/python2.6/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.6/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/tmp/python-test/local/lib/python2.6/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') Exception in thread reader 4: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.6/threading.py", line 460, in __bootstrap self.run() File "/tmp/python-test/local/lib/python2.6/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.6/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/tmp/python-test/local/lib/python2.6/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') Exception in thread reader 1: Traceback (most recent call last): File "/tmp/python-test/local/lib/python2.6/threading.py", line 460, in __bootstrap self.run() File "/tmp/python-test/local/lib/python2.6/threading.py", line 440, in run self.__target(*self.__args, **self.__kwargs) File "/tmp/python-test/local/lib/python2.6/bsddb/test/test_thread.py", line 281, in readerThread rec = dbutils.DeadlockWrap(c.next, max_retries=10) File "/tmp/python-test/local/lib/python2.6/bsddb/dbutils.py", line 62, in DeadlockWrap return function(*_args, **_kwargs) DBLockDeadlockError: (-30996, 'DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock') test_bufio test_bz2 test_cProfile test_calendar test_call test_capi test_cd test_cd skipped -- No module named cd test_cfgparser test_cgi test_charmapcodec test_cl test_cl skipped -- No module named cl test_class test_cmath test_cmd_line test_code test_codeccallbacks test_codecencodings_cn test_codecencodings_hk test_codecencodings_jp test_codecencodings_kr test_codecencodings_tw test_codecmaps_cn test_codecmaps_hk test_codecmaps_jp test_codecmaps_kr test_codecmaps_tw test_codecs test_codeop test_coding test_coercion test_colorsys test_commands test_compare test_compile test_compiler test_complex test_contains test_contextlib test_cookie test_cookielib test_copy test_copy_reg test_cpickle test_crypt test_csv test_ctypes test_datetime test_dbm test_decimal test_decorators test_defaultdict test_deque test_descr test_descrtut test_dict test_difflib test_dircache test_dis test_distutils test_dl test_doctest test_doctest2 test_dumbdbm test_dummy_thread test_dummy_threading test_email test_email_codecs test_email_renamed test_enumerate test_eof test_errno test_exception_variations test_extcall test_fcntl test_file test_filecmp test_fileinput test_float test_fnmatch test_fork1 test_format test_fpformat test_frozen test_funcattrs test_functools test_future test_gc test_gdbm test_generators test_genericpath test_genexps test_getargs test_getargs2 test_getopt test_gettext test_gl test_gl skipped -- No module named gl test_glob test_global test_grp test_gzip test_hash test_hashlib test_heapq test_hexoct test_hmac test_hotshot test_htmllib test_htmlparser test_httplib test_imageop test_imaplib test_imgfile test_imgfile skipped -- No module named imgfile test_imp test_import test_importhooks test_index test_inspect test_ioctl test_ioctl skipped -- Unable to open /dev/tty test_isinstance test_iter test_iterlen test_itertools test_largefile test_list test_locale test_logging test_long test_long_future test_longexp test_macfs test_macfs skipped -- No module named macfs test_macostools test_macostools skipped -- No module named macostools test_macpath test_mailbox test_marshal test_math test_md5 test_mhlib test_mimetools test_mimetypes test_minidom test_mmap test_module test_multibytecodec test_multibytecodec_support test_multifile test_mutants test_netrc test_new test_nis test_nis skipped -- Local domain name not set test_normalization test_ntpath test_old_mailbox test_openpty test_operator test_optparse test_os test_parser test_peepholer test_pep247 test_pep263 test_pep277 test_pep277 skipped -- test works only on NT+ test_pep292 test_pep352 test_pickle test_pickletools test_pkg test_pkgimport test_platform test_plistlib test_plistlib skipped -- No module named plistlib test_poll test_popen [7225 refs] [7225 refs] [7225 refs] test_popen2 test_posix test_posixpath test_pow test_pprint test_profile test_profilehooks test_pty test_pwd test_pyclbr test_pyexpat test_queue test_quopri [7600 refs] [7600 refs] test_random test_re test_repr test_resource test_rfc822 test_rgbimg test_richcmp test_robotparser test_runpy test_sax test_scope test_scriptpackages test_scriptpackages skipped -- No module named aetools test_select test_set test_sets test_sgmllib test_sha test_shelve test_shlex test_shutil test_signal test_site test_slice test_socket test_socket_ssl test_socketserver test_softspace test_sort test_sqlite test_startfile test_startfile skipped -- cannot import name startfile test_str test_strftime test_string test_stringprep test_strop test_strptime test_struct test_structseq test_subprocess [7220 refs] [7221 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] [7221 refs] [8771 refs] [7436 refs] [7221 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] [7220 refs] . [7220 refs] [7220 refs] this bit of output is from a test of stdout in a different process ... [7220 refs] [7220 refs] [7436 refs] test_sunaudiodev test_sunaudiodev skipped -- No module named sunaudiodev test_sundry test_symtable test_syntax test_sys [7220 refs] [7220 refs] test_tarfile test_tcl test_tcl skipped -- No module named _tkinter test_tempfile [7227 refs] test_textwrap test_thread test_threaded_import test_threadedtempfile test_threading test_threading_local test_threadsignals test_time test_timeout test_tokenize test_trace test_traceback test_transformer test_tuple test_ucn test_unary test_unicode test_unicode_file test_unicode_file skipped -- No Unicode filesystem semantics on this platform. test_unicodedata test_unittest test_univnewlines test_unpack test_urllib test_urllib2 test_urllib2net test test_urllib2net failed -- errors occurred; run in verbose mode for details test_urllibnet test test_urllibnet failed -- errors occurred; run in verbose mode for details test_urlparse test_userdict test_userlist test_userstring test_uu test_uuid WARNING: uuid.getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._ifconfig_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. WARNING: uuid._unixdll_getnode is unreliable on many platforms. It is disabled until the code and/or test can be fixed properly. test_wait3 test_wait4 test_warnings test_wave test_weakref test_whichdb test_winreg test_winreg skipped -- No module named _winreg test_winsound test_winsound skipped -- No module named winsound test_with test_wsgiref test_xdrlib test_xml_etree test_xml_etree_c test_xmllib test_xmlrpc test_xpickle test_xrange test_zipfile test_zipfile64 test_zipfile64 skipped -- test requires loads of disk-space bytes and a long time to run test_zipimport test_zlib 293 tests OK. 2 tests failed: test_urllib2net test_urllibnet 22 tests skipped: test_aepack test_al test_applesingle test_bsddb185 test_cd test_cl test_gl test_imgfile test_ioctl test_macfs test_macostools test_nis test_pep277 test_plistlib test_scriptpackages test_startfile test_sunaudiodev test_tcl test_unicode_file test_winreg test_winsound test_zipfile64 1 skip unexpected on linux2: test_ioctl [448044 refs] From buildbot at python.org Mon Sep 18 14:18:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Sep 2006 12:18:31 +0000 Subject: [Python-checkins] buildbot warnings in MIPS Debian 2.5 Message-ID: <20060918121831.9E9AC1E4007@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/14 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: anthony.baxter,martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Mon Sep 18 14:26:53 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 18 Sep 2006 12:26:53 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper 2.5 Message-ID: <20060918122653.54CBC1E4005@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/31 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: anthony.baxter,martin.v.loewis Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon Sep 18 21:16:05 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Sep 2006 21:16:05 +0200 (CEST) Subject: [Python-checkins] r51909 - python/branches/bcannon-objcap/Lib/test/test_interpreter.py Message-ID: <20060918191605.DF38E1E4006@bag.python.org> Author: brett.cannon Date: Mon Sep 18 21:16:05 2006 New Revision: 51909 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py Log: Placeholder class for tests for things that need to work at some point. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Mon Sep 18 21:16:05 2006 @@ -1,3 +1,12 @@ +"""XXX Use case tests: + * cannot open files + - test removal of open() as well as change to bz2. + * block imports + - built-ins + - .pyc/.pyo + - extension modules + +""" import interpreter import unittest @@ -54,15 +63,24 @@ self.interp.builtins = {} self.failUnlessRaises(TypeError, setattr, self.interp, 'builtins', []) - def test_effect(self): - # Make sure that setting 'builtin's actually affects the built-in - # namespace. - self.interp.builtins['msg'] = "hello" - self.interp.execute("msg") - self.interp.execute("import __builtin__; __builtin__.__dict__['test1'] = 'test1'") - self.failUnless('test1' in self.interp.builtins) - del self.interp.builtins['object'] - #self.failUnlessRaises(XXX, interp.execute, 'object') + def test_remove(self): + # Make sure that something can be removed from built-ins. + # XXX + pass + + def test_add_remove(self): + # Make sure you can add to the built-ins and then remove the same + # object. + self.interp.builtins['test'] = 'test' + self.interp.execute('test') + del self.interp.builtins['test'] + # XXX self.failUnlessRaises(XXX, interp.execute, 'test') + + + def test_empty_builtins(self): + # Make sure that emptying the built-ins truly make them non-existent. + self.interp.builtins = {} + # XXX self.failUnlessRaises(XXX, interp.execute, 'object') def test_copied(self): # Make sure built-ins are unique per interpreter. @@ -91,10 +109,20 @@ self.interp.modules = {} self.failUnlessRaises(TypeError, setattr, self.interp.modules, []) - def test_effect(self): - # Make sure mutating 'modules' has proper result. - # XXX Insert value in 'module', have sub-interpreter set into - # __builtin__, and check that same object. + def test_mutation(self): + # If a module is swapped for another one, make sure imports actually + # use the new module entry. + # XXX + pass + + def test_adding(self): + # If a module is added, make sure importing uses that module. + # XXX + pass + + def test_deleting(self): + # Make sure that a module is re-imported if it is removed. + # XXX pass def test_fresh(self): @@ -120,7 +148,7 @@ self.interp.sys_dict = sys_dict_copy self.failUnlessRaises(TypeError, setattr, self.interp, 'sys_dict', []) - def test_effect(self): + def test_mutating(self): # Changes to the dict should be reflected in the interpreter. sys_dict = self.interp.sys_dict sys_dict['version'] = 'test' @@ -129,6 +157,13 @@ self.interp.execute(test_sys_changed) self.failUnless(interp_return[0]) + def test_deletion(self): + # Make sure removing a value raises the proper exception when accessing + # through the 'sys' module. + del self.interp.sys_dict['version'] + # XXX self.failUnlessRaises(XXX, self.interp.execute, + # 'import sys; sys.version') + def test_copied(self): # sys_dict should be unique per interpreter (including mutable data # structures). @@ -142,6 +177,35 @@ self.failUnless(sys.path[-1] != 'test') +class PlaceHolder(BaseInterpTests): + + """Hold some tests that will need to pass at some point.""" + + def test_file_restrictions(self): + # You cannot open a file. + del self.interp.builtins['open'] + try: + self.interp.execute("open(%s, 'w')" % test_support.TESTFN) + finally: + try: + os.remove(test_support.TESTFN) + except OSError: + pass + # XXX bz2 module protection. + + def test_import_builtin(self): + # Block importing built-in modules. + pass + + def test_import_pyc(self): + # Block importing .pyc files. + pass + + def test_import_extensions(self): + # Block importing extension modules. + pass + + def test_main(): test_support.run_unittest( BasicInterpreterTests, From python-checkins at python.org Mon Sep 18 21:16:47 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Sep 2006 21:16:47 +0200 (CEST) Subject: [Python-checkins] r51910 - python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Message-ID: <20060918191647.6FB521E4005@bag.python.org> Author: brett.cannon Date: Mon Sep 18 21:16:47 2006 New Revision: 51910 Modified: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Log: Add output if the third attempt at getting to open() succeeds. Modified: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/security/evil__del__.py (original) +++ python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Mon Sep 18 21:16:47 2006 @@ -35,6 +35,7 @@ try: import __builtin__ temp = __builtin__.__dict__['open'] + self.stdout.write("(%s) Third Evil!\n" % self.num) except self.ImportError: self.stdout.write("(%s) Third Good!\n" % self.num) except self.KeyError: @@ -48,7 +49,7 @@ # Deletion in own scope. -temp = Evil(0) +Evil(0) # Cleanup of interpreter. __builtin__.__dict__['evil1'] = Evil(1) @@ -62,7 +63,6 @@ import __builtin__ import gc - interp = interpreter.Interpreter() print 'Same builtins?:', ('no' if id(__builtin__.__dict__) != id(interp.builtins) else 'yes') From python-checkins at python.org Mon Sep 18 22:20:15 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Sep 2006 22:20:15 +0200 (CEST) Subject: [Python-checkins] r51911 - in python/branches/bcannon-objcap: Doc/lib/libetree.tex Doc/lib/libpyexpat.tex Doc/lib/libsqlite3.tex Doc/lib/libuuid.tex Mac/BuildScript/build-installer.py Mac/Makefile.in Mac/Tools/fixapplepython23.py Misc/NEWS Modules/main.c Modules/resource.c Tools/msi/msi.py Message-ID: <20060918202015.889AA1E400C@bag.python.org> Author: brett.cannon Date: Mon Sep 18 22:20:12 2006 New Revision: 51911 Modified: python/branches/bcannon-objcap/ (props changed) python/branches/bcannon-objcap/Doc/lib/libetree.tex python/branches/bcannon-objcap/Doc/lib/libpyexpat.tex python/branches/bcannon-objcap/Doc/lib/libsqlite3.tex python/branches/bcannon-objcap/Doc/lib/libuuid.tex python/branches/bcannon-objcap/Mac/BuildScript/build-installer.py python/branches/bcannon-objcap/Mac/Makefile.in python/branches/bcannon-objcap/Mac/Tools/fixapplepython23.py python/branches/bcannon-objcap/Misc/NEWS python/branches/bcannon-objcap/Modules/main.c python/branches/bcannon-objcap/Modules/resource.c python/branches/bcannon-objcap/Tools/msi/msi.py Log: Merged revisions 51863-51910 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/bcannon-objcap/Doc/lib/libetree.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libetree.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libetree.tex Mon Sep 18 22:20:12 2006 @@ -1,45 +1,34 @@ -\section{\module{elementtree} --- The xml.etree.ElementTree Module} -\declaremodule{standard}{elementtree} +\section{\module{xml.etree.ElementTree} --- The ElementTree XML API} +\declaremodule{standard}{xml.etree.ElementTree} \moduleauthor{Fredrik Lundh}{fredrik at pythonware.com} -\modulesynopsis{This module provides implementations -of the Element and ElementTree types, plus support classes. +\modulesynopsis{Implementation of the ElementTree API.} -A C version of this API is available as xml.etree.cElementTree.} \versionadded{2.5} - -\subsection{Overview\label{elementtree-overview}} - The Element type is a flexible container object, designed to store hierarchical data structures in memory. The type can be described as a cross between a list and a dictionary. Each element has a number of properties associated with it: -\begin{itemize} -\item {} -a tag which is a string identifying what kind of data -this element represents (the element type, in other words). - -\item {} -a number of attributes, stored in a Python dictionary. - -\item {} -a text string. - -\item {} -an optional tail string. - -\item {} -a number of child elements, stored in a Python sequence +\begin{itemize} + \item a tag which is a string identifying what kind of data + this element represents (the element type, in other words). + \item a number of attributes, stored in a Python dictionary. + \item a text string. + \item an optional tail string. + \item a number of child elements, stored in a Python sequence \end{itemize} To create an element instance, use the Element or SubElement factory functions. -The ElementTree class can be used to wrap an element +The \class{ElementTree} class can be used to wrap an element structure, and convert it from and to XML. +A C implementation of this API is available as +\module{xml.etree.cElementTree}. + \subsection{Functions\label{elementtree-functions}} Modified: python/branches/bcannon-objcap/Doc/lib/libpyexpat.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libpyexpat.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libpyexpat.tex Mon Sep 18 22:20:12 2006 @@ -216,9 +216,10 @@ \begin{memberdesc}[xmlparser]{returns_unicode} If this attribute is set to a non-zero integer, the handler functions -will be passed Unicode strings. If \member{returns_unicode} is 0, -8-bit strings containing UTF-8 encoded data will be passed to the -handlers. +will be passed Unicode strings. If \member{returns_unicode} is +\constant{False}, 8-bit strings containing UTF-8 encoded data will be +passed to the handlers. This is \constant{True} by default when +Python is built with Unicode support. \versionchanged[Can be changed at any time to affect the result type]{1.6} \end{memberdesc} 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 Mon Sep 18 22:20:12 2006 @@ -146,8 +146,8 @@ wait for the lock to go away until raising an exception. The default for the timeout parameter is 5.0 (five seconds). -For the \var{isolation_level} parameter, please see \member{isolation_level} -\ref{sqlite3-Connection-IsolationLevel} property of \class{Connection} objects. +For the \var{isolation_level} parameter, please see the \member{isolation_level} +property of \class{Connection} objects in section~\ref{sqlite3-Connection-IsolationLevel}. SQLite natively supports only the types TEXT, INTEGER, FLOAT, BLOB and NULL. If you want to use other types, like you have to add support for them yourself. @@ -197,7 +197,7 @@ \verbatiminput{sqlite3/complete_statement.py} \end{funcdesc} -\begin{funcdesc}{}enable_callback_tracebacks{flag} +\begin{funcdesc}{enable_callback_tracebacks}{flag} By default you will not get any tracebacks in user-defined functions, aggregates, converters, authorizer callbacks etc. If you want to debug them, you can call this function with \var{flag} as True. Afterwards, you will get @@ -212,13 +212,14 @@ \label{sqlite3-Connection-IsolationLevel} \begin{memberdesc}{isolation_level} Get or set the current isolation level. None for autocommit mode or one of - "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See Controlling Transactions - \ref{sqlite3-Controlling-Transactions} for a more detailed explanation. + "DEFERRED", "IMMEDIATE" or "EXLUSIVE". See ``Controlling Transactions'', + section~\ref{sqlite3-Controlling-Transactions}, for a more detailed explanation. \end{memberdesc} \begin{methoddesc}{cursor}{\optional{cursorClass}} The cursor method accepts a single optional parameter \var{cursorClass}. - This is a custom cursor class which must extend \class{sqlite3.Cursor}. + If supplied, this must be a custom cursor class that extends + \class{sqlite3.Cursor}. \end{methoddesc} \begin{methoddesc}{execute}{sql, \optional{parameters}} @@ -244,7 +245,7 @@ Creates a user-defined function that you can later use from within SQL statements under the function name \var{name}. \var{num_params} is the number of parameters the function accepts, and \var{func} is a Python callable that is -called as SQL function. +called as the SQL function. The function can return any of the types supported by SQLite: unicode, str, int, long, float, buffer and None. @@ -274,7 +275,7 @@ Creates a collation with the specified \var{name} and \var{callable}. The callable will be passed two string arguments. It should return -1 if the first -is ordered lower than the second, 0 if they are ordered equal and 1 and if the +is ordered lower than the second, 0 if they are ordered equal and 1 if the first is ordered higher than the second. Note that this controls sorting (ORDER BY in SQL) so your comparisons don't affect other SQL operations. @@ -323,20 +324,21 @@ \begin{memberdesc}{row_factory} You can change this attribute to a callable that accepts the cursor and - the original row as tuple and will return the real result row. This - way, you can implement more advanced ways of returning results, like - ones that can also access columns by name. + the original row as a tuple and will return the real result row. This + way, you can implement more advanced ways of returning results, such + as returning an object that can also access columns by name. Example: \verbatiminput{sqlite3/row_factory.py} - If the standard tuple types don't suffice for you, and you want name-based + If returning a tuple doesn't suffice and you want name-based access to columns, you should consider setting \member{row_factory} to the - highly-optimized sqlite3.Row type. It provides both + highly-optimized \class{sqlite3.Row} type. \class{Row} provides both index-based and case-insensitive name-based access to columns with almost - no memory overhead. Much better than your own custom dictionary-based - approach or even a db_row based solution. + no memory overhead. It will probably be better than your own custom + dictionary-based approach or even a db_row based solution. + % XXX what's a db_row-based solution? \end{memberdesc} \begin{memberdesc}{text_factory} @@ -350,7 +352,7 @@ attribute to \constant{sqlite3.OptimizedUnicode}. You can also set it to any other callable that accepts a single bytestring - parameter and returns the result object. + parameter and returns the resulting object. See the following example code for illustration: @@ -358,7 +360,7 @@ \end{memberdesc} \begin{memberdesc}{total_changes} - Returns the total number of database rows that have be modified, inserted, + Returns the total number of database rows that have been modified, inserted, or deleted since the database connection was opened. \end{memberdesc} @@ -385,9 +387,9 @@ \verbatiminput{sqlite3/execute_2.py} - \method{execute} will only execute a single SQL statement. If you try to + \method{execute()} will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a Warning. Use - \method{executescript} if want to execute multiple SQL statements with one + \method{executescript()} if you want to execute multiple SQL statements with one call. \end{methoddesc} @@ -395,7 +397,7 @@ \begin{methoddesc}{executemany}{sql, seq_of_parameters} Executes a SQL command against all parameter sequences or mappings found in the sequence \var{sql}. The \module{sqlite3} module also allows -to use an iterator yielding parameters instead of a sequence. +using an iterator yielding parameters instead of a sequence. \verbatiminput{sqlite3/executemany_1.py} @@ -407,7 +409,7 @@ \begin{methoddesc}{executescript}{sql_script} This is a nonstandard convenience method for executing multiple SQL statements -at once. It issues a COMMIT statement before, then executes the SQL script it +at once. It issues a COMMIT statement first, then executes the SQL script it gets as a parameter. \var{sql_script} can be a bytestring or a Unicode string. @@ -464,20 +466,19 @@ \lineii{BLOB}{buffer} \end{tableii} -The type system of the \module{sqlite3} module is extensible in both ways: you can store +The type system of the \module{sqlite3} module is extensible in two ways: you can store additional Python types in a SQLite database via object adaptation, and you can let the \module{sqlite3} module convert SQLite types to different Python types via converters. \subsubsection{Using adapters to store additional Python types in SQLite databases} -Like described before, SQLite supports only a limited set of types natively. To +As described before, SQLite supports only a limited set of types natively. To use other Python types with SQLite, you must \strong{adapt} them to one of the sqlite3 -module's supported types for SQLite. So, one of NoneType, int, long, float, +module's supported types for SQLite: one of NoneType, int, long, float, str, unicode, buffer. -The \module{sqlite3} module uses the Python object adaptation, like described in PEP 246 -for this. The protocol to use is \class{PrepareProtocol}. +The \module{sqlite3} module uses Python object adaptation, as described in \pep{246} for this. The protocol to use is \class{PrepareProtocol}. There are two ways to enable the \module{sqlite3} module to adapt a custom Python type to one of the supported ones. @@ -493,8 +494,8 @@ self.x, self.y = x, y \end{verbatim} -Now you want to store the point in a single SQLite column. You'll have to -choose one of the supported types first that you use to represent the point in. +Now you want to store the point in a single SQLite column. First you'll have to +choose one of the supported types first to be used for representing the point. Let's just use str and separate the coordinates using a semicolon. Then you need to give your class a method \code{__conform__(self, protocol)} which must return the converted value. The parameter \var{protocol} will be @@ -507,13 +508,13 @@ The other possibility is to create a function that converts the type to the string representation and register the function with \method{register_adapter}. - \verbatiminput{sqlite3/adapter_point_2.py} - \begin{notice} The type/class to adapt must be a new-style class, i. e. it must have \class{object} as one of its bases. \end{notice} + \verbatiminput{sqlite3/adapter_point_2.py} + The \module{sqlite3} module has two default adapters for Python's built-in \class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we want to store \class{datetime.datetime} objects not in ISO representation, @@ -523,16 +524,17 @@ \subsubsection{Converting SQLite values to custom Python types} -Now that's all nice and dandy that you can send custom Python types to SQLite. +Writing an adapter lets you send custom Python types to SQLite. But to make it really useful we need to make the Python to SQLite to Python -roundtrip work. +roundtrip work. Enter converters. -Let's go back to the Point class. We stored the x and y coordinates separated -via semicolons as strings in SQLite. +Let's go back to the \class{Point} class. We stored the x and y +coordinates separated via semicolons as strings in SQLite. -Let's first define a converter function that accepts the string as a parameter and constructs a Point object from it. +First, we'll define a converter function that accepts the string as a +parameter and constructs a \class{Point} object from it. \begin{notice} Converter functions \strong{always} get called with a string, no matter @@ -558,11 +560,12 @@ \item Explicitly via the column name \end{itemize} -Both ways are described at \ref{sqlite3-Module-Contents} in the text explaining -the constants \constant{PARSE_DECLTYPES} and \constant{PARSE_COlNAMES}. +Both ways are described in ``Module Constants'', section~\ref{sqlite3-Module-Contents}, in +the entries for the constants \constant{PARSE_DECLTYPES} and +\constant{PARSE_COLNAMES}. -The following example illustrates both ways. +The following example illustrates both approaches. \verbatiminput{sqlite3/converter_point.py} @@ -571,8 +574,8 @@ There are default adapters for the date and datetime types in the datetime module. They will be sent as ISO dates/ISO timestamps to SQLite. -The default converters are registered under the name "date" for datetime.date -and under the name "timestamp" for datetime.datetime. +The default converters are registered under the name "date" for \class{datetime.date} +and under the name "timestamp" for \class{datetime.datetime}. This way, you can use date/timestamps from Python without any additional fiddling in most cases. The format of the adapters is also compatible with the @@ -584,12 +587,12 @@ \subsection{Controlling Transactions \label{sqlite3-Controlling-Transactions}} -By default, the \module{sqlite3} module opens transactions implicitly before a DML -statement (INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly -before a non-DML, non-DQL statement (i. e. anything other than +By default, the \module{sqlite3} module opens transactions implicitly before a Data Modification Language (DML) +statement (i.e. INSERT/UPDATE/DELETE/REPLACE), and commits transactions implicitly +before a non-DML, non-query statement (i. e. anything other than SELECT/INSERT/UPDATE/DELETE/REPLACE). -So if you are within a transaction, and issue a command like \code{CREATE TABLE +So if you are within a transaction and issue a command like \code{CREATE TABLE ...}, \code{VACUUM}, \code{PRAGMA}, the \module{sqlite3} module will commit implicitly before executing that command. There are two reasons for doing that. The first is that some of these commands don't work within transactions. The other reason @@ -618,17 +621,17 @@ Using the nonstandard \method{execute}, \method{executemany} and \method{executescript} methods of the \class{Connection} object, your code can -be written more concisely, because you don't have to create the - often -superfluous \class{Cursor} objects explicitly. Instead, the \class{Cursor} +be written more concisely because you don't have to create the (often +superfluous) \class{Cursor} objects explicitly. Instead, the \class{Cursor} objects are created implicitly and these shortcut methods return the cursor -objects. This way, you can for example execute a SELECT statement and iterate +objects. This way, you can execute a SELECT statement and iterate over it directly using only a single call on the \class{Connection} object. \verbatiminput{sqlite3/shortcut_methods.py} \subsubsection{Accessing columns by name instead of by index} -One cool feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class +One useful feature of the \module{sqlite3} module is the builtin \class{sqlite3.Row} class designed to be used as a row factory. Rows wrapped with this class can be accessed both by index (like tuples) and Modified: python/branches/bcannon-objcap/Doc/lib/libuuid.tex ============================================================================== --- python/branches/bcannon-objcap/Doc/lib/libuuid.tex (original) +++ python/branches/bcannon-objcap/Doc/lib/libuuid.tex Mon Sep 18 22:20:12 2006 @@ -95,10 +95,10 @@ \begin{memberdesc}{variant} The UUID variant, which determines the internal layout of the UUID. -This will be an integer equal to one of the constants +This will be one of the integer constants \constant{RESERVED_NCS}, \constant{RFC_4122}, \constant{RESERVED_MICROSOFT}, or -\constant{RESERVED_FUTURE}). +\constant{RESERVED_FUTURE}. \end{memberdesc} \begin{memberdesc}{version} @@ -106,7 +106,7 @@ when the variant is \constant{RFC_4122}). \end{memberdesc} -The \module{uuid} module defines the following functions +The \module{uuid} module defines the following functions: \begin{funcdesc}{getnode}{} Get the hardware address as a 48-bit positive integer. The first time this @@ -129,11 +129,8 @@ \index{uuid1} \begin{funcdesc}{uuid3}{namespace, name} -Generate a UUID based upon a MD5 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the MD5 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid3} @@ -143,31 +140,32 @@ \index{uuid4} \begin{funcdesc}{uuid5}{namespace, name} -Generate a UUID based upon a SHA-1 hash of the \var{name} string value -drawn from a specified namespace. \var{namespace} -must be one of \constant{NAMESPACE_DNS}, -\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, -or \constant{NAMESPACE_X500}. +Generate a UUID based on the SHA-1 hash +of a namespace identifier (which is a UUID) and a name (which is a string). \end{funcdesc} \index{uuid5} -The \module{uuid} module defines the following namespace constants +The \module{uuid} module defines the following namespace identifiers for use with \function{uuid3()} or \function{uuid5()}. \begin{datadesc}{NAMESPACE_DNS} -Fully-qualified domain name namespace UUID. +When this namespace is specified, +the \var{name} string is a fully-qualified domain name. \end{datadesc} \begin{datadesc}{NAMESPACE_URL} -URL namespace UUID. +When this namespace is specified, +the \var{name} string is a URL. \end{datadesc} \begin{datadesc}{NAMESPACE_OID} -ISO OID namespace UUID. +When this namespace is specified, +the \var{name} string is an ISO OID. \end{datadesc} \begin{datadesc}{NAMESPACE_X500} -X.500 DN namespace UUID. +When this namespace is specified, +the \var{name} string is an X.500 DN in DER or a text output format. \end{datadesc} The \module{uuid} module defines the following constants @@ -178,11 +176,11 @@ \end{datadesc} \begin{datadesc}{RFC_4122} -Uses UUID layout specified in \rfc{4122}. +Specifies the UUID layout given in \rfc{4122}. \end{datadesc} \begin{datadesc}{RESERVED_MICROSOFT} -Reserved for Microsoft backward compatibility. +Reserved for Microsoft compatibility. \end{datadesc} \begin{datadesc}{RESERVED_FUTURE} @@ -192,12 +190,13 @@ \begin{seealso} \seerfc{4122}{A Universally Unique IDentifier (UUID) URN Namespace}{ - This specifies a Uniform Resource Name namespace for UUIDs.} +This specification defines a Uniform Resource Name namespace for UUIDs, +the internal format of UUIDs, and methods of generating UUIDs.} \end{seealso} \subsection{Example \label{uuid-example}} -Here is a typical usage: +Here are some examples of typical usage of the \module{uuid} module: \begin{verbatim} >>> import uuid Modified: python/branches/bcannon-objcap/Mac/BuildScript/build-installer.py ============================================================================== --- python/branches/bcannon-objcap/Mac/BuildScript/build-installer.py (original) +++ python/branches/bcannon-objcap/Mac/BuildScript/build-installer.py Mon Sep 18 22:20:12 2006 @@ -945,6 +945,7 @@ ref, isDirectory = Carbon.File.FSPathMakeRef(filePath) if isDirectory: + return tmpPath = os.path.join(filePath, "Icon\r") if not os.path.exists(tmpPath): fp = open(tmpPath, 'w') Modified: python/branches/bcannon-objcap/Mac/Makefile.in ============================================================================== --- python/branches/bcannon-objcap/Mac/Makefile.in (original) +++ python/branches/bcannon-objcap/Mac/Makefile.in Mon Sep 18 22:20:12 2006 @@ -101,7 +101,7 @@ fi -pythonw: $(srcdir)/Tools/pythonw.c +pythonw: $(srcdir)/Tools/pythonw.c Makefile $(CC) $(LDFLAGS) -o $@ $(srcdir)/Tools/pythonw.c \ -DPYTHONWEXECUTABLE='"$(APPINSTALLDIR)/Contents/MacOS/Python"' @@ -249,3 +249,6 @@ rm pythonw cd PythonLauncher && make clean cd IDLE && make clean + +Makefile: $(srcdir)/Makefile.in ../config.status + cd .. && CONFIG_FILES=Mac/Makefile CONFIG_HEADERS= $(SHELL) ./config.status Modified: python/branches/bcannon-objcap/Mac/Tools/fixapplepython23.py ============================================================================== --- python/branches/bcannon-objcap/Mac/Tools/fixapplepython23.py (original) +++ python/branches/bcannon-objcap/Mac/Tools/fixapplepython23.py Mon Sep 18 22:20:12 2006 @@ -123,7 +123,8 @@ makescript(GXX_SCRIPT, "g++") # Finally fix the makefile rv = fix(MAKEFILE, do_apply) - sys.exit(rv) + #sys.exit(rv) + sys.exit(0) if __name__ == '__main__': main() Modified: python/branches/bcannon-objcap/Misc/NEWS ============================================================================== --- python/branches/bcannon-objcap/Misc/NEWS (original) +++ python/branches/bcannon-objcap/Misc/NEWS Mon Sep 18 22:20:12 2006 @@ -62,6 +62,8 @@ Extension Modules ----------------- +- RLIMIT_SBSIZE was added to the resource module where available. + - Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). Modified: python/branches/bcannon-objcap/Modules/main.c ============================================================================== --- python/branches/bcannon-objcap/Modules/main.c (original) +++ python/branches/bcannon-objcap/Modules/main.c Mon Sep 18 22:20:12 2006 @@ -60,32 +60,33 @@ static char *usage_1 = "\ Options and arguments (and corresponding environment variables):\n\ -c cmd : program passed in as string (terminates option list)\n\ --d : debug output from parser (also PYTHONDEBUG=x)\n\ +-d : debug output from parser; also PYTHONDEBUG=x\n\ -E : ignore environment variables (such as PYTHONPATH)\n\ -h : print this help message and exit (also --help)\n\ --i : inspect interactively after running script, (also PYTHONINSPECT=x)\n\ - and force prompts, even if stdin does not appear to be a terminal\n\ +-i : inspect interactively after running script; forces a prompt even\n\ + if stdin does not appear to be a terminal; also PYTHONINSPECT=x\n\ "; static char *usage_2 = "\ -m mod : run library module as a script (terminates option list)\n\ --O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x)\n\ +-O : optimize generated bytecode slightly; also PYTHONOPTIMIZE=x\n\ -OO : remove doc-strings in addition to the -O optimizations\n\ -Q arg : division options: -Qold (default), -Qwarn, -Qwarnall, -Qnew\n\ -S : don't imply 'import site' on initialization\n\ -t : issue warnings about inconsistent tab usage (-tt: issue errors)\n\ --u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)\n\ +-u : unbuffered binary stdout and stderr; also PYTHONUNBUFFERED=x\n\ "; static char *usage_3 = "\ see man page for details on internal buffering relating to '-u'\n\ --v : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\ +-v : verbose (trace import statements); also PYTHONVERBOSE=x\n\ + can be supplied multiple times to increase verbosity\n\ -V : print the Python version number and exit (also --version)\n\ --W arg : warning control (arg is action:message:category:module:lineno)\n\ +-W arg : warning control; arg is action:message:category:module:lineno\n\ -x : skip first line of source, allowing use of non-Unix forms of #!cmd\n\ file : program read from script file\n\ - : program read from stdin (default; interactive mode if a tty)\n\ "; static char *usage_4 = "\ -arg ...: arguments passed to program in sys.argv[1:]\n\ +arg ...: arguments passed to program in sys.argv[1:]\n\n\ Other environment variables:\n\ PYTHONSTARTUP: file executed on interactive startup (no default)\n\ PYTHONPATH : '%c'-separated list of directories prefixed to the\n\ Modified: python/branches/bcannon-objcap/Modules/resource.c ============================================================================== --- python/branches/bcannon-objcap/Modules/resource.c (original) +++ python/branches/bcannon-objcap/Modules/resource.c Mon Sep 18 22:20:12 2006 @@ -298,6 +298,10 @@ PyModule_AddIntConstant(m, "RLIMIT_MEMLOCK", RLIMIT_MEMLOCK); #endif +#ifdef RLIMIT_SBSIZE + PyModule_AddIntConstant(m, "RLIMIT_SBSIZE", RLIMIT_SBSIZE); +#endif + #ifdef RUSAGE_SELF PyModule_AddIntConstant(m, "RUSAGE_SELF", RUSAGE_SELF); #endif Modified: python/branches/bcannon-objcap/Tools/msi/msi.py ============================================================================== --- python/branches/bcannon-objcap/Tools/msi/msi.py (original) +++ python/branches/bcannon-objcap/Tools/msi/msi.py Mon Sep 18 22:20:12 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 python-checkins at python.org Mon Sep 18 23:27:52 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Sep 2006 23:27:52 +0200 (CEST) Subject: [Python-checkins] r51912 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py Modules/interpretermodule.c securing_python.txt Message-ID: <20060918212752.269AC1E4006@bag.python.org> Author: brett.cannon Date: Mon Sep 18 23:27:51 2006 New Revision: 51912 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/Modules/interpretermodule.c python/branches/bcannon-objcap/securing_python.txt Log: Rework interface for getting the built-ins namespace dict. Since it is cached the instant you create an interpreter by the initial execution frame, make it so that you need a function call to return the dict. That way people realize they cannot reassign the dict but it can be mutated. Need to verify that the sys_dict and modules dicts don't have the same issue. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Mon Sep 18 23:27:51 2006 @@ -1,12 +1,3 @@ -"""XXX Use case tests: - * cannot open files - - test removal of open() as well as change to bz2. - * block imports - - built-ins - - .pyc/.pyo - - extension modules - -""" import interpreter import unittest @@ -28,6 +19,12 @@ to_return.append(False) """ +test_builtins_contains = """ +import __builtin__ +_return.append(__builtin__.__dict__.__contains__("%s")) +""" + + class BaseInterpTests(unittest.TestCase): def setUp(self): @@ -49,52 +46,45 @@ class BuiltinsTests(BaseInterpTests): - """Test interpreter.Interpreter().builtins .""" + """Test interpreter.Interpreter().builtins() .""" def test_get(self): # Test the getting of 'builtins'. - builtins = self.interp.builtins + builtins = self.interp.builtins() self.failUnless(isinstance(builtins, dict)) self.failUnless('object' in builtins) - def test_set(self): - # Make sure setting 'builtins' can be done and has proper type - # checking. - self.interp.builtins = {} - self.failUnlessRaises(TypeError, setattr, self.interp, 'builtins', []) - def test_remove(self): # Make sure that something can be removed from built-ins. - # XXX - pass + builtins = self.interp.builtins() + del builtins['open'] + _return = [] + builtins['_return'] = _return + self.interp.execute(test_builtins_contains % 'open') + self.failUnless(not _return[-1]) def test_add_remove(self): # Make sure you can add to the built-ins and then remove the same # object. - self.interp.builtins['test'] = 'test' - self.interp.execute('test') - del self.interp.builtins['test'] - # XXX self.failUnlessRaises(XXX, interp.execute, 'test') - - - def test_empty_builtins(self): - # Make sure that emptying the built-ins truly make them non-existent. - self.interp.builtins = {} - # XXX self.failUnlessRaises(XXX, interp.execute, 'object') - + self.interp.builtins()['test'] = 'test' + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute(test_builtins_contains % 'test') + self.failUnless(_return[-1]) + del self.interp.builtins()['test'] + self.interp.execute(test_builtins_contains % 'test') + self.failUnless(not _return[-1]) + def test_copied(self): # Make sure built-ins are unique per interpreter. - self.failUnless(self.interp.builtins is not __builtin__.__dict__) - - try: - __builtin__.__dict__['test1'] = 'test1' - self.failUnless('test1' not in self.interp.builtins) - finally: - del __builtin__.__dict__['test1'] - self.interp.builtins['test2'] = 'test2' - self.failUnless('test2' not in __builtin__.__dict__) - - + master_id = id(__builtin__.__dict__) + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute('import __builtin__;' + '_return.append(id(__builtin__.__dict__))') + self.failUnless(_return[-1] != master_id) + + class ModulesTests(BaseInterpTests): """Test interpreter.Interpreter().modules .""" @@ -153,7 +143,7 @@ sys_dict = self.interp.sys_dict sys_dict['version'] = 'test' interp_return = [] - self.interp.builtins['to_return'] = interp_return + self.interp.builtins()['to_return'] = interp_return self.interp.execute(test_sys_changed) self.failUnless(interp_return[0]) @@ -183,7 +173,7 @@ def test_file_restrictions(self): # You cannot open a file. - del self.interp.builtins['open'] + del self.interp.builtins()['open'] try: self.interp.execute("open(%s, 'w')" % test_support.TESTFN) finally: Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Mon Sep 18 23:27:51 2006 @@ -99,45 +99,29 @@ Py_RETURN_NONE; } -static PyMethodDef interpreter_methods[] = { - {"execute", interpreter_exec, METH_O, - "Execute the passed-in string in the interpreter"}, - {NULL} -}; - - /* - Getter for 'builtins'. -*/ + Getter for 'builtins'. + + There is not setter because the creation of a new interpreter automatically + creates the initial execution frame which caches the built-in namespace. + */ static PyObject * -interpreter_get_builtins(PyObject *self, void *optional) +interpreter_builtins(PyObject *self) { - PyObject *builtins = PyInterpreter_GET_INTERP(self)->builtins; - - Py_INCREF(builtins); - return builtins; + PyObject *builtins = PyInterpreter_GET_INTERP(self)->builtins; + + Py_INCREF(builtins); + return builtins; } -/* - Setter for 'builtins'. -*/ -static int -interpreter_set_builtins(PyObject *self, PyObject *arg, void *optional) -{ - PyObject *old_builtins = PyInterpreter_GET_INTERP(self)->builtins; - - if (!PyDict_CheckExact(arg)) { - PyErr_SetString(PyExc_TypeError, - "'builtins' must be set to a dict"); - return -1; - } - - Py_INCREF(arg); - Py_DECREF(old_builtins); - PyInterpreter_GET_INTERP(self)->builtins = arg; +static PyMethodDef interpreter_methods[] = { + {"builtins", (PyCFunction)interpreter_builtins, METH_NOARGS, + "Return the built-in namespace dict"}, + {"execute", interpreter_exec, METH_O, + "Execute the passed-in string in the interpreter"}, + {NULL} +}; - return 0; -} /* Getter for 'modules'. @@ -207,8 +191,6 @@ static PyGetSetDef interpreter_getset[] = { - {"builtins", interpreter_get_builtins, interpreter_set_builtins, - "The built-ins dict for the interpreter.", NULL}, {"sys_dict", interpreter_get_sys_dict, interpreter_set_sys_dict, "The modules dict for 'sys'.", NULL}, {"modules", interpreter_get_modules, interpreter_set_modules, Modified: python/branches/bcannon-objcap/securing_python.txt ============================================================================== --- python/branches/bcannon-objcap/securing_python.txt (original) +++ python/branches/bcannon-objcap/securing_python.txt Mon Sep 18 23:27:51 2006 @@ -43,11 +43,7 @@ interrupt_main() not per-interpreter, and stack_size() can be dangerous) + Create sandboxed interpreter stdlib module - - Be able to specify built-ins - * XXX frames cache built-ins, so setting to a new dict does - not get propagated; need to either change ability to assign - to built-ins or add functions that allow to set and delete - keys individually. + - Be able to specify built-ins [done] - Set 'sys' module settings - Set 'sys.modules' - API From python-checkins at python.org Mon Sep 18 23:36:16 2006 From: python-checkins at python.org (guido.van.rossum) Date: Mon, 18 Sep 2006 23:36:16 +0200 (CEST) Subject: [Python-checkins] r51913 - python/trunk/Tools/scripts/byext.py Message-ID: <20060918213616.A86F61E4006@bag.python.org> Author: guido.van.rossum Date: Mon Sep 18 23:36:16 2006 New Revision: 51913 Modified: python/trunk/Tools/scripts/byext.py (props changed) Log: Make this thing executable. From python-checkins at python.org Mon Sep 18 23:37:22 2006 From: python-checkins at python.org (brett.cannon) Date: Mon, 18 Sep 2006 23:37:22 +0200 (CEST) Subject: [Python-checkins] r51914 - python/branches/bcannon-objcap/Lib/test/test_interpreter.py Message-ID: <20060918213722.B37721E4006@bag.python.org> Author: brett.cannon Date: Mon Sep 18 23:37:22 2006 New Revision: 51914 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py Log: Use a list in the module docstring to contain what to test against instead of a placeholder class. Also clarify which tests require exceptions to be implemented. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Mon Sep 18 23:37:22 2006 @@ -1,3 +1,16 @@ +""" Things to protect (and thus test) against: +* Importing + + built-ins + + .pyc/.pyo + + extension modules +* File access + + open() +* Evil methods + + __del__ + + __str__ (for exceptions) + + properties + +""" import interpreter import unittest @@ -133,10 +146,12 @@ self.failUnless('version' in sys_dict) def test_set(self): - # Make sure sys_dict can be set to a new dict. + # Make sure sys_dict can be set to a new dict and that it has desired + # effect. sys_dict_copy = self.interp.sys_dict.copy() self.interp.sys_dict = sys_dict_copy self.failUnlessRaises(TypeError, setattr, self.interp, 'sys_dict', []) + # XXX requires exceptions. def test_mutating(self): # Changes to the dict should be reflected in the interpreter. @@ -151,6 +166,7 @@ # Make sure removing a value raises the proper exception when accessing # through the 'sys' module. del self.interp.sys_dict['version'] + # XXX requires exceptions # XXX self.failUnlessRaises(XXX, self.interp.execute, # 'import sys; sys.version') @@ -167,35 +183,6 @@ self.failUnless(sys.path[-1] != 'test') -class PlaceHolder(BaseInterpTests): - - """Hold some tests that will need to pass at some point.""" - - def test_file_restrictions(self): - # You cannot open a file. - del self.interp.builtins()['open'] - try: - self.interp.execute("open(%s, 'w')" % test_support.TESTFN) - finally: - try: - os.remove(test_support.TESTFN) - except OSError: - pass - # XXX bz2 module protection. - - def test_import_builtin(self): - # Block importing built-in modules. - pass - - def test_import_pyc(self): - # Block importing .pyc files. - pass - - def test_import_extensions(self): - # Block importing extension modules. - pass - - def test_main(): test_support.run_unittest( BasicInterpreterTests, From python-checkins at python.org Tue Sep 19 00:22:37 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 19 Sep 2006 00:22:37 +0200 (CEST) Subject: [Python-checkins] r51915 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060918222237.A44761E4006@bag.python.org> Author: brett.cannon Date: Tue Sep 19 00:22:36 2006 New Revision: 51915 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Mention change in built-ins access. Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Tue Sep 19 00:22:36 2006 @@ -25,6 +25,11 @@ Extension Modules ----------------- +* rev. 51914: Changed accessing the built-in namespace dict from an attribute + to a function call. This is because the dict is cached in the execution + frame created when the interpreter is first created and thus setting the dict + to another dict has no affect. + * rev. 51880: Add access to the 'sys' modules data dict to Interpreter objects. * rev. 51875: Introduced the interpreter module. From python-checkins at python.org Tue Sep 19 01:00:16 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 19 Sep 2006 01:00:16 +0200 (CEST) Subject: [Python-checkins] r51916 - python/branches/bcannon-objcap/Lib/test/test_interpreter.py Message-ID: <20060918230016.7E6D51E4006@bag.python.org> Author: brett.cannon Date: Tue Sep 19 01:00:15 2006 New Revision: 51916 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py Log: Strengthen tests for interpreter.Interpreter().modules . Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Tue Sep 19 01:00:15 2006 @@ -42,7 +42,6 @@ def setUp(self): """Create a new interpreter.""" - self.interp = interpreter.Interpreter() @@ -106,6 +105,11 @@ # Make sure a dict is returned. modules = self.interp.modules self.failUnless(isinstance(modules, dict)) + master_id = id(modules) + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute('import sys; _return.append(id(sys.modules))') + self.failUnlessEqual(_return[-1], master_id) def test_set(self): # Make sure setting 'modules' can be done and has proper type checking. @@ -113,26 +117,33 @@ self.failUnlessRaises(TypeError, setattr, self.interp.modules, []) def test_mutation(self): - # If a module is swapped for another one, make sure imports actually - # use the new module entry. - # XXX - pass - - def test_adding(self): # If a module is added, make sure importing uses that module. - # XXX - pass + self.interp.modules['test1'] = 'test1' + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute('import test1; _return.append(test1)') + self.failUnlessEqual(_return[-1], 'test1') + self.interp.modules['test1'] = 'test2' + self.interp.execute('import test1; _return.append(test1)') + self.failUnlessEqual(_return[-1], 'test2') def test_deleting(self): # Make sure that a module is re-imported if it is removed. - # XXX - pass + self.failUnless('token' not in self.interp.modules) + self.interp.execute('import token') + del self.interp.modules['token'] + # XXX should really check that ImportError not raised. + self.interp.execute('import token') def test_fresh(self): - # Make sure that import Python modules are new instances. + # Make sure that imported Python modules are new instances. import token - self.interp.execute("import token") - self.failUnless(self.interp.modules['token'] is not token) + token.test = 'test' + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute("import token;" + "_return.append(hasattr(token, 'test'))") + self.failUnless(not _return[-1]) class SysDictTests(BaseInterpTests): From python-checkins at python.org Tue Sep 19 01:48:17 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 19 Sep 2006 01:48:17 +0200 (CEST) Subject: [Python-checkins] r51917 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py Modules/interpretermodule.c Message-ID: <20060918234817.978D81E4006@bag.python.org> Author: brett.cannon Date: Tue Sep 19 01:48:16 2006 New Revision: 51917 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/Modules/interpretermodule.c Log: Tweak the setter for 'modules' so that it also assigns the new dict to sys.modules. Also strenthen tests for 'modules'. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Tue Sep 19 01:48:16 2006 @@ -134,6 +134,15 @@ del self.interp.modules['token'] # XXX should really check that ImportError not raised. self.interp.execute('import token') + + def test_replacing(self): + # Replacing with a new dict should work. + new_modules = self.interp.modules.copy() + self.interp.modules = new_modules + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute('import sys; _return.append(id(sys.modules))') + self.failUnlessEqual(id(new_modules), _return[-1]) def test_fresh(self): # Make sure that imported Python modules are new instances. @@ -157,12 +166,11 @@ self.failUnless('version' in sys_dict) def test_set(self): - # Make sure sys_dict can be set to a new dict and that it has desired + # Make sure sys_dict can be set to a new dict and that it has desired # effect. sys_dict_copy = self.interp.sys_dict.copy() self.interp.sys_dict = sys_dict_copy self.failUnlessRaises(TypeError, setattr, self.interp, 'sys_dict', []) - # XXX requires exceptions. def test_mutating(self): # Changes to the dict should be reflected in the interpreter. @@ -171,7 +179,7 @@ interp_return = [] self.interp.builtins()['to_return'] = interp_return self.interp.execute(test_sys_changed) - self.failUnless(interp_return[0]) + self.failUnless(interp_return[-1]) def test_deletion(self): # Make sure removing a value raises the proper exception when accessing Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Tue Sep 19 01:48:16 2006 @@ -137,6 +137,16 @@ /* Setter for 'modules'. + + Assumes no one has stored away a reference to sys.modules . Since sys.modules + is set during interpreter creation, its reference is not updated unless done so + explicitly. + + One option would have been to take the approach of builtins(), which is to have + a function that returns the initial dict and thus prevent complete dict + replacement. But since assigning to sys.modules directly has not effect, + assuming people would treat sys.modules as something to not store away seemed + reasonable. */ static int interpreter_set_modules(PyObject *self, PyObject *arg, void *optional) @@ -152,6 +162,8 @@ Py_INCREF(arg); Py_DECREF(old_modules); PyInterpreter_GET_INTERP(self)->modules = arg; + PyDict_SetItemString(PyInterpreter_GET_INTERP(self)->sysdict, + "modules", arg); return 0; } From python-checkins at python.org Tue Sep 19 03:05:18 2006 From: python-checkins at python.org (anthony.baxter) Date: Tue, 19 Sep 2006 03:05:18 +0200 (CEST) Subject: [Python-checkins] r51918 - python/tags/r25 Message-ID: <20060919010518.8341C1E4007@bag.python.org> Author: anthony.baxter Date: Tue Sep 19 03:05:18 2006 New Revision: 51918 Added: python/tags/r25/ - copied from r51917, python/branches/release25-maint/ Log: Tagging for release of Python 2.5 From anthony at interlink.com.au Tue Sep 19 16:06:00 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 20 Sep 2006 00:06:00 +1000 Subject: [Python-checkins] release25-maint branch - please keep frozen for a day or two more. Message-ID: <200609200006.06585.anthony@interlink.com.au> Could people please treat the release25-maint branch as frozen for a day or two, just in case we have to cut an ohmygodnononokillme release? Thanks, Anthony -- Anthony Baxter It's never too late to have a happy childhood. From python-checkins at python.org Tue Sep 19 19:23:51 2006 From: python-checkins at python.org (gregory.p.smith) Date: Tue, 19 Sep 2006 19:23:51 +0200 (CEST) Subject: [Python-checkins] r51919 - in python/branches/release24-maint: Misc/NEWS Modules/_bsddb.c Message-ID: <20060919172351.B1A101E4006@bag.python.org> Author: gregory.p.smith Date: Tue Sep 19 19:23:50 2006 New Revision: 51919 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/_bsddb.c Log: fix a bug with bsddb.DB.stat reversing its flags and txn keyword arguments. (reported by Louis Zechtzer) Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Tue Sep 19 19:23:50 2006 @@ -46,6 +46,9 @@ - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 codepoints now. +- fixed a bug with bsddb.DB.stat: its flags and txn keyword arguments + were transposed. + Extension Modules ----------------- Modified: python/branches/release24-maint/Modules/_bsddb.c ============================================================================== --- python/branches/release24-maint/Modules/_bsddb.c (original) +++ python/branches/release24-maint/Modules/_bsddb.c Tue Sep 19 19:23:50 2006 @@ -2172,7 +2172,7 @@ #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - char* kwnames[] = { "txn", "flags", NULL }; + char* kwnames[] = { "flags", "txn", NULL }; #else char* kwnames[] = { "flags", NULL }; #endif From python-checkins at python.org Tue Sep 19 19:35:06 2006 From: python-checkins at python.org (gregory.p.smith) Date: Tue, 19 Sep 2006 19:35:06 +0200 (CEST) Subject: [Python-checkins] r51920 - in python/trunk: Misc/NEWS Modules/_bsddb.c Message-ID: <20060919173506.2720F1E4007@bag.python.org> Author: gregory.p.smith Date: Tue Sep 19 19:35:04 2006 New Revision: 51920 Modified: python/trunk/Misc/NEWS python/trunk/Modules/_bsddb.c Log: Fixes a bug with bsddb.DB.stat where the flags and txn keyword arguments are transposed. (reported by Louis Zechtzer) ..already committed to release24-maint ..needs committing to release25-maint Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Tue Sep 19 19:35:04 2006 @@ -58,6 +58,8 @@ - Bug #1531862: Do not close standard file descriptors in subprocess. +- fixed a bug with bsddb.DB.stat: its flags and txn keyword arguments + were transposed. Extension Modules ----------------- Modified: python/trunk/Modules/_bsddb.c ============================================================================== --- python/trunk/Modules/_bsddb.c (original) +++ python/trunk/Modules/_bsddb.c Tue Sep 19 19:35:04 2006 @@ -98,7 +98,7 @@ #error "eek! DBVER can't handle minor versions > 9" #endif -#define PY_BSDDB_VERSION "4.4.5" +#define PY_BSDDB_VERSION "4.4.6" static char *rcs_id = "$Id$"; @@ -2430,7 +2430,7 @@ #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - static char* kwnames[] = { "txn", "flags", NULL }; + static char* kwnames[] = { "flags", "txn", NULL }; #else static char* kwnames[] = { "flags", NULL }; #endif From python-checkins at python.org Wed Sep 20 20:34:29 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Sep 2006 20:34:29 +0200 (CEST) Subject: [Python-checkins] r51926 - python/trunk/Misc/NEWS Message-ID: <20060920183429.575661E4006@bag.python.org> Author: brett.cannon Date: Wed Sep 20 20:34:28 2006 New Revision: 51926 Modified: python/trunk/Misc/NEWS Log: Accidentally didn't commit Misc/NEWS entry on when __unicode__() was removed from exceptions. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 20 20:34:28 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1551432: Exceptions do not define an explicit __unicode__ method. This + allows calling unicode() on exceptions classes directly to succeed. + - Make _PyGILState_NoteThreadState() static, it was not used anywhere outside of pystate.c and should not be necessary. From python-checkins at python.org Wed Sep 20 20:43:13 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Sep 2006 20:43:13 +0200 (CEST) Subject: [Python-checkins] r51927 - in python/trunk: Misc/NEWS Objects/exceptions.c Message-ID: <20060920184313.C9E411E4011@bag.python.org> Author: brett.cannon Date: Wed Sep 20 20:43:13 2006 New Revision: 51927 Modified: python/trunk/Misc/NEWS python/trunk/Objects/exceptions.c Log: Allow exceptions to be directly sliced again (e.g., ``BaseException(1,2,3)[0:2]``). Discovered in Python 2.5.0 by Thomas Heller and reported to python-dev. This should be backported to 2.5 . Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 20 20:43:13 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Allow exception instances to be directly sliced again. + - Bug #1551432: Exceptions do not define an explicit __unicode__ method. This allows calling unicode() on exceptions classes directly to succeed. Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Wed Sep 20 20:43:13 2006 @@ -190,12 +190,19 @@ return PySequence_GetItem(self->args, index); } +static PyObject * +BaseException_getslice(PyBaseExceptionObject *self, + Py_ssize_t start, Py_ssize_t stop) +{ + return PySequence_GetSlice(self->args, start, stop); +} + static PySequenceMethods BaseException_as_sequence = { 0, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ (ssizeargfunc)BaseException_getitem, /* sq_item; */ - 0, /* sq_slice; */ + (ssizessizeargfunc)BaseException_getslice, /* sq_slice; */ 0, /* sq_ass_item; */ 0, /* sq_ass_slice; */ 0, /* sq_contains; */ From buildbot at python.org Wed Sep 20 20:49:50 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 20 Sep 2006 18:49:50 +0000 Subject: [Python-checkins] buildbot failure in sparc Ubuntu dapper trunk Message-ID: <20060920184950.6F3601E4006@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/705 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon BUILD FAILED: failed svn sincerely, -The Buildbot From python-checkins at python.org Wed Sep 20 21:28:36 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Sep 2006 21:28:36 +0200 (CEST) Subject: [Python-checkins] r51928 - in python/trunk/Misc: NEWS Vim/python.vim Vim/vim_syntax.py Message-ID: <20060920192836.264101E4006@bag.python.org> Author: brett.cannon Date: Wed Sep 20 21:28:35 2006 New Revision: 51928 Modified: python/trunk/Misc/NEWS python/trunk/Misc/Vim/python.vim python/trunk/Misc/Vim/vim_syntax.py Log: Make python.vim output more deterministic. Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 20 21:28:35 2006 @@ -103,6 +103,10 @@ Tools ----- +- Make auto-generated python.vim file list built-ins and exceptions in + alphatbetical order. Makes output more deterministic and easier to tell if + the file is stale or not. + - Bug #1546372: Fixed small bugglet in pybench that caused a missing file not to get reported properly. Modified: python/trunk/Misc/Vim/python.vim ============================================================================== --- python/trunk/Misc/Vim/python.vim (original) +++ python/trunk/Misc/Vim/python.vim Wed Sep 20 21:28:35 2006 @@ -62,39 +62,39 @@ if exists("python_highlight_builtins") - syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode - syn keyword pythonBuiltin enumerate reduce coerce intern exit issubclass - syn keyword pythonBuiltin divmod file Ellipsis apply isinstance open any - syn keyword pythonBuiltin locals help filter basestring slice copyright min - syn keyword pythonBuiltin super sum tuple hex execfile long id xrange chr - syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented - syn keyword pythonBuiltin map None float hash getattr buffer max reversed - syn keyword pythonBuiltin object quit len repr callable credits setattr - syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr - syn keyword pythonBuiltin delattr False input license classmethod type - syn keyword pythonBuiltin raw_input list iter compile reload range globals - syn keyword pythonBuiltin staticmethod str property round dir cmp + syn keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__ + syn keyword pythonBuiltin __import__ abs all any apply basestring bool + syn keyword pythonBuiltin buffer callable chr classmethod cmp coerce + syn keyword pythonBuiltin compile complex copyright credits delattr dict + syn keyword pythonBuiltin dir divmod enumerate eval execfile exit file + syn keyword pythonBuiltin filter float frozenset getattr globals hasattr + syn keyword pythonBuiltin hash help hex id input int intern isinstance + syn keyword pythonBuiltin issubclass iter len license list locals long map + syn keyword pythonBuiltin max min object oct open ord pow property quit + syn keyword pythonBuiltin range raw_input reduce reload repr reversed round + syn keyword pythonBuiltin set setattr slice sorted staticmethod str sum + syn keyword pythonBuiltin super tuple type unichr unicode vars xrange zip endif if exists("python_highlight_exceptions") - syn keyword pythonException GeneratorExit ImportError RuntimeError - syn keyword pythonException UnicodeTranslateError MemoryError StopIteration - syn keyword pythonException PendingDeprecationWarning EnvironmentError - syn keyword pythonException LookupError OSError DeprecationWarning - syn keyword pythonException UnicodeError UnicodeEncodeError - syn keyword pythonException FloatingPointError ReferenceError NameError - syn keyword pythonException IOError SyntaxError - syn keyword pythonException FutureWarning ImportWarning SystemExit - syn keyword pythonException Exception EOFError StandardError ValueError - syn keyword pythonException TabError KeyError ZeroDivisionError SystemError - syn keyword pythonException UnicodeDecodeError IndentationError - syn keyword pythonException AssertionError TypeError IndexError - syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning - syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError - syn keyword pythonException Warning NotImplementedError AttributeError - syn keyword pythonException OverflowError BaseException + syn keyword pythonException ArithmeticError AssertionError AttributeError + syn keyword pythonException BaseException DeprecationWarning EOFError + syn keyword pythonException EnvironmentError Exception FloatingPointError + syn keyword pythonException FutureWarning GeneratorExit IOError ImportError + syn keyword pythonException ImportWarning IndentationError IndexError + syn keyword pythonException KeyError KeyboardInterrupt LookupError + syn keyword pythonException MemoryError NameError NotImplementedError + syn keyword pythonException OSError OverflowError PendingDeprecationWarning + syn keyword pythonException ReferenceError RuntimeError RuntimeWarning + syn keyword pythonException StandardError StopIteration SyntaxError + syn keyword pythonException SyntaxWarning SystemError SystemExit TabError + syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError + syn keyword pythonException UnicodeEncodeError UnicodeError + syn keyword pythonException UnicodeTranslateError UnicodeWarning + syn keyword pythonException UserWarning ValueError Warning + syn keyword pythonException ZeroDivisionError endif Modified: python/trunk/Misc/Vim/vim_syntax.py ============================================================================== --- python/trunk/Misc/Vim/vim_syntax.py (original) +++ python/trunk/Misc/Vim/vim_syntax.py Wed Sep 20 21:28:35 2006 @@ -5,9 +5,9 @@ import __builtin__ from string import Template -comment_header = """" Auto-generated Vim syntax file for Python +comment_header = '''" Auto-generated Vim syntax file for Python. " -" To use: copy or symlink to ~/.vim/syntax/python.vim""" +" To use: copy or symlink to ~/.vim/syntax/python.vim''' statement_header = """ if exists("b:current_syntax") @@ -30,14 +30,14 @@ import_stmts = ('import', 'from') object_defs = ('def', 'class') -exception_names = frozenset(exc for exc in dir(exceptions) +exception_names = sorted(exc for exc in dir(exceptions) if not exc.startswith('__')) # Need to include functions that start with '__' (e.g., __import__), but # nothing that comes with modules (e.g., __name__), so just exclude anything in # the 'exceptions' module since we want to ignore exceptions *and* what any # module would have -builtin_names = frozenset(builtin for builtin in dir(__builtin__) +builtin_names = sorted(builtin for builtin in dir(__builtin__) if builtin not in dir(exceptions)) escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"', From python-checkins at python.org Wed Sep 20 22:08:10 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 20 Sep 2006 22:08:10 +0200 (CEST) Subject: [Python-checkins] r51929 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060920200810.48A4F1E400F@bag.python.org> Author: brett.cannon Date: Wed Sep 20 22:08:09 2006 New Revision: 51929 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Mark builtins and sys_dict as done. 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 20 22:08:09 2006 @@ -44,8 +44,8 @@ dangerous) + Create sandboxed interpreter stdlib module - Be able to specify built-ins [done] - - Set 'sys' module settings - - Set 'sys.modules' + - Set 'sys' module settings [done] + - Set 'sys.modules' [done] - API * Python * C From python-checkins at python.org Wed Sep 20 22:11:00 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 20 Sep 2006 22:11:00 +0200 (CEST) Subject: [Python-checkins] r51930 - sandbox/trunk/setuptools/doctest.py Message-ID: <20060920201100.8FDA61E4006@bag.python.org> Author: phillip.eby Date: Wed Sep 20 22:11:00 2006 New Revision: 51930 Modified: sandbox/trunk/setuptools/doctest.py Log: Python 2.5 compatibility fix Modified: sandbox/trunk/setuptools/doctest.py ============================================================================== --- sandbox/trunk/setuptools/doctest.py (original) +++ sandbox/trunk/setuptools/doctest.py Wed Sep 20 22:11:00 2006 @@ -1328,13 +1328,13 @@ __LINECACHE_FILENAME_RE = re.compile(r'[\w\.]+)' r'\[(?P\d+)\]>$') - def __patched_linecache_getlines(self, filename): + def __patched_linecache_getlines(self, filename, module_globals=None): m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] return example.source.splitlines(True) else: - return self.save_linecache_getlines(filename) + return self.save_linecache_getlines(filename, module_globals) def run(self, test, compileflags=None, out=None, clear_globs=True): """ From python-checkins at python.org Wed Sep 20 22:20:57 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 20 Sep 2006 22:20:57 +0200 (CEST) Subject: [Python-checkins] r51931 - sandbox/trunk/setuptools/doctest.py Message-ID: <20060920202057.BDD741E4006@bag.python.org> Author: phillip.eby Date: Wed Sep 20 22:20:57 2006 New Revision: 51931 Modified: sandbox/trunk/setuptools/doctest.py Log: Retain 2.3/2.4 compatibility as well... Modified: sandbox/trunk/setuptools/doctest.py ============================================================================== --- sandbox/trunk/setuptools/doctest.py (original) +++ sandbox/trunk/setuptools/doctest.py Wed Sep 20 22:20:57 2006 @@ -1333,8 +1333,10 @@ if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] return example.source.splitlines(True) - else: + elif self.save_linecache_getlines.func_code.co_argcount>1: return self.save_linecache_getlines(filename, module_globals) + else: + return self.save_linecache_getlines(filename) def run(self, test, compileflags=None, out=None, clear_globs=True): """ From python-checkins at python.org Wed Sep 20 22:22:05 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 20 Sep 2006 22:22:05 +0200 (CEST) Subject: [Python-checkins] r51932 - sandbox/branches/setuptools-0.6/setuptools/tests/doctest.py Message-ID: <20060920202205.5D75E1E4006@bag.python.org> Author: phillip.eby Date: Wed Sep 20 22:22:04 2006 New Revision: 51932 Modified: sandbox/branches/setuptools-0.6/setuptools/tests/doctest.py Log: Backport some Python 2.5 compatibility work Modified: sandbox/branches/setuptools-0.6/setuptools/tests/doctest.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/tests/doctest.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/tests/doctest.py Wed Sep 20 22:22:04 2006 @@ -1330,11 +1330,13 @@ __LINECACHE_FILENAME_RE = re.compile(r'[\w\.]+)' r'\[(?P\d+)\]>$') - def __patched_linecache_getlines(self, filename): + def __patched_linecache_getlines(self, filename, module_globals=None): m = self.__LINECACHE_FILENAME_RE.match(filename) if m and m.group('name') == self.test.name: example = self.test.examples[int(m.group('examplenum'))] return example.source.splitlines(True) + elif self.save_linecache_getlines.func_code.co_argcount>1: + return self.save_linecache_getlines(filename, module_globals) else: return self.save_linecache_getlines(filename) From buildbot at python.org Wed Sep 20 22:46:17 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 20 Sep 2006 20:46:17 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060920204617.D22C71E4006@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/564 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 20 22:48:21 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 20 Sep 2006 22:48:21 +0200 (CEST) Subject: [Python-checkins] r51935 - in sandbox/branches/setuptools-0.6: EasyInstall.txt api_tests.txt easy_install.py pkg_resources.py setup.py setuptools/command/__init__.py setuptools/command/easy_install.py setuptools/dist.py setuptools/tests/__init__.py Message-ID: <20060920204821.0A2DE1E4008@bag.python.org> Author: phillip.eby Date: Wed Sep 20 22:48:18 2006 New Revision: 51935 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/api_tests.txt sandbox/branches/setuptools-0.6/easy_install.py sandbox/branches/setuptools-0.6/pkg_resources.py sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/command/__init__.py sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/dist.py sandbox/branches/setuptools-0.6/setuptools/tests/__init__.py Log: Backport all known 2.5-compatibility fixes 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 20 22:48:18 2006 @@ -331,6 +331,10 @@ 2.4, you can use the ``easy_install-2.3`` or ``easy_install-2.4`` scripts to install packages for Python 2.3 or 2.4, respectively. +Also, if you're working with Python version 2.4 or higher, you can run Python +with ``-m easy_install`` to run that particular Python version's +``easy_install`` command. + Restricting Downloads with ``--allow-hosts`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1190,6 +1194,11 @@ Release Notes/Change History ============================ +0.6c3 + * You once again use "python -m easy_install" with Python 2.4 and above. + + * Python 2.5 compatibility fixes added. + 0.6c2 * Windows script wrappers now support quoted arguments and arguments containing spaces. (Patch contributed by Jim Fulton.) Modified: sandbox/branches/setuptools-0.6/api_tests.txt ============================================================================== --- sandbox/branches/setuptools-0.6/api_tests.txt (original) +++ sandbox/branches/setuptools-0.6/api_tests.txt Wed Sep 20 22:48:18 2006 @@ -274,13 +274,13 @@ >>> ws.add(foo12) # this will conflict with Foo 1.4 >>> ws.find_plugins(plugins) - ([JustATest 0.99, Foo 1.2 (f12)], {Foo 1.4 (f14): <...VersionConflict...>}) + ([JustATest 0.99, Foo 1.2 (f12)], {Foo 1.4 (f14): VersionConflict(...)}) But if you disallow fallbacks, the failed plugin will be skipped instead of trying older versions:: >>> ws.find_plugins(plugins, fallback=False) - ([JustATest 0.99], {Foo 1.4 (f14): <...VersionConflict...>}) + ([JustATest 0.99], {Foo 1.4 (f14): VersionConflict(...)}) Modified: sandbox/branches/setuptools-0.6/easy_install.py ============================================================================== --- sandbox/branches/setuptools-0.6/easy_install.py (original) +++ sandbox/branches/setuptools-0.6/easy_install.py Wed Sep 20 22:48:18 2006 @@ -1,15 +1,5 @@ -#!python -"""\ -This script/module exists for backward compatibility only! It will go away -entirely in 0.7. Please start using the 'easy_install' script or .exe instead -of using 'python -m easy_install' or running 'easy_install.py' directly. -""" +"""Run the EasyInstall command""" if __name__ == '__main__': - import sys - print >>sys.stderr, \ - "Please use the 'easy_install' script or executable instead." - print >>sys.stderr, \ - "(i.e., don't include the '.py' extension and don't use 'python -m')" - sys.exit(2) - + from setuptools.command.easy_install import main + main() Modified: sandbox/branches/setuptools-0.6/pkg_resources.py ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.py (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.py Wed Sep 20 22:48:18 2006 @@ -58,7 +58,7 @@ # Exceptions 'ResolutionError','VersionConflict','DistributionNotFound','UnknownExtra', 'ExtractionError', - + # Parsing functions and string utilities 'parse_requirements', 'parse_version', 'safe_name', 'safe_version', 'get_platform', 'compatible_platforms', 'yield_lines', 'split_sections', @@ -82,6 +82,7 @@ ] class ResolutionError(Exception): """Abstract base for dependency resolution errors""" + def __repr__(self): return self.__class__.__name__+repr(self.args) class VersionConflict(ResolutionError): """An already-installed version conflicts with the requested version""" @@ -91,7 +92,6 @@ class UnknownExtra(ResolutionError): """Distribution doesn't have an "extra feature" of the given name""" - _provider_factories = {} PY_MAJOR = sys.version[:3] EGG_DIST = 3 @@ -823,7 +823,7 @@ old_exc = sys.exc_info()[1] cache_path = self.extraction_path or get_default_cache() - + err = ExtractionError("""Can't extract file(s) to egg cache The following error occurred while trying to extract file(s) to the Python egg @@ -878,7 +878,7 @@ ensure_directory(target_path) except: self.extraction_error() - + self.cached_files[target_path] = 1 return target_path @@ -1264,11 +1264,11 @@ try: rename(tmpnam, real_path) - - except os.error: + + except os.error: if os.path.isfile(real_path): stat = os.stat(real_path) - + if stat.st_size==size and stat.st_mtime==timestamp: # size and stamp match, somebody did it just ahead of # us, so we're done Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Wed Sep 20 22:48:18 2006 @@ -23,8 +23,6 @@ from setuptools import setup, find_packages import sys scripts = [] -if sys.platform != "win32": - scripts = ["easy_install.py"] # for backward compatibility only setup( name="setuptools", @@ -38,13 +36,12 @@ keywords = "CPAN PyPI distutils eggs package management", url = "http://peak.telecommunity.com/DevCenter/setuptools", test_suite = 'setuptools.tests', - packages = find_packages(), package_data = {'setuptools':['*.exe']}, py_modules = ['pkg_resources', 'easy_install', 'site'], - zip_safe = False, # We want 'python -m easy_install' to work, for now :( + zip_safe = (sys.version>="2.5"), # <2.5 needs unzipped for -m to work entry_points = { @@ -80,12 +77,15 @@ "dependency_links.txt = setuptools.command.egg_info:overwrite_arg", ], + + + "console_scripts": [ "easy_install = setuptools.command.easy_install:main", "easy_install-%s = setuptools.command.easy_install:main" % sys.version[:3] ], - + "setuptools.file_finders": ["svn_cvs = setuptools.command.sdist:_default_revctrl"] }, Modified: sandbox/branches/setuptools-0.6/setuptools/command/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/__init__.py Wed Sep 20 22:48:18 2006 @@ -5,6 +5,10 @@ 'register', ] +import sys +if sys.version>='2.5': + # In Python 2.5 and above, distutils includes its own upload command + __all__.remove('upload') from distutils.command.bdist import bdist @@ -12,4 +16,4 @@ bdist.format_command['egg'] = ('bdist_egg', "Python .egg file") bdist.format_commands.append('egg') -del bdist +del bdist, sys 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 20 22:48:18 2006 @@ -1588,6 +1588,7 @@ with_ei_usage(lambda: setup( script_args = ['-q','easy_install', '-v']+argv, + script_name = sys.argv[0] or 'easy_install', distclass=DistributionWithoutHelpCommands, **kw ) ) @@ -1596,4 +1597,3 @@ - Modified: sandbox/branches/setuptools-0.6/setuptools/dist.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/dist.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/dist.py Wed Sep 20 22:48:18 2006 @@ -1,4 +1,4 @@ -__all__ = ['Distribution', 'Feature'] +__all__ = ['Distribution'] from distutils.core import Distribution as _Distribution from setuptools.depends import Require @@ -207,7 +207,7 @@ have_package_data = hasattr(self, "package_data") if not have_package_data: self.package_data = {} - self.requires = [] # XXX + self.require_features = [] self.features = {} self.dist_files = [] self.patch_missing_pkg_info(attrs) @@ -676,10 +676,10 @@ based on 'availabile', 'standard', and whether any other feature requires it. The default setting is 'True'. - 'requires' -- a string or sequence of strings naming features that should - also be included if this feature is included. Defaults to empty list. - May also contain 'Require' objects that should be added/removed from - the distribution. + 'require_features' -- a string or sequence of strings naming features + that should also be included if this feature is included. Defaults to + empty list. May also contain 'Require' objects that should be + added/removed from the distribution. 'remove' -- a string or list of strings naming packages to be removed from the distribution if this feature is *not* included. If the @@ -704,34 +704,34 @@ Aside from the methods, the only feature attributes that distributions look at are 'description' and 'optional'. """ - def __init__(self, description, standard=False, available=True, - optional=True, requires=(), remove=(), **extras + optional=True, require_features=(), remove=(), **extras ): self.description = description self.standard = standard self.available = available self.optional = optional - if isinstance(requires,(str,Require)): - requires = requires, + if isinstance(require_features,(str,Require)): + require_features = require_features, - self.requires = [r for r in requires if isinstance(r,str)] - er = [r for r in requires if not isinstance(r,str)] - if er: extras['requires'] = er + self.require_features = [ + r for r in require_features if isinstance(r,str) + ] + er = [r for r in require_features if not isinstance(r,str)] + if er: extras['require_features'] = er if isinstance(remove,str): remove = remove, self.remove = remove self.extras = extras - if not remove and not requires and not extras: + if not remove and not require_features and not extras: raise DistutilsSetupError( - "Feature %s: must define 'requires', 'remove', or at least one" + "Feature %s: must define 'require_features', 'remove', or at least one" " of 'packages', 'py_modules', etc." ) - def include_by_default(self): """Should this feature be included by default?""" return self.available and self.standard @@ -754,7 +754,7 @@ dist.include(**self.extras) - for f in self.requires: + for f in self.require_features: dist.include_feature(f) Modified: sandbox/branches/setuptools-0.6/setuptools/tests/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/tests/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/tests/__init__.py Wed Sep 20 22:48:18 2006 @@ -255,7 +255,7 @@ self.req = Require('Distutils','1.0.3','distutils') self.dist = makeSetup( features={ - 'foo': Feature("foo",standard=True,requires=['baz',self.req]), + 'foo': Feature("foo",standard=True,require_features=['baz',self.req]), 'bar': Feature("bar", standard=True, packages=['pkg.bar'], py_modules=['bar_et'], remove=['bar.ext'], ), @@ -281,7 +281,7 @@ self.failUnless( Feature("test",standard=True,remove='x').include_by_default() ) - # Feature must have either kwargs, removes, or requires + # Feature must have either kwargs, removes, or require_features self.assertRaises(DistutilsSetupError, Feature, "test") def testAvailability(self): @@ -320,7 +320,7 @@ self.failUnless('scripts/baz_it' in dist.scripts) self.failUnless(('libfoo','foo/foofoo.c') in dist.libraries) self.assertEqual(dist.ext_modules,[]) - self.assertEqual(dist.requires, [self.req]) + self.assertEqual(dist.require_features, [self.req]) # If we ask for bar, it should fail because we explicitly disabled # it on the command line From python-checkins at python.org Wed Sep 20 22:57:09 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 20 Sep 2006 22:57:09 +0200 (CEST) Subject: [Python-checkins] r51937 - in sandbox/branches/setuptools-0.6: pkg_resources.py pkg_resources.txt setuptools.egg-info/entry_points.txt Message-ID: <20060920205709.B6C421E4009@bag.python.org> Author: phillip.eby Date: Wed Sep 20 22:57:09 2006 New Revision: 51937 Modified: sandbox/branches/setuptools-0.6/pkg_resources.py sandbox/branches/setuptools-0.6/pkg_resources.txt sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt Log: More Python 2.5 compatibility fixes. Modified: sandbox/branches/setuptools-0.6/pkg_resources.py ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.py (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.py Wed Sep 20 22:57:09 2006 @@ -1502,13 +1502,13 @@ pass return importer - - - - - - - +try: + from pkgutil import get_importer, ImpImporter +except ImportError: + pass # Python 2.3 or 2.4, use our own implementation +else: + ImpWrapper = ImpImporter # Python 2.5, use pkgutil's implementation + del ImpLoader, ImpImporter Modified: sandbox/branches/setuptools-0.6/pkg_resources.txt ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.txt (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.txt Wed Sep 20 22:57:09 2006 @@ -1665,6 +1665,10 @@ "importer" object. This ``ImpWrapper`` is *not* cached; instead a new instance is returned each time. + (Note: When run under Python 2.5, this function is simply an alias for + ``pkgutil.get_importer()``, and instead of ``pkg_resources.ImpWrapper`` + instances, it may return ``pkgutil.ImpImporter`` instances.) + File/Path Utilities ------------------- @@ -1687,6 +1691,9 @@ Release Notes/Change History ---------------------------- +0.6c3 + * Python 2.5 compatibility fixes. + 0.6c2 * Fix a problem with eggs specified directly on ``PYTHONPATH`` on case-insensitive filesystems possibly not showing up in the default Modified: sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt Wed Sep 20 22:57:09 2006 @@ -28,7 +28,7 @@ [console_scripts] easy_install = setuptools.command.easy_install:main -easy_install-2.3 = setuptools.command.easy_install:main +easy_install-2.4 = setuptools.command.easy_install:main [distutils.commands] bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm From jimjjewett at gmail.com Wed Sep 20 23:05:21 2006 From: jimjjewett at gmail.com (Jim Jewett) Date: Wed, 20 Sep 2006 17:05:21 -0400 Subject: [Python-checkins] r51931 - sandbox/trunk/setuptools/doctest.py In-Reply-To: <20060920202057.BDD741E4006@bag.python.org> References: <20060920202057.BDD741E4006@bag.python.org> Message-ID: On 9/20/06, phillip.eby wrote: > Author: phillip.eby > Date: Wed Sep 20 22:20:57 2006 > New Revision: 51931 > > Modified: > sandbox/trunk/setuptools/doctest.py > Log: > Retain 2.3/2.4 compatibility as well... Please add that explanation to the code itself. > Modified: sandbox/trunk/setuptools/doctest.py > ============================================================================== > --- sandbox/trunk/setuptools/doctest.py (original) > +++ sandbox/trunk/setuptools/doctest.py Wed Sep 20 22:20:57 2006 > @@ -1333,8 +1333,10 @@ > if m and m.group('name') == self.test.name: > example = self.test.examples[int(m.group('examplenum'))] > return example.source.splitlines(True) > - else: # if the linecache is new enough > + elif self.save_linecache_getlines.func_code.co_argcount>1: > return self.save_linecache_getlines(filename, module_globals) # 2.3, 2.4 compatibility > + else: > + return self.save_linecache_getlines(filename) > > def run(self, test, compileflags=None, out=None, clear_globs=True): > """ > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From python-checkins at python.org Wed Sep 20 23:15:21 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 20 Sep 2006 23:15:21 +0200 (CEST) Subject: [Python-checkins] r51938 - sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh Message-ID: <20060920211521.3EFA01E4006@bag.python.org> Author: phillip.eby Date: Wed Sep 20 23:15:20 2006 New Revision: 51938 Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh Log: 0.6c3 release 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 20 23:15:20 2006 @@ -30,6 +30,9 @@ 'setuptools-0.6c1-py2.4.egg': 'b45adeda0667d2d2ffe14009364f2a4b', 'setuptools-0.6c2-py2.3.egg': 'f0064bf6aa2b7d0f3ba0b43f20817c27', 'setuptools-0.6c2-py2.4.egg': '616192eec35f47e8ea16cd6a122b7277', + 'setuptools-0.6c3-py2.3.egg': 'f181fa125dfe85a259c9cd6f1d7b78fa', + 'setuptools-0.6c3-py2.4.egg': 'e0ed74682c998bfb73bf803a50e7b71e', + 'setuptools-0.6c3-py2.5.egg': 'abef16fdd61955514841c7c6bd98965e', } import sys, os Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Wed Sep 20 23:15:20 2006 @@ -9,14 +9,15 @@ export VERSION="0.6c3" -wpython setup.py -q release source && \ -cpython setup.py -q release binary && \ -python ez_setup.py --md5update dist/setuptools-$VERSION*-py2.?.egg && \ - scp ez_setup.py virtual-python.py t3:web/PEAK/dist/ && \ +python2.3 setup.py -q release source && \ +python2.4 setup.py -q release binary && \ +python2.5 setup.py -q release binary && \ +python2.3 ez_setup.py --md5update dist/setuptools-$VERSION*-py2.?.egg && \ + cp ez_setup.py virtual-python.py ~/distrib/ && \ cp ez_setup.py ~/projects/ez_setup/__init__.py && \ svn ci -m "Update ez_setup for setuptools $VERSION" \ - ~/projects/ez_setup/__init__.py && \ - svn up ~/projects/*/ez_setup + ~/projects/ez_setup/__init__.py #&& \ + #svn up ~/projects/*/ez_setup # XXX update wiki pages from EasyInstall.txt, setuptools.txt, & # pkg_resources.txt From pje at telecommunity.com Wed Sep 20 23:21:17 2006 From: pje at telecommunity.com (Phillip J. Eby) Date: Wed, 20 Sep 2006 17:21:17 -0400 Subject: [Python-checkins] r51931 - sandbox/trunk/setuptools/doctest.py In-Reply-To: References: <20060920202057.BDD741E4006@bag.python.org> <20060920202057.BDD741E4006@bag.python.org> Message-ID: <5.1.1.6.0.20060920171807.02d42100@sparrow.telecommunity.com> At 05:05 PM 9/20/2006 -0400, Jim Jewett wrote: >On 9/20/06, phillip.eby wrote: >>Author: phillip.eby >>Date: Wed Sep 20 22:20:57 2006 >>New Revision: 51931 >> >>Modified: >> sandbox/trunk/setuptools/doctest.py >>Log: >>Retain 2.3/2.4 compatibility as well... > >Please add that explanation to the code itself. You're looking at the setuptools trunk's private copy of doctest, which will soon be moved to a ZipfileHotfixes project for backported versions of doctest and pydoc. That is, it's a copy whose sole reason for existence is to be a 2.3/2.4 backport. See the file path. :) From python-checkins at python.org Thu Sep 21 01:13:06 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 01:13:06 +0200 (CEST) Subject: [Python-checkins] r51939 - python/branches/bcannon-objcap/Lib/test/security/evil__del__.py python/branches/bcannon-objcap/Lib/test/security/evil__str__.py Message-ID: <20060920231306.DCB791E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 01:13:05 2006 New Revision: 51939 Added: python/branches/bcannon-objcap/Lib/test/security/evil__str__.py (contents, props changed) Modified: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Log: Add another security test where an exception is defined with a malicious __str__() method. Turns out to be a bad thing. Also update __del__() test to have nicer output. Modified: python/branches/bcannon-objcap/Lib/test/security/evil__del__.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/security/evil__del__.py (original) +++ python/branches/bcannon-objcap/Lib/test/security/evil__del__.py Thu Sep 21 01:13:05 2006 @@ -4,7 +4,6 @@ class Evil(object): - builtin = __builtin__.__dict__ stdout = sys.stdout NameError = NameError BaseException = BaseException @@ -16,40 +15,28 @@ self.num = num def __del__(self): - if 'open' in self.builtin: - self.stdout.write('(%s) First Evil!\n' % self.num) - else: - self.stdout.write("(%s) First Good!\n" % self.num) - self.stdout.flush() - + # Uses context of where deletion occurs, or where object defined? + # __import__() might be gone and thus raise a + # TypeError when trying to call it when it has been set to None. + try: + import __builtin__ + if 'open' in __builtin__.__dict__: + self.stdout.write("Evil 2!\n") + self.stdout.flush() + except self.TypeError: + pass try: temp = open except self.NameError: - self.stdout.write("(%s) Second Good!\n" % self.num) - except self.BaseException, exc: - self.stdout.write("Unexpected exception: %r\n" % exc) + pass else: - self.stdout.write("(%s) Second Evil!\n" % self.num) - finally: + self.stdout.write("Evil 3!\n") self.stdout.flush() - try: - import __builtin__ - temp = __builtin__.__dict__['open'] - self.stdout.write("(%s) Third Evil!\n" % self.num) - except self.ImportError: - self.stdout.write("(%s) Third Good!\n" % self.num) - except self.KeyError: - self.stdout.write("(%s) Third Good!\n" % self.num) - except self.TypeError: - self.stdout.write("(%s) Third Good!\n" % self.num) - except self.BaseException, exc: - self.stdout.write("Unexpected exception (2): %r\n" % exc) - finally: - self.stdout.flush() - + # Deletion in own scope. -Evil(0) +print "Creation in sub-interpreter's global scope, deletion from interpreter cleanup ..." +temp = Evil(0) # Cleanup of interpreter. __builtin__.__dict__['evil1'] = Evil(1) @@ -64,19 +51,15 @@ import gc interp = interpreter.Interpreter() -print 'Same builtins?:', ('no' if id(__builtin__.__dict__) != - id(interp.builtins) else 'yes') -del interp.builtins['open'] +del interp.builtins()['open'] gc.collect() if 'open' not in __builtin__.__dict__: print "'open()' missing!" -print 'Running interpreter ...' interp.execute(evil_str) -evil2 = interp.builtins['evil2'] -evil3 = interp.builtins['evil3'] +evil2 = interp.builtins()['evil2'] +evil3 = interp.builtins()['evil3'] -print 'Deleting interpreter ...' del interp gc.collect() Added: python/branches/bcannon-objcap/Lib/test/security/evil__str__.py ============================================================================== --- (empty file) +++ python/branches/bcannon-objcap/Lib/test/security/evil__str__.py Thu Sep 21 01:13:05 2006 @@ -0,0 +1,65 @@ +"""How evil can we be with an exception that defines a __str__() method?""" + +evil_source = ''' +import __builtin__ + +class EvilException(Exception): + + """Try to be evil!""" + + def __str__(self): + # Does this get it where the exception is used, or where the class was + #defined? + import __builtin__ + if 'open' in __builtin__.__dict__: + print "Evil 2!" + # Just try to get it directly from the built-in namespace. + try: + temp = open + except NameError: + pass + else: + print "Evil 3!" + + return "Evil exception!!!" + +__builtins__.__dict__['evil_cls'] = EvilException +__builtins__.__dict__['evil_inst'] = EvilException() +''' + +import interpreter + +interp = interpreter.Interpreter() +del interp.builtins()['open'] +interp.execute(evil_source) + +slave_cls = interp.builtins()['evil_cls'] +slave_inst = interp.builtins()['evil_inst'] +master_inst = slave_cls() + +print "Raising slave class ..." +try: + raise slave_cls +except Exception, exc: + print exc + +print "Raising slave instance ..." +try: + raise slave_inst +except Exception, exc: + print exc + +print "Raising master instance ..." +try: + raise master_inst +except Exception, exc: + print exc + +print "Just printing from the class ..." +print slave_cls + +print "Just printing from the slave instance ..." +print slave_inst + +print "Just printing from the master instance ..." +print master_inst \ No newline at end of file From python-checkins at python.org Thu Sep 21 01:14:15 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 01:14:15 +0200 (CEST) Subject: [Python-checkins] r51940 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060920231415.252B51E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 01:14:14 2006 New Revision: 51940 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Update Status with some notes. 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 21 01:14:14 2006 @@ -31,6 +31,7 @@ * Force to go through open() + Prevents opening unauthorized files. + Prevents using as a way to probe filesystem. + * Just promote removal - exit() * Have SystemExit exit the process only if no other interpreters are running. @@ -52,14 +53,10 @@ - Securely handle exceptions being raised in sub-interpreter * Raise InterpreterException w/ string for the exception type and a sanitized string for message? - * If type is exact of an exception in namespace, recreate, - otherwise make an instance of InterpreterException? - * Need to watch out for malicious __str__() instances that - could do something nasty. - - Be able to clear exceptions in the interpreter to allow reuse - * Raise an exception if the interpreter is used while an - exception is still set. - * Provide a function to clear any set exeception. + * Provide way to compare the raised exception in a safe manner + (i.e., expose PyErr_ExceptionMatches())? + * Provide exc_info() for those who know what they are doing? + + Raise a SecurityWarning when used? + Tear out old restricted mode code. From python-checkins at python.org Thu Sep 21 01:21:17 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 01:21:17 +0200 (CEST) Subject: [Python-checkins] r51941 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py Modules/interpretermodule.c securing_python.txt Message-ID: <20060920232117.44E2C1E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 01:21:16 2006 New Revision: 51941 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/Modules/interpretermodule.c python/branches/bcannon-objcap/securing_python.txt Log: Change exception raised by execute() to be RuntimeError instead of Exception. In doing so added the redirect_output() helper method that sets sys.stdout and sys.stderr so that you can redirect to a StringIO or other file-like object to block out writing to the screen. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Thu Sep 21 01:21:16 2006 @@ -9,6 +9,7 @@ + __del__ + __str__ (for exceptions) + properties + + something that raises SystemExit """ import interpreter @@ -17,6 +18,7 @@ from test import test_support import sys import __builtin__ +import StringIO simple_stmt = """ while True: @@ -168,9 +170,9 @@ def test_set(self): # Make sure sys_dict can be set to a new dict and that it has desired # effect. - sys_dict_copy = self.interp.sys_dict.copy() - self.interp.sys_dict = sys_dict_copy self.failUnlessRaises(TypeError, setattr, self.interp, 'sys_dict', []) + # XXX requires exceptions + # set to new dict, make sure exceptions raised when trying to get attribute from sys def test_mutating(self): # Changes to the dict should be reflected in the interpreter. @@ -200,6 +202,49 @@ self.failUnless(sys.argv[-1] != 'test') sys_dict['path'].append('test') self.failUnless(sys.path[-1] != 'test') + + +class InputOutputTests(BaseInterpTests): + + """Test stdin/stdout/stderr fiddling.""" + + def test_redirect_output_defaults(self): + # Make sure it sets stdout and stderr. + stdout, stderr = self.interp.redirect_output() + self.interp.execute("print 'test'") + self.failUnlessEqual("test\n", stdout.getvalue()) + self.failUnless(not stderr.getvalue()) + self.failUnlessRaises(RuntimeError, self.interp.execute, "+") + self.failUnless(stderr.getvalue()) + + def test_redirect_output_arguments(self): + # Test passing in arguments to redirect_output(). + new_stdout = StringIO.StringIO() + new_stderr = StringIO.StringIO() + used_stdout, used_stderr = self.interp.redirect_output(new_stdout, + new_stderr) + self.failUnless(used_stdout is new_stdout) + self.failUnless(used_stderr is new_stderr) + self.failUnlessRaises(RuntimeError, self.interp.execute, '=') + self.failUnlessEqual(new_stderr.getvalue(), used_stderr.getvalue()) + self.interp.execute("print 'test'") + self.failUnlessEqual(new_stdout.getvalue(), used_stdout.getvalue()) + + +class ExceptionsTests(BaseInterpTests): + + """Test exception usage.""" + + def test_execute_failure(self): + # RuntimeError should be raised when something goes bad in execute(). + stdout, stderr = self.interp.redirect_output() + self.failUnlessRaises(RuntimeError, self.interp.execute, "=") + + def test_exc_matches(self): + # Test exc_matches(). + stdout, stderr = self.interp.redirect_output() + self.failUnlessRaises(RuntimeError, self.interp.execute, '=') + #self.failUnless(self.interp.exc_matches(SyntaxError)) def test_main(): @@ -208,6 +253,8 @@ BuiltinsTests, ModulesTests, SysDictTests, + InputOutputTests, + ExceptionsTests, ) Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Thu Sep 21 01:21:16 2006 @@ -1,5 +1,8 @@ #include "Python.h" #include "interpreter.h" +#include "cStringIO.h" + +static struct PycStringIO_CAPI* PycStringIO = NULL; #define PyInterpreter_GET_INTERP(interp) \ (((PyInterpreterObject *)interp)->istate) @@ -61,6 +64,7 @@ return (PyObject *)self; } + /* Execute Python source code in the interpreter. */ @@ -91,8 +95,8 @@ PyThreadState_Swap(cur_tstate); if (result < 0) { - PyErr_SetString(PyExc_Exception, - "exception during execution in interpreter."); + PyErr_SetString(PyExc_RuntimeError, + "exception during execution"); return NULL; } @@ -114,11 +118,56 @@ return builtins; } +static PyObject * +redirect_output(PyObject *self, PyObject *args) +{ + PyObject *py_stdout = NULL; + PyObject *py_stderr = NULL; + PyObject *used_stdout_stderr = NULL; + + if (!PyArg_ParseTuple(args, "|OO", &py_stdout, &py_stderr)) + return NULL; + + if (!py_stdout) { + /* Argument for NewOutput() copied from PycStringIO->NewInput(). */ + py_stdout = (PycStringIO->NewOutput)(128); + if (!py_stdout) + return NULL; + } + + if (!py_stderr) { + /* Argument for NewOutput() copied from PycStringIO->NewInput(). */ + py_stderr = (PycStringIO->NewOutput)(128); + if (!py_stderr) + return NULL; + } + + used_stdout_stderr = PyTuple_New(2); + if (!used_stdout_stderr) + return NULL; + + if (PyDict_SetItemString(PyInterpreter_GET_INTERP(self)->sysdict, "stdout", + py_stdout) < 0) + return NULL; + if (PyDict_SetItemString(PyInterpreter_GET_INTERP(self)->sysdict, "stderr", + py_stderr) < 0) + return NULL; + + Py_INCREF(py_stdout); + Py_INCREF(py_stderr); + PyTuple_SET_ITEM(used_stdout_stderr, 0, py_stdout); + PyTuple_SET_ITEM(used_stdout_stderr, 1, py_stderr); + + return used_stdout_stderr; +} + static PyMethodDef interpreter_methods[] = { {"builtins", (PyCFunction)interpreter_builtins, METH_NOARGS, "Return the built-in namespace dict"}, {"execute", interpreter_exec, METH_O, "Execute the passed-in string in the interpreter"}, + {"redirect_output", (PyCFunction)redirect_output, METH_VARARGS, + "Redirect stdout to stderr"}, {NULL} }; @@ -279,4 +328,8 @@ if (PyModule_AddObject(module, "Interpreter", (PyObject *)&PyInterpreter_Type) < 0) return; + + PycString_IMPORT; + if (!PycStringIO) + return; } 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 21 01:21:16 2006 @@ -57,6 +57,7 @@ (i.e., expose PyErr_ExceptionMatches())? * Provide exc_info() for those who know what they are doing? + Raise a SecurityWarning when used? + - Redirect output [done] + Tear out old restricted mode code. From python-checkins at python.org Thu Sep 21 01:23:42 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 01:23:42 +0200 (CEST) Subject: [Python-checkins] r51942 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060920232342.AE6DA1E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 01:23:42 2006 New Revision: 51942 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Add mention of change to RuntimeError for execute() and addition of redirect_output(). Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Thu Sep 21 01:23:42 2006 @@ -25,6 +25,10 @@ Extension Modules ----------------- +* rev. 51941: Changed exception raised by interpreter.Interpreter().execute() + to RuntimError when something goes bad. Also added the redirect_output() + method. + * rev. 51914: Changed accessing the built-in namespace dict from an attribute to a function call. This is because the dict is cached in the execution frame created when the interpreter is first created and thus setting the dict From python-checkins at python.org Thu Sep 21 01:24:21 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 01:24:21 +0200 (CEST) Subject: [Python-checkins] r51943 - python/branches/bcannon-objcap/Modules/interpretermodule.c Message-ID: <20060920232421.8FDC71E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 01:24:21 2006 New Revision: 51943 Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c Log: Clarify doc for redirect_output(). Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Thu Sep 21 01:24:21 2006 @@ -163,11 +163,11 @@ static PyMethodDef interpreter_methods[] = { {"builtins", (PyCFunction)interpreter_builtins, METH_NOARGS, - "Return the built-in namespace dict"}, + "Return the built-in namespace dict."}, {"execute", interpreter_exec, METH_O, - "Execute the passed-in string in the interpreter"}, + "Execute the passed-in string in the interpreter."}, {"redirect_output", (PyCFunction)redirect_output, METH_VARARGS, - "Redirect stdout to stderr"}, + "Redirect stdout to stderr. Returns tuple of objects used."}, {NULL} }; From python-checkins at python.org Thu Sep 21 01:56:57 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 01:56:57 +0200 (CEST) Subject: [Python-checkins] r51944 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py Modules/interpretermodule.c Message-ID: <20060920235657.B81EF1E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 01:56:57 2006 New Revision: 51944 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/Modules/interpretermodule.c Log: Make sys_dict a function since the data dict seems to get cached somewhere. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Thu Sep 21 01:56:57 2006 @@ -134,7 +134,6 @@ self.failUnless('token' not in self.interp.modules) self.interp.execute('import token') del self.interp.modules['token'] - # XXX should really check that ImportError not raised. self.interp.execute('import token') def test_replacing(self): @@ -155,7 +154,18 @@ self.interp.execute("import token;" "_return.append(hasattr(token, 'test'))") self.failUnless(not _return[-1]) - + + def test_not_cached(self): + # Make sure that 'modules' dict is not cached. + builtin = self.interp.modules['__builtin__'] + main = self.interp.modules['__main__'] + self.interp.execute("import token") + self.interp.modules = {} + self.interp.modules['__builtin__'] = builtin + self.interp.modules['__main__'] = main + self.interp.execute("import token") + self.failUnless('token' in self.interp.modules) + class SysDictTests(BaseInterpTests): @@ -163,20 +173,13 @@ def test_get(self): # Make sure a dict is returned. - sys_dict = self.interp.sys_dict + sys_dict = self.interp.sys_dict() self.failUnless(isinstance(sys_dict, dict)) self.failUnless('version' in sys_dict) - def test_set(self): - # Make sure sys_dict can be set to a new dict and that it has desired - # effect. - self.failUnlessRaises(TypeError, setattr, self.interp, 'sys_dict', []) - # XXX requires exceptions - # set to new dict, make sure exceptions raised when trying to get attribute from sys - def test_mutating(self): # Changes to the dict should be reflected in the interpreter. - sys_dict = self.interp.sys_dict + sys_dict = self.interp.sys_dict() sys_dict['version'] = 'test' interp_return = [] self.interp.builtins()['to_return'] = interp_return @@ -186,7 +189,7 @@ def test_deletion(self): # Make sure removing a value raises the proper exception when accessing # through the 'sys' module. - del self.interp.sys_dict['version'] + del self.interp.sys_dict()['version'] # XXX requires exceptions # XXX self.failUnlessRaises(XXX, self.interp.execute, # 'import sys; sys.version') @@ -194,14 +197,14 @@ def test_copied(self): # sys_dict should be unique per interpreter (including mutable data # structures). - sys_dict = self.interp.sys_dict - sys_dict['version'] = 'test' - self.failUnless(sys.version != 'test') - # XXX check mutable data structures - sys_dict.setdefault('argv', []).append('test') - self.failUnless(sys.argv[-1] != 'test') - sys_dict['path'].append('test') - self.failUnless(sys.path[-1] != 'test') + sys_version = sys.version + self.interp.sys_dict()['version'] = 'test' + reload(sys) + self.failUnlessEqual(sys.version, sys_version) + _return = [] + self.interp.builtins()['_return'] = _return + self.interp.execute("import sys; _return.append(sys.version)") + self.failUnlessEqual(_return[-1], 'test') class InputOutputTests(BaseInterpTests): Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Thu Sep 21 01:56:57 2006 @@ -64,6 +64,34 @@ return (PyObject *)self; } +/* + Getter for 'builtins'. + + There is not setter because the creation of a new interpreter automatically + creates the initial execution frame which caches the built-in namespace. + */ +static PyObject * +interpreter_builtins(PyObject *self) +{ + PyObject *builtins = PyInterpreter_GET_INTERP(self)->builtins; + + Py_INCREF(builtins); + return builtins; +} + +/* + Getter for 'sys_dict'. + + There is no setter because the dict gets cached somewhere. + */ +static PyObject * +interpreter_sys_dict(PyObject *self) +{ + PyObject *sys_dict = PyInterpreter_GET_INTERP(self)->sysdict; + + Py_INCREF(sys_dict); + return sys_dict; +} /* Execute Python source code in the interpreter. @@ -103,21 +131,6 @@ Py_RETURN_NONE; } -/* - Getter for 'builtins'. - - There is not setter because the creation of a new interpreter automatically - creates the initial execution frame which caches the built-in namespace. - */ -static PyObject * -interpreter_builtins(PyObject *self) -{ - PyObject *builtins = PyInterpreter_GET_INTERP(self)->builtins; - - Py_INCREF(builtins); - return builtins; -} - static PyObject * redirect_output(PyObject *self, PyObject *args) { @@ -164,6 +177,8 @@ static PyMethodDef interpreter_methods[] = { {"builtins", (PyCFunction)interpreter_builtins, METH_NOARGS, "Return the built-in namespace dict."}, + {"sys_dict", (PyCFunction)interpreter_sys_dict, METH_NOARGS, + "Return the 'sys' module's data dictionary."}, {"execute", interpreter_exec, METH_O, "Execute the passed-in string in the interpreter."}, {"redirect_output", (PyCFunction)redirect_output, METH_VARARGS, @@ -217,43 +232,8 @@ return 0; } -/* - Getter for 'sys_dict'. -*/ -static PyObject * -interpreter_get_sys_dict(PyObject *self, void *optional) -{ - PyObject *sys_dict = PyInterpreter_GET_INTERP(self)->sysdict; - - Py_INCREF(sys_dict); - return sys_dict; -} - -/* - Setter for 'sys_dict'. -*/ -static int -interpreter_set_sys_dict(PyObject *self, PyObject *arg, void *optional) -{ - PyObject *old_sys_dict = PyInterpreter_GET_INTERP(self)->sysdict; - - if (!PyDict_Check(arg)) { - PyErr_SetString(PyExc_TypeError, - "'sys_dict' must be set to a dict"); - return -1; - } - - Py_INCREF(arg); - Py_DECREF(old_sys_dict); - PyInterpreter_GET_INTERP(self)->sysdict = arg; - - return 0; -} - static PyGetSetDef interpreter_getset[] = { - {"sys_dict", interpreter_get_sys_dict, interpreter_set_sys_dict, - "The modules dict for 'sys'.", NULL}, {"modules", interpreter_get_modules, interpreter_set_modules, "The dict used for sys.modules.", NULL}, {NULL} From python-checkins at python.org Thu Sep 21 02:03:00 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 02:03:00 +0200 (CEST) Subject: [Python-checkins] r51945 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060921000300.546EE1E401C@bag.python.org> Author: brett.cannon Date: Thu Sep 21 02:02:58 2006 New Revision: 51945 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Mention change of sys_dict to a function. Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Thu Sep 21 02:02:58 2006 @@ -25,6 +25,8 @@ Extension Modules ----------------- +* rev. 51944: Change sys_dict to a module since that dict is cached somewhere. + * rev. 51941: Changed exception raised by interpreter.Interpreter().execute() to RuntimError when something goes bad. Also added the redirect_output() method. From python-checkins at python.org Thu Sep 21 04:01:31 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 21 Sep 2006 04:01:31 +0200 (CEST) Subject: [Python-checkins] r51946 - sandbox/branches/setuptools-0.6/setup.cfg Message-ID: <20060921020131.A02F71E4006@bag.python.org> Author: phillip.eby Date: Thu Sep 21 04:01:31 2006 New Revision: 51946 Modified: sandbox/branches/setuptools-0.6/setup.cfg Log: Build .exe and .src.rpm files for releases as well as .egg and .tgz Modified: sandbox/branches/setuptools-0.6/setup.cfg ============================================================================== --- sandbox/branches/setuptools-0.6/setup.cfg (original) +++ sandbox/branches/setuptools-0.6/setup.cfg Thu Sep 21 04:01:31 2006 @@ -4,6 +4,10 @@ [aliases] release = egg_info -RDb '' -source = sdist register binary -binary = bdist_egg upload --show-response +source = sdist bdist_rpm register binary +binary = bdist_egg bdist_wininst upload --show-response +[bdist_rpm] +source_only = 1 +doc_files = setuptools.txt EasyInstall.txt pkg_resources.txt +requires = python-devel From python-checkins at python.org Thu Sep 21 07:13:23 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 21 Sep 2006 07:13:23 +0200 (CEST) Subject: [Python-checkins] r51947 - peps/trunk/pep-0356.txt Message-ID: <20060921051323.6EC1E1E4006@bag.python.org> Author: neal.norwitz Date: Thu Sep 21 07:13:21 2006 New Revision: 51947 Modified: peps/trunk/pep-0356.txt Log: 2.5 was released, yay Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Thu Sep 21 07:13:21 2006 @@ -40,7 +40,7 @@ beta 3: August 3, 2006 [completed] rc 1: August 17, 2006 [completed] rc 2: September 12, 2006 [completed] - final: September 19, 2006 [planned] + final: September 19, 2006 [completed] Completed features for 2.5 From python-checkins at python.org Thu Sep 21 07:15:30 2006 From: python-checkins at python.org (neal.norwitz) Date: Thu, 21 Sep 2006 07:15:30 +0200 (CEST) Subject: [Python-checkins] r51948 - peps/trunk/pep-0000.txt peps/trunk/pep-0356.txt Message-ID: <20060921051530.78A501E4015@bag.python.org> Author: neal.norwitz Date: Thu Sep 21 07:15:29 2006 New Revision: 51948 Modified: peps/trunk/pep-0000.txt peps/trunk/pep-0356.txt Log: Marking 2.5 PEP as final Modified: peps/trunk/pep-0000.txt ============================================================================== --- peps/trunk/pep-0000.txt (original) +++ peps/trunk/pep-0000.txt Thu Sep 21 07:15:29 2006 @@ -64,7 +64,7 @@ I 306 How to Change Python's Grammar Hudson I 333 Python Web Server Gateway Interface v1.0 Eby I 339 Design of the CPython Compiler Cannon - I 356 Python 2.5 Release Schedule Norwitz, et al + IF 356 Python 2.5 Release Schedule Norwitz, et al I 360 Externally Maintained Packages Cannon I 361 Python 2.6 Release Schedule Norwitz, et al I 3100 Python 3.0 Plans Kuchling, Cannon @@ -420,7 +420,7 @@ SA 353 Using ssize_t as the index type von Loewis S 354 Enumerations in Python Finney S 355 Path - Object oriented filesystem paths Lindqvist - I 356 Python 2.5 Release Schedule Norwitz, et al + IF 356 Python 2.5 Release Schedule Norwitz, et al SF 357 Allowing Any Object to be Used for Slicing Oliphant S 358 The "bytes" Object Schemenauer SW 359 The "make" Statement Bethard Modified: peps/trunk/pep-0356.txt ============================================================================== --- peps/trunk/pep-0356.txt (original) +++ peps/trunk/pep-0356.txt Thu Sep 21 07:15:29 2006 @@ -3,7 +3,7 @@ Version: $Revision$ Last-Modified: $Date$ Author: Neal Norwitz, GvR, Anthony Baxter -Status: Draft +Status: Final Type: Informational Created: 07-Feb-2006 Python-Version: 2.5 From anthony at interlink.com.au Thu Sep 21 13:12:03 2006 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 21 Sep 2006 21:12:03 +1000 Subject: [Python-checkins] release25-maint is UNFROZEN Message-ID: <200609212112.04923.anthony@interlink.com.au> Ok - it's been 48 hours, and I've not seen any brown-paper-bag bugs, so I'm declaring the 2.5 maintenance branch open for business. As specified in PEP-006, this is a maintenance branch only suitable for bug fixes. No functionality changes should be checked in without discussion and agreement on python-dev first. Thanks to everyone for helping make 2.5 happen. It's been a long slog there, but I think we can all be proud of the result. Anthony -- Anthony Baxter It's never too late to have a happy childhood. From arigo at tunes.org Thu Sep 21 14:35:11 2006 From: arigo at tunes.org (Armin Rigo) Date: Thu, 21 Sep 2006 14:35:11 +0200 Subject: [Python-checkins] [Python-Dev] release25-maint is UNFROZEN In-Reply-To: <200609212112.04923.anthony@interlink.com.au> References: <200609212112.04923.anthony@interlink.com.au> Message-ID: <20060921123510.GA22457@code0.codespeak.net> Hi Anthony, On Thu, Sep 21, 2006 at 09:12:03PM +1000, Anthony Baxter wrote: > Thanks to everyone for helping make 2.5 happen. It's been a long slog there, > but I think we can all be proud of the result. Thanks for the hassle! I've got another bit of it for you, though. The freezed 2.5 documentation doesn't seem to be available on-line. At least, the doc links from the release page point to the 'dev' 2.6a0 version, and the URL following the common scheme - http://www.python.org/doc/2.5/ - doesn't work. A bientot, Armin From python-checkins at python.org Thu Sep 21 17:09:57 2006 From: python-checkins at python.org (walter.doerwald) Date: Thu, 21 Sep 2006 17:09:57 +0200 (CEST) Subject: [Python-checkins] r51949 - python/trunk/Python/getargs.c Message-ID: <20060921150957.B1D071E4006@bag.python.org> Author: walter.doerwald Date: Thu Sep 21 17:09:55 2006 New Revision: 51949 Modified: python/trunk/Python/getargs.c Log: Fix typo. Modified: python/trunk/Python/getargs.c ============================================================================== --- python/trunk/Python/getargs.c (original) +++ python/trunk/Python/getargs.c Thu Sep 21 17:09:55 2006 @@ -1747,7 +1747,7 @@ /* For type constructors that don't take keyword args * * Sets a TypeError and returns 0 if the kwds dict is - * not emtpy, returns 1 otherwise + * not empty, returns 1 otherwise */ int _PyArg_NoKeywords(const char *funcname, PyObject *kw) From python-checkins at python.org Thu Sep 21 19:50:27 2006 From: python-checkins at python.org (jack.diederich) Date: Thu, 21 Sep 2006 19:50:27 +0200 (CEST) Subject: [Python-checkins] r51950 - in python/trunk: Lib/test/test_itertools.py Modules/itertoolsmodule.c Message-ID: <20060921175027.4DB101E4006@bag.python.org> Author: jack.diederich Date: Thu Sep 21 19:50:26 2006 New Revision: 51950 Modified: python/trunk/Lib/test/test_itertools.py python/trunk/Modules/itertoolsmodule.c Log: * regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_t which breaks negative counts * added test for negative numbers will backport to 2.5.1 Modified: python/trunk/Lib/test/test_itertools.py ============================================================================== --- python/trunk/Lib/test/test_itertools.py (original) +++ python/trunk/Lib/test/test_itertools.py Thu Sep 21 19:50:26 2006 @@ -58,6 +58,10 @@ self.assertEqual(repr(c), 'count(3)') c.next() self.assertEqual(repr(c), 'count(4)') + c = count(-9) + self.assertEqual(repr(c), 'count(-9)') + c.next() + self.assertEqual(c.next(), -8) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) Modified: python/trunk/Modules/itertoolsmodule.c ============================================================================== --- python/trunk/Modules/itertoolsmodule.c (original) +++ python/trunk/Modules/itertoolsmodule.c Thu Sep 21 19:50:26 2006 @@ -2072,7 +2072,7 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromSize_t(lz->cnt++); + return PyInt_FromSsize_t(lz->cnt++); } static PyObject * From buildbot at python.org Thu Sep 21 20:07:24 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 21 Sep 2006 18:07:24 +0000 Subject: [Python-checkins] buildbot warnings in sparc Ubuntu dapper trunk Message-ID: <20060921180724.50E9D1E4007@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/706 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,walter.doerwald Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 21 20:12:16 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 20:12:16 +0200 (CEST) Subject: [Python-checkins] r51951 - in python/branches/release25-maint: Lib/test/test_exceptions.py Misc/NEWS Objects/exceptions.c Message-ID: <20060921181216.3AB821E4006@bag.python.org> Author: brett.cannon Date: Thu Sep 21 20:12:15 2006 New Revision: 51951 Modified: python/branches/release25-maint/Lib/test/test_exceptions.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/exceptions.c Log: Backport of fix to allow exception instances to be sliced once again. 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 Thu Sep 21 20:12:15 2006 @@ -279,6 +279,13 @@ 'pickled "%r", attribute "%s' % (e, checkArgName)) + def testSlicing(self): + # Test that you can slice an exception directly instead of requiring + # going through the 'args' attribute. + args = (1, 2, 3) + exc = BaseException(*args) + self.failUnlessEqual(exc[:], args) + def testKeywordArgs(self): # test that builtin exception don't take keyword args, # but user-defined subclasses can if they want Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Thu Sep 21 20:12:15 2006 @@ -4,6 +4,17 @@ (editors: check NEWS.help for information about editing NEWS using ReST.) +What's New in Python 2.5.1c1? +============================= + +*Release date: XX-XXX-XXXX* + +Core and builtins +----------------- + +- Allow exception instances to be directly sliced again. + + What's New in Python 2.5 (final) ================================ Modified: python/branches/release25-maint/Objects/exceptions.c ============================================================================== --- python/branches/release25-maint/Objects/exceptions.c (original) +++ python/branches/release25-maint/Objects/exceptions.c Thu Sep 21 20:12:15 2006 @@ -190,12 +190,19 @@ return PySequence_GetItem(self->args, index); } +static PyObject * +BaseException_getslice(PyBaseExceptionObject *self, + Py_ssize_t start, Py_ssize_t stop) +{ + return PySequence_GetSlice(self->args, start, stop); +} + static PySequenceMethods BaseException_as_sequence = { 0, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ (ssizeargfunc)BaseException_getitem, /* sq_item; */ - 0, /* sq_slice; */ + (ssizessizeargfunc)BaseException_getslice, /* sq_slice; */ 0, /* sq_ass_item; */ 0, /* sq_ass_slice; */ 0, /* sq_contains; */ From python-checkins at python.org Thu Sep 21 20:32:12 2006 From: python-checkins at python.org (jack.diederich) Date: Thu, 21 Sep 2006 20:32:12 +0200 (CEST) Subject: [Python-checkins] r51952 - in python/branches/release25-maint: Lib/test/test_itertools.py Modules/itertoolsmodule.c Message-ID: <20060921183212.8BB941E4004@bag.python.org> Author: jack.diederich Date: Thu Sep 21 20:32:11 2006 New Revision: 51952 Modified: python/branches/release25-maint/Lib/test/test_itertools.py python/branches/release25-maint/Modules/itertoolsmodule.c Log: backport of r51950 * regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_t which breaks negative counts * added test for negative numbers 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 Thu Sep 21 20:32:11 2006 @@ -58,6 +58,10 @@ self.assertEqual(repr(c), 'count(3)') c.next() self.assertEqual(repr(c), 'count(4)') + c = count(-9) + self.assertEqual(repr(c), 'count(-9)') + c.next() + self.assertEqual(c.next(), -8) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) Modified: python/branches/release25-maint/Modules/itertoolsmodule.c ============================================================================== --- python/branches/release25-maint/Modules/itertoolsmodule.c (original) +++ python/branches/release25-maint/Modules/itertoolsmodule.c Thu Sep 21 20:32:11 2006 @@ -2072,7 +2072,7 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromSize_t(lz->cnt++); + return PyInt_FromSsize_t(lz->cnt++); } static PyObject * From buildbot at python.org Thu Sep 21 20:32:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 21 Sep 2006 18:32:59 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk Message-ID: <20060921183300.4A7AB1E4004@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/1449 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: jack.diederich Build Had Warnings: warnings test sincerely, -The Buildbot From jackdied at jackdied.com Thu Sep 21 20:53:44 2006 From: jackdied at jackdied.com (Jack Diederich) Date: Thu, 21 Sep 2006 14:53:44 -0400 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk In-Reply-To: <20060921183300.4A7AB1E4004@bag.python.org> References: <20060921183300.4A7AB1E4004@bag.python.org> Message-ID: <20060921185344.GH5928@performancedrivers.com> On Thu, Sep 21, 2006 at 06:32:59PM +0000, buildbot at python.org wrote: > 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/1449 > > Buildbot URL: http://www.python.org/dev/buildbot/all/ > > Build Reason: > Build Source Stamp: [branch trunk] HEAD > Blamelist: jack.diederich > FAIL: test_count (test.test_itertools.TestBasicOps) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/buildslave/bb/trunk.psf-g4/build/Lib/test/test_itertools.py", line 62, in test_count self.assertEqual(repr(c), 'count(-9)') AssertionError: 'count(4294967287)' != 'count(-9)' The repr uses PyString_FromFormat("count(%zd)", lz->cnt) where lz->cnt is a Py_Ssize_t. Looking in stringobject.c that seems the right thing to do .. Any ideas? -Jack From jackdied at jackdied.com Thu Sep 21 21:00:21 2006 From: jackdied at jackdied.com (Jack Diederich) Date: Thu, 21 Sep 2006 15:00:21 -0400 Subject: [Python-checkins] buildbot warnings in g4 osx.4 trunk In-Reply-To: <20060921185344.GH5928@performancedrivers.com> References: <20060921183300.4A7AB1E4004@bag.python.org> <20060921185344.GH5928@performancedrivers.com> Message-ID: <20060921190021.GI5928@performancedrivers.com> Never mind, new tests and and old binary seems probable. On Thu, Sep 21, 2006 at 02:53:44PM -0400, Jack Diederich wrote: > On Thu, Sep 21, 2006 at 06:32:59PM +0000, buildbot at python.org wrote: > > 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/1449 > > > > Buildbot URL: http://www.python.org/dev/buildbot/all/ > > > > Build Reason: > > Build Source Stamp: [branch trunk] HEAD > > Blamelist: jack.diederich > > > > FAIL: test_count (test.test_itertools.TestBasicOps) > ---------------------------------------------------------------------- > Traceback (most recent call last): > File "/Users/buildslave/bb/trunk.psf-g4/build/Lib/test/test_itertools.py", line 62, in test_count > self.assertEqual(repr(c), 'count(-9)') > AssertionError: 'count(4294967287)' != 'count(-9)' > > The repr uses PyString_FromFormat("count(%zd)", lz->cnt) where lz->cnt > is a Py_Ssize_t. Looking in stringobject.c that seems the right thing > to do .. > > Any ideas? > > -Jack > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From nnorwitz at gmail.com Thu Sep 21 21:17:09 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 21 Sep 2006 12:17:09 -0700 Subject: [Python-checkins] [Python-Dev] release25-maint is UNFROZEN In-Reply-To: <20060921123510.GA22457@code0.codespeak.net> References: <200609212112.04923.anthony@interlink.com.au> <20060921123510.GA22457@code0.codespeak.net> Message-ID: On 9/21/06, Armin Rigo wrote: > Hi Anthony, > > On Thu, Sep 21, 2006 at 09:12:03PM +1000, Anthony Baxter wrote: > > Thanks to everyone for helping make 2.5 happen. It's been a long slog there, > > but I think we can all be proud of the result. > > Thanks for the hassle! I've got another bit of it for you, though. The > freezed 2.5 documentation doesn't seem to be available on-line. At > least, the doc links from the release page point to the 'dev' 2.6a0 > version, and the URL following the common scheme - > http://www.python.org/doc/2.5/ - doesn't work. I got http://docs.python.org/dev/2.5/ working last night. So when the 2.5 docs are updated these pages will reflect that. http://docs.python.org/ should point to the 2.5 doc too. I looked at making these changes, but was confused by what needed to be done. n From nnorwitz at gmail.com Thu Sep 21 21:35:45 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Thu, 21 Sep 2006 12:35:45 -0700 Subject: [Python-checkins] r51950 - in python/trunk: Lib/test/test_itertools.py Modules/itertoolsmodule.c In-Reply-To: <20060921175027.4DB101E4006@bag.python.org> References: <20060921175027.4DB101E4006@bag.python.org> Message-ID: Can we get a Misc/NEWS entry for this on trunk and in 2.5? Thanks. On 9/21/06, jack.diederich wrote: > Author: jack.diederich > Date: Thu Sep 21 19:50:26 2006 > New Revision: 51950 > > Modified: > python/trunk/Lib/test/test_itertools.py > python/trunk/Modules/itertoolsmodule.c > Log: > * regression bug, count_next was coercing a Py_ssize_t to an unsigned Py_size_t > which breaks negative counts > * added test for negative numbers > will backport to 2.5.1 > > > Modified: python/trunk/Lib/test/test_itertools.py > ============================================================================== > --- python/trunk/Lib/test/test_itertools.py (original) > +++ python/trunk/Lib/test/test_itertools.py Thu Sep 21 19:50:26 2006 > @@ -58,6 +58,10 @@ > self.assertEqual(repr(c), 'count(3)') > c.next() > self.assertEqual(repr(c), 'count(4)') > + c = count(-9) > + self.assertEqual(repr(c), 'count(-9)') > + c.next() > + self.assertEqual(c.next(), -8) > > def test_cycle(self): > self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) > > Modified: python/trunk/Modules/itertoolsmodule.c > ============================================================================== > --- python/trunk/Modules/itertoolsmodule.c (original) > +++ python/trunk/Modules/itertoolsmodule.c Thu Sep 21 19:50:26 2006 > @@ -2072,7 +2072,7 @@ > static PyObject * > count_next(countobject *lz) > { > - return PyInt_FromSize_t(lz->cnt++); > + return PyInt_FromSsize_t(lz->cnt++); > } > > static PyObject * > _______________________________________________ > Python-checkins mailing list > Python-checkins at python.org > http://mail.python.org/mailman/listinfo/python-checkins > From buildbot at python.org Thu Sep 21 21:48:57 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 21 Sep 2006 19:48:57 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 2.5 Message-ID: <20060921194857.D58301E4004@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/41 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: jack.diederich Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Thu Sep 21 22:34:49 2006 From: python-checkins at python.org (jack.diederich) Date: Thu, 21 Sep 2006 22:34:49 +0200 (CEST) Subject: [Python-checkins] r51953 - python/trunk/Misc/NEWS Message-ID: <20060921203449.D1BC31E4004@bag.python.org> Author: jack.diederich Date: Thu Sep 21 22:34:49 2006 New Revision: 51953 Modified: python/trunk/Misc/NEWS Log: added itertools.count(-n) fix Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Thu Sep 21 22:34:49 2006 @@ -69,6 +69,8 @@ Extension Modules ----------------- +- Fix itertools.count(n) to work with negative numbers again. + - RLIMIT_SBSIZE was added to the resource module where available. - Bug #1551427: fix a wrong NULL pointer check in the win32 version From python-checkins at python.org Thu Sep 21 22:38:40 2006 From: python-checkins at python.org (jack.diederich) Date: Thu, 21 Sep 2006 22:38:40 +0200 (CEST) Subject: [Python-checkins] r51954 - python/branches/release25-maint/Misc/NEWS Message-ID: <20060921203840.559191E4004@bag.python.org> Author: jack.diederich Date: Thu Sep 21 22:38:39 2006 New Revision: 51954 Modified: python/branches/release25-maint/Misc/NEWS Log: added itertools.count(-n) fix Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Thu Sep 21 22:38:39 2006 @@ -14,6 +14,11 @@ - Allow exception instances to be directly sliced again. +Extension Modules +----------------- + +- Fix itertools.count(n) to work with negative numbers again. + What's New in Python 2.5 (final) ================================ From python-checkins at python.org Thu Sep 21 22:59:07 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 21 Sep 2006 22:59:07 +0200 (CEST) Subject: [Python-checkins] r51955 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20060921205907.AB89A1E4004@bag.python.org> Author: phillip.eby Date: Thu Sep 21 22:59:07 2006 New Revision: 51955 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Fix easy_install not recognizing win32.exe files that include a custom bitmap. 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 Thu Sep 21 22:59:07 2006 @@ -1249,7 +1249,7 @@ if tag not in (0x1234567A, 0x1234567B): return None # not a valid tag - f.seek(prepended-(12+cfglen+bmlen)) + f.seek(prepended-(12+cfglen)) cfg = ConfigParser.RawConfigParser({'version':'','target_version':''}) try: cfg.readfp(StringIO.StringIO(f.read(cfglen).split(chr(0),1)[0])) From python-checkins at python.org Thu Sep 21 23:00:59 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 21 Sep 2006 23:00:59 +0200 (CEST) Subject: [Python-checkins] r51956 - in sandbox/branches/setuptools-0.6: ez_setup.py release.sh setup.py setuptools/__init__.py version.dat Message-ID: <20060921210059.1059F1E4006@bag.python.org> Author: phillip.eby Date: Thu Sep 21 23:00:58 2006 New Revision: 51956 Modified: sandbox/branches/setuptools-0.6/ez_setup.py sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools/__init__.py sandbox/branches/setuptools-0.6/version.dat Log: Bump version #'s to 0.6c4 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 Thu Sep 21 23:00:58 2006 @@ -14,7 +14,7 @@ This file can also be run as a script to install or upgrade setuptools. """ import sys -DEFAULT_VERSION = "0.6c3" +DEFAULT_VERSION = "0.6c4" DEFAULT_URL = "http://cheeseshop.python.org/packages/%s/s/setuptools/" % sys.version[:3] md5_data = { Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Thu Sep 21 23:00:58 2006 @@ -7,7 +7,7 @@ # If your initials aren't PJE, don't run it. :) # -export VERSION="0.6c3" +export VERSION="0.6c4" python2.3 setup.py -q release source && \ python2.4 setup.py -q release binary && \ Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Thu Sep 21 23:00:58 2006 @@ -19,7 +19,7 @@ d = {}; execfile(convert_path('setuptools/command/__init__.py'), d) SETUP_COMMANDS = d['__all__'] -VERSION = "0.6c3" +VERSION = "0.6c4" from setuptools import setup, find_packages import sys scripts = [] Modified: sandbox/branches/setuptools-0.6/setuptools/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/__init__.py Thu Sep 21 23:00:58 2006 @@ -7,7 +7,7 @@ from distutils.util import convert_path import os.path -__version__ = '0.6c3' +__version__ = '0.6c4' __all__ = [ 'setup', 'Distribution', 'Feature', 'Command', 'Extension', 'Require', 'find_packages' Modified: sandbox/branches/setuptools-0.6/version.dat ============================================================================== --- sandbox/branches/setuptools-0.6/version.dat (original) +++ sandbox/branches/setuptools-0.6/version.dat Thu Sep 21 23:00:58 2006 @@ -1,6 +1,6 @@ [setuptools] status = 'release candidate' major = 0 -build = 3 +build = 4 minor = 6 From python-checkins at python.org Thu Sep 21 23:02:22 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 21 Sep 2006 23:02:22 +0200 (CEST) Subject: [Python-checkins] r51957 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py Message-ID: <20060921210222.5C64A1E4004@bag.python.org> Author: phillip.eby Date: Thu Sep 21 23:02:21 2006 New Revision: 51957 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Fix easy_install not recognizing win32.exe files that include a custom bitmap. (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 Thu Sep 21 23:02:21 2006 @@ -1194,6 +1194,10 @@ Release Notes/Change History ============================ +0.6c4 + * Fixed not recogninzing ``win32.exe`` installers that included a custom + bitmap. + 0.6c3 * You once again use "python -m easy_install" with Python 2.4 and above. 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 Thu Sep 21 23:02:21 2006 @@ -1249,7 +1249,7 @@ if tag not in (0x1234567A, 0x1234567B): return None # not a valid tag - f.seek(prepended-(12+cfglen+bmlen)) + f.seek(prepended-(12+cfglen)) cfg = ConfigParser.RawConfigParser({'version':'','target_version':''}) try: cfg.readfp(StringIO.StringIO(f.read(cfglen).split(chr(0),1)[0])) From python-checkins at python.org Thu Sep 21 23:47:57 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 23:47:57 +0200 (CEST) Subject: [Python-checkins] r51958 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py Modules/interpretermodule.c securing_python.txt Message-ID: <20060921214757.8DDBC1E4004@bag.python.org> Author: brett.cannon Date: Thu Sep 21 23:47:56 2006 New Revision: 51958 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/Modules/interpretermodule.c python/branches/bcannon-objcap/securing_python.txt Log: Fix up handling exceptions. Added exc_matches() method to allow comparing against whether the raised exception matches the one passed in. execute() also now clears any exceptions before beginning execution. RuntimeError raised by the method also now has its message contain the name of the exception raised. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Thu Sep 21 23:47:56 2006 @@ -190,9 +190,10 @@ # Make sure removing a value raises the proper exception when accessing # through the 'sys' module. del self.interp.sys_dict()['version'] - # XXX requires exceptions - # XXX self.failUnlessRaises(XXX, self.interp.execute, - # 'import sys; sys.version') + stdout, stderr = self.interp.redirect_output() + self.failUnlessRaises(RuntimeError, self.interp.execute, + 'import sys; sys.version') + self.failUnless(self.interp.exc_matches(AttributeError)) def test_copied(self): # sys_dict should be unique per interpreter (including mutable data @@ -217,8 +218,8 @@ self.interp.execute("print 'test'") self.failUnlessEqual("test\n", stdout.getvalue()) self.failUnless(not stderr.getvalue()) - self.failUnlessRaises(RuntimeError, self.interp.execute, "+") - self.failUnless(stderr.getvalue()) + self.interp.execute(r"import sys; sys.stderr.write('test\n')") + self.failUnlessEqual('test\n', stderr.getvalue()) def test_redirect_output_arguments(self): # Test passing in arguments to redirect_output(). @@ -247,8 +248,29 @@ # Test exc_matches(). stdout, stderr = self.interp.redirect_output() self.failUnlessRaises(RuntimeError, self.interp.execute, '=') - #self.failUnless(self.interp.exc_matches(SyntaxError)) - + self.failUnless(self.interp.exc_matches(SyntaxError)) + self.failUnless(not self.interp.exc_matches(TypeError)) + + def test_exception_cleared(self): + # No exception should be set after a successful execution. + stdout, stderr = self.interp.redirect_output() + self.failUnlessRaises(RuntimeError, self.interp.execute, '=') + self.interp.execute('2 + 3') + self.failUnlessRaises(LookupError, self.interp.exc_matches, Exception) + + def test_multiple_exc_checks(self): + # Be able to check the exception multiple times. + stdout, stderr = self.interp.redirect_output() + self.failUnlessRaises(RuntimeError, self.interp.execute, '=') + for x in range(2): + self.failUnless(self.interp.exc_matches(SyntaxError)) + + def test_SystemExit_safe(self): + # Raising SystemExit should not cause the process to exit. + self.failUnlessRaises(RuntimeError, self.interp.execute, + "raise SystemExit") + self.failUnless(self.interp.exc_matches(SystemExit)) + def test_main(): test_support.run_unittest( Modified: python/branches/bcannon-objcap/Modules/interpretermodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/interpretermodule.c (original) +++ python/branches/bcannon-objcap/Modules/interpretermodule.c Thu Sep 21 23:47:56 2006 @@ -97,12 +97,14 @@ Execute Python source code in the interpreter. */ static PyObject * -interpreter_exec(PyObject *self, PyObject *arg) +interpreter_exec(PyInterpreterObject *self, PyObject *arg) { - PyInterpreterObject *interp_self = (PyInterpreterObject *)self; const char *str_arg = NULL; PyThreadState* cur_tstate = NULL; - int result = 0; + PyObject *main_module = NULL; + PyObject *main_dict = NULL; + PyObject *result = NULL; + const char *exc_name = NULL; if (!PyString_Check(arg)) { PyErr_SetString(PyExc_TypeError, "argument must be a string"); @@ -113,21 +115,40 @@ if (!str_arg) return NULL; - cur_tstate = PyThreadState_Swap(interp_self->tstate); + /* Execute in 'self'. */ + cur_tstate = PyThreadState_Swap(self->tstate); + + /* If a previous exception was present, clear it out. */ + if (PyErr_Occurred()) + PyErr_Clear(); + + /* Code borrowed from PyRun_SimpleStringFlags(). */ + main_module = PyImport_AddModule("__main__"); + if (!main_module) { + goto back_to_caller; + } + + main_dict = PyModule_GetDict(main_module); - result = PyRun_SimpleString(str_arg); - if (result < 0) { - PyErr_Clear(); + result = PyRun_String(str_arg, Py_file_input, main_dict, main_dict); + + if (result) { + Py_DECREF(result); + } + else { + exc_name = ((PyTypeObject *)PyErr_Occurred())->tp_name; } + back_to_caller: + /* Execute in calling interpreter. */ PyThreadState_Swap(cur_tstate); - if (result < 0) { - PyErr_SetString(PyExc_RuntimeError, - "exception during execution"); + if (!result) { + PyErr_Format(PyExc_RuntimeError, + "execution raised during execution (%s)", exc_name); return NULL; } - + Py_RETURN_NONE; } @@ -143,14 +164,14 @@ if (!py_stdout) { /* Argument for NewOutput() copied from PycStringIO->NewInput(). */ - py_stdout = (PycStringIO->NewOutput)(128); + py_stdout = (PycStringIO->NewOutput)(512); if (!py_stdout) return NULL; } if (!py_stderr) { /* Argument for NewOutput() copied from PycStringIO->NewInput(). */ - py_stderr = (PycStringIO->NewOutput)(128); + py_stderr = (PycStringIO->NewOutput)(512); if (!py_stderr) return NULL; } @@ -174,15 +195,55 @@ return used_stdout_stderr; } +static PyObject * +exc_matches(PyInterpreterObject *self, PyObject *arg) +{ + PyThreadState *starting_tstate = NULL; + PyObject *raised_exc = NULL; + int result = 0; + + /* Can only compare against exception classes or instances. */ + if (!(PyExceptionClass_Check(arg) || PyExceptionInstance_Check(arg))) { + PyErr_SetString(PyExc_TypeError, + "argument must be an exception class or instance"); + return NULL; + } + + /* Now executing under 'self'. */ + starting_tstate = PyThreadState_Swap(self->tstate); + + raised_exc = PyErr_Occurred(); + + if (!raised_exc) { + /* Executing under calling interpreter. */ + PyThreadState_Swap(starting_tstate); + PyErr_SetString(PyExc_LookupError, "no exception set"); + return NULL; + } + + if (PyErr_GivenExceptionMatches(raised_exc, arg)) + result = 1; + + /* Execute under calling interpreter. */ + PyThreadState_Swap(starting_tstate); + + if (result) + Py_RETURN_TRUE; + else + Py_RETURN_FALSE; +} + static PyMethodDef interpreter_methods[] = { {"builtins", (PyCFunction)interpreter_builtins, METH_NOARGS, "Return the built-in namespace dict."}, {"sys_dict", (PyCFunction)interpreter_sys_dict, METH_NOARGS, "Return the 'sys' module's data dictionary."}, - {"execute", interpreter_exec, METH_O, + {"execute", (PyCFunction)interpreter_exec, METH_O, "Execute the passed-in string in the interpreter."}, {"redirect_output", (PyCFunction)redirect_output, METH_VARARGS, "Redirect stdout to stderr. Returns tuple of objects used."}, + {"exc_matches", (PyCFunction)exc_matches, METH_O, + "Check if the raised exception in the interpreter matches the argument"}, {NULL} }; @@ -245,7 +306,7 @@ \n\ XXX"); -PyTypeObject PyInterpreter_Type = { +static PyTypeObject PyInterpreter_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "interpreterInterpreter", /* tp_name */ 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 21 23:47:56 2006 @@ -34,7 +34,8 @@ * Just promote removal - exit() * Have SystemExit exit the process only if no other - interpreters are running. + interpreters are running. [done] + * XXX Safe? + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) @@ -48,15 +49,10 @@ - Set 'sys' module settings [done] - Set 'sys.modules' [done] - API - * Python + * Python [done] * C - Securely handle exceptions being raised in sub-interpreter - * Raise InterpreterException w/ string for the exception type - and a sanitized string for message? - * Provide way to compare the raised exception in a safe manner - (i.e., expose PyErr_ExceptionMatches())? - * Provide exc_info() for those who know what they are doing? - + Raise a SecurityWarning when used? + [done] - Redirect output [done] + Tear out old restricted mode code. From python-checkins at python.org Thu Sep 21 23:48:51 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 21 Sep 2006 23:48:51 +0200 (CEST) Subject: [Python-checkins] r51959 - python/branches/bcannon-objcap/BRANCHNEWS Message-ID: <20060921214851.6B2251E4004@bag.python.org> Author: brett.cannon Date: Thu Sep 21 23:48:51 2006 New Revision: 51959 Modified: python/branches/bcannon-objcap/BRANCHNEWS Log: Mention exc_matches(). Modified: python/branches/bcannon-objcap/BRANCHNEWS ============================================================================== --- python/branches/bcannon-objcap/BRANCHNEWS (original) +++ python/branches/bcannon-objcap/BRANCHNEWS Thu Sep 21 23:48:51 2006 @@ -25,6 +25,8 @@ Extension Modules ----------------- +* rev. 51958: Fix up handling exceptions. Added exc_matches() exception. + * rev. 51944: Change sys_dict to a module since that dict is cached somewhere. * rev. 51941: Changed exception raised by interpreter.Interpreter().execute() From python-checkins at python.org Thu Sep 21 23:59:00 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 21 Sep 2006 23:59:00 +0200 (CEST) Subject: [Python-checkins] r51960 - sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Message-ID: <20060921215900.70A471E4006@bag.python.org> Author: phillip.eby Date: Thu Sep 21 23:58:59 2006 New Revision: 51960 Modified: sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Log: Support uploading bdist_rpm files on older Python versions (2.3/2.4) Modified: sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Thu Sep 21 23:58:59 2006 @@ -1,8 +1,10 @@ # This is just a kludge so that bdist_rpm doesn't guess wrong about the # distribution name and version, if the egg_info command is going to alter -# them, and another kludge to allow you to build old-style non-egg RPMs +# them, another kludge to allow you to build old-style non-egg RPMs, and +# finally, a kludge to track .rpm files for uploading when run on Python <2.5. from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm +import sys class bdist_rpm(_bdist_rpm): @@ -10,10 +12,33 @@ _bdist_rpm.initialize_options(self) self.no_egg = None + if sys.version<"2.5": + # Track for uploading any .rpm file(s) moved to self.dist_dir + def move_file(self, src, dst, level=1): + _bdist_rpm.move_file(self, src, dst, level) + if dst==self.dist_dir and src.endswith('.rpm'): + getattr(self.distribution,'dist_files',[]).append( + ('bdist_egg', + src.endswith('.src.rpm') and 'any' or get_python_version(), + os.path.join(dst, os.path.basename(src))) + ) + def run(self): self.run_command('egg_info') # ensure distro name is up-to-date _bdist_rpm.run(self) + + + + + + + + + + + + def _make_spec_file(self): version = self.distribution.get_version() rpmversion = version.replace('-','_') @@ -35,3 +60,23 @@ ] spec.insert(spec.index(line24)+1, "%define unmangled_version "+version) return spec + + + + + + + + + + + + + + + + + + + + From python-checkins at python.org Fri Sep 22 00:01:23 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:01:23 +0200 (CEST) Subject: [Python-checkins] r51961 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/bdist_rpm.py Message-ID: <20060921220123.0EFF51E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:01:22 2006 New Revision: 51961 Modified: sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py Log: Fix ``upload`` not uploading files built by ``bdist_rpm`` on Python 2.3 and 2.4. (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 Fri Sep 22 00:01:22 2006 @@ -2563,6 +2563,10 @@ Release Notes/Change History ---------------------------- +0.6c4 + * Fix ``upload`` not uploading files built by ``bdist_rpm`` on Python 2.3 and + 2.4. + 0.6c3 * Fixed breakages caused by Subversion 1.4's new "working copy" format Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_rpm.py Fri Sep 22 00:01:22 2006 @@ -1,8 +1,10 @@ # This is just a kludge so that bdist_rpm doesn't guess wrong about the # distribution name and version, if the egg_info command is going to alter -# them, and another kludge to allow you to build old-style non-egg RPMs +# them, another kludge to allow you to build old-style non-egg RPMs, and +# finally, a kludge to track .rpm files for uploading when run on Python <2.5. from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm +import sys class bdist_rpm(_bdist_rpm): @@ -10,10 +12,33 @@ _bdist_rpm.initialize_options(self) self.no_egg = None + if sys.version<"2.5": + # Track for uploading any .rpm file(s) moved to self.dist_dir + def move_file(self, src, dst, level=1): + _bdist_rpm.move_file(self, src, dst, level) + if dst==self.dist_dir and src.endswith('.rpm'): + getattr(self.distribution,'dist_files',[]).append( + ('bdist_egg', + src.endswith('.src.rpm') and 'any' or get_python_version(), + os.path.join(dst, os.path.basename(src))) + ) + def run(self): self.run_command('egg_info') # ensure distro name is up-to-date _bdist_rpm.run(self) + + + + + + + + + + + + def _make_spec_file(self): version = self.distribution.get_version() rpmversion = version.replace('-','_') @@ -55,14 +80,3 @@ - - - - - - - - - - - From fdrake at acm.org Fri Sep 22 00:08:38 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Thu, 21 Sep 2006 18:08:38 -0400 Subject: [Python-checkins] r51961 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/bdist_rpm.py In-Reply-To: <20060921220123.0EFF51E4004@bag.python.org> References: <20060921220123.0EFF51E4004@bag.python.org> Message-ID: <200609211808.39308.fdrake@acm.org> On Thursday 21 September 2006 18:01, phillip.eby wrote: > def run(self): > self.run_command('egg_info') # ensure distro name is > up-to-date _bdist_rpm.run(self) > > + > + > + > + > + > + > + > + > + > + > + > + > def _make_spec_file(self): > version = self.distribution.get_version() Hey, I think I just found a bug in your text editor! :-) -Fred -- Fred L. Drake, Jr. From python-checkins at python.org Fri Sep 22 00:11:23 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:11:23 +0200 (CEST) Subject: [Python-checkins] r51962 - sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.cfg Message-ID: <20060921221123.268CC1E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:11:22 2006 New Revision: 51962 Modified: sandbox/branches/setuptools-0.6/release.sh sandbox/branches/setuptools-0.6/setup.cfg Log: Build & upload win32 installers Modified: sandbox/branches/setuptools-0.6/release.sh ============================================================================== --- sandbox/branches/setuptools-0.6/release.sh (original) +++ sandbox/branches/setuptools-0.6/release.sh Fri Sep 22 00:11:22 2006 @@ -9,9 +9,9 @@ export VERSION="0.6c4" -python2.3 setup.py -q release source && \ -python2.4 setup.py -q release binary && \ -python2.5 setup.py -q release binary && \ +python2.3 setup.py -q release source --target-version=2.3 upload && \ +python2.4 setup.py -q release binary --target-version=2.4 upload && \ +python2.5 setup.py -q release binary --target-version=2.5 upload && \ python2.3 ez_setup.py --md5update dist/setuptools-$VERSION*-py2.?.egg && \ cp ez_setup.py virtual-python.py ~/distrib/ && \ cp ez_setup.py ~/projects/ez_setup/__init__.py && \ Modified: sandbox/branches/setuptools-0.6/setup.cfg ============================================================================== --- sandbox/branches/setuptools-0.6/setup.cfg (original) +++ sandbox/branches/setuptools-0.6/setup.cfg Fri Sep 22 00:11:22 2006 @@ -5,7 +5,10 @@ [aliases] release = egg_info -RDb '' source = sdist bdist_rpm register binary -binary = bdist_egg bdist_wininst upload --show-response +binary = bdist_egg bdist_wininst + +[upload] +show_response = 1 [bdist_rpm] source_only = 1 From python-checkins at python.org Fri Sep 22 00:13:40 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:13:40 +0200 (CEST) Subject: [Python-checkins] r51963 - sandbox/trunk/setuptools/setuptools/command/__init__.py sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Message-ID: <20060921221340.D1DFE1E4006@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:13:40 2006 New Revision: 51963 Added: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py (contents, props changed) Modified: sandbox/trunk/setuptools/setuptools/command/__init__.py Log: Fix bdist_wininst files not being uploaded by "upload" Modified: sandbox/trunk/setuptools/setuptools/command/__init__.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/__init__.py (original) +++ sandbox/trunk/setuptools/setuptools/command/__init__.py Fri Sep 22 00:13:40 2006 @@ -2,13 +2,14 @@ 'alias', 'bdist_egg', 'bdist_rpm', 'build_ext', 'build_py', 'develop', 'easy_install', 'egg_info', 'install', 'install_lib', 'rotate', 'saveopts', 'sdist', 'setopt', 'test', 'upload', 'install_egg_info', 'install_scripts', - 'register', + 'register', 'bdist_wininst', ] import sys if sys.version>='2.5': # In Python 2.5 and above, distutils includes its own upload command __all__.remove('upload') + __all__.remove('bdist_wininst') # this is only for 'upload' support from distutils.command.bdist import bdist Added: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py ============================================================================== --- (empty file) +++ sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Fri Sep 22 00:13:40 2006 @@ -0,0 +1,22 @@ +from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst +import sys + +class bdist_wininst(_bdist_wininst): + + def create_exe(self, arcname, fullname, bitmap=None): + + _bdist_wininst.create_exe(self, arcname, fullname, bitmap) + + if self.target_version: + installer_name = os.path.join(self.dist_dir, + "%s.win32-py%s.exe" % + (fullname, self.target_version)) + pyversion = self.target_version + else: + installer_name = os.path.join(self.dist_dir, + "%s.win32.exe" % fullname) + pyversion = 'any' + + getattr(self.distribution,'dist_files',[]).append( + ('bdist_wininst', pyversion, installer_name) + ) From python-checkins at python.org Fri Sep 22 00:15:29 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:15:29 +0200 (CEST) Subject: [Python-checkins] r51964 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/__init__.py setuptools/command/bdist_wininst.py Message-ID: <20060921221529.066621E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:15:28 2006 New Revision: 51964 Added: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py - copied unchanged from r51963, sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Modified: sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/__init__.py Log: Fix bdist_wininst files not being uploaded by "upload" (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 Fri Sep 22 00:15:28 2006 @@ -2564,8 +2564,8 @@ ---------------------------- 0.6c4 - * Fix ``upload`` not uploading files built by ``bdist_rpm`` on Python 2.3 and - 2.4. + * Fix ``upload`` command not uploading files built by ``bdist_rpm`` or + ``bdist_wininst`` under Python 2.3 and 2.4. 0.6c3 * Fixed breakages caused by Subversion 1.4's new "working copy" format Modified: sandbox/branches/setuptools-0.6/setuptools/command/__init__.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/__init__.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/__init__.py Fri Sep 22 00:15:28 2006 @@ -2,13 +2,14 @@ 'alias', 'bdist_egg', 'bdist_rpm', 'build_ext', 'build_py', 'develop', 'easy_install', 'egg_info', 'install', 'install_lib', 'rotate', 'saveopts', 'sdist', 'setopt', 'test', 'upload', 'install_egg_info', 'install_scripts', - 'register', + 'register', 'bdist_wininst', ] import sys if sys.version>='2.5': # In Python 2.5 and above, distutils includes its own upload command __all__.remove('upload') + __all__.remove('bdist_wininst') # this is only for 'upload' support from distutils.command.bdist import bdist From python-checkins at python.org Fri Sep 22 00:26:48 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:26:48 +0200 (CEST) Subject: [Python-checkins] r51965 - sandbox/branches/setuptools-0.6/setup.cfg Message-ID: <20060921222648.933651E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:26:48 2006 New Revision: 51965 Modified: sandbox/branches/setuptools-0.6/setup.cfg Log: bdist_rpm runs sdist and thus will cause it to upload anyway Modified: sandbox/branches/setuptools-0.6/setup.cfg ============================================================================== --- sandbox/branches/setuptools-0.6/setup.cfg (original) +++ sandbox/branches/setuptools-0.6/setup.cfg Fri Sep 22 00:26:48 2006 @@ -4,7 +4,7 @@ [aliases] release = egg_info -RDb '' -source = sdist bdist_rpm register binary +source = bdist_rpm register binary binary = bdist_egg bdist_wininst [upload] From python-checkins at python.org Fri Sep 22 00:27:36 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:27:36 +0200 (CEST) Subject: [Python-checkins] r51966 - sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Message-ID: <20060921222736.BE1DE1E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:27:36 2006 New Revision: 51966 Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Log: Fix bad import Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_wininst.py Fri Sep 22 00:27:36 2006 @@ -1,5 +1,5 @@ from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst -import sys +import os class bdist_wininst(_bdist_wininst): From python-checkins at python.org Fri Sep 22 00:28:31 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 00:28:31 +0200 (CEST) Subject: [Python-checkins] r51967 - sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Message-ID: <20060921222831.B85381E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 00:28:31 2006 New Revision: 51967 Modified: sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Log: Fix broken imports. Modified: sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_rpm.py Fri Sep 22 00:28:31 2006 @@ -19,7 +19,7 @@ if dst==self.dist_dir and src.endswith('.rpm'): getattr(self.distribution,'dist_files',[]).append( ('bdist_egg', - src.endswith('.src.rpm') and 'any' or get_python_version(), + src.endswith('.src.rpm') and 'any' or sys.version[:3], os.path.join(dst, os.path.basename(src))) ) Modified: sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_wininst.py Fri Sep 22 00:28:31 2006 @@ -1,5 +1,5 @@ from distutils.command.bdist_wininst import bdist_wininst as _bdist_wininst -import sys +import os class bdist_wininst(_bdist_wininst): From python-checkins at python.org Fri Sep 22 02:03:59 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 02:03:59 +0200 (CEST) Subject: [Python-checkins] r51968 - in sandbox/trunk/setuptools: setup.py setuptools.egg-info/entry_points.txt setuptools.txt setuptools/command/bdist_egg.py setuptools/command/easy_install.py Message-ID: <20060922000359.6C04E1E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 02:03:56 2006 New Revision: 51968 Modified: sandbox/trunk/setuptools/setup.py sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt sandbox/trunk/setuptools/setuptools.txt sandbox/trunk/setuptools/setuptools/command/bdist_egg.py sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Add support for "eggsecutable" headers: a /bin/sh script that is prepended to an .egg file to allow it to be run as a script on Unix-ish platforms. (This is mainly so that setuptools itself can have a single-file installer on Unix, without doing multiple downloads, dealing with firewalls, etc.) Modified: sandbox/trunk/setuptools/setup.py ============================================================================== --- sandbox/trunk/setuptools/setup.py (original) +++ sandbox/trunk/setuptools/setup.py Fri Sep 22 02:03:56 2006 @@ -75,9 +75,13 @@ "easy_install = setuptools.command.easy_install:main", "easy_install-%s = setuptools.command.easy_install:main" % sys.version[:3] - ], + ], "setuptools.file_finders": - ["svn_cvs = setuptools.command.sdist:_default_revctrl"] + ["svn_cvs = setuptools.command.sdist:_default_revctrl"], + + + "setuptools.installation": + ['eggsecutable = setuptools.command.easy_install:bootstrap'], }, classifiers = [f.strip() for f in """ @@ -117,7 +121,3 @@ - - - - Modified: sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt (original) +++ sandbox/trunk/setuptools/setuptools.egg-info/entry_points.txt Fri Sep 22 02:03:56 2006 @@ -30,6 +30,9 @@ easy_install = setuptools.command.easy_install:main easy_install-2.3 = setuptools.command.easy_install:main +[setuptools.installation] +eggsecutable = setuptools.command.easy_install:bootstrap + [distutils.commands] bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm rotate = setuptools.command.rotate:rotate @@ -44,10 +47,10 @@ alias = setuptools.command.alias:alias easy_install = setuptools.command.easy_install:easy_install install_scripts = setuptools.command.install_scripts:install_scripts +bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst bdist_egg = setuptools.command.bdist_egg:bdist_egg install = setuptools.command.install:install test = setuptools.command.test:test install_lib = setuptools.command.install_lib:install_lib build_ext = setuptools.command.build_ext:build_ext sdist = setuptools.command.sdist:sdist - Modified: sandbox/trunk/setuptools/setuptools.txt ============================================================================== --- sandbox/trunk/setuptools/setuptools.txt (original) +++ sandbox/trunk/setuptools/setuptools.txt Fri Sep 22 02:03:56 2006 @@ -498,6 +498,43 @@ Services and Plugins`_. +"Eggsecutable" Scripts +---------------------- + +Occasionally, there are situations where it's desirable to make an ``.egg`` +file directly executable. You can do this by including an entry point such +as the following:: + + setup( + # other arguments here... + entry_points = { + 'setuptools.installation': [ + 'eggsecutable = my_package.some_module:main_func', + ] + } + ) + +Any eggs built from the above setup script will include a short excecutable +prelude that imports and calls ``main_func()`` from ``my_package.some_module``. +The prelude can be run on Unix-like platforms (including Mac and Linux) by +invoking the egg with ``/bin/sh``, or by enabling execute permissions on the +``.egg`` file. For the executable prelude to run, the appropriate version of +Python must be available via the ``PATH`` environment variable, under its +"long" name. That is, if the egg is built for Python 2.3, there must be a +``python2.3`` executable present in a directory on ``PATH``. + +This feature is primarily intended to support bootstrapping the installation of +setuptools itself on non-Windows platforms, but may also be useful for other +projects as well. + +IMPORTANT NOTE: Eggs with an "eggsecutable" header cannot be renamed, or +invoked via symlinks. They *must* be invoked using their original filename, in +order to ensure that, once running, ``pkg_resources`` will know what project +and version is in use. The header script will check this and exit with an +error if the ``.egg`` file has been renamed or is invoked via a symlink that +changes its base name. + + Declaring Dependencies ====================== Modified: sandbox/trunk/setuptools/setuptools/command/bdist_egg.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_egg.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_egg.py Fri Sep 22 02:03:56 2006 @@ -8,7 +8,9 @@ from distutils.dir_util import remove_tree, mkpath from distutils.sysconfig import get_python_version, get_python_lib from distutils import log +from distutils.errors import DistutilsSetupError from pkg_resources import get_build_platform, Distribution, ensure_directory +from pkg_resources import EntryPoint from types import CodeType from setuptools.extension import Library @@ -37,8 +39,6 @@ # stub __init__.py for packages distributed without one NS_PKG_STUB = '__import__("pkg_resources").declare_namespace(__name__)' - - class bdist_egg(Command): description = "create an \"egg\" distribution" @@ -233,7 +233,7 @@ # Make the archive make_zipfile(self.egg_output, archive_root, verbose=self.verbose, - dry_run=self.dry_run) + dry_run=self.dry_run, mode=self.gen_header()) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) @@ -285,6 +285,47 @@ return init_files + def gen_header(self): + epm = EntryPoint.parse_map(self.distribution.entry_points or '') + ep = epm.get('setuptools.installation',{}).get('eggsecutable') + if ep is None: + return 'w' # not an eggsecutable, do it the usual way. + + if not ep.attrs or ep.extras: + raise DistutilsSetupError( + "eggsecutable entry point (%r) cannot have 'extras' " + "or refer to a module" % (ep,) + ) + + pyver = sys.version[:3] + pkg = ep.module_name + full = '.'.join(ep.attrs) + base = ep.attrs[0] + basename = os.path.basename(self.egg_output) + + header = ( + "#!/bin/sh\n" + 'if [[ `basename $0` = "%(basename)s" ]]\n' + 'then exec python%(pyver)s -c "' + "import sys, os; sys.path.insert(0, os.path.abspath('$0')); " + "from %(pkg)s import %(base)s; sys.exit(%(full)s())" + '" "$@"\n' + 'else\n' + ' echo $0 is not the correct name for this egg file.\n' + ' echo Please rename it back to %(basename)s and try again.\n' + ' exec false\n' + 'fi\n' + + ) % locals() + + if not self.dry_run: + f = open(self.egg_output, 'w') + f.write(header) + f.close() + return 'a' + + + def copy_metadata_to(self, target_dir): prefix = os.path.join(self.egg_info,'') for path in self.ei_cmd.filelist.files: @@ -415,7 +456,9 @@ 'install_lib', 'install_dir', 'install_data', 'install_base' ] -def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0, compress=None): +def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=None, + mode='w' +): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed @@ -426,7 +469,7 @@ mkpath(os.path.dirname(zip_filename), dry_run=dry_run) log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) - def visit (z, dirname, names): + def visit(z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): @@ -440,12 +483,10 @@ compression = [zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED][bool(compress)] if not dry_run: - z = zipfile.ZipFile(zip_filename, "w", compression=compression) + z = zipfile.ZipFile(zip_filename, mode, compression=compression) os.path.walk(base_dir, visit, z) z.close() else: os.path.walk(base_dir, visit, None) - return zip_filename - # 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 Fri Sep 22 02:03:56 2006 @@ -1550,10 +1550,10 @@ except os.error: onerror(os.rmdir, path, sys.exc_info()) - - - - +def bootstrap(): + # This function is called when setuptools*.egg is run using /bin/sh + import setuptools; argv0 = os.path.dirname(setuptools.__path__[0]) + sys.argv[0] = argv0; sys.argv.append(argv0); main() def main(argv=None, **kw): From python-checkins at python.org Fri Sep 22 02:09:11 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 22 Sep 2006 02:09:11 +0200 (CEST) Subject: [Python-checkins] r51969 - in sandbox/branches/setuptools-0.6: setup.py setuptools.egg-info/entry_points.txt setuptools.txt setuptools/command/bdist_egg.py setuptools/command/easy_install.py Message-ID: <20060922000911.AFE081E4004@bag.python.org> Author: phillip.eby Date: Fri Sep 22 02:09:06 2006 New Revision: 51969 Modified: sandbox/branches/setuptools-0.6/setup.py sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Add support for "eggsecutable" headers: a /bin/sh script that is prepended to an .egg file to allow it to be run as a script on Unix-ish platforms. (This is mainly so that setuptools itself can have a single-file installer on Unix, without doing multiple downloads, dealing with firewalls, etc.) (Backport from trunk) Modified: sandbox/branches/setuptools-0.6/setup.py ============================================================================== --- sandbox/branches/setuptools-0.6/setup.py (original) +++ sandbox/branches/setuptools-0.6/setup.py Fri Sep 22 02:09:06 2006 @@ -84,10 +84,13 @@ "easy_install = setuptools.command.easy_install:main", "easy_install-%s = setuptools.command.easy_install:main" % sys.version[:3] - ], + ], "setuptools.file_finders": - ["svn_cvs = setuptools.command.sdist:_default_revctrl"] + ["svn_cvs = setuptools.command.sdist:_default_revctrl"], + + "setuptools.installation": + ['eggsecutable = setuptools.command.easy_install:bootstrap'], }, classifiers = [f.strip() for f in """ @@ -118,6 +121,3 @@ - - - Modified: sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.egg-info/entry_points.txt Fri Sep 22 02:09:06 2006 @@ -30,6 +30,9 @@ easy_install = setuptools.command.easy_install:main easy_install-2.4 = setuptools.command.easy_install:main +[setuptools.installation] +eggsecutable = setuptools.command.easy_install:bootstrap + [distutils.commands] bdist_rpm = setuptools.command.bdist_rpm:bdist_rpm rotate = setuptools.command.rotate:rotate @@ -44,10 +47,10 @@ alias = setuptools.command.alias:alias easy_install = setuptools.command.easy_install:easy_install install_scripts = setuptools.command.install_scripts:install_scripts +bdist_wininst = setuptools.command.bdist_wininst:bdist_wininst bdist_egg = setuptools.command.bdist_egg:bdist_egg install = setuptools.command.install:install test = setuptools.command.test:test install_lib = setuptools.command.install_lib:install_lib build_ext = setuptools.command.build_ext:build_ext sdist = setuptools.command.sdist:sdist - Modified: sandbox/branches/setuptools-0.6/setuptools.txt ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools.txt (original) +++ sandbox/branches/setuptools-0.6/setuptools.txt Fri Sep 22 02:09:06 2006 @@ -498,6 +498,43 @@ Services and Plugins`_. +"Eggsecutable" Scripts +---------------------- + +Occasionally, there are situations where it's desirable to make an ``.egg`` +file directly executable. You can do this by including an entry point such +as the following:: + + setup( + # other arguments here... + entry_points = { + 'setuptools.installation': [ + 'eggsecutable = my_package.some_module:main_func', + ] + } + ) + +Any eggs built from the above setup script will include a short excecutable +prelude that imports and calls ``main_func()`` from ``my_package.some_module``. +The prelude can be run on Unix-like platforms (including Mac and Linux) by +invoking the egg with ``/bin/sh``, or by enabling execute permissions on the +``.egg`` file. For the executable prelude to run, the appropriate version of +Python must be available via the ``PATH`` environment variable, under its +"long" name. That is, if the egg is built for Python 2.3, there must be a +``python2.3`` executable present in a directory on ``PATH``. + +This feature is primarily intended to support bootstrapping the installation of +setuptools itself on non-Windows platforms, but may also be useful for other +projects as well. + +IMPORTANT NOTE: Eggs with an "eggsecutable" header cannot be renamed, or +invoked via symlinks. They *must* be invoked using their original filename, in +order to ensure that, once running, ``pkg_resources`` will know what project +and version is in use. The header script will check this and exit with an +error if the ``.egg`` file has been renamed or is invoked via a symlink that +changes its base name. + + Declaring Dependencies ====================== @@ -2567,6 +2604,12 @@ * Fix ``upload`` command not uploading files built by ``bdist_rpm`` or ``bdist_wininst`` under Python 2.3 and 2.4. + * Add support for "eggsecutable" headers: a ``#!/bin/sh`` script that is + prepended to an ``.egg`` file to allow it to be run as a script on Unix-ish + platforms. (This is mainly so that setuptools itself can have a single-file + installer on Unix, without doing multiple downloads, dealing with firewalls, + etc.) + 0.6c3 * Fixed breakages caused by Subversion 1.4's new "working copy" format Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py Fri Sep 22 02:09:06 2006 @@ -8,7 +8,9 @@ from distutils.dir_util import remove_tree, mkpath from distutils.sysconfig import get_python_version, get_python_lib from distutils import log +from distutils.errors import DistutilsSetupError from pkg_resources import get_build_platform, Distribution, ensure_directory +from pkg_resources import EntryPoint from types import CodeType from setuptools.extension import Library @@ -37,8 +39,6 @@ # stub __init__.py for packages distributed without one NS_PKG_STUB = '__import__("pkg_resources").declare_namespace(__name__)' - - class bdist_egg(Command): description = "create an \"egg\" distribution" @@ -233,7 +233,7 @@ # Make the archive make_zipfile(self.egg_output, archive_root, verbose=self.verbose, - dry_run=self.dry_run) + dry_run=self.dry_run, mode=self.gen_header()) if not self.keep_temp: remove_tree(self.bdist_dir, dry_run=self.dry_run) @@ -285,6 +285,47 @@ return init_files + def gen_header(self): + epm = EntryPoint.parse_map(self.distribution.entry_points or '') + ep = epm.get('setuptools.installation',{}).get('eggsecutable') + if ep is None: + return 'w' # not an eggsecutable, do it the usual way. + + if not ep.attrs or ep.extras: + raise DistutilsSetupError( + "eggsecutable entry point (%r) cannot have 'extras' " + "or refer to a module" % (ep,) + ) + + pyver = sys.version[:3] + pkg = ep.module_name + full = '.'.join(ep.attrs) + base = ep.attrs[0] + basename = os.path.basename(self.egg_output) + + header = ( + "#!/bin/sh\n" + 'if [[ `basename $0` = "%(basename)s" ]]\n' + 'then exec python%(pyver)s -c "' + "import sys, os; sys.path.insert(0, os.path.abspath('$0')); " + "from %(pkg)s import %(base)s; sys.exit(%(full)s())" + '" "$@"\n' + 'else\n' + ' echo $0 is not the correct name for this egg file.\n' + ' echo Please rename it back to %(basename)s and try again.\n' + ' exec false\n' + 'fi\n' + + ) % locals() + + if not self.dry_run: + f = open(self.egg_output, 'w') + f.write(header) + f.close() + return 'a' + + + def copy_metadata_to(self, target_dir): prefix = os.path.join(self.egg_info,'') for path in self.ei_cmd.filelist.files: @@ -415,7 +456,9 @@ 'install_lib', 'install_dir', 'install_data', 'install_base' ] -def make_zipfile (zip_filename, base_dir, verbose=0, dry_run=0, compress=None): +def make_zipfile(zip_filename, base_dir, verbose=0, dry_run=0, compress=None, + mode='w' +): """Create a zip file from all the files under 'base_dir'. The output zip file will be named 'base_dir' + ".zip". Uses either the "zipfile" Python module (if available) or the InfoZIP "zip" utility (if installed @@ -426,7 +469,7 @@ mkpath(os.path.dirname(zip_filename), dry_run=dry_run) log.info("creating '%s' and adding '%s' to it", zip_filename, base_dir) - def visit (z, dirname, names): + def visit(z, dirname, names): for name in names: path = os.path.normpath(os.path.join(dirname, name)) if os.path.isfile(path): @@ -440,12 +483,10 @@ compression = [zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED][bool(compress)] if not dry_run: - z = zipfile.ZipFile(zip_filename, "w", compression=compression) + z = zipfile.ZipFile(zip_filename, mode, compression=compression) os.path.walk(base_dir, visit, z) z.close() else: os.path.walk(base_dir, visit, None) - return zip_filename - # 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 Fri Sep 22 02:09:06 2006 @@ -1550,10 +1550,10 @@ except os.error: onerror(os.rmdir, path, sys.exc_info()) - - - - +def bootstrap(): + # This function is called when setuptools*.egg is run using /bin/sh + import setuptools; argv0 = os.path.dirname(setuptools.__path__[0]) + sys.argv[0] = argv0; sys.argv.append(argv0); main() def main(argv=None, **kw): From buildbot at python.org Fri Sep 22 02:23:42 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Sep 2006 00:23:42 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060922002342.DD8651E4004@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/34 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release25-maint] HEAD Blamelist: jack.diederich Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri Sep 22 06:54:25 2006 From: python-checkins at python.org (fred.drake) Date: Fri, 22 Sep 2006 06:54:25 +0200 (CEST) Subject: [Python-checkins] r51970 - peps/trunk/pep-0101.txt Message-ID: <20060922045425.73A041E4004@bag.python.org> Author: fred.drake Date: Fri Sep 22 06:54:25 2006 New Revision: 51970 Modified: peps/trunk/pep-0101.txt Log: at least get the doc locations right Modified: peps/trunk/pep-0101.txt ============================================================================== --- peps/trunk/pep-0101.txt (original) +++ peps/trunk/pep-0101.txt Fri Sep 22 06:54:25 2006 @@ -298,13 +298,13 @@ $ cvs commit -m \ "Add website content for Python $VERSION documentation." - Log into creosote.python.org using SSH and unpack a copy of the + Log into dinsdale.python.org using SSH and unpack a copy of the documentation into place: - # on creosote: - $ cd /ftp/www.python.org/doc - $ tar xjf \ - /ftp/ftp.python.org/pub/python/doc/$VERSION/html-$VERSION.tar.bz2 + # on dinsdale: + $ cd /data/ftp.python.org/pub/www.python.org/doc + $ bzip2 -dc /data/python-releases/doc/$VERSION/html-$VERSION.tar.bz2 \ + | tar xf - $ mv Python-Docs-$VERSION $VERSION $ find $VERSION -type d | xargs chmod g+s From python-checkins at python.org Fri Sep 22 10:16:27 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 22 Sep 2006 10:16:27 +0200 (CEST) Subject: [Python-checkins] r51971 - in python/trunk: Include/pyport.h Misc/NEWS configure configure.in Message-ID: <20060922081627.B97041E4004@bag.python.org> Author: neal.norwitz Date: Fri Sep 22 10:16:26 2006 New Revision: 51971 Modified: python/trunk/Include/pyport.h python/trunk/Misc/NEWS python/trunk/configure python/trunk/configure.in Log: Fix %zd string formatting on Mac OS X so it prints negative numbers. In addition to testing positive numbers, verify negative numbers work in configure. In order to avoid compiler warnings on OS X 10.4, also change the order of the check for the format character to use (PY_FORMAT_SIZE_T) in the sprintf format for Py_ssize_t. This patch changes PY_FORMAT_SIZE_T from "" to "l" if it wasn't defined at configure time. Need to verify the buildbot results. Backport candidate (if everyone thinks this patch can't be improved). Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Fri Sep 22 10:16:26 2006 @@ -126,10 +126,10 @@ * Py_ssize_t on the platform. */ #ifndef PY_FORMAT_SIZE_T -# if SIZEOF_SIZE_T == SIZEOF_INT -# define PY_FORMAT_SIZE_T "" -# elif SIZEOF_SIZE_T == SIZEOF_LONG +# if SIZEOF_SIZE_T == SIZEOF_LONG # define PY_FORMAT_SIZE_T "l" +# elif SIZEOF_SIZE_T == SIZEOF_INT +# define PY_FORMAT_SIZE_T "" # elif defined(MS_WINDOWS) # define PY_FORMAT_SIZE_T "I" # else Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Sep 22 10:16:26 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Fix %zd string formatting on Mac OS X so it prints negative numbers. + - Allow exception instances to be directly sliced again. - Bug #1551432: Exceptions do not define an explicit __unicode__ method. This Modified: python/trunk/configure ============================================================================== --- python/trunk/configure (original) +++ python/trunk/configure Fri Sep 22 10:16:26 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 51173 . +# From configure.in Revision: 51727 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.6. # @@ -22110,12 +22110,26 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) return 1; return 0; Modified: python/trunk/configure.in ============================================================================== --- python/trunk/configure.in (original) +++ python/trunk/configure.in Fri Sep 22 10:16:26 2006 @@ -3352,14 +3352,28 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) return 1; - + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) + return 1; + return 0; }], [AC_MSG_RESULT(yes) From python-checkins at python.org Fri Sep 22 10:18:11 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 22 Sep 2006 10:18:11 +0200 (CEST) Subject: [Python-checkins] r51972 - in python/trunk: Lib/test/test_complex_args.py Misc/NEWS Python/ast.c Message-ID: <20060922081811.0BAF91E4004@bag.python.org> Author: neal.norwitz Date: Fri Sep 22 10:18:10 2006 New Revision: 51972 Added: python/trunk/Lib/test/test_complex_args.py (contents, props changed) Modified: python/trunk/Misc/NEWS python/trunk/Python/ast.c Log: Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). These tests should be improved. Hopefully this fixes variations when flipping back and forth between fpdef and fplist. Backport candidate. Added: python/trunk/Lib/test/test_complex_args.py ============================================================================== --- (empty file) +++ python/trunk/Lib/test/test_complex_args.py Fri Sep 22 10:18:10 2006 @@ -0,0 +1,91 @@ + +import unittest +from test import test_support + +class ComplexArgsTestCase(unittest.TestCase): + + def check(self, func, expected, *args): + self.assertEqual(func(*args), expected) + + # These functions are tested below as lambdas too. If you add a function test, + # also add a similar lambda test. + + def test_func_parens_no_unpacking(self): + def f(((((x))))): return x + self.check(f, 1, 1) + # Inner parens are elided, same as: f(x,) + def f(((x)),): return x + self.check(f, 2, 2) + + def test_func_1(self): + def f(((((x),)))): return x + self.check(f, 3, (3,)) + def f(((((x)),))): return x + self.check(f, 4, (4,)) + def f(((((x))),)): return x + self.check(f, 5, (5,)) + def f(((x),)): return x + self.check(f, 6, (6,)) + + def test_func_2(self): + def f(((((x)),),)): return x + self.check(f, 2, ((2,),)) + + def test_func_3(self): + def f((((((x)),),),)): return x + self.check(f, 3, (((3,),),)) + + def test_func_complex(self): + def f((((((x)),),),), a, b, c): return x, a, b, c + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + def f(((((((x)),)),),), a, b, c): return x, a, b, c + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + def f(a, b, c, ((((((x)),)),),)): return a, b, c, x + self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),)) + + # Duplicate the tests above, but for lambda. If you add a lambda test, + # also add a similar function test above. + + def test_lambda_parens_no_unpacking(self): + f = lambda (((((x))))): x + self.check(f, 1, 1) + # Inner parens are elided, same as: f(x,) + f = lambda ((x)),: x + self.check(f, 2, 2) + + def test_lambda_1(self): + f = lambda (((((x),)))): x + self.check(f, 3, (3,)) + f = lambda (((((x)),))): x + self.check(f, 4, (4,)) + f = lambda (((((x))),)): x + self.check(f, 5, (5,)) + f = lambda (((x),)): x + self.check(f, 6, (6,)) + + def test_lambda_2(self): + f = lambda (((((x)),),)): x + self.check(f, 2, ((2,),)) + + def test_lambda_3(self): + f = lambda ((((((x)),),),)): x + self.check(f, 3, (((3,),),)) + + def test_lambda_complex(self): + f = lambda (((((x)),),),), a, b, c: (x, a, b, c) + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + f = lambda ((((((x)),)),),), a, b, c: (x, a, b, c) + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + f = lambda a, b, c, ((((((x)),)),),): (a, b, c, x) + self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),)) + + +def test_main(): + test_support.run_unittest(ComplexArgsTestCase) + +if __name__ == "__main__": + test_main() Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Fri Sep 22 10:18:10 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). + - Fix %zd string formatting on Mac OS X so it prints negative numbers. - Allow exception instances to be directly sliced again. Modified: python/trunk/Python/ast.c ============================================================================== --- python/trunk/Python/ast.c (original) +++ python/trunk/Python/ast.c Fri Sep 22 10:18:10 2006 @@ -560,10 +560,17 @@ if (!args) return NULL; + /* fpdef: NAME | '(' fplist ')' + fplist: fpdef (',' fpdef)* [','] + */ REQ(n, fplist); for (i = 0; i < len; i++) { - const node *child = CHILD(CHILD(n, 2*i), 0); + const node *fpdef_node = CHILD(n, 2*i); + const node *child; expr_ty arg; +set_name: + /* fpdef_node is either a NAME or an fplist */ + child = CHILD(fpdef_node, 0); if (TYPE(child) == NAME) { if (!strcmp(STR(child), "None")) { ast_error(child, "assignment to None"); @@ -573,7 +580,17 @@ child->n_col_offset, c->c_arena); } else { - arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); + assert(TYPE(fpdef_node) == fpdef); + /* fpdef_node[0] is not a name, so it must be a '(', get CHILD[1] */ + child = CHILD(fpdef_node, 1); + assert(TYPE(child) == fplist); + /* NCH == 1 means we have (x), we need to elide the extra parens */ + if (NCH(child) == 1) { + fpdef_node = CHILD(child, 0); + assert(TYPE(fpdef_node) == fpdef); + goto set_name; + } + arg = compiler_complex_args(c, child); } asdl_seq_SET(args, i, arg); } @@ -631,6 +648,7 @@ ch = CHILD(n, i); switch (TYPE(ch)) { case fpdef: + handle_fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ /* XXX Should NCH(n) check be made a separate check? */ @@ -656,7 +674,11 @@ asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); } else { /* def foo((x)): setup for checking NAME below. */ + /* Loop because there can be many parens and tuple + unpacking mixed in. */ ch = CHILD(ch, 0); + assert(TYPE(ch) == fpdef); + goto handle_fpdef; } } if (TYPE(CHILD(ch, 0)) == NAME) { From python-checkins at python.org Fri Sep 22 10:22:18 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 10:22:18 +0200 (CEST) Subject: [Python-checkins] r51973 - python/branches/theller_modulefinder Message-ID: <20060922082218.B199B1E4004@bag.python.org> Author: thomas.heller Date: Fri Sep 22 10:22:18 2006 New Revision: 51973 Added: python/branches/theller_modulefinder/ - copied from r51972, python/trunk/ Log: Creating a branch to work on modulefinder From python-checkins at python.org Fri Sep 22 10:31:53 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 10:31:53 +0200 (CEST) Subject: [Python-checkins] r51974 - python/branches/theller_modulefinder Message-ID: <20060922083153.6A9FA1E4006@bag.python.org> Author: thomas.heller Date: Fri Sep 22 10:31:53 2006 New Revision: 51974 Modified: python/branches/theller_modulefinder/ (props changed) Log: Initialized merge tracking via "svnmerge" with revisions "1-51972" from svn+ssh://pythondev at svn.python.org/python/trunk From python-checkins at python.org Fri Sep 22 10:47:23 2006 From: python-checkins at python.org (neal.norwitz) Date: Fri, 22 Sep 2006 10:47:23 +0200 (CEST) Subject: [Python-checkins] r51975 - python/trunk/Include/pyport.h Message-ID: <20060922084723.E18FC1E4006@bag.python.org> Author: neal.norwitz Date: Fri Sep 22 10:47:23 2006 New Revision: 51975 Modified: python/trunk/Include/pyport.h Log: Mostly revert this file to the same version as before. Only force setting of PY_FORMAT_SIZE_T to "l" for Mac OSX. I don't know a better define to use. This should get rid of the warnings on other platforms and Mac too. Modified: python/trunk/Include/pyport.h ============================================================================== --- python/trunk/Include/pyport.h (original) +++ python/trunk/Include/pyport.h Fri Sep 22 10:47:23 2006 @@ -126,10 +126,10 @@ * Py_ssize_t on the platform. */ #ifndef PY_FORMAT_SIZE_T -# if SIZEOF_SIZE_T == SIZEOF_LONG -# define PY_FORMAT_SIZE_T "l" -# elif SIZEOF_SIZE_T == SIZEOF_INT +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) # define PY_FORMAT_SIZE_T "" +# elif SIZEOF_SIZE_T == SIZEOF_LONG +# define PY_FORMAT_SIZE_T "l" # elif defined(MS_WINDOWS) # define PY_FORMAT_SIZE_T "I" # else From python-checkins at python.org Fri Sep 22 11:06:50 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 11:06:50 +0200 (CEST) Subject: [Python-checkins] r51976 - python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Message-ID: <20060922090650.AFA061E4006@bag.python.org> Author: thomas.heller Date: Fri Sep 22 11:06:50 2006 New Revision: 51976 Added: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py (contents, props changed) Log: A basic test for modulefinder. Added: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py ============================================================================== --- (empty file) +++ python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Fri Sep 22 11:06:50 2006 @@ -0,0 +1,85 @@ +import __future__ +import sys, os +import unittest +import modulefinder +import distutils.dir_util + +from test import test_support + +# FIXME: do NOT create files in the current directory +TEST_DIR = os.path.abspath("testing") +TEST_PATH = [TEST_DIR, os.path.dirname(__future__.__file__)] + +# Each test description is a list of 4 items: +# +# 1. a module name that will be imported by modulefinder +# 2. a list of module names that modulefinder is required to find +# 3. a list of module names that modulefinder should complain +# about because they are not found +# 4. a string specifying a package to create; the format is obvious imo. +# +# Each package will be created in TEST_DIR, and TEST_DIR will be +# removed after the tests again. +# Modulefinder searches in a path that contains TEST_DIR, plus +# the standard Lib directory. + +package_test = [ + "a.module", + ["a", "a.b", "a.c", "a.module", "sys", "mymodule"], + ["blahblah"], + """\ +mymodule.py +a/__init__.py + import blahblah + from a import b + import c +a/module.py + import sys + from a import b as x +a/b.py +a/c.py + from a.module import x + import mymodule +"""] + +def open_file(path): + ##print "#", os.path.abspath(path) + dirname = os.path.dirname(path) + distutils.dir_util.mkpath(dirname) + return open(path, "w") + +def create_package(source): + ofi = None + for line in source.splitlines(): + if line.startswith(" ") or line.startswith("\t"): + ofi.write(line.strip() + "\n") + else: + ofi = open_file(os.path.join(TEST_DIR, line.strip())) + +class ModuleFinderTest(unittest.TestCase): + def _do_test(self, info): + import_this, modules, missing, source = info + directory = import_this.split(".")[0] + create_package(source) + try: + mf = modulefinder.ModuleFinder(path=TEST_PATH) + mf.import_hook(import_this) +## mf.report() + bad = mf.badmodules.keys() + self.failUnlessEqual(bad, missing) + modules = set(modules) + found = set(mf.modules.keys()) + more = list(found - modules) + less = list(modules - found) + self.failUnlessEqual((more, less), ([], [])) + finally: + distutils.dir_util.remove_tree(TEST_DIR) + + def test_package(self): + self._do_test(package_test) + +def test_main(): + test_support.run_unittest(ModuleFinderTest) + +if __name__ == "__main__": + test_main() From python-checkins at python.org Fri Sep 22 12:01:44 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 12:01:44 +0200 (CEST) Subject: [Python-checkins] r51977 - python/branches/theller_modulefinder/Lib/modulefinder.py Message-ID: <20060922100144.1DB9C1E4015@bag.python.org> Author: thomas.heller Date: Fri Sep 22 12:01:43 2006 New Revision: 51977 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py Log: Refactor the opcode decoding in scan_code() into a separate generator which should make it easier to provide different decoding for Python 2.5 and later, where IMPORT_NAME takes two arguments instead of one. Decode the opcode arguments with struct.unpack which is a lot faster. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 12:01:43 2006 @@ -8,6 +8,7 @@ import os import sys import new +import struct if hasattr(sys.__stdout__, "newlines"): READ_MODE = "U" # universal line endings @@ -15,11 +16,12 @@ # remain compatible with Python < 2.3 READ_MODE = "r" -LOAD_CONST = dis.opname.index('LOAD_CONST') -IMPORT_NAME = dis.opname.index('IMPORT_NAME') -STORE_NAME = dis.opname.index('STORE_NAME') -STORE_GLOBAL = dis.opname.index('STORE_GLOBAL') +LOAD_CONST = chr(dis.opname.index('LOAD_CONST')) +IMPORT_NAME = chr(dis.opname.index('IMPORT_NAME')) +STORE_NAME = chr(dis.opname.index('STORE_NAME')) +STORE_GLOBAL = chr(dis.opname.index('STORE_GLOBAL')) STORE_OPS = [STORE_NAME, STORE_GLOBAL] +HAVE_ARGUMENT = chr(dis.HAVE_ARGUMENT) # Modulefinder does a good job at simulating Python's, but it can not # handle __path__ modifications packages make at runtime. Therefore there @@ -317,26 +319,38 @@ fullname = name + "." + sub self._add_badmodule(fullname, caller) + def yield_opcodes(self, co, + unpack = struct.unpack): + # Scan the code, and yield 'interesting' opcode combinations + code = co.co_code + names = co.co_names + consts = co.co_consts + LOAD_AND_IMPORT = LOAD_CONST + IMPORT_NAME + while code: + c = code[0] + if c in STORE_OPS: + oparg, = unpack('= HAVE_ARGUMENT: + code = code[3:] + else: + code = code[1:] + def scan_code(self, co, m): code = co.co_code - n = len(code) - i = 0 - fromlist = None - while i < n: - c = code[i] - i = i+1 - op = ord(c) - if op >= dis.HAVE_ARGUMENT: - oparg = ord(code[i]) + ord(code[i+1])*256 - i = i+2 - if op == LOAD_CONST: - # An IMPORT_NAME is always preceded by a LOAD_CONST, it's - # a tuple of "from" names, or None for a regular import. - # The tuple may contain "*" for "from import *" - fromlist = co.co_consts[oparg] - elif op == IMPORT_NAME: - assert fromlist is None or type(fromlist) is tuple - name = co.co_names[oparg] + for what, args in self.yield_opcodes(co): + if what == "store": + name, = args + m.globalnames[name] = 1 + elif what == "import": + fromlist, name = args have_star = 0 if fromlist is not None: if "*" in fromlist: @@ -362,10 +376,10 @@ m.starimports[name] = 1 else: m.starimports[name] = 1 - elif op in STORE_OPS: - # keep track of all global names that are assigned to - name = co.co_names[oparg] - m.globalnames[name] = 1 + else: + # We don't expect anything else from the generator. + raise RuntimeError(what) + for c in co.co_consts: if isinstance(c, type(co)): self.scan_code(c, m) From python-checkins at python.org Fri Sep 22 13:40:52 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 13:40:52 +0200 (CEST) Subject: [Python-checkins] r51978 - python/branches/theller_modulefinder/Lib/modulefinder.py Message-ID: <20060922114052.E7E381E4006@bag.python.org> Author: thomas.heller Date: Fri Sep 22 13:40:52 2006 New Revision: 51978 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py Log: Rename the yield_opcodes method into scan_opcodes, and implement a scan_opcodes_15 method that will be used in Python 2.5 and later with the two-arguments IMPORT_NAME opcode. The latter yields additional results: 'absolute_import' and 'relative_import', which are not yet supported in scan_code, but raise a runtime error instead of interpreting the bytecode as 'normal' import. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 13:40:52 2006 @@ -319,8 +319,8 @@ fullname = name + "." + sub self._add_badmodule(fullname, caller) - def yield_opcodes(self, co, - unpack = struct.unpack): + def scan_opcodes(self, co, + unpack = struct.unpack): # Scan the code, and yield 'interesting' opcode combinations code = co.co_code names = co.co_names @@ -343,9 +343,43 @@ else: code = code[1:] + def scan_opcodes_25(self, co, + unpack = struct.unpack): + # Scan the code, and yield 'interesting' opcode combinations + code = co.co_code + names = co.co_names + consts = co.co_consts + LOAD_LOAD_AND_IMPORT = LOAD_CONST + LOAD_CONST + IMPORT_NAME + while code: + c = code[0] + if c in STORE_OPS: + oparg, = unpack('= HAVE_ARGUMENT: + code = code[3:] + else: + code = code[1:] + def scan_code(self, co, m): code = co.co_code - for what, args in self.yield_opcodes(co): + if sys.version_info >= (2, 5): + scanner = self.scan_opcodes_25 + else: + scanner = self.scan_opcodes + for what, args in scanner(co): if what == "store": name, = args m.globalnames[name] = 1 @@ -376,6 +410,10 @@ m.starimports[name] = 1 else: m.starimports[name] = 1 + elif what == "absolute_import": + raise RuntimeError("absolute import not yet implemented") + elif what == "relative_import": + raise RuntimeError("relative import not yet implemented") else: # We don't expect anything else from the generator. raise RuntimeError(what) From python-checkins at python.org Fri Sep 22 13:59:40 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 13:59:40 +0200 (CEST) Subject: [Python-checkins] r51979 - python/branches/theller_modulefinder/Lib/modulefinder.py Message-ID: <20060922115940.F27DF1E4012@bag.python.org> Author: thomas.heller Date: Fri Sep 22 13:59:40 2006 New Revision: 51979 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py Log: Reenable Python 2.2 comatibility. Raise NotImplementedError instead of RuntimeError on absolute or relative imports. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 13:59:40 2006 @@ -1,7 +1,7 @@ """Find modules used by a script, using introspection.""" - # This module should be kept compatible with Python 2.2, see PEP 291. +from __future__ import generators import dis import imp import marshal @@ -325,7 +325,6 @@ code = co.co_code names = co.co_names consts = co.co_consts - LOAD_AND_IMPORT = LOAD_CONST + IMPORT_NAME while code: c = code[0] if c in STORE_OPS: @@ -333,7 +332,7 @@ yield "store", (names[oparg],) code = code[3:] continue - if code[:6:3] == LOAD_AND_IMPORT: + if c == LOAD_CONST and code[3] == IMPORT_NAME: oparg_1, oparg_2 = unpack(' Author: thomas.heller Date: Fri Sep 22 14:08:55 2006 New Revision: 51980 Modified: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Log: Add a test for absolute imports when they are available. The test currently fails with NotImplementedError in modulefinder. Modified: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/test/test_modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Fri Sep 22 14:08:55 2006 @@ -1,12 +1,20 @@ import __future__ import sys, os import unittest -import modulefinder import distutils.dir_util from test import test_support -# FIXME: do NOT create files in the current directory +try: set +except NameError: from sets import Set as set + +import modulefinder + +# XXX To test modulefinder with Python 2.2, sets.py and +# modulefinder.py must be available - they are not in the standard +# library. + +# XXX FIXME: do NOT create files in the current directory TEST_DIR = os.path.abspath("testing") TEST_PATH = [TEST_DIR, os.path.dirname(__future__.__file__)] @@ -25,7 +33,7 @@ package_test = [ "a.module", - ["a", "a.b", "a.c", "a.module", "sys", "mymodule"], + ["a", "a.b", "a.c", "a.module", "mymodule", "sys"], ["blahblah"], """\ mymodule.py @@ -42,6 +50,38 @@ import mymodule """] +absolute_import_test = [ + "a.module", + ["a", "a.module", + "b", "b.x", "b.y", "b.z", + "__future__", "sys", "time"], + ["blahblah"], + """\ +mymodule.py +a/__init__.py +a/module.py + from __future__ import absolute_import + import sys # this is a.sys + import blahblah # fails + import time # this is NOT a.time + import b.x # this is NOT a.b.x + from b import y + from b.z import * +a/time.py +a/sys.py + import mymodule +a/b/__init__.py +a/b/x.py +a/b/y.py +a/b/z.py +b/__init__.py + import z +b/unused.py +b/x.py +b/y.py +b/z.py +"""] + def open_file(path): ##print "#", os.path.abspath(path) dirname = os.path.dirname(path) @@ -59,27 +99,41 @@ class ModuleFinderTest(unittest.TestCase): def _do_test(self, info): import_this, modules, missing, source = info - directory = import_this.split(".")[0] create_package(source) try: mf = modulefinder.ModuleFinder(path=TEST_PATH) mf.import_hook(import_this) ## mf.report() - bad = mf.badmodules.keys() - self.failUnlessEqual(bad, missing) modules = set(modules) found = set(mf.modules.keys()) more = list(found - modules) less = list(modules - found) + # check if we found what we expected, not more, not less self.failUnlessEqual((more, less), ([], [])) + + # check if missing modules are reported correctly + bad = mf.badmodules.keys() + self.failUnlessEqual(bad, missing) finally: distutils.dir_util.remove_tree(TEST_DIR) def test_package(self): self._do_test(package_test) + if getattr(__future__, "absolute_import", None): + + def test_absolute_imports(self): + import_this, modules, missing, source = absolute_import_test + create_package(source) + try: + mf = modulefinder.ModuleFinder(path=TEST_PATH) + self.assertRaises(NotImplementedError, + lambda: mf.import_hook(import_this)) + finally: + distutils.dir_util.remove_tree(TEST_DIR) + def test_main(): test_support.run_unittest(ModuleFinderTest) if __name__ == "__main__": - test_main() + unittest.main() From buildbot at python.org Fri Sep 22 14:11:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 22 Sep 2006 12:11:52 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060922121152.C70D01E4006@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/568 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 Fri Sep 22 14:27:38 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 14:27:38 +0200 (CEST) Subject: [Python-checkins] r51981 - in python/branches/theller_modulefinder/Lib: modulefinder.py test/test_modulefinder.py Message-ID: <20060922122738.983791E4015@bag.python.org> Author: thomas.heller Date: Fri Sep 22 14:27:37 2006 New Revision: 51981 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Log: Preliminary implementation of absolute imports in modulefinder by adding a 'level' argument to _safe_import_hook and import_hook. The absolute_import_test now succeeds. Added a relative_import_test which fails with NotImplementedError. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 14:27:37 2006 @@ -120,9 +120,12 @@ stuff = (ext, "r", imp.PY_SOURCE) self.load_module(name, fp, pathname, stuff) - def import_hook(self, name, caller=None, fromlist=None): - self.msg(3, "import_hook", name, caller, fromlist) - parent = self.determine_parent(caller) + def import_hook(self, name, caller=None, fromlist=None, level=-1): + self.msg(3, "import_hook", name, caller, fromlist, level) + if level == 0: # absolute import + parent = None + else: + parent = self.determine_parent(caller) q, tail = self.find_head_package(parent, name) m = self.load_tail(q, tail) if not fromlist: @@ -296,13 +299,13 @@ self.badmodules[name] = {} self.badmodules[name][caller.__name__] = 1 - def _safe_import_hook(self, name, caller, fromlist): + def _safe_import_hook(self, name, caller, fromlist, level=-1): # wrapper for self.import_hook() that won't raise ImportError if name in self.badmodules: self._add_badmodule(name, caller) return try: - self.import_hook(name, caller) + self.import_hook(name, caller, level=level) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) self._add_badmodule(name, caller) @@ -313,7 +316,7 @@ self._add_badmodule(sub, caller) continue try: - self.import_hook(name, caller, [sub]) + self.import_hook(name, caller, [sub], level=level) except ImportError, msg: self.msg(2, "ImportError:", str(msg)) fullname = name + "." + sub @@ -410,7 +413,10 @@ else: m.starimports[name] = 1 elif what == "absolute_import": - raise NotImplementedError("absolute import not yet implemented") + fromlist, name = args + # XXX code missing, see above + self._safe_import_hook(name, m, fromlist, level=0) + # XXX code missing, see above elif what == "relative_import": raise NotImplementedError("relative import not yet implemented") else: Modified: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/test/test_modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Fri Sep 22 14:27:37 2006 @@ -44,10 +44,11 @@ a/module.py import sys from a import b as x + from a.c import sillyname a/b.py a/c.py from a.module import x - import mymodule + import mymodule as sillyname """] absolute_import_test = [ @@ -82,6 +83,37 @@ b/z.py """] +relative_import_test = [ + "a.module", + ["a", "a.module", + "b", "b.x", "b.y", "b.z", + "__future__", "sys", "time"], + ["blahblah"], + """\ +mymodule.py +a/__init__.py +a/module.py + from __future__ import absolute_import + import sys # this is a.sys + import blahblah # fails + import time # this is NOT a.time + from . import x # this is a.b.x + from .b import y, z +a/time.py +a/sys.py + import mymodule +a/b/__init__.py +a/b/x.py +a/b/y.py +a/b/z.py +b/__init__.py + import z +b/unused.py +b/x.py +b/y.py +b/z.py +"""] + def open_file(path): ##print "#", os.path.abspath(path) dirname = os.path.dirname(path) @@ -123,7 +155,10 @@ if getattr(__future__, "absolute_import", None): def test_absolute_imports(self): - import_this, modules, missing, source = absolute_import_test + self._do_test(absolute_import_test) + + def test_relative_imports(self): + import_this, modules, missing, source = relative_import_test create_package(source) try: mf = modulefinder.ModuleFinder(path=TEST_PATH) From fdrake at acm.org Fri Sep 22 14:44:55 2006 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 22 Sep 2006 08:44:55 -0400 Subject: [Python-checkins] [Python-Dev] release25-maint is UNFROZEN In-Reply-To: <20060921123510.GA22457@code0.codespeak.net> References: <200609212112.04923.anthony@interlink.com.au> <20060921123510.GA22457@code0.codespeak.net> Message-ID: <200609220844.55724.fdrake@acm.org> On Thursday 21 September 2006 08:35, Armin Rigo wrote: > Thanks for the hassle! I've got another bit of it for you, though. The > freezed 2.5 documentation doesn't seem to be available on-line. At > least, the doc links from the release page point to the 'dev' 2.6a0 > version, and the URL following the common scheme - > http://www.python.org/doc/2.5/ - doesn't work. This should mostly be working now. The page at www.python.org/doc/2.5/ isn't "really" right, but will do the trick. Hopefully I'll be able to work out how these pages should be updated properly at the Arlington sprint this weekend, at which point I can update PEP 101 appropriately and make sure this gets done when releases are made. -Fred -- Fred L. Drake, Jr. From python-checkins at python.org Fri Sep 22 16:41:31 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 16:41:31 +0200 (CEST) Subject: [Python-checkins] r51982 - in python/branches/theller_modulefinder/Lib: modulefinder.py test/test_modulefinder.py Message-ID: <20060922144131.306B41E4019@bag.python.org> Author: thomas.heller Date: Fri Sep 22 16:41:30 2006 New Revision: 51982 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Log: Partial progress with relative imports. 'from ...x import y' seems to work, 'from ... import z' does not. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 16:41:30 2006 @@ -122,10 +122,7 @@ def import_hook(self, name, caller=None, fromlist=None, level=-1): self.msg(3, "import_hook", name, caller, fromlist, level) - if level == 0: # absolute import - parent = None - else: - parent = self.determine_parent(caller) + parent = self.determine_parent(caller, level=level) q, tail = self.find_head_package(parent, name) m = self.load_tail(q, tail) if not fromlist: @@ -134,12 +131,21 @@ self.ensure_fromlist(m, fromlist) return None - def determine_parent(self, caller): - self.msgin(4, "determine_parent", caller) - if not caller: + def determine_parent(self, caller, level=-1): + self.msgin(4, "determine_parent", caller, level) + if not caller or level == 0: self.msgout(4, "determine_parent -> None") return None pname = caller.__name__ + if level >= 1: + if caller.__path__: + level -= 1 + if pname.count(".") < level: + raise ImportError, "relative importpath too deep" + pname = ".".join(pname.split(".")[:-level]) + parent = self.modules[pname] + self.msgout(4, "determine_parent ->", parent) + return parent if caller.__path__: parent = self.modules[pname] assert caller is parent @@ -325,6 +331,7 @@ def scan_opcodes(self, co, unpack = struct.unpack): # Scan the code, and yield 'interesting' opcode combinations + # Version for Python 2.4 and older code = co.co_code names = co.co_names consts = co.co_consts @@ -348,6 +355,7 @@ def scan_opcodes_25(self, co, unpack = struct.unpack): # Scan the code, and yield 'interesting' opcode combinations + # Python 2.5 version (has absolute and relative imports) code = co.co_code names = co.co_names consts = co.co_consts @@ -418,7 +426,9 @@ self._safe_import_hook(name, m, fromlist, level=0) # XXX code missing, see above elif what == "relative_import": - raise NotImplementedError("relative import not yet implemented") + level, fromlist, name = args + # XXX code missing, see above + self._safe_import_hook(name, m, fromlist, level=level) else: # We don't expect anything else from the generator. raise RuntimeError(what) Modified: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/test/test_modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Fri Sep 22 16:41:30 2006 @@ -55,20 +55,20 @@ "a.module", ["a", "a.module", "b", "b.x", "b.y", "b.z", - "__future__", "sys", "time"], + "__future__", "sys", "exceptions"], ["blahblah"], """\ mymodule.py a/__init__.py a/module.py from __future__ import absolute_import - import sys # this is a.sys + import sys # sys import blahblah # fails - import time # this is NOT a.time - import b.x # this is NOT a.b.x - from b import y - from b.z import * -a/time.py + import exceptions # exceptions + import b.x # b.x + from b import y # b.y + from b.z import * # b.z.* +a/exceptions.py a/sys.py import mymodule a/b/__init__.py @@ -85,33 +85,41 @@ relative_import_test = [ "a.module", - ["a", "a.module", - "b", "b.x", "b.y", "b.z", - "__future__", "sys", "time"], - ["blahblah"], + ["__future__", + "a", "a.module", + "a.b", "a.b.y", "a.b.z", + "a.b.c", "a.b.c.moduleC", + "a.b.c.d", "a.b.c.e", + "exceptions"], + [], +# The 'from ... import name' constructs stil fail' """\ mymodule.py a/__init__.py + ##from . import sys # a.sys a/module.py - from __future__ import absolute_import - import sys # this is a.sys - import blahblah # fails - import time # this is NOT a.time - from . import x # this is a.b.x + from __future__ import absolute_import # __future__ + import exceptions # exceptions + #from . import x # a.x from .b import y, z -a/time.py + #from . import sys # a.sys +a/exceptions.py a/sys.py - import mymodule a/b/__init__.py + #from .c import moduleC + from a.b.c import moduleC a/b/x.py a/b/y.py a/b/z.py -b/__init__.py - import z -b/unused.py -b/x.py -b/y.py -b/z.py +a/b/c/__init__.py + from ..c import e # a.b.c.e +a/b/c/moduleC.py + # + #from .. import c + #from .. import x # a.b.x + from ..c import d # a.b.c.d +a/b/c/d.py +a/b/c/e.py """] def open_file(path): @@ -129,13 +137,23 @@ ofi = open_file(os.path.join(TEST_DIR, line.strip())) class ModuleFinderTest(unittest.TestCase): - def _do_test(self, info): + def _do_test(self, info, report=False): import_this, modules, missing, source = info create_package(source) try: mf = modulefinder.ModuleFinder(path=TEST_PATH) mf.import_hook(import_this) -## mf.report() + if report: + mf.report() + + opath = sys.path[:] + sys.path = TEST_PATH + try: + __import__(import_this) + except: + import traceback; traceback.print_exc() + sys.path = opath + modules = set(modules) found = set(mf.modules.keys()) more = list(found - modules) @@ -158,14 +176,7 @@ self._do_test(absolute_import_test) def test_relative_imports(self): - import_this, modules, missing, source = relative_import_test - create_package(source) - try: - mf = modulefinder.ModuleFinder(path=TEST_PATH) - self.assertRaises(NotImplementedError, - lambda: mf.import_hook(import_this)) - finally: - distutils.dir_util.remove_tree(TEST_DIR) + self._do_test(relative_import_test) def test_main(): test_support.run_unittest(ModuleFinderTest) From python-checkins at python.org Fri Sep 22 20:23:05 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 20:23:05 +0200 (CEST) Subject: [Python-checkins] r51983 - in python/branches/theller_modulefinder/Lib: modulefinder.py test/test_modulefinder.py Message-ID: <20060922182305.746781E4006@bag.python.org> Author: thomas.heller Date: Fri Sep 22 20:23:04 2006 New Revision: 51983 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Log: More progress with relative imports. 'from ...x import y' now works from inside an __init__.py file. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 20:23:04 2006 @@ -137,9 +137,14 @@ self.msgout(4, "determine_parent -> None") return None pname = caller.__name__ - if level >= 1: + if level >= 1: # relative import if caller.__path__: level -= 1 + if level == 0: + parent = self.modules[pname] + assert parent is caller + self.msgout(4, "determine_parent ->", parent) + return parent if pname.count(".") < level: raise ImportError, "relative importpath too deep" pname = ".".join(pname.split(".")[:-level]) Modified: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/test/test_modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Fri Sep 22 20:23:04 2006 @@ -90,36 +90,36 @@ "a.b", "a.b.y", "a.b.z", "a.b.c", "a.b.c.moduleC", "a.b.c.d", "a.b.c.e", + "a.b.x", "exceptions"], [], -# The 'from ... import name' constructs stil fail' """\ mymodule.py a/__init__.py - ##from . import sys # a.sys + from .b import y, z # a.b.y, a.b.z a/module.py from __future__ import absolute_import # __future__ import exceptions # exceptions - #from . import x # a.x - from .b import y, z - #from . import sys # a.sys a/exceptions.py a/sys.py a/b/__init__.py - #from .c import moduleC - from a.b.c import moduleC + from ..b import x # a.b.x + #from a.b.c import moduleC + from .c import moduleC # a.b.moduleC a/b/x.py + # Shouldn't this work? It doesn't seem to, + # in Python: + #from ..b import x a/b/y.py a/b/z.py +a/b/g.py a/b/c/__init__.py from ..c import e # a.b.c.e a/b/c/moduleC.py - # - #from .. import c - #from .. import x # a.b.x from ..c import d # a.b.c.d a/b/c/d.py a/b/c/e.py +a/b/c/x.py """] def open_file(path): From python-checkins at python.org Fri Sep 22 21:34:52 2006 From: python-checkins at python.org (thomas.heller) Date: Fri, 22 Sep 2006 21:34:52 +0200 (CEST) Subject: [Python-checkins] r51984 - in python/branches/theller_modulefinder/Lib: modulefinder.py test/test_modulefinder.py Message-ID: <20060922193452.A018E1E4006@bag.python.org> Author: thomas.heller Date: Fri Sep 22 21:34:51 2006 New Revision: 51984 Modified: python/branches/theller_modulefinder/Lib/modulefinder.py python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Log: Relative imports in the form 'from ... import name' now also work. Modified: python/branches/theller_modulefinder/Lib/modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/modulefinder.py Fri Sep 22 21:34:51 2006 @@ -427,13 +427,20 @@ m.starimports[name] = 1 elif what == "absolute_import": fromlist, name = args - # XXX code missing, see above + # XXX self._safe_import_hook(name, m, fromlist, level=0) - # XXX code missing, see above + # XXX elif what == "relative_import": level, fromlist, name = args - # XXX code missing, see above - self._safe_import_hook(name, m, fromlist, level=level) + # XXX + if name: + self._safe_import_hook(name, m, fromlist, level=level) + # XXX + else: + # XXX + parent = self.determine_parent(m, level=level) + self._safe_import_hook(parent.__name__, None, fromlist, level=0) + # XXX else: # We don't expect anything else from the generator. raise RuntimeError(what) Modified: python/branches/theller_modulefinder/Lib/test/test_modulefinder.py ============================================================================== --- python/branches/theller_modulefinder/Lib/test/test_modulefinder.py (original) +++ python/branches/theller_modulefinder/Lib/test/test_modulefinder.py Fri Sep 22 21:34:51 2006 @@ -107,9 +107,6 @@ #from a.b.c import moduleC from .c import moduleC # a.b.moduleC a/b/x.py - # Shouldn't this work? It doesn't seem to, - # in Python: - #from ..b import x a/b/y.py a/b/z.py a/b/g.py @@ -122,6 +119,45 @@ a/b/c/x.py """] +relative_import_test_2 = [ + "a.module", + ["a", "a.module", + "a.sys", + "a.b", "a.b.y", "a.b.z", + "a.b.c", "a.b.c.d", + "a.b.c.e", + "a.b.c.moduleC", + "a.b.c.f", + "a.b.x", + "a.another"], + [], + """\ +mymodule.py +a/__init__.py + from . import sys # a.sys +a/another.py +a/module.py + from .b import y, z # a.b.y, a.b.z +a/exceptions.py +a/sys.py +a/b/__init__.py + from .c import moduleC # a.b.c.moduleC + from .c import d # a.b.c.d +a/b/x.py +a/b/y.py +a/b/z.py +a/b/c/__init__.py + from . import e # a.b.c.e +a/b/c/moduleC.py + # + from . import f # a.b.c.f + from .. import x # a.b.x + from ... import another # a.another +a/b/c/d.py +a/b/c/e.py +a/b/c/f.py +"""] + def open_file(path): ##print "#", os.path.abspath(path) dirname = os.path.dirname(path) @@ -145,15 +181,15 @@ mf.import_hook(import_this) if report: mf.report() - - opath = sys.path[:] - sys.path = TEST_PATH - try: - __import__(import_this) - except: - import traceback; traceback.print_exc() - sys.path = opath - +## # This wouldn't work in general when executed several times: +## opath = sys.path[:] +## sys.path = TEST_PATH +## try: +## __import__(import_this) +## except: +## import traceback; traceback.print_exc() +## sys.path = opath +## return modules = set(modules) found = set(mf.modules.keys()) more = list(found - modules) @@ -178,6 +214,9 @@ def test_relative_imports(self): self._do_test(relative_import_test) + def test_relative_imports_2(self): + self._do_test(relative_import_test_2) + def test_main(): test_support.run_unittest(ModuleFinderTest) From python-checkins at python.org Fri Sep 22 22:10:38 2006 From: python-checkins at python.org (martin.v.loewis) Date: Fri, 22 Sep 2006 22:10:38 +0200 (CEST) Subject: [Python-checkins] r51985 - peps/trunk/pep-0353.txt Message-ID: <20060922201038.F0A381E4006@bag.python.org> Author: martin.v.loewis Date: Fri Sep 22 22:10:37 2006 New Revision: 51985 Modified: peps/trunk/pep-0353.txt Log: Guard definitions against redefinition. Proposed by David Abrahams. Modified: peps/trunk/pep-0353.txt ============================================================================== --- peps/trunk/pep-0353.txt (original) +++ peps/trunk/pep-0353.txt Fri Sep 22 22:10:37 2006 @@ -133,7 +133,7 @@ to ssizeargfunc). Compatibility with previous Python versions can be achieved with the test:: - #if PY_VERSION_HEX < 0x02050000 + #if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) typedef int Py_ssize_t; #define PY_SSIZE_T_MAX INT_MAX #define PY_SSIZE_T_MIN INT_MIN From python-checkins at python.org Sat Sep 23 02:26:32 2006 From: python-checkins at python.org (fred.drake) Date: Sat, 23 Sep 2006 02:26:32 +0200 (CEST) Subject: [Python-checkins] r51986 - in python/trunk/Doc: Makefile whatsnew/whatsnew26.tex Message-ID: <20060923002632.77F5C1E4006@bag.python.org> Author: fred.drake Date: Sat Sep 23 02:26:31 2006 New Revision: 51986 Added: python/trunk/Doc/whatsnew/whatsnew26.tex Modified: python/trunk/Doc/Makefile Log: add boilerplate "What's New" document so the docs will build Modified: python/trunk/Doc/Makefile ============================================================================== --- python/trunk/Doc/Makefile (original) +++ python/trunk/Doc/Makefile Sat Sep 23 02:26:31 2006 @@ -122,7 +122,7 @@ # The end of this should reflect the major/minor version numbers of # the release: -WHATSNEW=whatsnew25 +WHATSNEW=whatsnew26 # what's what MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ Added: python/trunk/Doc/whatsnew/whatsnew26.tex ============================================================================== --- (empty file) +++ python/trunk/Doc/whatsnew/whatsnew26.tex Sat Sep 23 02:26:31 2006 @@ -0,0 +1,134 @@ +\documentclass{howto} +\usepackage{distutils} +% $Id: whatsnew25.tex 37952 2004-12-03 13:54:09Z akuchling $ + + +\title{What's New in Python 2.6} +\release{0.0} +\author{A.M. Kuchling} +\authoraddress{\email{amk at amk.ca}} + +\begin{document} +\maketitle +\tableofcontents + +This article explains the new features in Python 2.6. No release date +for Python 2.6 has been set; it will probably be released in late 2007. + +% Compare with previous release in 2 - 3 sentences here. + +This article doesn't attempt to provide a complete specification of +the new features, but instead provides a convenient overview. For +full details, you should refer to the documentation for Python 2.6. +% add hyperlink when the documentation becomes available online. +If you want to understand the complete implementation and design +rationale, refer to the PEP for a particular new feature. + + +%====================================================================== + +% Large, PEP-level features and changes should be described here. + + +%====================================================================== +\section{Other Language Changes} + +Here are all of the changes that Python 2.6 makes to the core Python +language. + +\begin{itemize} +\item TBD + +\end{itemize} + + +%====================================================================== +\subsection{Optimizations} + +\begin{itemize} + +\item Optimizations should be described here. + +\end{itemize} + +The net result of the 2.6 optimizations is that Python 2.6 runs the +pystone benchmark around XX\% faster than Python 2.5. + + +%====================================================================== +\section{New, Improved, and Deprecated Modules} + +As usual, Python's standard library received a number of enhancements and +bug fixes. Here's a partial list of the most notable changes, sorted +alphabetically by module name. Consult the +\file{Misc/NEWS} file in the source tree for a more +complete list of changes, or look through the CVS logs for all the +details. + +\begin{itemize} + +\item Descriptions go here. + +\end{itemize} + + +%====================================================================== +% whole new modules get described in \subsections here + + +% ====================================================================== +\section{Build and C API Changes} + +Changes to Python's build process and to the C API include: + +\begin{itemize} + +\item Detailed changes are listed here. + +\end{itemize} + + +%====================================================================== +\subsection{Port-Specific Changes} + +Platform-specific changes go here. + + +%====================================================================== +\section{Other Changes and Fixes \label{section-other}} + +As usual, there were a bunch of other improvements and bugfixes +scattered throughout the source tree. A search through the change +logs finds there were XXX patches applied and YYY bugs fixed between +Python 2.5 and 2.6. Both figures are likely to be underestimates. + +Some of the more notable changes are: + +\begin{itemize} + +\item Details go here. + +\end{itemize} + + +%====================================================================== +\section{Porting to Python 2.6} + +This section lists previously described changes that may require +changes to your code: + +\begin{itemize} + +\item Everything is all in the details! + +\end{itemize} + + +%====================================================================== +\section{Acknowledgements \label{acks}} + +The author would like to thank the following people for offering +suggestions, corrections and assistance with various drafts of this +article: . + +\end{document} From python-checkins at python.org Sat Sep 23 06:11:40 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 23 Sep 2006 06:11:40 +0200 (CEST) Subject: [Python-checkins] r51987 - in python/trunk: Modules/almodule.c Modules/bz2module.c Python/pystate.c Message-ID: <20060923041140.3284C1E4002@bag.python.org> Author: neal.norwitz Date: Sat Sep 23 06:11:38 2006 New Revision: 51987 Modified: python/trunk/Modules/almodule.c python/trunk/Modules/bz2module.c python/trunk/Python/pystate.c Log: Remove extra semi-colons reported by Johnny Lee on python-dev. Backport if anyone cares. Modified: python/trunk/Modules/almodule.c ============================================================================== --- python/trunk/Modules/almodule.c (original) +++ python/trunk/Modules/almodule.c Sat Sep 23 06:11:38 2006 @@ -1686,7 +1686,7 @@ { int res, param; ALparamInfo pinfo; - PyObject *v, *item;; + PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; Modified: python/trunk/Modules/bz2module.c ============================================================================== --- python/trunk/Modules/bz2module.c (original) +++ python/trunk/Modules/bz2module.c Sat Sep 23 06:11:38 2006 @@ -1023,12 +1023,12 @@ case MODE_CLOSED: PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - goto cleanup;; + goto cleanup; default: PyErr_SetString(PyExc_IOError, "seek works only while reading"); - goto cleanup;; + goto cleanup; } if (where == 2) { Modified: python/trunk/Python/pystate.c ============================================================================== --- python/trunk/Python/pystate.c (original) +++ python/trunk/Python/pystate.c Sat Sep 23 06:11:38 2006 @@ -501,7 +501,7 @@ { PyThread_delete_key(autoTLSkey); autoTLSkey = 0; - autoInterpreterState = NULL;; + autoInterpreterState = NULL; } /* When a thread state is created for a thread by some mechanism other than From buildbot at python.org Sat Sep 23 07:06:52 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 23 Sep 2006 05:06:52 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060923050652.F2CE91E4002@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/1176 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: fred.drake,neal.norwitz Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 23 11:21:53 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 23 Sep 2006 09:21:53 +0000 Subject: [Python-checkins] buildbot failure in x86 OpenBSD trunk Message-ID: <20060923092153.C57211E4002@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/1289 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: The web-page 'force build' button was pressed by 'Talo': Talo Build Source Stamp: [branch Talo] Talo Blamelist: BUILD FAILED: failed svn sincerely, -The Buildbot From buildbot at python.org Sat Sep 23 14:46:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 23 Sep 2006 12:46:41 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060923124641.B6A281E4004@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/104 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,brett.cannon,fred.drake,georg.brandl,gregory.p.smith,jack.diederich,ka-ping.yee,martin.v.loewis,neal.norwitz,ronald.oussoren,walter.doerwald Build Had Warnings: warnings test sincerely, -The Buildbot From buildbot at python.org Sat Sep 23 15:35:32 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 23 Sep 2006 13:35:32 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.4 Message-ID: <20060923133532.562BF1E4002@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/11 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: gregory.p.smith Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat Sep 23 20:10:13 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 23 Sep 2006 20:10:13 +0200 (CEST) Subject: [Python-checkins] r51988 - python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex Message-ID: <20060923181013.C86361E4012@bag.python.org> Author: neal.norwitz Date: Sat Sep 23 20:10:12 2006 New Revision: 51988 Modified: python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex Log: SF Bug #1563963, add missing word and cleanup first sentance 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 Sat Sep 23 20:10:12 2006 @@ -540,10 +540,10 @@ StopIteration \end{verbatim} -Because \keyword{yield} will often be returning \constant{None}, you +\keyword{yield} will usually return \constant{None}, you should always check for this case. Don't just use its value in expressions unless you're sure that the \method{send()} method -will be the only method used resume your generator function. +will be the only method used to resume your generator function. In addition to \method{send()}, there are two other new methods on generators: From python-checkins at python.org Sat Sep 23 20:11:58 2006 From: python-checkins at python.org (neal.norwitz) Date: Sat, 23 Sep 2006 20:11:58 +0200 (CEST) Subject: [Python-checkins] r51989 - python/trunk/Doc/whatsnew/whatsnew25.tex Message-ID: <20060923181158.95A6D1E400F@bag.python.org> Author: neal.norwitz Date: Sat Sep 23 20:11:58 2006 New Revision: 51989 Modified: python/trunk/Doc/whatsnew/whatsnew25.tex Log: SF Bug #1563963, add missing word and cleanup first sentance Modified: python/trunk/Doc/whatsnew/whatsnew25.tex ============================================================================== --- python/trunk/Doc/whatsnew/whatsnew25.tex (original) +++ python/trunk/Doc/whatsnew/whatsnew25.tex Sat Sep 23 20:11:58 2006 @@ -540,10 +540,10 @@ StopIteration \end{verbatim} -Because \keyword{yield} will often be returning \constant{None}, you +\keyword{yield} will usually return \constant{None}, you should always check for this case. Don't just use its value in expressions unless you're sure that the \method{send()} method -will be the only method used resume your generator function. +will be the only method used to resume your generator function. In addition to \method{send()}, there are two other new methods on generators: From amk at amk.ca Sat Sep 23 20:47:33 2006 From: amk at amk.ca (A.M. Kuchling) Date: Sat, 23 Sep 2006 14:47:33 -0400 Subject: [Python-checkins] r51988 - python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex In-Reply-To: <20060923181013.C86361E4012@bag.python.org> References: <20060923181013.C86361E4012@bag.python.org> Message-ID: <20060923184733.GA13267@Andrew-iBook2.local> On Sat, Sep 23, 2006 at 08:10:13PM +0200, neal.norwitz wrote: > -Because \keyword{yield} will often be returning \constant{None}, you > should always check for this case. Don't just use its value in > +\keyword{yield} will usually return \constant{None}, you > should always check for this case. Don't just use its value in I don't think this change makes sense: the original sentence was 'Because , you should always '. Your change takes out 'Because', which I think breaks the sentence (it's now a run-on sentence). --amk From nnorwitz at gmail.com Sat Sep 23 20:55:21 2006 From: nnorwitz at gmail.com (Neal Norwitz) Date: Sat, 23 Sep 2006 11:55:21 -0700 Subject: [Python-checkins] r51988 - python/branches/release25-maint/Doc/whatsnew/whatsnew25.tex In-Reply-To: <20060923184733.GA13267@Andrew-iBook2.local> References: <20060923181013.C86361E4012@bag.python.org> <20060923184733.GA13267@Andrew-iBook2.local> Message-ID: On 9/23/06, A.M. Kuchling wrote: > On Sat, Sep 23, 2006 at 08:10:13PM +0200, neal.norwitz wrote: > > -Because \keyword{yield} will often be returning \constant{None}, you > > should always check for this case. Don't just use its value in > > > +\keyword{yield} will usually return \constant{None}, you > > should always check for this case. Don't just use its value in > > I don't think this change makes sense: the original sentence was > 'Because , you should always '. Your change > takes out 'Because', which I think breaks the sentence (it's now a > run-on sentence). If you take out the markup it is: yield will usually return None, you should always check for this case. The phrase before the comma can be a sentance on its own. As can the phrase after the comma. Perhaps the comma should be a semi-colon (or even a period). I don't really remember the definition of a run-on sentance, so it could be. :-) I was just trying to simplify the language. Also many people dislike beginning a sentance with 'because.' If you want to change it to something that's not a run-on, that's fine with me. n From python-checkins at python.org Sat Sep 23 21:53:21 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 23 Sep 2006 21:53:21 +0200 (CEST) Subject: [Python-checkins] r51990 - python/trunk/Lib/test/test_time.py Message-ID: <20060923195321.2CBA31E4002@bag.python.org> Author: brett.cannon Date: Sat Sep 23 21:53:20 2006 New Revision: 51990 Modified: python/trunk/Lib/test/test_time.py Log: Make output on test_strptime() be more verbose in face of failure. This is in hopes that more information will help debug the failing test on HPPA Ubuntu. Modified: python/trunk/Lib/test/test_time.py ============================================================================== --- python/trunk/Lib/test/test_time.py (original) +++ python/trunk/Lib/test/test_time.py Sat Sep 23 21:53:20 2006 @@ -102,15 +102,19 @@ self.assertEquals(expected, result) def test_strptime(self): + # Should be able to go round-trip from strftime to strptime without + # throwing an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): - format = ' %' + directive + format = '%' + directive + strf_output = time.strftime(format, tt) try: - time.strptime(time.strftime(format, tt), format) + time.strptime(strf_output, format) except ValueError: - self.fail('conversion specifier: %r failed.' % format) + self.fail("conversion specifier %r failed with '%s' input." % + (format, strf_output)) def test_asctime(self): time.asctime(time.gmtime(self.t)) From python-checkins at python.org Sun Sep 24 12:36:04 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 24 Sep 2006 12:36:04 +0200 (CEST) Subject: [Python-checkins] r51991 - in python/trunk: Lib/webbrowser.py Misc/NEWS Message-ID: <20060924103604.3E6B91E4004@bag.python.org> Author: georg.brandl Date: Sun Sep 24 12:36:01 2006 New Revision: 51991 Modified: python/trunk/Lib/webbrowser.py python/trunk/Misc/NEWS Log: Fix webbrowser.BackgroundBrowser on Windows. Modified: python/trunk/Lib/webbrowser.py ============================================================================== --- python/trunk/Lib/webbrowser.py (original) +++ python/trunk/Lib/webbrowser.py Sun Sep 24 12:36:01 2006 @@ -165,7 +165,10 @@ cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: - p = subprocess.Popen(cmdline, close_fds=True) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False @@ -178,11 +181,14 @@ def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) try: - p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + setsid = getattr(os, 'setsid', None) + if not setsid: + setsid = getattr(os, 'setpgrp', None) + p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Sep 24 12:36:01 2006 @@ -52,6 +52,9 @@ Library ------- +- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because + the close_fds arg to subprocess.Popen is not supported). + - Reverted patch #1504333 to sgmllib because it introduced an infinite loop. - Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE From python-checkins at python.org Sun Sep 24 12:36:09 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 24 Sep 2006 12:36:09 +0200 (CEST) Subject: [Python-checkins] r51992 - in python/branches/release25-maint: Lib/webbrowser.py Misc/NEWS Message-ID: <20060924103609.9E4A31E400C@bag.python.org> Author: georg.brandl Date: Sun Sep 24 12:36:08 2006 New Revision: 51992 Modified: python/branches/release25-maint/Lib/webbrowser.py python/branches/release25-maint/Misc/NEWS Log: Fix webbrowser.BackgroundBrowser on Windows. (backport from rev. 51991) Modified: python/branches/release25-maint/Lib/webbrowser.py ============================================================================== --- python/branches/release25-maint/Lib/webbrowser.py (original) +++ python/branches/release25-maint/Lib/webbrowser.py Sun Sep 24 12:36:08 2006 @@ -165,7 +165,10 @@ cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: - p = subprocess.Popen(cmdline, close_fds=True) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False @@ -178,11 +181,14 @@ def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) try: - p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + setsid = getattr(os, 'setsid', None) + if not setsid: + setsid = getattr(os, 'setpgrp', None) + p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sun Sep 24 12:36:08 2006 @@ -14,12 +14,21 @@ - Allow exception instances to be directly sliced again. + Extension Modules ----------------- - Fix itertools.count(n) to work with negative numbers again. +Library +------- + +- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because + the close_fds arg to subprocess.Popen is not supported). + + + What's New in Python 2.5 (final) ================================ @@ -27,6 +36,7 @@ No changes since release candidate 2. + What's New in Python 2.5 release candidate 2? ============================================= From buildbot at python.org Sun Sep 24 12:41:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 24 Sep 2006 10:41:10 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian trunk Message-ID: <20060924104110.B17DC1E4002@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/493 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: brett.cannon,neal.norwitz Build Had Warnings: warnings failed slave lost sincerely, -The Buildbot From buildbot at python.org Sun Sep 24 14:17:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 24 Sep 2006 12:17:31 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060924121731.54F231E4003@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/571 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 python-checkins at python.org Sun Sep 24 14:35:37 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 24 Sep 2006 14:35:37 +0200 (CEST) Subject: [Python-checkins] r51993 - in python/trunk: Lib/test/test_future.py Misc/NEWS Parser/parser.c Message-ID: <20060924123537.B096C1E400C@bag.python.org> Author: georg.brandl Date: Sun Sep 24 14:35:36 2006 New Revision: 51993 Modified: python/trunk/Lib/test/test_future.py python/trunk/Misc/NEWS python/trunk/Parser/parser.c Log: Fix a bug in the parser's future statement handling that led to "with" not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement Modified: python/trunk/Lib/test/test_future.py ============================================================================== --- python/trunk/Lib/test/test_future.py (original) +++ python/trunk/Lib/test/test_future.py Sun Sep 24 14:35:36 2006 @@ -82,6 +82,27 @@ else: self.fail("expected exception didn't occur") + def test_parserhack(self): + # test that the parser.c::future_hack function works as expected + # Note: although this test must pass, it's not testing the original + # bug as of 2.6 since the with statement is not optional and + # the parser hack disabled. If a new keyword is introduced in + # 2.6, change this to refer to the new future import. + try: + exec "from __future__ import division, with_statement; with = 0" + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + try: + exec "from __future__ import (with_statement, division); with = 0" + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + def test_main(): test_support.run_unittest(FutureTest) Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Sep 24 14:35:36 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Fix a bug in the parser's future statement handling that led to "with" + not being recognized as a keyword after, e.g., this statement: + from __future__ import division, with_statement + - Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). - Fix %zd string formatting on Mac OS X so it prints negative numbers. Modified: python/trunk/Parser/parser.c ============================================================================== --- python/trunk/Parser/parser.c (original) +++ python/trunk/Parser/parser.c Sun Sep 24 14:35:36 2006 @@ -181,7 +181,7 @@ future_hack(parser_state *ps) { node *n = ps->p_stack.s_top->s_parent; - node *ch; + node *ch, *cch; int i; /* from __future__ import ..., must have at least 4 children */ @@ -195,15 +195,17 @@ if (NCH(ch) == 1 && STR(CHILD(ch, 0)) && strcmp(STR(CHILD(ch, 0)), "__future__") != 0) return; - for (i = 3; i < NCH(n); i += 2) { - /* XXX: assume we don't have parentheses in import: - from __future__ import (x, y, z) - */ - ch = CHILD(n, i); - if (NCH(ch) == 1) - ch = CHILD(ch, 0); - if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME && - strcmp(STR(CHILD(ch, 0)), "with_statement") == 0) { + ch = CHILD(n, 3); + /* ch can be a star, a parenthesis or import_as_names */ + if (TYPE(ch) == STAR) + return; + if (TYPE(ch) == LPAR) + ch = CHILD(n, 4); + + for (i = 0; i < NCH(ch); i += 2) { + cch = CHILD(ch, i); + if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME && + strcmp(STR(CHILD(cch, 0)), "with_statement") == 0) { ps->p_flags |= CO_FUTURE_WITH_STATEMENT; break; } From python-checkins at python.org Sun Sep 24 14:35:41 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 24 Sep 2006 14:35:41 +0200 (CEST) Subject: [Python-checkins] r51994 - in python/branches/release25-maint: Lib/test/test_future.py Misc/NEWS Parser/parser.c Message-ID: <20060924123541.693081E4004@bag.python.org> Author: georg.brandl Date: Sun Sep 24 14:35:40 2006 New Revision: 51994 Modified: python/branches/release25-maint/Lib/test/test_future.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Parser/parser.c Log: Fix a bug in the parser's future statement handling that led to "with" not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement (backport from rev. 51993) Modified: python/branches/release25-maint/Lib/test/test_future.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_future.py (original) +++ python/branches/release25-maint/Lib/test/test_future.py Sun Sep 24 14:35:40 2006 @@ -82,6 +82,23 @@ else: self.fail("expected exception didn't occur") + def test_parserhack(self): + # test that the parser.c::future_hack function works as expected + try: + exec "from __future__ import division, with_statement; with = 0" + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + try: + exec "from __future__ import (with_statement, division); with = 0" + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + def test_main(): test_support.run_unittest(FutureTest) Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sun Sep 24 14:35:40 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Fix a bug in the parser's future statement handling that led to "with" + not being recognized as a keyword after, e.g., this statement: + from __future__ import division, with_statement + - Allow exception instances to be directly sliced again. Modified: python/branches/release25-maint/Parser/parser.c ============================================================================== --- python/branches/release25-maint/Parser/parser.c (original) +++ python/branches/release25-maint/Parser/parser.c Sun Sep 24 14:35:40 2006 @@ -181,7 +181,7 @@ future_hack(parser_state *ps) { node *n = ps->p_stack.s_top->s_parent; - node *ch; + node *ch, *cch; int i; /* from __future__ import ..., must have at least 4 children */ @@ -195,15 +195,17 @@ if (NCH(ch) == 1 && STR(CHILD(ch, 0)) && strcmp(STR(CHILD(ch, 0)), "__future__") != 0) return; - for (i = 3; i < NCH(n); i += 2) { - /* XXX: assume we don't have parentheses in import: - from __future__ import (x, y, z) - */ - ch = CHILD(n, i); - if (NCH(ch) == 1) - ch = CHILD(ch, 0); - if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME && - strcmp(STR(CHILD(ch, 0)), "with_statement") == 0) { + ch = CHILD(n, 3); + /* ch can be a star, a parenthesis or import_as_names */ + if (TYPE(ch) == STAR) + return; + if (TYPE(ch) == LPAR) + ch = CHILD(n, 4); + + for (i = 0; i < NCH(ch); i += 2) { + cch = CHILD(ch, i); + if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME && + strcmp(STR(CHILD(cch, 0)), "with_statement") == 0) { ps->p_flags |= CO_FUTURE_WITH_STATEMENT; break; } From buildbot at python.org Sun Sep 24 14:41:56 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 24 Sep 2006 12:41:56 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060924124156.D2A651E4002@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/106 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 python-checkins at python.org Sun Sep 24 14:50:26 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 24 Sep 2006 14:50:26 +0200 (CEST) Subject: [Python-checkins] r51995 - in python/trunk: Lib/test/test_traceback.py Lib/traceback.py Misc/NEWS Message-ID: <20060924125026.459FD1E4002@bag.python.org> Author: georg.brandl Date: Sun Sep 24 14:50:24 2006 New Revision: 51995 Modified: python/trunk/Lib/test/test_traceback.py python/trunk/Lib/traceback.py python/trunk/Misc/NEWS Log: Fix a bug in traceback.format_exception_only() that led to an error being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. Modified: python/trunk/Lib/test/test_traceback.py ============================================================================== --- python/trunk/Lib/test/test_traceback.py (original) +++ python/trunk/Lib/test/test_traceback.py Sun Sep 24 14:50:24 2006 @@ -149,6 +149,10 @@ str_value = '' % X.__name__ self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n') + def test_without_exception(self): + err = traceback.format_exception_only(None, None) + self.assertEqual(err, ['None\n']) + def test_main(): run_unittest(TracebackCases) Modified: python/trunk/Lib/traceback.py ============================================================================== --- python/trunk/Lib/traceback.py (original) +++ python/trunk/Lib/traceback.py Sun Sep 24 14:50:24 2006 @@ -170,7 +170,7 @@ # would throw another exception and mask the original problem. if (isinstance(etype, BaseException) or isinstance(etype, types.InstanceType) or - type(etype) is str): + etype is None or type(etype) is str): return [_format_final_exc_line(etype, value)] stype = etype.__name__ Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sun Sep 24 14:50:24 2006 @@ -56,6 +56,10 @@ Library ------- +- Fix a bug in traceback.format_exception_only() that led to an error + being raised when print_exc() was called without an exception set. + In version 2.4, this printed "None", restored that behavior. + - Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because the close_fds arg to subprocess.Popen is not supported). From python-checkins at python.org Sun Sep 24 14:50:30 2006 From: python-checkins at python.org (georg.brandl) Date: Sun, 24 Sep 2006 14:50:30 +0200 (CEST) Subject: [Python-checkins] r51996 - in python/branches/release25-maint: Lib/test/test_traceback.py Lib/traceback.py Misc/NEWS Message-ID: <20060924125030.32A671E4002@bag.python.org> Author: georg.brandl Date: Sun Sep 24 14:50:28 2006 New Revision: 51996 Modified: python/branches/release25-maint/Lib/test/test_traceback.py python/branches/release25-maint/Lib/traceback.py python/branches/release25-maint/Misc/NEWS Log: Fix a bug in traceback.format_exception_only() that led to an error being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. (backport from rev. 51995) Modified: python/branches/release25-maint/Lib/test/test_traceback.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_traceback.py (original) +++ python/branches/release25-maint/Lib/test/test_traceback.py Sun Sep 24 14:50:28 2006 @@ -149,6 +149,10 @@ str_value = '' % X.__name__ self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n') + def test_without_exception(self): + err = traceback.format_exception_only(None, None) + self.assertEqual(err, ['None\n']) + def test_main(): run_unittest(TracebackCases) Modified: python/branches/release25-maint/Lib/traceback.py ============================================================================== --- python/branches/release25-maint/Lib/traceback.py (original) +++ python/branches/release25-maint/Lib/traceback.py Sun Sep 24 14:50:28 2006 @@ -170,7 +170,7 @@ # would throw another exception and mask the original problem. if (isinstance(etype, BaseException) or isinstance(etype, types.InstanceType) or - type(etype) is str): + etype is None or type(etype) is str): return [_format_final_exc_line(etype, value)] stype = etype.__name__ Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sun Sep 24 14:50:28 2006 @@ -28,6 +28,10 @@ Library ------- +- Fix a bug in traceback.format_exception_only() that led to an error + being raised when print_exc() was called without an exception set. + In version 2.4, this printed "None", restored that behavior. + - Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because the close_fds arg to subprocess.Popen is not supported). From buildbot at python.org Sun Sep 24 16:18:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 24 Sep 2006 14:18:35 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20060924141835.F282F1E4002@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/39 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 Sun Sep 24 23:29:43 2006 From: buildbot at python.org (buildbot at python.org) Date: Sun, 24 Sep 2006 21:29:43 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian trunk Message-ID: <20060924212943.3DD8C1E4002@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/573 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 gwtufu at rr.com Mon Sep 25 01:34:46 2006 From: gwtufu at rr.com (Nelly Poole) Date: Sun, 24 Sep 2006 19:34:46 -0400 Subject: [Python-checkins] witch genitals Message-ID: <001c01c6e032$9d0fc1ed$e92e7f46@sfr> allowing you to quickly store, track, and search to any point in time or to any particular Users can create their own word lists and quizzes This release underwent intense conformance testing using the SAFTest suite. The metrics panel has undergone a major rewrite and should run much better now. function to selectively obfuscate certain A reconnection problem when talking directly to HTTP xend has been fixed. open source project or small company Web sites. The user dictionary option has been removed. graph objects, and GOBLET, a graphical user interface to the library functions. to any console or terminal based copy program. that makes it possible to easily build a static The statistics are maintained, in which each Website dealt with separately and together. server are included with the distribution. security, correlation, and qualification in one stereoscopic view via quadbuffer-capable stereo to any point in time or to any particular An English HTML version of Code-Aster documentation is included. can schedule full and incremental logical or raw stereoscopic view via quadbuffer-capable stereo added very soon, as will classes, multiplatform per second when using programs that do not report code is easy to extend for any other uses, like to track your entire computer system inventory. It adds some textures make with The GIMP and POV-RAY. and data is collected in realtime into a MySQL database. The statistics are maintained, in which each Website dealt with separately and together. Fixes for Linux and improved documentation. A reconnection problem when talking directly to HTTP xend has been fixed. Cite enables Web developers to set up complete Web -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/python-checkins/attachments/20060924/dda2761f/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: image/gif Size: 10941 bytes Desc: not available Url : http://mail.python.org/pipermail/python-checkins/attachments/20060924/dda2761f/attachment.gif From python-checkins at python.org Mon Sep 25 08:53:43 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 25 Sep 2006 08:53:43 +0200 (CEST) Subject: [Python-checkins] r51997 - in python/branches/release25-maint: Modules/almodule.c Modules/bz2module.c Python/pystate.c Message-ID: <20060925065343.14E371E4002@bag.python.org> Author: georg.brandl Date: Mon Sep 25 08:53:42 2006 New Revision: 51997 Modified: python/branches/release25-maint/Modules/almodule.c python/branches/release25-maint/Modules/bz2module.c python/branches/release25-maint/Python/pystate.c Log: Backport rev. 51987: superfluous semicola. Modified: python/branches/release25-maint/Modules/almodule.c ============================================================================== --- python/branches/release25-maint/Modules/almodule.c (original) +++ python/branches/release25-maint/Modules/almodule.c Mon Sep 25 08:53:42 2006 @@ -1686,7 +1686,7 @@ { int res, param; ALparamInfo pinfo; - PyObject *v, *item;; + PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; Modified: python/branches/release25-maint/Modules/bz2module.c ============================================================================== --- python/branches/release25-maint/Modules/bz2module.c (original) +++ python/branches/release25-maint/Modules/bz2module.c Mon Sep 25 08:53:42 2006 @@ -1023,12 +1023,12 @@ case MODE_CLOSED: PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - goto cleanup;; + goto cleanup; default: PyErr_SetString(PyExc_IOError, "seek works only while reading"); - goto cleanup;; + goto cleanup; } if (where == 2) { Modified: python/branches/release25-maint/Python/pystate.c ============================================================================== --- python/branches/release25-maint/Python/pystate.c (original) +++ python/branches/release25-maint/Python/pystate.c Mon Sep 25 08:53:42 2006 @@ -501,7 +501,7 @@ { PyThread_delete_key(autoTLSkey); autoTLSkey = 0; - autoInterpreterState = NULL;; + autoInterpreterState = NULL; } /* When a thread state is created for a thread by some mechanism other than From python-checkins at python.org Mon Sep 25 08:58:01 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 25 Sep 2006 08:58:01 +0200 (CEST) Subject: [Python-checkins] r51998 - in python/branches/release25-maint: Include/pyport.h Misc/NEWS configure configure.in Message-ID: <20060925065801.B586A1E4002@bag.python.org> Author: georg.brandl Date: Mon Sep 25 08:58:00 2006 New Revision: 51998 Modified: python/branches/release25-maint/Include/pyport.h python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/configure python/branches/release25-maint/configure.in Log: Backport rev. 51971: Fix %zd string formatting on Mac OS X so it prints negative numbers. In addition to testing positive numbers, verify negative numbers work in configure. In order to avoid compiler warnings on OS X 10.4, also change the order of the check for the format character to use (PY_FORMAT_SIZE_T) in the sprintf format for Py_ssize_t. This patch changes PY_FORMAT_SIZE_T from "" to "l" if it wasn't defined at configure time. Need to verify the buildbot results. Modified: python/branches/release25-maint/Include/pyport.h ============================================================================== --- python/branches/release25-maint/Include/pyport.h (original) +++ python/branches/release25-maint/Include/pyport.h Mon Sep 25 08:58:00 2006 @@ -126,7 +126,7 @@ * Py_ssize_t on the platform. */ #ifndef PY_FORMAT_SIZE_T -# if SIZEOF_SIZE_T == SIZEOF_INT +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) # define PY_FORMAT_SIZE_T "" # elif SIZEOF_SIZE_T == SIZEOF_LONG # define PY_FORMAT_SIZE_T "l" Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 25 08:58:00 2006 @@ -16,6 +16,8 @@ not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement +- Fix %zd string formatting on Mac OS X so it prints negative numbers. + - Allow exception instances to be directly sliced again. Modified: python/branches/release25-maint/configure ============================================================================== --- python/branches/release25-maint/configure (original) +++ python/branches/release25-maint/configure Mon Sep 25 08:58:00 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 51173 . +# From configure.in Revision: 51727 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.5. # @@ -22110,12 +22110,26 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) return 1; return 0; Modified: python/branches/release25-maint/configure.in ============================================================================== --- python/branches/release25-maint/configure.in (original) +++ python/branches/release25-maint/configure.in Mon Sep 25 08:58:00 2006 @@ -3352,14 +3352,28 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) return 1; - + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) + return 1; + return 0; }], [AC_MSG_RESULT(yes) From python-checkins at python.org Mon Sep 25 09:04:11 2006 From: python-checkins at python.org (georg.brandl) Date: Mon, 25 Sep 2006 09:04:11 +0200 (CEST) Subject: [Python-checkins] r51999 - in python/branches/release25-maint: Lib/test/test_complex_args.py Misc/NEWS Python/ast.c Message-ID: <20060925070411.875B11E4002@bag.python.org> Author: georg.brandl Date: Mon Sep 25 09:04:10 2006 New Revision: 51999 Added: python/branches/release25-maint/Lib/test/test_complex_args.py Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Python/ast.c Log: Backport rev. 51972: Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). These tests should be improved. Hopefully this fixes variations when flipping back and forth between fpdef and fplist. Added: python/branches/release25-maint/Lib/test/test_complex_args.py ============================================================================== --- (empty file) +++ python/branches/release25-maint/Lib/test/test_complex_args.py Mon Sep 25 09:04:10 2006 @@ -0,0 +1,91 @@ + +import unittest +from test import test_support + +class ComplexArgsTestCase(unittest.TestCase): + + def check(self, func, expected, *args): + self.assertEqual(func(*args), expected) + + # These functions are tested below as lambdas too. If you add a function test, + # also add a similar lambda test. + + def test_func_parens_no_unpacking(self): + def f(((((x))))): return x + self.check(f, 1, 1) + # Inner parens are elided, same as: f(x,) + def f(((x)),): return x + self.check(f, 2, 2) + + def test_func_1(self): + def f(((((x),)))): return x + self.check(f, 3, (3,)) + def f(((((x)),))): return x + self.check(f, 4, (4,)) + def f(((((x))),)): return x + self.check(f, 5, (5,)) + def f(((x),)): return x + self.check(f, 6, (6,)) + + def test_func_2(self): + def f(((((x)),),)): return x + self.check(f, 2, ((2,),)) + + def test_func_3(self): + def f((((((x)),),),)): return x + self.check(f, 3, (((3,),),)) + + def test_func_complex(self): + def f((((((x)),),),), a, b, c): return x, a, b, c + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + def f(((((((x)),)),),), a, b, c): return x, a, b, c + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + def f(a, b, c, ((((((x)),)),),)): return a, b, c, x + self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),)) + + # Duplicate the tests above, but for lambda. If you add a lambda test, + # also add a similar function test above. + + def test_lambda_parens_no_unpacking(self): + f = lambda (((((x))))): x + self.check(f, 1, 1) + # Inner parens are elided, same as: f(x,) + f = lambda ((x)),: x + self.check(f, 2, 2) + + def test_lambda_1(self): + f = lambda (((((x),)))): x + self.check(f, 3, (3,)) + f = lambda (((((x)),))): x + self.check(f, 4, (4,)) + f = lambda (((((x))),)): x + self.check(f, 5, (5,)) + f = lambda (((x),)): x + self.check(f, 6, (6,)) + + def test_lambda_2(self): + f = lambda (((((x)),),)): x + self.check(f, 2, ((2,),)) + + def test_lambda_3(self): + f = lambda ((((((x)),),),)): x + self.check(f, 3, (((3,),),)) + + def test_lambda_complex(self): + f = lambda (((((x)),),),), a, b, c: (x, a, b, c) + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + f = lambda ((((((x)),)),),), a, b, c: (x, a, b, c) + self.check(f, (3, 9, 8, 7), (((3,),),), 9, 8, 7) + + f = lambda a, b, c, ((((((x)),)),),): (a, b, c, x) + self.check(f, (9, 8, 7, 3), 9, 8, 7, (((3,),),)) + + +def test_main(): + test_support.run_unittest(ComplexArgsTestCase) + +if __name__ == "__main__": + test_main() Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Mon Sep 25 09:04:10 2006 @@ -16,6 +16,8 @@ not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement +- Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). + - Fix %zd string formatting on Mac OS X so it prints negative numbers. - Allow exception instances to be directly sliced again. Modified: python/branches/release25-maint/Python/ast.c ============================================================================== --- python/branches/release25-maint/Python/ast.c (original) +++ python/branches/release25-maint/Python/ast.c Mon Sep 25 09:04:10 2006 @@ -566,10 +566,17 @@ if (!args) return NULL; + /* fpdef: NAME | '(' fplist ')' + fplist: fpdef (',' fpdef)* [','] + */ REQ(n, fplist); for (i = 0; i < len; i++) { - const node *child = CHILD(CHILD(n, 2*i), 0); + const node *fpdef_node = CHILD(n, 2*i); + const node *child; expr_ty arg; +set_name: + /* fpdef_node is either a NAME or an fplist */ + child = CHILD(fpdef_node, 0); if (TYPE(child) == NAME) { if (!strcmp(STR(child), "None")) { ast_error(child, "assignment to None"); @@ -579,7 +586,17 @@ child->n_col_offset, c->c_arena); } else { - arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); + assert(TYPE(fpdef_node) == fpdef); + /* fpdef_node[0] is not a name, so it must be a '(', get CHILD[1] */ + child = CHILD(fpdef_node, 1); + assert(TYPE(child) == fplist); + /* NCH == 1 means we have (x), we need to elide the extra parens */ + if (NCH(child) == 1) { + fpdef_node = CHILD(child, 0); + assert(TYPE(fpdef_node) == fpdef); + goto set_name; + } + arg = compiler_complex_args(c, child); } asdl_seq_SET(args, i, arg); } @@ -637,6 +654,7 @@ ch = CHILD(n, i); switch (TYPE(ch)) { case fpdef: + handle_fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ /* XXX Should NCH(n) check be made a separate check? */ @@ -662,7 +680,11 @@ asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); } else { /* def foo((x)): setup for checking NAME below. */ + /* Loop because there can be many parens and tuple + upacking mixed in. */ ch = CHILD(ch, 0); + assert(TYPE(ch) == fpdef); + goto handle_fpdef; } } if (TYPE(CHILD(ch, 0)) == NAME) { From buildbot at python.org Mon Sep 25 09:54:38 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 25 Sep 2006 07:54:38 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20060925075438.D969C1E4002@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/39 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 Mon Sep 25 10:16:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 25 Sep 2006 08:16:09 +0000 Subject: [Python-checkins] buildbot warnings in sparc solaris10 gcc 2.5 Message-ID: <20060925081609.ACBDB1E400F@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/46 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 Mon Sep 25 11:00:18 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 25 Sep 2006 09:00:18 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.5 Message-ID: <20060925090018.937721E4002@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/38 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 Mon Sep 25 11:05:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 25 Sep 2006 09:05:04 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.5 Message-ID: <20060925090504.B625D1E4004@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/42 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 python-checkins at python.org Mon Sep 25 17:16:26 2006 From: python-checkins at python.org (armin.rigo) Date: Mon, 25 Sep 2006 17:16:26 +0200 (CEST) Subject: [Python-checkins] r52000 - python/trunk/Lib/test/crashers/loosing_mro_ref.py Message-ID: <20060925151626.A2D0E1E4002@bag.python.org> Author: armin.rigo Date: Mon Sep 25 17:16:26 2006 New Revision: 52000 Added: python/trunk/Lib/test/crashers/loosing_mro_ref.py (contents, props changed) Log: Another crasher. Added: python/trunk/Lib/test/crashers/loosing_mro_ref.py ============================================================================== --- (empty file) +++ python/trunk/Lib/test/crashers/loosing_mro_ref.py Mon Sep 25 17:16:26 2006 @@ -0,0 +1,36 @@ +""" +There is a way to put keys of any type in a type's dictionary. +I think this allows various kinds of crashes, but so far I have only +found a convoluted attack of _PyType_Lookup(), which uses the mro of the +type without holding a strong reference to it. Probably works with +super.__getattribute__() too, which uses the same kind of code. +""" + +class MyKey(object): + def __hash__(self): + return hash('mykey') + + def __cmp__(self, other): + # the following line decrefs the previous X.__mro__ + X.__bases__ = (Base2,) + # trash all tuples of length 3, to make sure that the items of + # the previous X.__mro__ are really garbage + z = [] + for i in range(1000): + z.append((i, None, None)) + return -1 + + +class Base(object): + mykey = 'from Base' + +class Base2(object): + mykey = 'from Base2' + +class X(Base): + # you can't add a non-string key to X.__dict__, but it can be + # there from the beginning :-) + locals()[MyKey()] = 5 + +print X.mykey +# I get a segfault, or a slightly wrong assertion error in a debug build. From buildbot at python.org Mon Sep 25 18:17:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Mon, 25 Sep 2006 16:17:10 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060925161710.411E51E4002@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/109 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: armin.rigo Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Mon Sep 25 19:58:47 2006 From: python-checkins at python.org (phillip.eby) Date: Mon, 25 Sep 2006 19:58:47 +0200 (CEST) Subject: [Python-checkins] r52001 - in sandbox/trunk/setuptools: pkg_resources.py pkg_resources.txt setuptools/tests/test_resources.py Message-ID: <20060925175847.E6FF71E4002@bag.python.org> Author: phillip.eby Date: Mon Sep 25 19:58:46 2006 New Revision: 52001 Modified: sandbox/trunk/setuptools/pkg_resources.py sandbox/trunk/setuptools/pkg_resources.txt sandbox/trunk/setuptools/setuptools/tests/test_resources.py Log: Fix "dev" versions being considered newer than release candidates. :( Modified: sandbox/trunk/setuptools/pkg_resources.py ============================================================================== --- sandbox/trunk/setuptools/pkg_resources.py (original) +++ sandbox/trunk/setuptools/pkg_resources.py Mon Sep 25 19:58:46 2006 @@ -1665,7 +1665,7 @@ ).match component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE) -replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c'}.get +replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}.get def _parse_version_parts(s): for part in component_re.split(s): Modified: sandbox/trunk/setuptools/pkg_resources.txt ============================================================================== --- sandbox/trunk/setuptools/pkg_resources.txt (original) +++ sandbox/trunk/setuptools/pkg_resources.txt Mon Sep 25 19:58:46 2006 @@ -1546,7 +1546,8 @@ Finally, to handle miscellaneous cases, the strings "pre", "preview", and "rc" are treated as if they were "c", i.e. as though they were release candidates, and therefore are not as new as a version string that does not - contain them. + contain them. And the string "dev" is treated as if it were an "@" sign; + that is, a version coming before even "a" or "alpha". .. _yield_lines(): Modified: sandbox/trunk/setuptools/setuptools/tests/test_resources.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/tests/test_resources.py (original) +++ sandbox/trunk/setuptools/setuptools/tests/test_resources.py Mon Sep 25 19:58:46 2006 @@ -471,6 +471,7 @@ c('0.0.4', '0.4.0') c('0pl1', '0.4pl1') c('2.1.0-rc1','2.1.0') + c('2.1dev','2.1a0') torture =""" 0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1 @@ -481,3 +482,12 @@ for p,v1 in enumerate(torture): for v2 in torture[p+1:]: c(v2,v1) + + + + + + + + + From python-checkins at python.org Mon Sep 25 20:00:16 2006 From: python-checkins at python.org (phillip.eby) Date: Mon, 25 Sep 2006 20:00:16 +0200 (CEST) Subject: [Python-checkins] r52002 - in sandbox/branches/setuptools-0.6: pkg_resources.py pkg_resources.txt setuptools/tests/test_resources.py Message-ID: <20060925180016.0A41F1E4002@bag.python.org> Author: phillip.eby Date: Mon Sep 25 20:00:15 2006 New Revision: 52002 Modified: sandbox/branches/setuptools-0.6/pkg_resources.py sandbox/branches/setuptools-0.6/pkg_resources.txt sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py Log: Fix "dev" versions being considered newer than release candidates. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/pkg_resources.py ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.py (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.py Mon Sep 25 20:00:15 2006 @@ -1747,7 +1747,7 @@ ).match component_re = re.compile(r'(\d+ | [a-z]+ | \.| -)', re.VERBOSE) -replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c'}.get +replace = {'pre':'c', 'preview':'c','-':'final-','rc':'c','dev':'@'}.get def _parse_version_parts(s): for part in component_re.split(s): Modified: sandbox/branches/setuptools-0.6/pkg_resources.txt ============================================================================== --- sandbox/branches/setuptools-0.6/pkg_resources.txt (original) +++ sandbox/branches/setuptools-0.6/pkg_resources.txt Mon Sep 25 20:00:15 2006 @@ -1540,7 +1540,8 @@ Finally, to handle miscellaneous cases, the strings "pre", "preview", and "rc" are treated as if they were "c", i.e. as though they were release candidates, and therefore are not as new as a version string that does not - contain them. + contain them. And the string "dev" is treated as if it were an "@" sign; + that is, a version coming before even "a" or "alpha". .. _yield_lines(): @@ -1691,6 +1692,9 @@ Release Notes/Change History ---------------------------- +0.6c4 + * Fix "dev" versions being considered newer than release candidates. + 0.6c3 * Python 2.5 compatibility fixes. Modified: sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/tests/test_resources.py Mon Sep 25 20:00:15 2006 @@ -471,6 +471,7 @@ c('0.0.4', '0.4.0') c('0pl1', '0.4pl1') c('2.1.0-rc1','2.1.0') + c('2.1dev','2.1a0') torture =""" 0.80.1-3 0.80.1-2 0.80.1-1 0.79.9999+0.80.0pre4-1 From python-checkins at python.org Mon Sep 25 23:24:20 2006 From: python-checkins at python.org (phillip.eby) Date: Mon, 25 Sep 2006 23:24:20 +0200 (CEST) Subject: [Python-checkins] r52003 - in sandbox/trunk/setuptools: EasyInstall.txt setuptools/package_index.py Message-ID: <20060925212420.52AD51E4004@bag.python.org> Author: phillip.eby Date: Mon Sep 25 23:24:19 2006 New Revision: 52003 Modified: sandbox/trunk/setuptools/EasyInstall.txt sandbox/trunk/setuptools/setuptools/package_index.py Log: Fix SF download problems when server returns HTML instead of a 404. Use sf-mirrors.telecommunity.com as a fallback to get SF mirror info if the first dl.sourceforge.net attempt doesn't work. Modified: sandbox/trunk/setuptools/EasyInstall.txt ============================================================================== --- sandbox/trunk/setuptools/EasyInstall.txt (original) +++ sandbox/trunk/setuptools/EasyInstall.txt Mon Sep 25 23:24:19 2006 @@ -355,6 +355,14 @@ ``python.org`` and ``myintranet.example.com`` domains, unless overridden on the command line. +Note that if you want to allow downloads from Sourceforge, you need to enable +the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated +as if they had this hostname. (If a download attempt from +``dl.sourceforge.net`` fails, it is automatically retried using a randomly +selected mirror IP drawn from the ``sf-mirrors.telecommunity.com`` round-robin +addres. The IP's, however, are not checked against the ``--allow-hosts`` +mask.) + Installing on Un-networked Machines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Mon Sep 25 23:24:19 2006 @@ -533,7 +533,6 @@ dl_blocksize = 8192 def _download_to(self, url, filename): - self.url_ok(url,True) # raises error if not allowed self.info("Downloading %s", url) # Download the file fp, tfp, info = None, None, None @@ -572,9 +571,18 @@ def reporthook(self, url, filename, blocknum, blksize, size): pass # no-op - def retry_sf_download(self, url, filename): + + def _attempt_download(self, url, filename): + headers = self._download_to(url, filename) + if 'html' in headers['content-type'].lower(): + return self._download_html(url, headers, filename) + else: + return filename + + def _retry_sf_download(self, url, filename): + self.url_ok(url, True) # raises error if not allowed try: - return self._download_to(url, filename) + return self._attempt_download(url, filename) except (KeyboardInterrupt,SystemExit): raise except: @@ -588,7 +596,9 @@ self.warn("Download failed: %s", sys.exc_info()[1]) url = urlparse.urlunparse((scheme, mirror, path, param, '', frag)) try: - return self._download_to(url, filename) + return self._attempt_download(url, filename) + except (KeyboardInterrupt,SystemExit): + raise except: _sf_mirrors.remove(mirror) # don't retry the same mirror mirror = get_sf_ip() @@ -603,16 +613,6 @@ - - - - - - - - - - def open_url(self, url): if url.startswith('file:'): return local_open(url) @@ -648,16 +648,16 @@ elif scheme=='file': return urllib2.url2pathname(urlparse.urlparse(url)[2]) else: - headers = self.retry_sf_download(url, filename) - if 'html' in headers['content-type'].lower(): - return self._download_html(url, headers, filename, tmpdir) - else: - return filename + return self._retry_sf_download(url, filename) + + + + def scan_url(self, url): self.process_url(url, True) - def _download_html(self, url, headers, filename, tmpdir): + def _download_html(self, url, headers, filename): file = open(filename) for line in file: if line.strip(): @@ -700,7 +700,8 @@ def get_sf_ip(): if not _sf_mirrors: try: - _sf_mirrors[:] = socket.gethostbyname_ex('dl.sourceforge.net')[-1] + _sf_mirrors[:] = socket.gethostbyname_ex( + 'sf-mirrors.telecommunity.com')[-1] except socket.error: # DNS-bl0ck1n9 f1r3w4llz sUx0rs! _sf_mirrors[:] = ['dl.sourceforge.net'] @@ -734,5 +735,4 @@ - # this line is a kludge to keep the trailing blank lines for pje's editor From python-checkins at python.org Mon Sep 25 23:32:00 2006 From: python-checkins at python.org (phillip.eby) Date: Mon, 25 Sep 2006 23:32:00 +0200 (CEST) Subject: [Python-checkins] r52004 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/package_index.py Message-ID: <20060925213200.46F951E4004@bag.python.org> Author: phillip.eby Date: Mon Sep 25 23:31:59 2006 New Revision: 52004 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/package_index.py Log: Fixed SF downloads aborting when a SF mirror returns an HTML page when it should've returned a 404. Fall back to ``sf-mirrors.telecommunity.com`` round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work. (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 Mon Sep 25 23:31:59 2006 @@ -355,6 +355,14 @@ ``python.org`` and ``myintranet.example.com`` domains, unless overridden on the command line. +Note that if you want to allow downloads from Sourceforge, you need to enable +the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated +as if they had this hostname. (If a download attempt from +``dl.sourceforge.net`` fails, it is automatically retried using a randomly +selected mirror IP drawn from the ``sf-mirrors.telecommunity.com`` round-robin +addres. The IP's, however, are not checked against the ``--allow-hosts`` +mask.) + Installing on Un-networked Machines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1198,6 +1206,10 @@ * Fixed not recogninzing ``win32.exe`` installers that included a custom bitmap. + * Fixed SF downloads aborting when a SF mirror returns an HTML page when it + should've returned a 404. Fall back to ``sf-mirrors.telecommunity.com`` + round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work. + 0.6c3 * You once again use "python -m easy_install" with Python 2.4 and above. Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Mon Sep 25 23:31:59 2006 @@ -533,7 +533,6 @@ dl_blocksize = 8192 def _download_to(self, url, filename): - self.url_ok(url,True) # raises error if not allowed self.info("Downloading %s", url) # Download the file fp, tfp, info = None, None, None @@ -572,9 +571,18 @@ def reporthook(self, url, filename, blocknum, blksize, size): pass # no-op - def retry_sf_download(self, url, filename): + + def _attempt_download(self, url, filename): + headers = self._download_to(url, filename) + if 'html' in headers['content-type'].lower(): + return self._download_html(url, headers, filename) + else: + return filename + + def _retry_sf_download(self, url, filename): + self.url_ok(url, True) # raises error if not allowed try: - return self._download_to(url, filename) + return self._attempt_download(url, filename) except (KeyboardInterrupt,SystemExit): raise except: @@ -588,7 +596,9 @@ self.warn("Download failed: %s", sys.exc_info()[1]) url = urlparse.urlunparse((scheme, mirror, path, param, '', frag)) try: - return self._download_to(url, filename) + return self._attempt_download(url, filename) + except (KeyboardInterrupt,SystemExit): + raise except: _sf_mirrors.remove(mirror) # don't retry the same mirror mirror = get_sf_ip() @@ -603,16 +613,6 @@ - - - - - - - - - - def open_url(self, url): if url.startswith('file:'): return local_open(url) @@ -648,16 +648,16 @@ elif scheme=='file': return urllib2.url2pathname(urlparse.urlparse(url)[2]) else: - headers = self.retry_sf_download(url, filename) - if 'html' in headers['content-type'].lower(): - return self._download_html(url, headers, filename, tmpdir) - else: - return filename + return self._retry_sf_download(url, filename) + + + + def scan_url(self, url): self.process_url(url, True) - def _download_html(self, url, headers, filename, tmpdir): + def _download_html(self, url, headers, filename): file = open(filename) for line in file: if line.strip(): @@ -700,7 +700,8 @@ def get_sf_ip(): if not _sf_mirrors: try: - _sf_mirrors[:] = socket.gethostbyname_ex('dl.sourceforge.net')[-1] + _sf_mirrors[:] = socket.gethostbyname_ex( + 'sf-mirrors.telecommunity.com')[-1] except socket.error: # DNS-bl0ck1n9 f1r3w4llz sUx0rs! _sf_mirrors[:] = ['dl.sourceforge.net'] @@ -734,5 +735,4 @@ - # this line is a kludge to keep the trailing blank lines for pje's editor From python-checkins at python.org Tue Sep 26 00:38:49 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 26 Sep 2006 00:38:49 +0200 (CEST) Subject: [Python-checkins] r52005 - in python/branches/bcannon-objcap: Doc/Makefile Doc/whatsnew/whatsnew25.tex Doc/whatsnew/whatsnew26.tex Include/pyport.h Lib/test/crashers/loosing_mro_ref.py Lib/test/test_complex_args.py Lib/test/test_future.py Lib/test/test_itertools.py Lib/test/test_time.py Lib/test/test_traceback.py Lib/traceback.py Lib/webbrowser.py Misc/NEWS Misc/Vim/python.vim Misc/Vim/vim_syntax.py Modules/_bsddb.c Modules/almodule.c Modules/bz2module.c Modules/itertoolsmodule.c Objects/exceptions.c Parser/parser.c Python/ast.c Python/getargs.c Python/pystate.c Tools/scripts/byext.py configure configure.in Message-ID: <20060925223849.438FA1E4003@bag.python.org> Author: brett.cannon Date: Tue Sep 26 00:38:43 2006 New Revision: 52005 Added: python/branches/bcannon-objcap/Doc/whatsnew/whatsnew26.tex - copied unchanged from r52000, python/trunk/Doc/whatsnew/whatsnew26.tex python/branches/bcannon-objcap/Lib/test/crashers/loosing_mro_ref.py - copied unchanged from r52000, python/trunk/Lib/test/crashers/loosing_mro_ref.py python/branches/bcannon-objcap/Lib/test/test_complex_args.py - copied unchanged from r52000, python/trunk/Lib/test/test_complex_args.py Modified: python/branches/bcannon-objcap/ (props changed) python/branches/bcannon-objcap/Doc/Makefile python/branches/bcannon-objcap/Doc/whatsnew/whatsnew25.tex python/branches/bcannon-objcap/Include/pyport.h python/branches/bcannon-objcap/Lib/test/test_future.py python/branches/bcannon-objcap/Lib/test/test_itertools.py python/branches/bcannon-objcap/Lib/test/test_time.py python/branches/bcannon-objcap/Lib/test/test_traceback.py python/branches/bcannon-objcap/Lib/traceback.py python/branches/bcannon-objcap/Lib/webbrowser.py python/branches/bcannon-objcap/Misc/NEWS python/branches/bcannon-objcap/Misc/Vim/python.vim python/branches/bcannon-objcap/Misc/Vim/vim_syntax.py python/branches/bcannon-objcap/Modules/_bsddb.c python/branches/bcannon-objcap/Modules/almodule.c python/branches/bcannon-objcap/Modules/bz2module.c python/branches/bcannon-objcap/Modules/itertoolsmodule.c python/branches/bcannon-objcap/Objects/exceptions.c python/branches/bcannon-objcap/Parser/parser.c python/branches/bcannon-objcap/Python/ast.c python/branches/bcannon-objcap/Python/getargs.c python/branches/bcannon-objcap/Python/pystate.c python/branches/bcannon-objcap/Tools/scripts/byext.py (props changed) python/branches/bcannon-objcap/configure python/branches/bcannon-objcap/configure.in Log: Merged revisions 51911-52004 via svnmerge from svn+ssh://pythondev at svn.python.org/python/trunk Modified: python/branches/bcannon-objcap/Doc/Makefile ============================================================================== --- python/branches/bcannon-objcap/Doc/Makefile (original) +++ python/branches/bcannon-objcap/Doc/Makefile Tue Sep 26 00:38:43 2006 @@ -122,7 +122,7 @@ # The end of this should reflect the major/minor version numbers of # the release: -WHATSNEW=whatsnew25 +WHATSNEW=whatsnew26 # what's what MANDVIFILES= paper-$(PAPER)/api.dvi paper-$(PAPER)/ext.dvi \ 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 26 00:38:43 2006 @@ -540,10 +540,10 @@ StopIteration \end{verbatim} -Because \keyword{yield} will often be returning \constant{None}, you +\keyword{yield} will usually return \constant{None}, you should always check for this case. Don't just use its value in expressions unless you're sure that the \method{send()} method -will be the only method used resume your generator function. +will be the only method used to resume your generator function. In addition to \method{send()}, there are two other new methods on generators: Modified: python/branches/bcannon-objcap/Include/pyport.h ============================================================================== --- python/branches/bcannon-objcap/Include/pyport.h (original) +++ python/branches/bcannon-objcap/Include/pyport.h Tue Sep 26 00:38:43 2006 @@ -126,7 +126,7 @@ * Py_ssize_t on the platform. */ #ifndef PY_FORMAT_SIZE_T -# if SIZEOF_SIZE_T == SIZEOF_INT +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) # define PY_FORMAT_SIZE_T "" # elif SIZEOF_SIZE_T == SIZEOF_LONG # define PY_FORMAT_SIZE_T "l" Modified: python/branches/bcannon-objcap/Lib/test/test_future.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_future.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_future.py Tue Sep 26 00:38:43 2006 @@ -82,6 +82,27 @@ else: self.fail("expected exception didn't occur") + def test_parserhack(self): + # test that the parser.c::future_hack function works as expected + # Note: although this test must pass, it's not testing the original + # bug as of 2.6 since the with statement is not optional and + # the parser hack disabled. If a new keyword is introduced in + # 2.6, change this to refer to the new future import. + try: + exec "from __future__ import division, with_statement; with = 0" + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + try: + exec "from __future__ import (with_statement, division); with = 0" + except SyntaxError: + pass + else: + self.fail("syntax error didn't occur") + + def test_main(): test_support.run_unittest(FutureTest) 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 26 00:38:43 2006 @@ -58,6 +58,10 @@ self.assertEqual(repr(c), 'count(3)') c.next() self.assertEqual(repr(c), 'count(4)') + c = count(-9) + self.assertEqual(repr(c), 'count(-9)') + c.next() + self.assertEqual(c.next(), -8) def test_cycle(self): self.assertEqual(take(10, cycle('abc')), list('abcabcabca')) Modified: python/branches/bcannon-objcap/Lib/test/test_time.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_time.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_time.py Tue Sep 26 00:38:43 2006 @@ -102,15 +102,19 @@ self.assertEquals(expected, result) def test_strptime(self): + # Should be able to go round-trip from strftime to strptime without + # throwing an exception. tt = time.gmtime(self.t) for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I', 'j', 'm', 'M', 'p', 'S', 'U', 'w', 'W', 'x', 'X', 'y', 'Y', 'Z', '%'): - format = ' %' + directive + format = '%' + directive + strf_output = time.strftime(format, tt) try: - time.strptime(time.strftime(format, tt), format) + time.strptime(strf_output, format) except ValueError: - self.fail('conversion specifier: %r failed.' % format) + self.fail("conversion specifier %r failed with '%s' input." % + (format, strf_output)) def test_asctime(self): time.asctime(time.gmtime(self.t)) Modified: python/branches/bcannon-objcap/Lib/test/test_traceback.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_traceback.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_traceback.py Tue Sep 26 00:38:43 2006 @@ -149,6 +149,10 @@ str_value = '' % X.__name__ self.assertEqual(err[0], X.__name__ + ': ' + str_value + '\n') + def test_without_exception(self): + err = traceback.format_exception_only(None, None) + self.assertEqual(err, ['None\n']) + def test_main(): run_unittest(TracebackCases) Modified: python/branches/bcannon-objcap/Lib/traceback.py ============================================================================== --- python/branches/bcannon-objcap/Lib/traceback.py (original) +++ python/branches/bcannon-objcap/Lib/traceback.py Tue Sep 26 00:38:43 2006 @@ -170,7 +170,7 @@ # would throw another exception and mask the original problem. if (isinstance(etype, BaseException) or isinstance(etype, types.InstanceType) or - type(etype) is str): + etype is None or type(etype) is str): return [_format_final_exc_line(etype, value)] stype = etype.__name__ Modified: python/branches/bcannon-objcap/Lib/webbrowser.py ============================================================================== --- python/branches/bcannon-objcap/Lib/webbrowser.py (original) +++ python/branches/bcannon-objcap/Lib/webbrowser.py Tue Sep 26 00:38:43 2006 @@ -165,7 +165,10 @@ cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] try: - p = subprocess.Popen(cmdline, close_fds=True) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + p = subprocess.Popen(cmdline, close_fds=True) return not p.wait() except OSError: return False @@ -178,11 +181,14 @@ def open(self, url, new=0, autoraise=1): cmdline = [self.name] + [arg.replace("%s", url) for arg in self.args] - setsid = getattr(os, 'setsid', None) - if not setsid: - setsid = getattr(os, 'setpgrp', None) try: - p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) + if sys.platform[:3] == 'win': + p = subprocess.Popen(cmdline) + else: + setsid = getattr(os, 'setsid', None) + if not setsid: + setsid = getattr(os, 'setpgrp', None) + p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid) return (p.poll() is None) except OSError: return False Modified: python/branches/bcannon-objcap/Misc/NEWS ============================================================================== --- python/branches/bcannon-objcap/Misc/NEWS (original) +++ python/branches/bcannon-objcap/Misc/NEWS Tue Sep 26 00:38:43 2006 @@ -12,6 +12,19 @@ Core and builtins ----------------- +- Fix a bug in the parser's future statement handling that led to "with" + not being recognized as a keyword after, e.g., this statement: + from __future__ import division, with_statement + +- Bug #1557232: fix seg fault with def f((((x)))) and def f(((x),)). + +- Fix %zd string formatting on Mac OS X so it prints negative numbers. + +- Allow exception instances to be directly sliced again. + +- Bug #1551432: Exceptions do not define an explicit __unicode__ method. This + allows calling unicode() on exceptions classes directly to succeed. + - Make _PyGILState_NoteThreadState() static, it was not used anywhere outside of pystate.c and should not be necessary. @@ -43,6 +56,13 @@ Library ------- +- Fix a bug in traceback.format_exception_only() that led to an error + being raised when print_exc() was called without an exception set. + In version 2.4, this printed "None", restored that behavior. + +- Make webbrowser.BackgroundBrowser usable in Windows (it wasn't because + the close_fds arg to subprocess.Popen is not supported). + - Reverted patch #1504333 to sgmllib because it introduced an infinite loop. - Patch #1553314: Fix the inspect.py slowdown that was hurting IPython & SAGE @@ -58,10 +78,14 @@ - Bug #1531862: Do not close standard file descriptors in subprocess. +- fixed a bug with bsddb.DB.stat: its flags and txn keyword arguments + were transposed. Extension Modules ----------------- +- Fix itertools.count(n) to work with negative numbers again. + - RLIMIT_SBSIZE was added to the resource module where available. - Bug #1551427: fix a wrong NULL pointer check in the win32 version @@ -96,6 +120,10 @@ Tools ----- +- Make auto-generated python.vim file list built-ins and exceptions in + alphatbetical order. Makes output more deterministic and easier to tell if + the file is stale or not. + - Bug #1546372: Fixed small bugglet in pybench that caused a missing file not to get reported properly. Modified: python/branches/bcannon-objcap/Misc/Vim/python.vim ============================================================================== --- python/branches/bcannon-objcap/Misc/Vim/python.vim (original) +++ python/branches/bcannon-objcap/Misc/Vim/python.vim Tue Sep 26 00:38:43 2006 @@ -62,39 +62,39 @@ if exists("python_highlight_builtins") - syn keyword pythonBuiltin unichr all set abs vars int __import__ unicode - syn keyword pythonBuiltin enumerate reduce coerce intern exit issubclass - syn keyword pythonBuiltin divmod file Ellipsis apply isinstance open any - syn keyword pythonBuiltin locals help filter basestring slice copyright min - syn keyword pythonBuiltin super sum tuple hex execfile long id xrange chr - syn keyword pythonBuiltin complex bool zip pow dict True oct NotImplemented - syn keyword pythonBuiltin map None float hash getattr buffer max reversed - syn keyword pythonBuiltin object quit len repr callable credits setattr - syn keyword pythonBuiltin eval frozenset sorted ord __debug__ hasattr - syn keyword pythonBuiltin delattr False input license classmethod type - syn keyword pythonBuiltin raw_input list iter compile reload range globals - syn keyword pythonBuiltin staticmethod str property round dir cmp + syn keyword pythonBuiltin Ellipsis False None NotImplemented True __debug__ + syn keyword pythonBuiltin __import__ abs all any apply basestring bool + syn keyword pythonBuiltin buffer callable chr classmethod cmp coerce + syn keyword pythonBuiltin compile complex copyright credits delattr dict + syn keyword pythonBuiltin dir divmod enumerate eval execfile exit file + syn keyword pythonBuiltin filter float frozenset getattr globals hasattr + syn keyword pythonBuiltin hash help hex id input int intern isinstance + syn keyword pythonBuiltin issubclass iter len license list locals long map + syn keyword pythonBuiltin max min object oct open ord pow property quit + syn keyword pythonBuiltin range raw_input reduce reload repr reversed round + syn keyword pythonBuiltin set setattr slice sorted staticmethod str sum + syn keyword pythonBuiltin super tuple type unichr unicode vars xrange zip endif if exists("python_highlight_exceptions") - syn keyword pythonException GeneratorExit ImportError RuntimeError - syn keyword pythonException UnicodeTranslateError MemoryError StopIteration - syn keyword pythonException PendingDeprecationWarning EnvironmentError - syn keyword pythonException LookupError OSError DeprecationWarning - syn keyword pythonException UnicodeError UnicodeEncodeError - syn keyword pythonException FloatingPointError ReferenceError NameError - syn keyword pythonException IOError SyntaxError - syn keyword pythonException FutureWarning ImportWarning SystemExit - syn keyword pythonException Exception EOFError StandardError ValueError - syn keyword pythonException TabError KeyError ZeroDivisionError SystemError - syn keyword pythonException UnicodeDecodeError IndentationError - syn keyword pythonException AssertionError TypeError IndexError - syn keyword pythonException RuntimeWarning KeyboardInterrupt UserWarning - syn keyword pythonException SyntaxWarning UnboundLocalError ArithmeticError - syn keyword pythonException Warning NotImplementedError AttributeError - syn keyword pythonException OverflowError BaseException + syn keyword pythonException ArithmeticError AssertionError AttributeError + syn keyword pythonException BaseException DeprecationWarning EOFError + syn keyword pythonException EnvironmentError Exception FloatingPointError + syn keyword pythonException FutureWarning GeneratorExit IOError ImportError + syn keyword pythonException ImportWarning IndentationError IndexError + syn keyword pythonException KeyError KeyboardInterrupt LookupError + syn keyword pythonException MemoryError NameError NotImplementedError + syn keyword pythonException OSError OverflowError PendingDeprecationWarning + syn keyword pythonException ReferenceError RuntimeError RuntimeWarning + syn keyword pythonException StandardError StopIteration SyntaxError + syn keyword pythonException SyntaxWarning SystemError SystemExit TabError + syn keyword pythonException TypeError UnboundLocalError UnicodeDecodeError + syn keyword pythonException UnicodeEncodeError UnicodeError + syn keyword pythonException UnicodeTranslateError UnicodeWarning + syn keyword pythonException UserWarning ValueError Warning + syn keyword pythonException ZeroDivisionError endif Modified: python/branches/bcannon-objcap/Misc/Vim/vim_syntax.py ============================================================================== --- python/branches/bcannon-objcap/Misc/Vim/vim_syntax.py (original) +++ python/branches/bcannon-objcap/Misc/Vim/vim_syntax.py Tue Sep 26 00:38:43 2006 @@ -5,9 +5,9 @@ import __builtin__ from string import Template -comment_header = """" Auto-generated Vim syntax file for Python +comment_header = '''" Auto-generated Vim syntax file for Python. " -" To use: copy or symlink to ~/.vim/syntax/python.vim""" +" To use: copy or symlink to ~/.vim/syntax/python.vim''' statement_header = """ if exists("b:current_syntax") @@ -30,14 +30,14 @@ import_stmts = ('import', 'from') object_defs = ('def', 'class') -exception_names = frozenset(exc for exc in dir(exceptions) +exception_names = sorted(exc for exc in dir(exceptions) if not exc.startswith('__')) # Need to include functions that start with '__' (e.g., __import__), but # nothing that comes with modules (e.g., __name__), so just exclude anything in # the 'exceptions' module since we want to ignore exceptions *and* what any # module would have -builtin_names = frozenset(builtin for builtin in dir(__builtin__) +builtin_names = sorted(builtin for builtin in dir(__builtin__) if builtin not in dir(exceptions)) escapes = (r'+\\[abfnrtv\'"\\]+', r'"\\\o\{1,3}"', r'"\\x\x\{2}"', Modified: python/branches/bcannon-objcap/Modules/_bsddb.c ============================================================================== --- python/branches/bcannon-objcap/Modules/_bsddb.c (original) +++ python/branches/bcannon-objcap/Modules/_bsddb.c Tue Sep 26 00:38:43 2006 @@ -98,7 +98,7 @@ #error "eek! DBVER can't handle minor versions > 9" #endif -#define PY_BSDDB_VERSION "4.4.5" +#define PY_BSDDB_VERSION "4.4.6" static char *rcs_id = "$Id$"; @@ -2430,7 +2430,7 @@ #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - static char* kwnames[] = { "txn", "flags", NULL }; + static char* kwnames[] = { "flags", "txn", NULL }; #else static char* kwnames[] = { "flags", NULL }; #endif Modified: python/branches/bcannon-objcap/Modules/almodule.c ============================================================================== --- python/branches/bcannon-objcap/Modules/almodule.c (original) +++ python/branches/bcannon-objcap/Modules/almodule.c Tue Sep 26 00:38:43 2006 @@ -1686,7 +1686,7 @@ { int res, param; ALparamInfo pinfo; - PyObject *v, *item;; + PyObject *v, *item; if (!PyArg_ParseTuple(args, "ii:GetParamInfo", &res, ¶m)) return NULL; Modified: python/branches/bcannon-objcap/Modules/bz2module.c ============================================================================== --- python/branches/bcannon-objcap/Modules/bz2module.c (original) +++ python/branches/bcannon-objcap/Modules/bz2module.c Tue Sep 26 00:38:43 2006 @@ -1023,12 +1023,12 @@ case MODE_CLOSED: PyErr_SetString(PyExc_ValueError, "I/O operation on closed file"); - goto cleanup;; + goto cleanup; default: PyErr_SetString(PyExc_IOError, "seek works only while reading"); - goto cleanup;; + goto cleanup; } if (where == 2) { 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 26 00:38:43 2006 @@ -2072,7 +2072,7 @@ static PyObject * count_next(countobject *lz) { - return PyInt_FromSize_t(lz->cnt++); + return PyInt_FromSsize_t(lz->cnt++); } static PyObject * 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 26 00:38:43 2006 @@ -190,12 +190,19 @@ return PySequence_GetItem(self->args, index); } +static PyObject * +BaseException_getslice(PyBaseExceptionObject *self, + Py_ssize_t start, Py_ssize_t stop) +{ + return PySequence_GetSlice(self->args, start, stop); +} + static PySequenceMethods BaseException_as_sequence = { 0, /* sq_length; */ 0, /* sq_concat; */ 0, /* sq_repeat; */ (ssizeargfunc)BaseException_getitem, /* sq_item; */ - 0, /* sq_slice; */ + (ssizessizeargfunc)BaseException_getslice, /* sq_slice; */ 0, /* sq_ass_item; */ 0, /* sq_ass_slice; */ 0, /* sq_contains; */ Modified: python/branches/bcannon-objcap/Parser/parser.c ============================================================================== --- python/branches/bcannon-objcap/Parser/parser.c (original) +++ python/branches/bcannon-objcap/Parser/parser.c Tue Sep 26 00:38:43 2006 @@ -181,7 +181,7 @@ future_hack(parser_state *ps) { node *n = ps->p_stack.s_top->s_parent; - node *ch; + node *ch, *cch; int i; /* from __future__ import ..., must have at least 4 children */ @@ -195,15 +195,17 @@ if (NCH(ch) == 1 && STR(CHILD(ch, 0)) && strcmp(STR(CHILD(ch, 0)), "__future__") != 0) return; - for (i = 3; i < NCH(n); i += 2) { - /* XXX: assume we don't have parentheses in import: - from __future__ import (x, y, z) - */ - ch = CHILD(n, i); - if (NCH(ch) == 1) - ch = CHILD(ch, 0); - if (NCH(ch) >= 1 && TYPE(CHILD(ch, 0)) == NAME && - strcmp(STR(CHILD(ch, 0)), "with_statement") == 0) { + ch = CHILD(n, 3); + /* ch can be a star, a parenthesis or import_as_names */ + if (TYPE(ch) == STAR) + return; + if (TYPE(ch) == LPAR) + ch = CHILD(n, 4); + + for (i = 0; i < NCH(ch); i += 2) { + cch = CHILD(ch, i); + if (NCH(cch) >= 1 && TYPE(CHILD(cch, 0)) == NAME && + strcmp(STR(CHILD(cch, 0)), "with_statement") == 0) { ps->p_flags |= CO_FUTURE_WITH_STATEMENT; break; } 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 26 00:38:43 2006 @@ -560,10 +560,17 @@ if (!args) return NULL; + /* fpdef: NAME | '(' fplist ')' + fplist: fpdef (',' fpdef)* [','] + */ REQ(n, fplist); for (i = 0; i < len; i++) { - const node *child = CHILD(CHILD(n, 2*i), 0); + const node *fpdef_node = CHILD(n, 2*i); + const node *child; expr_ty arg; +set_name: + /* fpdef_node is either a NAME or an fplist */ + child = CHILD(fpdef_node, 0); if (TYPE(child) == NAME) { if (!strcmp(STR(child), "None")) { ast_error(child, "assignment to None"); @@ -573,7 +580,17 @@ child->n_col_offset, c->c_arena); } else { - arg = compiler_complex_args(c, CHILD(CHILD(n, 2*i), 1)); + assert(TYPE(fpdef_node) == fpdef); + /* fpdef_node[0] is not a name, so it must be a '(', get CHILD[1] */ + child = CHILD(fpdef_node, 1); + assert(TYPE(child) == fplist); + /* NCH == 1 means we have (x), we need to elide the extra parens */ + if (NCH(child) == 1) { + fpdef_node = CHILD(child, 0); + assert(TYPE(fpdef_node) == fpdef); + goto set_name; + } + arg = compiler_complex_args(c, child); } asdl_seq_SET(args, i, arg); } @@ -631,6 +648,7 @@ ch = CHILD(n, i); switch (TYPE(ch)) { case fpdef: + handle_fpdef: /* XXX Need to worry about checking if TYPE(CHILD(n, i+1)) is anything other than EQUAL or a comma? */ /* XXX Should NCH(n) check be made a separate check? */ @@ -656,7 +674,11 @@ asdl_seq_SET(args, k++, compiler_complex_args(c, ch)); } else { /* def foo((x)): setup for checking NAME below. */ + /* Loop because there can be many parens and tuple + unpacking mixed in. */ ch = CHILD(ch, 0); + assert(TYPE(ch) == fpdef); + goto handle_fpdef; } } if (TYPE(CHILD(ch, 0)) == NAME) { Modified: python/branches/bcannon-objcap/Python/getargs.c ============================================================================== --- python/branches/bcannon-objcap/Python/getargs.c (original) +++ python/branches/bcannon-objcap/Python/getargs.c Tue Sep 26 00:38:43 2006 @@ -1747,7 +1747,7 @@ /* For type constructors that don't take keyword args * * Sets a TypeError and returns 0 if the kwds dict is - * not emtpy, returns 1 otherwise + * not empty, returns 1 otherwise */ int _PyArg_NoKeywords(const char *funcname, PyObject *kw) Modified: python/branches/bcannon-objcap/Python/pystate.c ============================================================================== --- python/branches/bcannon-objcap/Python/pystate.c (original) +++ python/branches/bcannon-objcap/Python/pystate.c Tue Sep 26 00:38:43 2006 @@ -501,7 +501,7 @@ { PyThread_delete_key(autoTLSkey); autoTLSkey = 0; - autoInterpreterState = NULL;; + autoInterpreterState = NULL; } /* When a thread state is created for a thread by some mechanism other than Modified: python/branches/bcannon-objcap/configure ============================================================================== --- python/branches/bcannon-objcap/configure (original) +++ python/branches/bcannon-objcap/configure Tue Sep 26 00:38:43 2006 @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 51173 . +# From configure.in Revision: 51727 . # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.59 for python 2.6. # @@ -22110,12 +22110,26 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) + return 1; + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) return 1; return 0; Modified: python/branches/bcannon-objcap/configure.in ============================================================================== --- python/branches/bcannon-objcap/configure.in (original) +++ python/branches/bcannon-objcap/configure.in Tue Sep 26 00:38:43 2006 @@ -3352,14 +3352,28 @@ int main() { - char buffer[4]; + char buffer[256]; + +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_LONG +typedef long Py_ssize_t; +#else +typedef int Py_ssize_t; +#endif if(sprintf(buffer, "%zd", (size_t)123) < 0) return 1; - if (strncmp(buffer, "123", 3)) + if (strcmp(buffer, "123")) return 1; - + + if (sprintf(buffer, "%zd", (Py_ssize_t)-123) < 0) + return 1; + + if (strcmp(buffer, "-123")) + return 1; + return 0; }], [AC_MSG_RESULT(yes) From python-checkins at python.org Tue Sep 26 18:17:41 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 26 Sep 2006 18:17:41 +0200 (CEST) Subject: [Python-checkins] r52006 - sandbox/trunk/setuptools/setuptools/command/egg_info.py Message-ID: <20060926161741.BBD211E4006@bag.python.org> Author: phillip.eby Date: Tue Sep 26 18:17:41 2006 New Revision: 52006 Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py Log: Handle empty revision numbers in SVN 1.4 "entries" format Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/egg_info.py (original) +++ sandbox/trunk/setuptools/setuptools/command/egg_info.py Tue Sep 26 18:17:41 2006 @@ -221,7 +221,7 @@ data = map(str.splitlines,data.split('\n\x0c\n')) del data[0][0] # get rid of the '8' dirurl = data[0][3] - localrev = max([int(d[9]) for d in data if len(d)>9]) + localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]) elif data.startswith(' Author: phillip.eby Date: Tue Sep 26 18:21:25 2006 New Revision: 52007 Modified: sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py Log: Handle empty revision numbers in SVN 1.4 "entries" format (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 Tue Sep 26 18:21:25 2006 @@ -2610,6 +2610,8 @@ installer on Unix, without doing multiple downloads, dealing with firewalls, etc.) + * Fix problem with empty revision numbers in Subversion 1.4 ``entries`` files + 0.6c3 * Fixed breakages caused by Subversion 1.4's new "working copy" format Modified: sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py Tue Sep 26 18:21:25 2006 @@ -221,7 +221,7 @@ data = map(str.splitlines,data.split('\n\x0c\n')) del data[0][0] # get rid of the '8' dirurl = data[0][3] - localrev = max([int(d[9]) for d in data if len(d)>9]) + localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]) elif data.startswith(' Author: phillip.eby Date: Tue Sep 26 22:15:05 2006 New Revision: 52008 Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py sandbox/trunk/setuptools/setuptools/command/sdist.py Log: Should've used distutils.log.warn instead of warnings.warn Modified: sandbox/trunk/setuptools/setuptools/command/egg_info.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/egg_info.py (original) +++ sandbox/trunk/setuptools/setuptools/command/egg_info.py Tue Sep 26 22:15:05 2006 @@ -226,8 +226,7 @@ dirurl = urlre.search(data).group(1) # get repository URL localrev = max([int(m.group(1)) for m in revre.finditer(data)]) else: - from warnings import warn - warn("unrecognized .svn/entries format; skipping "+base) + log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue if base==os.curdir: @@ -244,6 +243,7 @@ + def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") Modified: sandbox/trunk/setuptools/setuptools/command/sdist.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/sdist.py (original) +++ sandbox/trunk/setuptools/setuptools/command/sdist.py Tue Sep 26 22:15:05 2006 @@ -95,8 +95,7 @@ for match in entries_pattern.finditer(data): yield joinpath(dirname,unescape(match.group(1))) else: - from warnings import warn - warn("unrecognized .svn/entries format in "+dirname) + log.warn("unrecognized .svn/entries format in %s", dirname) finders = [ @@ -121,6 +120,7 @@ + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" From python-checkins at python.org Tue Sep 26 22:19:22 2006 From: python-checkins at python.org (phillip.eby) Date: Tue, 26 Sep 2006 22:19:22 +0200 (CEST) Subject: [Python-checkins] r52009 - sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py sandbox/branches/setuptools-0.6/setuptools/command/sdist.py Message-ID: <20060926201922.2068E1E4006@bag.python.org> Author: phillip.eby Date: Tue Sep 26 22:19:21 2006 New Revision: 52009 Modified: sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py sandbox/branches/setuptools-0.6/setuptools/command/sdist.py Log: Should've used distutils.log.warn instead of warnings.warn (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/egg_info.py Tue Sep 26 22:19:21 2006 @@ -226,8 +226,7 @@ dirurl = urlre.search(data).group(1) # get repository URL localrev = max([int(m.group(1)) for m in revre.finditer(data)]) else: - from warnings import warn - warn("unrecognized .svn/entries format; skipping "+base) + log.warn("unrecognized .svn/entries format; skipping %s", base) dirs[:] = [] continue if base==os.curdir: @@ -244,6 +243,7 @@ + def find_sources(self): """Generate SOURCES.txt manifest file""" manifest_filename = os.path.join(self.egg_info,"SOURCES.txt") Modified: sandbox/branches/setuptools-0.6/setuptools/command/sdist.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/sdist.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/sdist.py Tue Sep 26 22:19:21 2006 @@ -95,8 +95,7 @@ for match in entries_pattern.finditer(data): yield joinpath(dirname,unescape(match.group(1))) else: - from warnings import warn - warn("unrecognized .svn/entries format in "+dirname) + log.warn("unrecognized .svn/entries format in %s", dirname) finders = [ @@ -121,6 +120,7 @@ + class sdist(_sdist): """Smart sdist that finds anything supported by revision control""" From python-checkins at python.org Tue Sep 26 22:52:32 2006 From: python-checkins at python.org (brett.cannon) Date: Tue, 26 Sep 2006 22:52:32 +0200 (CEST) Subject: [Python-checkins] r52010 - in python/branches/bcannon-objcap: Lib/test/test_interpreter.py securing_python.txt Message-ID: <20060926205232.E6EDE1E4011@bag.python.org> Author: brett.cannon Date: Tue Sep 26 22:52:32 2006 New Revision: 52010 Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py python/branches/bcannon-objcap/securing_python.txt Log: Verified that exit() does not cause the entire process to exit. Modified: python/branches/bcannon-objcap/Lib/test/test_interpreter.py ============================================================================== --- python/branches/bcannon-objcap/Lib/test/test_interpreter.py (original) +++ python/branches/bcannon-objcap/Lib/test/test_interpreter.py Tue Sep 26 22:52:32 2006 @@ -1,4 +1,4 @@ -""" Things to protect (and thus test) against: +?""" Things to protect (and thus test) against: * Importing + built-ins + .pyc/.pyo @@ -270,6 +270,8 @@ self.failUnlessRaises(RuntimeError, self.interp.execute, "raise SystemExit") self.failUnless(self.interp.exc_matches(SystemExit)) + self.failUnlessRaises(RuntimeError, self.interp.execute, "exit()") + self.failUnless(self.interp.exc_matches(SystemExit)) def test_main(): 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 26 22:52:32 2006 @@ -20,7 +20,7 @@ - frame * do not allow importing 'sys' module to get to sys._getframe(), sys._current_frames(), or setting a trace - or profile function. + or profile function. - object() [done] * Remove object.__subclasses__ (`Mutable Shared State`_) [done] + Sandboxed versions of built-ins (`Sanitizing Built-In Types`_) @@ -34,8 +34,7 @@ * Just promote removal - exit() * Have SystemExit exit the process only if no other - interpreters are running. [done] - * XXX Safe? + interpreters are running. [done] + Filesystem path hiding (`Filesystem Information`_) + Tweaked stdlib modules - mini 'sys' module (`Making the ``sys`` Module Safe`_) From python-checkins at python.org Wed Sep 27 01:38:24 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 27 Sep 2006 01:38:24 +0200 (CEST) Subject: [Python-checkins] r52011 - in python/trunk: Lib/_strptime.py Misc/NEWS Message-ID: <20060926233824.00AC21E4006@bag.python.org> Author: brett.cannon Date: Wed Sep 27 01:38:24 2006 New Revision: 52011 Modified: python/trunk/Lib/_strptime.py python/trunk/Misc/NEWS Log: Make the error message for when the time data and format do not match clearer. Modified: python/trunk/Lib/_strptime.py ============================================================================== --- python/trunk/Lib/_strptime.py (original) +++ python/trunk/Lib/_strptime.py Wed Sep 27 01:38:24 2006 @@ -306,7 +306,7 @@ _cache_lock.release() found = format_regex.match(data_string) if not found: - raise ValueError("time data did not match format: data=%s fmt=%s" % + raise ValueError("time data %r does not match format %r" % (data_string, format)) if len(data_string) != found.end(): raise ValueError("unconverted data remains: %s" % Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 27 01:38:24 2006 @@ -56,6 +56,9 @@ Library ------- +- Made the error message for time.strptime when the data data and format do + match be more clear. + - Fix a bug in traceback.format_exception_only() that led to an error being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. From buildbot at python.org Wed Sep 27 02:48:28 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Sep 2006 00:48:28 +0000 Subject: [Python-checkins] buildbot warnings in x86 XP-2 trunk Message-ID: <20060927004829.0F4631E4008@bag.python.org> The Buildbot has detected a new failure of x86 XP-2 trunk. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520XP-2%2520trunk/builds/920 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: armin.rigo,brett.cannon,fred.drake,georg.brandl,jack.diederich,neal.norwitz,walter.doerwald Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 27 03:56:48 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 27 Sep 2006 03:56:48 +0200 (CEST) Subject: [Python-checkins] r52012 - in sandbox/trunk/setuptools: EasyInstall.txt setuptools/command/easy_install.py setuptools/package_index.py Message-ID: <20060927015648.DD75B1E4007@bag.python.org> Author: phillip.eby Date: Wed Sep 27 03:56:48 2006 New Revision: 52012 Modified: sandbox/trunk/setuptools/EasyInstall.txt sandbox/trunk/setuptools/setuptools/command/easy_install.py sandbox/trunk/setuptools/setuptools/package_index.py Log: Allow explicit selection of Sourceforge mirror(s) with --sf-mirror, and further refine download/retry algorithm. Modified: sandbox/trunk/setuptools/EasyInstall.txt ============================================================================== --- sandbox/trunk/setuptools/EasyInstall.txt (original) +++ sandbox/trunk/setuptools/EasyInstall.txt Wed Sep 27 03:56:48 2006 @@ -357,11 +357,37 @@ Note that if you want to allow downloads from Sourceforge, you need to enable the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated -as if they had this hostname. (If a download attempt from -``dl.sourceforge.net`` fails, it is automatically retried using a randomly -selected mirror IP drawn from the ``sf-mirrors.telecommunity.com`` round-robin -addres. The IP's, however, are not checked against the ``--allow-hosts`` -mask.) +as if they had this hostname, regardless of which mirror is actually used to +do the downloading. If you want to restrict downloading to specific +Sourceforge hosts, you must use the ``--sf-mirrors`` option to set what hosts +will be substituted for ``dl.sourceforge.net``. See the next section for more +details. + + +Selecting Your Preferred Sourceforge Mirror(s) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can use the ``--sf-mirrors`` option on the command line, or via the +standard `configuration files`_, to select what Sourceforge mirrors you want +downloads to take place from. For example, putting this in your +configuration:: + + [easy_install] + sf_mirrors = superb-east, superb-west, easynews + +Would cause ``easy_install`` to always perform Sourceforge downloads using +``superb-east.dl.sourceforge.net``, ``superb-west.dl.sourceforge.net``, or +``easynews.dl.sourceforge.net``. You can also specify IP addresses or full +domain names. + +The actual mirror used will be selected at runtime. If the selected mirror +fails, another mirror will be selected, after eliminating the failed mirror as +a possible choice. + +If you don't specify any mirrors, ``easy_install`` will randomly select mirrors +from the list of IP addresses for ``sf-mirrors.telecommunity.com``. And if +the DNS lookup fails, it will simply make a single download attempt to +``dl.sourceforge.net``, without using any mirrors at all. Installing on Un-networked Machines @@ -883,6 +909,32 @@ setting for this option in their `configuration files`_, and then manually override the setting on the command line as needed. + Note that if you wish to allow Sourceforge downloads, you must allow access + to ``dl.sourceforge.net``. You do not have to list individual Sourceforge + mirror addresses, as mirror selection is controlled by the ``--sf-mirrors`` + option. + +``--sf-mirrors=NAMES`` (New in 0.6c4) + Set the list of Sourceforge mirror sites to use for downloads published by + Sourceforge. EasyInstall will randomly select one for each Sourceforge + download attempt. + + Mirror sites can be given by name (e.g. ``easynews``, ``superb-east``, + etc.) or by full hostname/IP address (e.g. ``easynews.dl.sf.net``). Use a + comma to separate mirrors. + + If you do not provide any names, EasyInstall will use the list of IP + addresses provided by the ``sf-mirrors.telecommunity.com`` subdomain, which + is automatically updated daily from Sourceforge's UI pages and DNS. + + If, due to firewall protections or server failure, it isn't possible to get + the mirror list from ``sf-mirrors.telecommunity.com``, EasyInstall will + attempt to perform all downloads directly from ``dl.sourceforge.net`` + without selecting a mirror. (Note, however, that this is extremely + unreliable due to Sourceforge not keeping the ``dl.sourceforge.net`` IP + addresses up to date with their UI! This is why the backup system at + ``sf-mirrors.telecommunity.com`` exists.) + ``--prefix=DIR`` (New in 0.6a10) Use the specified directory as a base for computing the default installation and script directories. On Windows, the resulting default 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 27 03:56:48 2006 @@ -70,6 +70,7 @@ ('editable', 'e', "Install specified packages in editable form"), ('no-deps', 'N', "don't install dependencies"), ('allow-hosts=', 'H', "pattern(s) that hostnames must match"), + ('sf-mirrors=', None, "Sourceforge mirror(s) to use"), ] boolean_options = [ 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy', @@ -79,7 +80,6 @@ negative_opt = {'always-unzip': 'zip-ok'} create_index = PackageIndex - def initialize_options(self): self.zip_ok = None self.install_dir = self.script_dir = self.exclude_scripts = None @@ -90,7 +90,7 @@ self.optimize = self.record = None self.upgrade = self.always_copy = self.multi_version = None self.editable = self.no_deps = self.allow_hosts = None - self.root = self.prefix = self.no_report = None + self.root = self.prefix = self.no_report = self.sf_mirrors = None # Options not specifiable via command line self.package_index = None @@ -166,10 +166,10 @@ hosts = [s.strip() for s in self.allow_hosts.split(',')] else: hosts = ['*'] - if self.package_index is None: self.package_index = self.create_index( - self.index_url, search_path = self.shadow_path, hosts=hosts + self.index_url, search_path = self.shadow_path, hosts=hosts, + sf_mirrors = self.sf_mirrors ) self.local_index = Environment(self.shadow_path+sys.path) Modified: sandbox/trunk/setuptools/setuptools/package_index.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/package_index.py (original) +++ sandbox/trunk/setuptools/setuptools/package_index.py Wed Sep 27 03:56:48 2006 @@ -14,7 +14,7 @@ '([^<]+)\n\s+\\(md5\\)' ) - +SF_DOWNLOAD = 'dl.sourceforge.net' URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split() @@ -165,7 +165,9 @@ class PackageIndex(Environment): """A distribution index that scans web pages for download URLs""" - def __init__(self,index_url="http://www.python.org/pypi",hosts=('*',),*args,**kw): + def __init__(self, index_url="http://www.python.org/pypi", hosts=('*',), + sf_mirrors=None, *args, **kw + ): Environment.__init__(self,*args,**kw) self.index_url = index_url + "/"[:not index_url.endswith('/')] self.scanned_urls = {} @@ -173,6 +175,33 @@ self.package_pages = {} self.allows = re.compile('|'.join(map(translate,hosts))).match self.to_scan = [] + if sf_mirrors: + if isinstance(sf_mirrors,str): + self.sf_mirrors = map(str.strip, sf_mirrors.split(',')) + else: + self.sf_mirrors = map(str.strip, sf_mirrors) + else: + self.sf_mirrors = () + + + def _get_mirrors(self): + mirrors = [] + for mirror in self.sf_mirrors: + if mirror: + if '.' not in mirror: + mirror += '.dl.sourceforge.net' + mirrors.append(mirror) + + if not mirrors: + try: + mirrors.extend( + socket.gethostbyname_ex('sf-mirrors.telecommunity.com')[-1] + ) + except socket.error: + # DNS-bl0ck1n9 f1r3w4llz sUx0rs! + mirrors[:] = [SF_DOWNLOAD] + + return mirrors def process_url(self, url, retrieve=False): """Evaluate a URL as a possible download, and maybe retrieve it""" @@ -202,7 +231,6 @@ f = self.open_url(url) self.fetched_urls[url] = self.fetched_urls[f.url] = True - if 'html' not in f.headers.get('content-type', '').lower(): f.close() # not html, we can't process it return @@ -212,7 +240,6 @@ f.close() if url.startswith(self.index_url) and getattr(f,'code',None)!=404: page = self.process_index(url, page) - for match in HREF.finditer(page): link = urlparse.urljoin(base, match.group(1)) self.process_url(link) @@ -244,6 +271,20 @@ + + + + + + + + + + + + + + def process_index(self,url,page): """Process the contents of a PyPI page""" def scan(link): @@ -581,27 +622,27 @@ def _retry_sf_download(self, url, filename): self.url_ok(url, True) # raises error if not allowed - try: - return self._attempt_download(url, filename) - except (KeyboardInterrupt,SystemExit): - raise - except: - scheme, server, path, param, query, frag = urlparse.urlparse(url) - if server!='dl.sourceforge.net': - raise + scheme, server, path, param, query, frag = urlparse.urlparse(url) + + if server == SF_DOWNLOAD: + mirrors = self._get_mirrors() + query = '' + else: + mirrors = [server] - mirror = get_sf_ip() + while mirrors or server != SF_DOWNLOAD: + mirror = random.choice(mirrors) + url = urlparse.urlunparse((scheme,mirror,path,param,query,frag)) - while _sf_mirrors: - self.warn("Download failed: %s", sys.exc_info()[1]) - url = urlparse.urlunparse((scheme, mirror, path, param, '', frag)) try: return self._attempt_download(url, filename) except (KeyboardInterrupt,SystemExit): raise except: - _sf_mirrors.remove(mirror) # don't retry the same mirror - mirror = get_sf_ip() + if server != SF_DOWNLOAD: + raise + self.warn("Download failed: %s", sys.exc_info()[1]) + mirrors.remove(mirror) raise # fail if no mirror works @@ -692,22 +733,9 @@ if server!='prdownloads.sourceforge.net': return url return urlparse.urlunparse( - (scheme, 'dl.sourceforge.net', 'sourceforge'+path, param, '', frag) + (scheme, SF_DOWNLOAD, 'sourceforge'+path, param, '', frag) ) -_sf_mirrors = [] - -def get_sf_ip(): - if not _sf_mirrors: - try: - _sf_mirrors[:] = socket.gethostbyname_ex( - 'sf-mirrors.telecommunity.com')[-1] - except socket.error: - # DNS-bl0ck1n9 f1r3w4llz sUx0rs! - _sf_mirrors[:] = ['dl.sourceforge.net'] - return random.choice(_sf_mirrors) - - def local_open(url): """Read a local path, with special support for directories""" scheme, server, path, param, query, frag = urlparse.urlparse(url) @@ -735,4 +763,17 @@ + + + + + + + + + + + + + # this line is a kludge to keep the trailing blank lines for pje's editor From python-checkins at python.org Wed Sep 27 03:58:23 2006 From: python-checkins at python.org (phillip.eby) Date: Wed, 27 Sep 2006 03:58:23 +0200 (CEST) Subject: [Python-checkins] r52013 - in sandbox/branches/setuptools-0.6: EasyInstall.txt setuptools/command/easy_install.py setuptools/package_index.py Message-ID: <20060927015823.4A0221E4006@bag.python.org> Author: phillip.eby Date: Wed Sep 27 03:58:22 2006 New Revision: 52013 Modified: sandbox/branches/setuptools-0.6/EasyInstall.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py sandbox/branches/setuptools-0.6/setuptools/package_index.py Log: Allow explicit selection of Sourceforge mirror(s) with ``--sf-mirror``, and further refine download/retry algorithm. (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 27 03:58:22 2006 @@ -357,11 +357,37 @@ Note that if you want to allow downloads from Sourceforge, you need to enable the ``dl.sourceforge.net`` host. All Sourceforge mirror downloads are treated -as if they had this hostname. (If a download attempt from -``dl.sourceforge.net`` fails, it is automatically retried using a randomly -selected mirror IP drawn from the ``sf-mirrors.telecommunity.com`` round-robin -addres. The IP's, however, are not checked against the ``--allow-hosts`` -mask.) +as if they had this hostname, regardless of which mirror is actually used to +do the downloading. If you want to restrict downloading to specific +Sourceforge hosts, you must use the ``--sf-mirrors`` option to set what hosts +will be substituted for ``dl.sourceforge.net``. See the next section for more +details. + + +Selecting Your Preferred Sourceforge Mirror(s) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can use the ``--sf-mirrors`` option on the command line, or via the +standard `configuration files`_, to select what Sourceforge mirrors you want +downloads to take place from. For example, putting this in your +configuration:: + + [easy_install] + sf_mirrors = superb-east, superb-west, easynews + +Would cause ``easy_install`` to always perform Sourceforge downloads using +``superb-east.dl.sourceforge.net``, ``superb-west.dl.sourceforge.net``, or +``easynews.dl.sourceforge.net``. You can also specify IP addresses or full +domain names. + +The actual mirror used will be selected at runtime. If the selected mirror +fails, another mirror will be selected, after eliminating the failed mirror as +a possible choice. + +If you don't specify any mirrors, ``easy_install`` will randomly select mirrors +from the list of IP addresses for ``sf-mirrors.telecommunity.com``. And if +the DNS lookup fails, it will simply make a single download attempt to +``dl.sourceforge.net``, without using any mirrors at all. Installing on Un-networked Machines @@ -883,6 +909,32 @@ setting for this option in their `configuration files`_, and then manually override the setting on the command line as needed. + Note that if you wish to allow Sourceforge downloads, you must allow access + to ``dl.sourceforge.net``. You do not have to list individual Sourceforge + mirror addresses, as mirror selection is controlled by the ``--sf-mirrors`` + option. + +``--sf-mirrors=NAMES`` (New in 0.6c4) + Set the list of Sourceforge mirror sites to use for downloads published by + Sourceforge. EasyInstall will randomly select one for each Sourceforge + download attempt. + + Mirror sites can be given by name (e.g. ``easynews``, ``superb-east``, + etc.) or by full hostname/IP address (e.g. ``easynews.dl.sf.net``). Use a + comma to separate mirrors. + + If you do not provide any names, EasyInstall will use the list of IP + addresses provided by the ``sf-mirrors.telecommunity.com`` subdomain, which + is automatically updated daily from Sourceforge's UI pages and DNS. + + If, due to firewall protections or server failure, it isn't possible to get + the mirror list from ``sf-mirrors.telecommunity.com``, EasyInstall will + attempt to perform all downloads directly from ``dl.sourceforge.net`` + without selecting a mirror. (Note, however, that this is extremely + unreliable due to Sourceforge not keeping the ``dl.sourceforge.net`` IP + addresses up to date with their UI! This is why the backup system at + ``sf-mirrors.telecommunity.com`` exists.) + ``--prefix=DIR`` (New in 0.6a10) Use the specified directory as a base for computing the default installation and script directories. On Windows, the resulting default @@ -1210,6 +1262,9 @@ should've returned a 404. Fall back to ``sf-mirrors.telecommunity.com`` round-robin address for SF mirrors if ``dl.sourceforge.net`` doesn't work. + * Allow explicit selection of Sourceforge mirror(s) with ``--sf-mirror``, and + further refine download/retry algorithm. + 0.6c3 * You once again use "python -m easy_install" with Python 2.4 and above. 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 27 03:58:22 2006 @@ -70,6 +70,7 @@ ('editable', 'e', "Install specified packages in editable form"), ('no-deps', 'N', "don't install dependencies"), ('allow-hosts=', 'H', "pattern(s) that hostnames must match"), + ('sf-mirrors=', None, "Sourceforge mirror(s) to use"), ] boolean_options = [ 'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy', @@ -79,7 +80,6 @@ negative_opt = {'always-unzip': 'zip-ok'} create_index = PackageIndex - def initialize_options(self): self.zip_ok = None self.install_dir = self.script_dir = self.exclude_scripts = None @@ -90,7 +90,7 @@ self.optimize = self.record = None self.upgrade = self.always_copy = self.multi_version = None self.editable = self.no_deps = self.allow_hosts = None - self.root = self.prefix = self.no_report = None + self.root = self.prefix = self.no_report = self.sf_mirrors = None # Options not specifiable via command line self.package_index = None @@ -166,10 +166,10 @@ hosts = [s.strip() for s in self.allow_hosts.split(',')] else: hosts = ['*'] - if self.package_index is None: self.package_index = self.create_index( - self.index_url, search_path = self.shadow_path, hosts=hosts + self.index_url, search_path = self.shadow_path, hosts=hosts, + sf_mirrors = self.sf_mirrors ) self.local_index = Environment(self.shadow_path+sys.path) Modified: sandbox/branches/setuptools-0.6/setuptools/package_index.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/package_index.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/package_index.py Wed Sep 27 03:58:22 2006 @@ -14,7 +14,7 @@ '([^<]+)\n\s+\\(md5\\)' ) - +SF_DOWNLOAD = 'dl.sourceforge.net' URL_SCHEME = re.compile('([-+.a-z0-9]{2,}):',re.I).match EXTENSIONS = ".tar.gz .tar.bz2 .tar .zip .tgz".split() @@ -165,7 +165,9 @@ class PackageIndex(Environment): """A distribution index that scans web pages for download URLs""" - def __init__(self,index_url="http://www.python.org/pypi",hosts=('*',),*args,**kw): + def __init__(self, index_url="http://www.python.org/pypi", hosts=('*',), + sf_mirrors=None, *args, **kw + ): Environment.__init__(self,*args,**kw) self.index_url = index_url + "/"[:not index_url.endswith('/')] self.scanned_urls = {} @@ -173,6 +175,33 @@ self.package_pages = {} self.allows = re.compile('|'.join(map(translate,hosts))).match self.to_scan = [] + if sf_mirrors: + if isinstance(sf_mirrors,str): + self.sf_mirrors = map(str.strip, sf_mirrors.split(',')) + else: + self.sf_mirrors = map(str.strip, sf_mirrors) + else: + self.sf_mirrors = () + + + def _get_mirrors(self): + mirrors = [] + for mirror in self.sf_mirrors: + if mirror: + if '.' not in mirror: + mirror += '.dl.sourceforge.net' + mirrors.append(mirror) + + if not mirrors: + try: + mirrors.extend( + socket.gethostbyname_ex('sf-mirrors.telecommunity.com')[-1] + ) + except socket.error: + # DNS-bl0ck1n9 f1r3w4llz sUx0rs! + mirrors[:] = [SF_DOWNLOAD] + + return mirrors def process_url(self, url, retrieve=False): """Evaluate a URL as a possible download, and maybe retrieve it""" @@ -202,7 +231,6 @@ f = self.open_url(url) self.fetched_urls[url] = self.fetched_urls[f.url] = True - if 'html' not in f.headers.get('content-type', '').lower(): f.close() # not html, we can't process it return @@ -212,7 +240,6 @@ f.close() if url.startswith(self.index_url) and getattr(f,'code',None)!=404: page = self.process_index(url, page) - for match in HREF.finditer(page): link = urlparse.urljoin(base, match.group(1)) self.process_url(link) @@ -244,6 +271,20 @@ + + + + + + + + + + + + + + def process_index(self,url,page): """Process the contents of a PyPI page""" def scan(link): @@ -581,27 +622,27 @@ def _retry_sf_download(self, url, filename): self.url_ok(url, True) # raises error if not allowed - try: - return self._attempt_download(url, filename) - except (KeyboardInterrupt,SystemExit): - raise - except: - scheme, server, path, param, query, frag = urlparse.urlparse(url) - if server!='dl.sourceforge.net': - raise + scheme, server, path, param, query, frag = urlparse.urlparse(url) + + if server == SF_DOWNLOAD: + mirrors = self._get_mirrors() + query = '' + else: + mirrors = [server] - mirror = get_sf_ip() + while mirrors or server != SF_DOWNLOAD: + mirror = random.choice(mirrors) + url = urlparse.urlunparse((scheme,mirror,path,param,query,frag)) - while _sf_mirrors: - self.warn("Download failed: %s", sys.exc_info()[1]) - url = urlparse.urlunparse((scheme, mirror, path, param, '', frag)) try: return self._attempt_download(url, filename) except (KeyboardInterrupt,SystemExit): raise except: - _sf_mirrors.remove(mirror) # don't retry the same mirror - mirror = get_sf_ip() + if server != SF_DOWNLOAD: + raise + self.warn("Download failed: %s", sys.exc_info()[1]) + mirrors.remove(mirror) raise # fail if no mirror works @@ -692,22 +733,9 @@ if server!='prdownloads.sourceforge.net': return url return urlparse.urlunparse( - (scheme, 'dl.sourceforge.net', 'sourceforge'+path, param, '', frag) + (scheme, SF_DOWNLOAD, 'sourceforge'+path, param, '', frag) ) -_sf_mirrors = [] - -def get_sf_ip(): - if not _sf_mirrors: - try: - _sf_mirrors[:] = socket.gethostbyname_ex( - 'sf-mirrors.telecommunity.com')[-1] - except socket.error: - # DNS-bl0ck1n9 f1r3w4llz sUx0rs! - _sf_mirrors[:] = ['dl.sourceforge.net'] - return random.choice(_sf_mirrors) - - def local_open(url): """Read a local path, with special support for directories""" scheme, server, path, param, query, frag = urlparse.urlparse(url) @@ -735,4 +763,17 @@ + + + + + + + + + + + + + # this line is a kludge to keep the trailing blank lines for pje's editor From python-checkins at python.org Wed Sep 27 18:37:31 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 18:37:31 +0200 (CEST) Subject: [Python-checkins] r52014 - python/trunk/Misc/NEWS Message-ID: <20060927163731.8802B1E4007@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 18:37:30 2006 New Revision: 52014 Modified: python/trunk/Misc/NEWS Log: Add news item for rev. 51815 Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Wed Sep 27 18:37:30 2006 @@ -105,6 +105,12 @@ - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 0213:2 codepoints now. +- Bug #1552726: in readline.c, avoid repeatedly polling in interactive + mode by only placing a timeout on the select() if an input hook has + been defined. This prevents an interactive Python from waking up 10 + times per second. Patch by Richard Boulton. + + Tests ----- From python-checkins at python.org Wed Sep 27 21:02:03 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:02:03 +0200 (CEST) Subject: [Python-checkins] r52015 - in python/branches/release24-maint: Misc/NEWS Modules/_cursesmodule.c Message-ID: <20060927190203.79FF11E4009@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:02:02 2006 New Revision: 52015 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/_cursesmodule.c Log: [Backport rev.51254 from neal.norwitz] Handle failure from PyModule_GetDict() (Klocwork 208). Fix a bunch of refleaks in the init of the module. This would only be found when running python -v. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Sep 27 21:02:02 2006 @@ -61,6 +61,9 @@ - Bug #1471938: Fix curses module build problem on Solaris 8; patch by Paul Eggert. +- cursesmodule: fix a number of reference leaks with 'python -v'; handle + failure from PyModule_GetDict (Klocwork 208). + - Bug #1512695: cPickle.loads could crash if it was interrupted with a KeyboardInterrupt. Modified: python/branches/release24-maint/Modules/_cursesmodule.c ============================================================================== --- python/branches/release24-maint/Modules/_cursesmodule.c (original) +++ python/branches/release24-maint/Modules/_cursesmodule.c Wed Sep 27 21:02:02 2006 @@ -1784,7 +1784,6 @@ PyCurses_InitScr(PyObject *self) { WINDOW *win; - PyObject *nlines, *cols; if (initialised == TRUE) { wrefresh(stdscr); @@ -1803,7 +1802,12 @@ /* This was moved from initcurses() because it core dumped on SGI, where they're not defined until you've called initscr() */ #define SetDictInt(string,ch) \ - PyDict_SetItemString(ModDict,string,PyInt_FromLong((long) (ch))); + do { \ + PyObject *o = PyInt_FromLong((long) (ch)); \ + if (o && PyDict_SetItemString(ModDict, string, o) == 0) { \ + Py_DECREF(o); \ + } \ + } while (0) /* Here are some graphic symbols you can use */ SetDictInt("ACS_ULCORNER", (ACS_ULCORNER)); @@ -1872,12 +1876,8 @@ SetDictInt("ACS_STERLING", (ACS_STERLING)); #endif - nlines = PyInt_FromLong((long) LINES); - PyDict_SetItemString(ModDict, "LINES", nlines); - Py_DECREF(nlines); - cols = PyInt_FromLong((long) COLS); - PyDict_SetItemString(ModDict, "COLS", cols); - Py_DECREF(cols); + SetDictInt("LINES", LINES); + SetDictInt("COLS", COLS); return (PyObject *)PyCursesWindow_New(win); } @@ -2487,6 +2487,8 @@ /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); + if (d == NULL) + return; ModDict = d; /* For PyCurses_InitScr to use later */ /* Add a CObject for the C API */ @@ -2600,6 +2602,10 @@ if (strncmp(key_n,"KEY_F(",6)==0) { char *p1, *p2; key_n2 = malloc(strlen(key_n)+1); + if (!key_n2) { + PyErr_NoMemory(); + break; + } p1 = key_n; p2 = key_n2; while (*p1) { @@ -2612,7 +2618,7 @@ *p2 = (char)0; } else key_n2 = key_n; - PyDict_SetItemString(d,key_n2,PyInt_FromLong((long) key)); + SetDictInt(key_n2,key); if (key_n2 != key_n) free(key_n2); } From python-checkins at python.org Wed Sep 27 21:04:54 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:04:54 +0200 (CEST) Subject: [Python-checkins] r52016 - in python/branches/release24-maint: Misc/NEWS Modules/_cursesmodule.c Message-ID: <20060927190454.3AA9F1E4007@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:04:53 2006 New Revision: 52016 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/_cursesmodule.c Log: [Backport of rev. 51683 by neal.norwitz] Bug #1548092: fix curses.tparm seg fault on invalid input. Needs backport to 2.5.1 and earlier. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Sep 27 21:04:53 2006 @@ -61,6 +61,8 @@ - Bug #1471938: Fix curses module build problem on Solaris 8; patch by Paul Eggert. +- Bug #1548092: fix curses.tparm() segfault on invalid input. + - cursesmodule: fix a number of reference leaks with 'python -v'; handle failure from PyModule_GetDict (Klocwork 208). Modified: python/branches/release24-maint/Modules/_cursesmodule.c ============================================================================== --- python/branches/release24-maint/Modules/_cursesmodule.c (original) +++ python/branches/release24-maint/Modules/_cursesmodule.c Wed Sep 27 21:04:53 2006 @@ -2278,6 +2278,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 Wed Sep 27 21:17:41 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:17:41 +0200 (CEST) Subject: [Python-checkins] r52017 - in python/branches/release24-maint: Misc/NEWS Modules/_bsddb.c Modules/_curses_panel.c Modules/_cursesmodule.c Modules/_heapqmodule.c Modules/_localemodule.c Modules/_randommodule.c Modules/_sre.c Modules/_ssl.c Modules/_testcapimodule.c Modules/_tkinter.c Modules/almodule.c Modules/arraymodule.c Modules/audioop.c Modules/binascii.c Modules/bsddbmodule.c Modules/bz2module.c Modules/cPickle.c Modules/cStringIO.c Modules/cdmodule.c Modules/clmodule.c Modules/cmathmodule.c Modules/collectionsmodule.c Modules/datetimemodule.c Modules/dbmmodule.c Modules/dlmodule.c Modules/errnomodule.c Modules/fcntlmodule.c Modules/flmodule.c Modules/fmmodule.c Modules/fpectlmodule.c Modules/fpetestmodule.c Modules/gcmodule.c Modules/gdbmmodule.c Modules/grpmodule.c Modules/imageop.c Modules/imgfile.c Modules/itertoolsmodule.c Modules/linuxaudiodev.c Modules/mathmodule.c Modules/md5module.c Modules/mmapmodule.c Modules/nismodule.c Modules/operator.c Modules/ossaudiodev.c Modules/parsermodule.c Modules/posixmodule.c Modules/puremodule.c Modules/pwdmodule.c Modules/pyexpat.c Modules/readline.c Modules/regexmodule.c Modules/resource.c Modules/rgbimgmodule.c Modules/selectmodule.c Modules/shamodule.c Modules/signalmodule.c Modules/socketmodule.c Modules/stropmodule.c Modules/structmodule.c Modules/sunaudiodev.c Modules/svmodule.c Modules/symtablemodule.c Modules/syslogmodule.c Modules/termios.c Modules/threadmodule.c Modules/timemodule.c Modules/xxmodule.c PC/_subprocess.c PC/_winreg.c PC/msvcrtmodule.c PC/winsound.c Python/import.c Python/marshal.c Python/sysmodule.c Message-ID: <20060927191741.309581E4006@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:17:32 2006 New Revision: 52017 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/_bsddb.c python/branches/release24-maint/Modules/_curses_panel.c python/branches/release24-maint/Modules/_cursesmodule.c python/branches/release24-maint/Modules/_heapqmodule.c python/branches/release24-maint/Modules/_localemodule.c python/branches/release24-maint/Modules/_randommodule.c python/branches/release24-maint/Modules/_sre.c python/branches/release24-maint/Modules/_ssl.c python/branches/release24-maint/Modules/_testcapimodule.c python/branches/release24-maint/Modules/_tkinter.c python/branches/release24-maint/Modules/almodule.c python/branches/release24-maint/Modules/arraymodule.c python/branches/release24-maint/Modules/audioop.c python/branches/release24-maint/Modules/binascii.c python/branches/release24-maint/Modules/bsddbmodule.c python/branches/release24-maint/Modules/bz2module.c python/branches/release24-maint/Modules/cPickle.c python/branches/release24-maint/Modules/cStringIO.c python/branches/release24-maint/Modules/cdmodule.c python/branches/release24-maint/Modules/clmodule.c python/branches/release24-maint/Modules/cmathmodule.c python/branches/release24-maint/Modules/collectionsmodule.c python/branches/release24-maint/Modules/datetimemodule.c python/branches/release24-maint/Modules/dbmmodule.c python/branches/release24-maint/Modules/dlmodule.c python/branches/release24-maint/Modules/errnomodule.c python/branches/release24-maint/Modules/fcntlmodule.c python/branches/release24-maint/Modules/flmodule.c python/branches/release24-maint/Modules/fmmodule.c python/branches/release24-maint/Modules/fpectlmodule.c python/branches/release24-maint/Modules/fpetestmodule.c python/branches/release24-maint/Modules/gcmodule.c python/branches/release24-maint/Modules/gdbmmodule.c python/branches/release24-maint/Modules/grpmodule.c python/branches/release24-maint/Modules/imageop.c python/branches/release24-maint/Modules/imgfile.c python/branches/release24-maint/Modules/itertoolsmodule.c python/branches/release24-maint/Modules/linuxaudiodev.c python/branches/release24-maint/Modules/mathmodule.c python/branches/release24-maint/Modules/md5module.c python/branches/release24-maint/Modules/mmapmodule.c python/branches/release24-maint/Modules/nismodule.c python/branches/release24-maint/Modules/operator.c python/branches/release24-maint/Modules/ossaudiodev.c python/branches/release24-maint/Modules/parsermodule.c python/branches/release24-maint/Modules/posixmodule.c python/branches/release24-maint/Modules/puremodule.c python/branches/release24-maint/Modules/pwdmodule.c python/branches/release24-maint/Modules/pyexpat.c python/branches/release24-maint/Modules/readline.c python/branches/release24-maint/Modules/regexmodule.c python/branches/release24-maint/Modules/resource.c python/branches/release24-maint/Modules/rgbimgmodule.c python/branches/release24-maint/Modules/selectmodule.c python/branches/release24-maint/Modules/shamodule.c python/branches/release24-maint/Modules/signalmodule.c python/branches/release24-maint/Modules/socketmodule.c python/branches/release24-maint/Modules/stropmodule.c python/branches/release24-maint/Modules/structmodule.c python/branches/release24-maint/Modules/sunaudiodev.c python/branches/release24-maint/Modules/svmodule.c python/branches/release24-maint/Modules/symtablemodule.c python/branches/release24-maint/Modules/syslogmodule.c python/branches/release24-maint/Modules/termios.c python/branches/release24-maint/Modules/threadmodule.c python/branches/release24-maint/Modules/timemodule.c python/branches/release24-maint/Modules/xxmodule.c python/branches/release24-maint/PC/_subprocess.c python/branches/release24-maint/PC/_winreg.c python/branches/release24-maint/PC/msvcrtmodule.c python/branches/release24-maint/PC/winsound.c python/branches/release24-maint/Python/import.c python/branches/release24-maint/Python/marshal.c python/branches/release24-maint/Python/sysmodule.c Log: [Backport of rev. 42093 by neal.norwitz] Check return result from Py_InitModule*(). This API can fail. Probably should be backported. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Sep 27 21:17:32 2006 @@ -15,6 +15,8 @@ - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. +- Fix warnings reported by Klocwork's static analysis tool. + - 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/Modules/_bsddb.c ============================================================================== --- python/branches/release24-maint/Modules/_bsddb.c (original) +++ python/branches/release24-maint/Modules/_bsddb.c Wed Sep 27 21:17:32 2006 @@ -4846,6 +4846,8 @@ /* Create the module and add the functions */ m = Py_InitModule(_bsddbModuleName, bsddb_methods); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/_curses_panel.c ============================================================================== --- python/branches/release24-maint/Modules/_curses_panel.c (original) +++ python/branches/release24-maint/Modules/_curses_panel.c Wed Sep 27 21:17:32 2006 @@ -464,6 +464,8 @@ /* Create the module and add the functions */ m = Py_InitModule("_curses_panel", PyCurses_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); /* For exception _curses_panel.error */ Modified: python/branches/release24-maint/Modules/_cursesmodule.c ============================================================================== --- python/branches/release24-maint/Modules/_cursesmodule.c (original) +++ python/branches/release24-maint/Modules/_cursesmodule.c Wed Sep 27 21:17:32 2006 @@ -2488,6 +2488,8 @@ /* Create the module and add the functions */ m = Py_InitModule("_curses", PyCurses_methods); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/_heapqmodule.c ============================================================================== --- python/branches/release24-maint/Modules/_heapqmodule.c (original) +++ python/branches/release24-maint/Modules/_heapqmodule.c Wed Sep 27 21:17:32 2006 @@ -610,6 +610,8 @@ PyObject *m; m = Py_InitModule3("_heapq", heapq_methods, module_doc); + if (m == NULL) + return; PyModule_AddObject(m, "__about__", PyString_FromString(__about__)); } Modified: python/branches/release24-maint/Modules/_localemodule.c ============================================================================== --- python/branches/release24-maint/Modules/_localemodule.c (original) +++ python/branches/release24-maint/Modules/_localemodule.c Wed Sep 27 21:17:32 2006 @@ -715,6 +715,8 @@ #endif m = Py_InitModule("_locale", PyLocale_Methods); + if (m == NULL) + return; d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/_randommodule.c ============================================================================== --- python/branches/release24-maint/Modules/_randommodule.c (original) +++ python/branches/release24-maint/Modules/_randommodule.c Wed Sep 27 21:17:32 2006 @@ -573,6 +573,8 @@ if (PyType_Ready(&Random_Type) < 0) return; m = Py_InitModule3("_random", NULL, module_doc); + if (m == NULL) + return; Py_INCREF(&Random_Type); PyModule_AddObject(m, "Random", (PyObject *)&Random_Type); } Modified: python/branches/release24-maint/Modules/_sre.c ============================================================================== --- python/branches/release24-maint/Modules/_sre.c (original) +++ python/branches/release24-maint/Modules/_sre.c Wed Sep 27 21:17:32 2006 @@ -3389,6 +3389,8 @@ Scanner_Type.ob_type = &PyType_Type; m = Py_InitModule("_" SRE_MODULE, _functions); + if (m == NULL) + return; d = PyModule_GetDict(m); x = PyInt_FromLong(SRE_MAGIC); Modified: python/branches/release24-maint/Modules/_ssl.c ============================================================================== --- python/branches/release24-maint/Modules/_ssl.c (original) +++ python/branches/release24-maint/Modules/_ssl.c Wed Sep 27 21:17:32 2006 @@ -657,6 +657,8 @@ PySSL_Type.ob_type = &PyType_Type; m = Py_InitModule3("_ssl", PySSL_methods, module_doc); + if (m == NULL) + return; d = PyModule_GetDict(m); /* Load _socket module and its C API */ Modified: python/branches/release24-maint/Modules/_testcapimodule.c ============================================================================== --- python/branches/release24-maint/Modules/_testcapimodule.c (original) +++ python/branches/release24-maint/Modules/_testcapimodule.c Wed Sep 27 21:17:32 2006 @@ -856,6 +856,8 @@ Copyable_Type.ob_type = &PyType_Type; m = Py_InitModule("_testcapi", TestMethods); + if (m == NULL) + return; PyModule_AddObject(m, "UCHAR_MAX", PyInt_FromLong(UCHAR_MAX)); PyModule_AddObject(m, "USHRT_MAX", PyInt_FromLong(USHRT_MAX)); Modified: python/branches/release24-maint/Modules/_tkinter.c ============================================================================== --- python/branches/release24-maint/Modules/_tkinter.c (original) +++ python/branches/release24-maint/Modules/_tkinter.c Wed Sep 27 21:17:32 2006 @@ -3093,6 +3093,8 @@ #endif m = Py_InitModule("_tkinter", moduleMethods); + if (m == NULL) + return; d = PyModule_GetDict(m); Tkinter_TclError = PyErr_NewException("_tkinter.TclError", NULL, NULL); Modified: python/branches/release24-maint/Modules/almodule.c ============================================================================== --- python/branches/release24-maint/Modules/almodule.c (original) +++ python/branches/release24-maint/Modules/almodule.c Wed Sep 27 21:17:32 2006 @@ -1998,6 +1998,8 @@ m = Py_InitModule4("al", al_methods, al_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/arraymodule.c ============================================================================== --- python/branches/release24-maint/Modules/arraymodule.c (original) +++ python/branches/release24-maint/Modules/arraymodule.c Wed Sep 27 21:17:32 2006 @@ -2096,6 +2096,8 @@ Arraytype.ob_type = &PyType_Type; PyArrayIter_Type.ob_type = &PyType_Type; m = Py_InitModule3("array", a_methods, module_doc); + if (m == NULL) + return; Py_INCREF((PyObject *)&Arraytype); PyModule_AddObject(m, "ArrayType", (PyObject *)&Arraytype); Modified: python/branches/release24-maint/Modules/audioop.c ============================================================================== --- python/branches/release24-maint/Modules/audioop.c (original) +++ python/branches/release24-maint/Modules/audioop.c Wed Sep 27 21:17:32 2006 @@ -1376,6 +1376,8 @@ { PyObject *m, *d; m = Py_InitModule("audioop", audioop_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); AudioopError = PyErr_NewException("audioop.error", NULL, NULL); if (AudioopError != NULL) Modified: python/branches/release24-maint/Modules/binascii.c ============================================================================== --- python/branches/release24-maint/Modules/binascii.c (original) +++ python/branches/release24-maint/Modules/binascii.c Wed Sep 27 21:17:32 2006 @@ -1334,6 +1334,8 @@ /* Create the module and add the functions */ m = Py_InitModule("binascii", binascii_module_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); x = PyString_FromString(doc_binascii); Modified: python/branches/release24-maint/Modules/bsddbmodule.c ============================================================================== --- python/branches/release24-maint/Modules/bsddbmodule.c (original) +++ python/branches/release24-maint/Modules/bsddbmodule.c Wed Sep 27 21:17:32 2006 @@ -849,6 +849,8 @@ Bsddbtype.ob_type = &PyType_Type; m = Py_InitModule("bsddb185", bsddbmodule_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); BsddbError = PyErr_NewException("bsddb.error", NULL, NULL); if (BsddbError != NULL) Modified: python/branches/release24-maint/Modules/bz2module.c ============================================================================== --- python/branches/release24-maint/Modules/bz2module.c (original) +++ python/branches/release24-maint/Modules/bz2module.c Wed Sep 27 21:17:32 2006 @@ -2197,6 +2197,8 @@ BZ2Decomp_Type.ob_type = &PyType_Type; m = Py_InitModule3("bz2", bz2_methods, bz2__doc__); + if (m == NULL) + return; PyModule_AddObject(m, "__author__", PyString_FromString(__author__)); Modified: python/branches/release24-maint/Modules/cPickle.c ============================================================================== --- python/branches/release24-maint/Modules/cPickle.c (original) +++ python/branches/release24-maint/Modules/cPickle.c Wed Sep 27 21:17:32 2006 @@ -5741,6 +5741,8 @@ m = Py_InitModule4("cPickle", cPickle_methods, cPickle_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/cStringIO.c ============================================================================== --- python/branches/release24-maint/Modules/cStringIO.c (original) +++ python/branches/release24-maint/Modules/cStringIO.c Wed Sep 27 21:17:32 2006 @@ -718,6 +718,7 @@ m = Py_InitModule4("cStringIO", IO_methods, cStringIO_module_documentation, (PyObject*)NULL,PYTHON_API_VERSION); + if (m == NULL) return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/cdmodule.c ============================================================================== --- python/branches/release24-maint/Modules/cdmodule.c (original) +++ python/branches/release24-maint/Modules/cdmodule.c Wed Sep 27 21:17:32 2006 @@ -760,6 +760,8 @@ PyObject *m, *d; m = Py_InitModule("cd", CD_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); CdError = PyErr_NewException("cd.error", NULL, NULL); Modified: python/branches/release24-maint/Modules/clmodule.c ============================================================================== --- python/branches/release24-maint/Modules/clmodule.c (original) +++ python/branches/release24-maint/Modules/clmodule.c Wed Sep 27 21:17:32 2006 @@ -963,6 +963,8 @@ PyObject *m, *d, *x; m = Py_InitModule("cl", cl_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); ClError = PyErr_NewException("cl.error", NULL, NULL); Modified: python/branches/release24-maint/Modules/cmathmodule.c ============================================================================== --- python/branches/release24-maint/Modules/cmathmodule.c (original) +++ python/branches/release24-maint/Modules/cmathmodule.c Wed Sep 27 21:17:32 2006 @@ -417,6 +417,8 @@ PyObject *m; m = Py_InitModule3("cmath", cmath_methods, module_doc); + if (m == NULL) + return; PyModule_AddObject(m, "pi", PyFloat_FromDouble(atan(1.0) * 4.0)); Modified: python/branches/release24-maint/Modules/collectionsmodule.c ============================================================================== --- python/branches/release24-maint/Modules/collectionsmodule.c (original) +++ python/branches/release24-maint/Modules/collectionsmodule.c Wed Sep 27 21:17:32 2006 @@ -1036,6 +1036,8 @@ PyObject *m; m = Py_InitModule3("collections", NULL, module_doc); + if (m == NULL) + return; if (PyType_Ready(&deque_type) < 0) return; Modified: python/branches/release24-maint/Modules/datetimemodule.c ============================================================================== --- python/branches/release24-maint/Modules/datetimemodule.c (original) +++ python/branches/release24-maint/Modules/datetimemodule.c Wed Sep 27 21:17:32 2006 @@ -4581,6 +4581,8 @@ m = Py_InitModule3("datetime", module_methods, "Fast implementation of the datetime type."); + if (m == NULL) + return; if (PyType_Ready(&PyDateTime_DateType) < 0) return; Modified: python/branches/release24-maint/Modules/dbmmodule.c ============================================================================== --- python/branches/release24-maint/Modules/dbmmodule.c (original) +++ python/branches/release24-maint/Modules/dbmmodule.c Wed Sep 27 21:17:32 2006 @@ -359,6 +359,8 @@ Dbmtype.ob_type = &PyType_Type; m = Py_InitModule("dbm", dbmmodule_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); if (DbmError == NULL) DbmError = PyErr_NewException("dbm.error", NULL, NULL); Modified: python/branches/release24-maint/Modules/dlmodule.c ============================================================================== --- python/branches/release24-maint/Modules/dlmodule.c (original) +++ python/branches/release24-maint/Modules/dlmodule.c Wed Sep 27 21:17:32 2006 @@ -219,6 +219,8 @@ /* Create the module and add the functions */ m = Py_InitModule("dl", dl_methods); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/errnomodule.c ============================================================================== --- python/branches/release24-maint/Modules/errnomodule.c (original) +++ python/branches/release24-maint/Modules/errnomodule.c Wed Sep 27 21:17:32 2006 @@ -57,6 +57,8 @@ { PyObject *m, *d, *de; m = Py_InitModule3("errno", errno_methods, errno__doc__); + if (m == NULL) + return; d = PyModule_GetDict(m); de = PyDict_New(); if (!d || !de || PyDict_SetItemString(d, "errorcode", de) < 0) Modified: python/branches/release24-maint/Modules/fcntlmodule.c ============================================================================== --- python/branches/release24-maint/Modules/fcntlmodule.c (original) +++ python/branches/release24-maint/Modules/fcntlmodule.c Wed Sep 27 21:17:32 2006 @@ -598,6 +598,8 @@ /* Create the module and add the functions and documentation */ m = Py_InitModule3("fcntl", fcntl_methods, module_doc); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/flmodule.c ============================================================================== --- python/branches/release24-maint/Modules/flmodule.c (original) +++ python/branches/release24-maint/Modules/flmodule.c Wed Sep 27 21:17:32 2006 @@ -2130,6 +2130,8 @@ initfl(void) { Py_InitModule("fl", forms_methods); + if (m == NULL) + return; foreground(); fl_init(); } Modified: python/branches/release24-maint/Modules/fmmodule.c ============================================================================== --- python/branches/release24-maint/Modules/fmmodule.c (original) +++ python/branches/release24-maint/Modules/fmmodule.c Wed Sep 27 21:17:32 2006 @@ -258,5 +258,7 @@ initfm(void) { Py_InitModule("fm", fm_methods); + if (m == NULL) + return; fminit(); } Modified: python/branches/release24-maint/Modules/fpectlmodule.c ============================================================================== --- python/branches/release24-maint/Modules/fpectlmodule.c (original) +++ python/branches/release24-maint/Modules/fpectlmodule.c Wed Sep 27 21:17:32 2006 @@ -265,6 +265,8 @@ { PyObject *m, *d; m = Py_InitModule("fpectl", fpectl_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); fpe_error = PyErr_NewException("fpectl.error", NULL, NULL); if (fpe_error != NULL) Modified: python/branches/release24-maint/Modules/fpetestmodule.c ============================================================================== --- python/branches/release24-maint/Modules/fpetestmodule.c (original) +++ python/branches/release24-maint/Modules/fpetestmodule.c Wed Sep 27 21:17:32 2006 @@ -177,6 +177,8 @@ PyObject *m, *d; m = Py_InitModule("fpetest", fpetest_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); fpe_error = PyErr_NewException("fpetest.error", NULL, NULL); if (fpe_error != NULL) Modified: python/branches/release24-maint/Modules/gcmodule.c ============================================================================== --- python/branches/release24-maint/Modules/gcmodule.c (original) +++ python/branches/release24-maint/Modules/gcmodule.c Wed Sep 27 21:17:32 2006 @@ -1161,6 +1161,8 @@ gc__doc__, NULL, PYTHON_API_VERSION); + if (m == NULL) + return; if (garbage == NULL) { garbage = PyList_New(0); Modified: python/branches/release24-maint/Modules/gdbmmodule.c ============================================================================== --- python/branches/release24-maint/Modules/gdbmmodule.c (original) +++ python/branches/release24-maint/Modules/gdbmmodule.c Wed Sep 27 21:17:32 2006 @@ -512,6 +512,8 @@ m = Py_InitModule4("gdbm", dbmmodule_methods, gdbmmodule__doc__, (PyObject *)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; d = PyModule_GetDict(m); DbmError = PyErr_NewException("gdbm.error", NULL, NULL); if (DbmError != NULL) { Modified: python/branches/release24-maint/Modules/grpmodule.c ============================================================================== --- python/branches/release24-maint/Modules/grpmodule.c (original) +++ python/branches/release24-maint/Modules/grpmodule.c Wed Sep 27 21:17:32 2006 @@ -171,6 +171,8 @@ { PyObject *m, *d; m = Py_InitModule3("grp", grp_methods, grp__doc__); + if (m == NULL) + return; d = PyModule_GetDict(m); PyStructSequence_InitType(&StructGrpType, &struct_group_type_desc); PyDict_SetItemString(d, "struct_group", (PyObject *) &StructGrpType); Modified: python/branches/release24-maint/Modules/imageop.c ============================================================================== --- python/branches/release24-maint/Modules/imageop.c (original) +++ python/branches/release24-maint/Modules/imageop.c Wed Sep 27 21:17:32 2006 @@ -776,6 +776,8 @@ { PyObject *m; m = Py_InitModule("imageop", imageop_methods); + if (m == NULL) + return; ImageopDict = PyModule_GetDict(m); ImageopError = PyErr_NewException("imageop.error", NULL, NULL); if (ImageopError != NULL) Modified: python/branches/release24-maint/Modules/imgfile.c ============================================================================== --- python/branches/release24-maint/Modules/imgfile.c (original) +++ python/branches/release24-maint/Modules/imgfile.c Wed Sep 27 21:17:32 2006 @@ -492,6 +492,8 @@ { PyObject *m, *d; m = Py_InitModule("imgfile", imgfile_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); ImgfileError = PyErr_NewException("imgfile.error", NULL, NULL); if (ImgfileError != NULL) Modified: python/branches/release24-maint/Modules/itertoolsmodule.c ============================================================================== --- python/branches/release24-maint/Modules/itertoolsmodule.c (original) +++ python/branches/release24-maint/Modules/itertoolsmodule.c Wed Sep 27 21:17:32 2006 @@ -2454,6 +2454,8 @@ teedataobject_type.ob_type = &PyType_Type; m = Py_InitModule3("itertools", module_methods, module_doc); + if (m == NULL) + return; for (i=0 ; typelist[i] != NULL ; i++) { if (PyType_Ready(typelist[i]) < 0) Modified: python/branches/release24-maint/Modules/linuxaudiodev.c ============================================================================== --- python/branches/release24-maint/Modules/linuxaudiodev.c (original) +++ python/branches/release24-maint/Modules/linuxaudiodev.c Wed Sep 27 21:17:32 2006 @@ -491,6 +491,8 @@ PyObject *m; m = Py_InitModule("linuxaudiodev", linuxaudiodev_methods); + if (m == NULL) + return; LinuxAudioError = PyErr_NewException("linuxaudiodev.error", NULL, NULL); if (LinuxAudioError) Modified: python/branches/release24-maint/Modules/mathmodule.c ============================================================================== --- python/branches/release24-maint/Modules/mathmodule.c (original) +++ python/branches/release24-maint/Modules/mathmodule.c Wed Sep 27 21:17:32 2006 @@ -355,6 +355,8 @@ PyObject *m, *d, *v; m = Py_InitModule3("math", math_methods, module_doc); + if (m == NULL) + goto finally; d = PyModule_GetDict(m); if (!(v = PyFloat_FromDouble(atan(1.0) * 4.0))) Modified: python/branches/release24-maint/Modules/md5module.c ============================================================================== --- python/branches/release24-maint/Modules/md5module.c (original) +++ python/branches/release24-maint/Modules/md5module.c Wed Sep 27 21:17:32 2006 @@ -261,6 +261,8 @@ MD5type.ob_type = &PyType_Type; m = Py_InitModule3("md5", md5_functions, module_doc); + if (m == NULL) + return; d = PyModule_GetDict(m); PyDict_SetItemString(d, "MD5Type", (PyObject *)&MD5type); PyModule_AddIntConstant(m, "digest_size", 16); Modified: python/branches/release24-maint/Modules/mmapmodule.c ============================================================================== --- python/branches/release24-maint/Modules/mmapmodule.c (original) +++ python/branches/release24-maint/Modules/mmapmodule.c Wed Sep 27 21:17:32 2006 @@ -1093,6 +1093,8 @@ mmap_object_type.ob_type = &PyType_Type; module = Py_InitModule ("mmap", mmap_functions); + if (module == NULL) + return; dict = PyModule_GetDict (module); mmap_module_error = PyExc_EnvironmentError; Py_INCREF(mmap_module_error); Modified: python/branches/release24-maint/Modules/nismodule.c ============================================================================== --- python/branches/release24-maint/Modules/nismodule.c (original) +++ python/branches/release24-maint/Modules/nismodule.c Wed Sep 27 21:17:32 2006 @@ -379,6 +379,8 @@ { PyObject *m, *d; m = Py_InitModule("nis", nis_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); NisError = PyErr_NewException("nis.error", NULL, NULL); if (NisError != NULL) Modified: python/branches/release24-maint/Modules/operator.c ============================================================================== --- python/branches/release24-maint/Modules/operator.c (original) +++ python/branches/release24-maint/Modules/operator.c Wed Sep 27 21:17:32 2006 @@ -480,6 +480,8 @@ /* Create the module and add the functions */ m = Py_InitModule4("operator", operator_methods, operator_doc, (PyObject*)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; if (PyType_Ready(&itemgetter_type) < 0) return; Modified: python/branches/release24-maint/Modules/ossaudiodev.c ============================================================================== --- python/branches/release24-maint/Modules/ossaudiodev.c (original) +++ python/branches/release24-maint/Modules/ossaudiodev.c Wed Sep 27 21:17:32 2006 @@ -943,6 +943,8 @@ PyObject *m; m = Py_InitModule("ossaudiodev", ossaudiodev_methods); + if (m == NULL) + return; OSSAudioError = PyErr_NewException("ossaudiodev.OSSAudioError", NULL, NULL); Modified: python/branches/release24-maint/Modules/parsermodule.c ============================================================================== --- python/branches/release24-maint/Modules/parsermodule.c (original) +++ python/branches/release24-maint/Modules/parsermodule.c Wed Sep 27 21:17:32 2006 @@ -3106,6 +3106,8 @@ PyST_Type.ob_type = &PyType_Type; module = Py_InitModule("parser", parser_functions); + if (module == NULL) + return; if (parser_error == 0) parser_error = PyErr_NewException("parser.ParserError", NULL, NULL); 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 27 21:17:32 2006 @@ -7935,6 +7935,8 @@ m = Py_InitModule3(MODNAME, posix_methods, posix__doc__); + if (m == NULL) + return; /* Initialize environ dictionary */ v = convertenviron(); Modified: python/branches/release24-maint/Modules/puremodule.c ============================================================================== --- python/branches/release24-maint/Modules/puremodule.c (original) +++ python/branches/release24-maint/Modules/puremodule.c Wed Sep 27 21:17:32 2006 @@ -952,6 +952,8 @@ PyObject *m, *d; m = Py_InitModule("pure", pure_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); /* this is bogus because we should be able to find this information Modified: python/branches/release24-maint/Modules/pwdmodule.c ============================================================================== --- python/branches/release24-maint/Modules/pwdmodule.c (original) +++ python/branches/release24-maint/Modules/pwdmodule.c Wed Sep 27 21:17:32 2006 @@ -183,6 +183,8 @@ { PyObject *m; m = Py_InitModule3("pwd", pwd_methods, pwd__doc__); + if (m == NULL) + return; PyStructSequence_InitType(&StructPwdType, &struct_pwd_type_desc); Py_INCREF((PyObject *) &StructPwdType); Modified: python/branches/release24-maint/Modules/pyexpat.c ============================================================================== --- python/branches/release24-maint/Modules/pyexpat.c (original) +++ python/branches/release24-maint/Modules/pyexpat.c Wed Sep 27 21:17:32 2006 @@ -1853,6 +1853,8 @@ /* Create the module and add the functions */ m = Py_InitModule3(MODULE_NAME, pyexpat_methods, pyexpat_module_documentation); + if (m == NULL) + return; /* Add some symbolic constants to the module */ if (ErrorObject == NULL) { Modified: python/branches/release24-maint/Modules/readline.c ============================================================================== --- python/branches/release24-maint/Modules/readline.c (original) +++ python/branches/release24-maint/Modules/readline.c Wed Sep 27 21:17:32 2006 @@ -927,6 +927,8 @@ m = Py_InitModule4("readline", readline_methods, doc_module, (PyObject *)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; PyOS_ReadlineFunctionPointer = call_readline; setup_readline(); Modified: python/branches/release24-maint/Modules/regexmodule.c ============================================================================== --- python/branches/release24-maint/Modules/regexmodule.c (original) +++ python/branches/release24-maint/Modules/regexmodule.c Wed Sep 27 21:17:32 2006 @@ -652,6 +652,8 @@ Regextype.ob_type = &PyType_Type; m = Py_InitModule("regex", regex_global_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); if (PyErr_Warn(PyExc_DeprecationWarning, Modified: python/branches/release24-maint/Modules/resource.c ============================================================================== --- python/branches/release24-maint/Modules/resource.c (original) +++ python/branches/release24-maint/Modules/resource.c Wed Sep 27 21:17:32 2006 @@ -234,6 +234,8 @@ /* Create the module and add the functions */ m = Py_InitModule("resource", resource_methods); + if (m == NULL) + return; /* Add some symbolic constants to the module */ if (ResourceError == NULL) { Modified: python/branches/release24-maint/Modules/rgbimgmodule.c ============================================================================== --- python/branches/release24-maint/Modules/rgbimgmodule.c (original) +++ python/branches/release24-maint/Modules/rgbimgmodule.c Wed Sep 27 21:17:32 2006 @@ -756,6 +756,8 @@ { PyObject *m, *d; m = Py_InitModule("rgbimg", rgbimg_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); ImgfileError = PyErr_NewException("rgbimg.error", NULL, NULL); if (ImgfileError != NULL) Modified: python/branches/release24-maint/Modules/selectmodule.c ============================================================================== --- python/branches/release24-maint/Modules/selectmodule.c (original) +++ python/branches/release24-maint/Modules/selectmodule.c Wed Sep 27 21:17:32 2006 @@ -662,6 +662,8 @@ { PyObject *m; m = Py_InitModule3("select", select_methods, module_doc); + if (m == NULL) + return; SelectError = PyErr_NewException("select.error", NULL, NULL); Py_INCREF(SelectError); Modified: python/branches/release24-maint/Modules/shamodule.c ============================================================================== --- python/branches/release24-maint/Modules/shamodule.c (original) +++ python/branches/release24-maint/Modules/shamodule.c Wed Sep 27 21:17:32 2006 @@ -532,6 +532,8 @@ SHAtype.ob_type = &PyType_Type; m = Py_InitModule("sha", SHA_functions); + if (m == NULL) + return; /* Add some symbolic constants to the module */ insint("blocksize", 1); /* For future use, in case some hash Modified: python/branches/release24-maint/Modules/signalmodule.c ============================================================================== --- python/branches/release24-maint/Modules/signalmodule.c (original) +++ python/branches/release24-maint/Modules/signalmodule.c Wed Sep 27 21:17:32 2006 @@ -317,6 +317,8 @@ /* Create the module and add the functions */ m = Py_InitModule3("signal", signal_methods, module_doc); + if (m == NULL) + return; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/socketmodule.c ============================================================================== --- python/branches/release24-maint/Modules/socketmodule.c (original) +++ python/branches/release24-maint/Modules/socketmodule.c Wed Sep 27 21:17:32 2006 @@ -3872,6 +3872,8 @@ m = Py_InitModule3(PySocket_MODULE_NAME, socket_methods, socket_doc); + if (m == NULL) + return; socket_error = PyErr_NewException("socket.error", NULL, NULL); if (socket_error == NULL) Modified: python/branches/release24-maint/Modules/stropmodule.c ============================================================================== --- python/branches/release24-maint/Modules/stropmodule.c (original) +++ python/branches/release24-maint/Modules/stropmodule.c Wed Sep 27 21:17:32 2006 @@ -1210,6 +1210,8 @@ int c, n; m = Py_InitModule4("strop", strop_methods, strop_module__doc__, (PyObject*)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; /* Create 'whitespace' object */ n = 0; Modified: python/branches/release24-maint/Modules/structmodule.c ============================================================================== --- python/branches/release24-maint/Modules/structmodule.c (original) +++ python/branches/release24-maint/Modules/structmodule.c Wed Sep 27 21:17:32 2006 @@ -1278,6 +1278,8 @@ /* Create the module and add the functions */ m = Py_InitModule4("struct", struct_methods, struct__doc__, (PyObject*)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; /* Add some symbolic constants to the module */ if (StructError == NULL) { Modified: python/branches/release24-maint/Modules/sunaudiodev.c ============================================================================== --- python/branches/release24-maint/Modules/sunaudiodev.c (original) +++ python/branches/release24-maint/Modules/sunaudiodev.c Wed Sep 27 21:17:32 2006 @@ -456,6 +456,8 @@ PyObject *m, *d; m = Py_InitModule("sunaudiodev", sunaudiodev_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); SunAudioError = PyErr_NewException("sunaudiodev.error", NULL, NULL); if (SunAudioError) Modified: python/branches/release24-maint/Modules/svmodule.c ============================================================================== --- python/branches/release24-maint/Modules/svmodule.c (original) +++ python/branches/release24-maint/Modules/svmodule.c Wed Sep 27 21:17:32 2006 @@ -956,6 +956,8 @@ PyObject *m, *d; m = Py_InitModule("sv", sv_methods); + if (m == NULL) + return; d = PyModule_GetDict(m); SvError = PyErr_NewException("sv.error", NULL, NULL); Modified: python/branches/release24-maint/Modules/symtablemodule.c ============================================================================== --- python/branches/release24-maint/Modules/symtablemodule.c (original) +++ python/branches/release24-maint/Modules/symtablemodule.c Wed Sep 27 21:17:32 2006 @@ -51,6 +51,8 @@ PyObject *m; m = Py_InitModule("_symtable", symtable_methods); + if (m == NULL) + return; PyModule_AddIntConstant(m, "USE", USE); PyModule_AddIntConstant(m, "DEF_GLOBAL", DEF_GLOBAL); PyModule_AddIntConstant(m, "DEF_LOCAL", DEF_LOCAL); Modified: python/branches/release24-maint/Modules/syslogmodule.c ============================================================================== --- python/branches/release24-maint/Modules/syslogmodule.c (original) +++ python/branches/release24-maint/Modules/syslogmodule.c Wed Sep 27 21:17:32 2006 @@ -163,6 +163,8 @@ /* Create the module and add the functions */ m = Py_InitModule("syslog", syslog_methods); + if (m == NULL) + return; /* Add some symbolic constants to the module */ Modified: python/branches/release24-maint/Modules/termios.c ============================================================================== --- python/branches/release24-maint/Modules/termios.c (original) +++ python/branches/release24-maint/Modules/termios.c Wed Sep 27 21:17:32 2006 @@ -910,6 +910,8 @@ m = Py_InitModule4("termios", termios_methods, termios__doc__, (PyObject *)NULL, PYTHON_API_VERSION); + if (m == NULL) + return; if (TermiosError == NULL) { TermiosError = PyErr_NewException("termios.error", NULL, NULL); Modified: python/branches/release24-maint/Modules/threadmodule.c ============================================================================== --- python/branches/release24-maint/Modules/threadmodule.c (original) +++ python/branches/release24-maint/Modules/threadmodule.c Wed Sep 27 21:17:32 2006 @@ -650,6 +650,8 @@ /* Create the module and add the functions */ m = Py_InitModule3("thread", thread_methods, thread_doc); + if (m == NULL) + return; /* Add a symbolic constant */ d = PyModule_GetDict(m); Modified: python/branches/release24-maint/Modules/timemodule.c ============================================================================== --- python/branches/release24-maint/Modules/timemodule.c (original) +++ python/branches/release24-maint/Modules/timemodule.c Wed Sep 27 21:17:32 2006 @@ -785,6 +785,8 @@ PyObject *m; char *p; m = Py_InitModule3("time", time_methods, module_doc); + if (m == NULL) + return; /* Accept 2-digit dates unless PYTHONY2K is set and non-empty */ p = Py_GETENV("PYTHONY2K"); Modified: python/branches/release24-maint/Modules/xxmodule.c ============================================================================== --- python/branches/release24-maint/Modules/xxmodule.c (original) +++ python/branches/release24-maint/Modules/xxmodule.c Wed Sep 27 21:17:32 2006 @@ -352,6 +352,8 @@ /* Create the module and add the functions */ m = Py_InitModule3("xx", xx_methods, module_doc); + if (m == NULL) + return; /* Add some symbolic constants to the module */ if (ErrorObject == NULL) { Modified: python/branches/release24-maint/PC/_subprocess.c ============================================================================== --- python/branches/release24-maint/PC/_subprocess.c (original) +++ python/branches/release24-maint/PC/_subprocess.c Wed Sep 27 21:17:32 2006 @@ -530,6 +530,8 @@ sp_handle_as_number.nb_int = (unaryfunc) sp_handle_as_int; m = Py_InitModule("_subprocess", sp_functions); + if (m == NULL) + return; d = PyModule_GetDict(m); /* constants */ Modified: python/branches/release24-maint/PC/_winreg.c ============================================================================== --- python/branches/release24-maint/PC/_winreg.c (original) +++ python/branches/release24-maint/PC/_winreg.c Wed Sep 27 21:17:32 2006 @@ -1459,6 +1459,8 @@ { PyObject *m, *d; m = Py_InitModule3("_winreg", winreg_methods, module_doc); + if (m == NULL) + return; d = PyModule_GetDict(m); PyHKEY_Type.ob_type = &PyType_Type; PyHKEY_Type.tp_doc = PyHKEY_doc; Modified: python/branches/release24-maint/PC/msvcrtmodule.c ============================================================================== --- python/branches/release24-maint/PC/msvcrtmodule.c (original) +++ python/branches/release24-maint/PC/msvcrtmodule.c Wed Sep 27 21:17:32 2006 @@ -221,6 +221,8 @@ initmsvcrt(void) { PyObject *m = Py_InitModule("msvcrt", msvcrt_functions); + if (m == NULL) + return; PyObject *d = PyModule_GetDict(m); /* constants for the locking() function's mode argument */ Modified: python/branches/release24-maint/PC/winsound.c ============================================================================== --- python/branches/release24-maint/PC/winsound.c (original) +++ python/branches/release24-maint/PC/winsound.c Wed Sep 27 21:17:32 2006 @@ -218,6 +218,8 @@ PyObject *module = Py_InitModule3("winsound", sound_methods, sound_module_doc); + if (module == NULL) + return; PyObject *dict = PyModule_GetDict(module); ADD_DEFINE(SND_ASYNC); Modified: python/branches/release24-maint/Python/import.c ============================================================================== --- python/branches/release24-maint/Python/import.c (original) +++ python/branches/release24-maint/Python/import.c Wed Sep 27 21:17:32 2006 @@ -2822,6 +2822,8 @@ m = Py_InitModule4("imp", imp_methods, doc_imp, NULL, PYTHON_API_VERSION); + if (m == NULL) + goto failure; d = PyModule_GetDict(m); if (setint(d, "SEARCH_ERROR", SEARCH_ERROR) < 0) goto failure; Modified: python/branches/release24-maint/Python/marshal.c ============================================================================== --- python/branches/release24-maint/Python/marshal.c (original) +++ python/branches/release24-maint/Python/marshal.c Wed Sep 27 21:17:32 2006 @@ -928,5 +928,7 @@ PyMarshal_Init(void) { PyObject *mod = Py_InitModule("marshal", marshal_methods); + if (mod == NULL) + return; PyModule_AddIntConstant(mod, "version", Py_MARSHAL_VERSION); } Modified: python/branches/release24-maint/Python/sysmodule.c ============================================================================== --- python/branches/release24-maint/Python/sysmodule.c (original) +++ python/branches/release24-maint/Python/sysmodule.c Wed Sep 27 21:17:32 2006 @@ -944,6 +944,8 @@ #endif m = Py_InitModule3("sys", sys_methods, sys_doc); + if (m == NULL) + return NULL; sysdict = PyModule_GetDict(m); { From python-checkins at python.org Wed Sep 27 21:23:06 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:23:06 +0200 (CEST) Subject: [Python-checkins] r52018 - python/trunk/Doc/ext/extending.tex Message-ID: <20060927192306.4AE671E4006@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:23:05 2006 New Revision: 52018 Modified: python/trunk/Doc/ext/extending.tex Log: Make examples do error checking on Py_InitModule Modified: python/trunk/Doc/ext/extending.tex ============================================================================== --- python/trunk/Doc/ext/extending.tex (original) +++ python/trunk/Doc/ext/extending.tex Wed Sep 27 21:23:05 2006 @@ -221,6 +221,8 @@ PyObject *m; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; SpamError = PyErr_NewException("spam.error", NULL, NULL); Py_INCREF(SpamError); @@ -365,9 +367,9 @@ created module based upon the table (an array of \ctype{PyMethodDef} structures) that was passed as its second argument. \cfunction{Py_InitModule()} returns a pointer to the module object -that it creates (which is unused here). It aborts with a fatal error -if the module could not be initialized satisfactorily, so the caller -doesn't need to check for errors. +that it creates (which is unused here). It may abort with a fatal error +for certain errors, or return \NULL{} if the module could not be +initialized satisfactorily. When embedding Python, the \cfunction{initspam()} function is not called automatically unless there's an entry in the @@ -1276,6 +1278,8 @@ PyObject *c_api_object; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; /* Initialize the C API pointer array */ PySpam_API[PySpam_System_NUM] = (void *)PySpam_System; @@ -1362,7 +1366,9 @@ { PyObject *m; - Py_InitModule("client", ClientMethods); + m = Py_InitModule("client", ClientMethods); + if (m == NULL) + return; if (import_spam() < 0) return; /* additional initialization can happen here */ From python-checkins at python.org Wed Sep 27 21:23:38 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:23:38 +0200 (CEST) Subject: [Python-checkins] r52019 - python/branches/release24-maint/Doc/ext/extending.tex Message-ID: <20060927192338.808651E400A@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:23:38 2006 New Revision: 52019 Modified: python/branches/release24-maint/Doc/ext/extending.tex Log: Make examples do error checking on Py_InitModule Modified: python/branches/release24-maint/Doc/ext/extending.tex ============================================================================== --- python/branches/release24-maint/Doc/ext/extending.tex (original) +++ python/branches/release24-maint/Doc/ext/extending.tex Wed Sep 27 21:23:38 2006 @@ -221,6 +221,8 @@ PyObject *m; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; SpamError = PyErr_NewException("spam.error", NULL, NULL); Py_INCREF(SpamError); @@ -365,9 +367,9 @@ created module based upon the table (an array of \ctype{PyMethodDef} structures) that was passed as its second argument. \cfunction{Py_InitModule()} returns a pointer to the module object -that it creates (which is unused here). It aborts with a fatal error -if the module could not be initialized satisfactorily, so the caller -doesn't need to check for errors. +that it creates (which is unused here). It may abort with a fatal error +for certain errors, or return \NULL{} if the module could not be +initialized satisfactorily. When embedding Python, the \cfunction{initspam()} function is not called automatically unless there's an entry in the @@ -1276,6 +1278,8 @@ PyObject *c_api_object; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; /* Initialize the C API pointer array */ PySpam_API[PySpam_System_NUM] = (void *)PySpam_System; @@ -1362,7 +1366,9 @@ { PyObject *m; - Py_InitModule("client", ClientMethods); + m = Py_InitModule("client", ClientMethods); + if (m == NULL) + return; if (import_spam() < 0) return; /* additional initialization can happen here */ From python-checkins at python.org Wed Sep 27 21:24:28 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:24:28 +0200 (CEST) Subject: [Python-checkins] r52020 - python/branches/release25-maint/Doc/ext/extending.tex Message-ID: <20060927192428.4348C1E400A@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:24:27 2006 New Revision: 52020 Modified: python/branches/release25-maint/Doc/ext/extending.tex Log: Make examples do error checking on Py_InitModule Modified: python/branches/release25-maint/Doc/ext/extending.tex ============================================================================== --- python/branches/release25-maint/Doc/ext/extending.tex (original) +++ python/branches/release25-maint/Doc/ext/extending.tex Wed Sep 27 21:24:27 2006 @@ -221,6 +221,8 @@ PyObject *m; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; SpamError = PyErr_NewException("spam.error", NULL, NULL); Py_INCREF(SpamError); @@ -365,9 +367,9 @@ created module based upon the table (an array of \ctype{PyMethodDef} structures) that was passed as its second argument. \cfunction{Py_InitModule()} returns a pointer to the module object -that it creates (which is unused here). It aborts with a fatal error -if the module could not be initialized satisfactorily, so the caller -doesn't need to check for errors. +that it creates (which is unused here). It may abort with a fatal error +for certain errors, or return \NULL{} if the module could not be +initialized satisfactorily. When embedding Python, the \cfunction{initspam()} function is not called automatically unless there's an entry in the @@ -1276,6 +1278,8 @@ PyObject *c_api_object; m = Py_InitModule("spam", SpamMethods); + if (m == NULL) + return; /* Initialize the C API pointer array */ PySpam_API[PySpam_System_NUM] = (void *)PySpam_System; @@ -1362,7 +1366,9 @@ { PyObject *m; - Py_InitModule("client", ClientMethods); + m = Py_InitModule("client", ClientMethods); + if (m == NULL) + return; if (import_spam() < 0) return; /* additional initialization can happen here */ From buildbot at python.org Wed Sep 27 21:27:31 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Sep 2006 19:27:31 +0000 Subject: [Python-checkins] buildbot warnings in x86 W2k 2.4 Message-ID: <20060927192731.F31451E4007@bag.python.org> The Buildbot has detected a new failure of x86 W2k 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520W2k%25202.4/builds/206 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 27 21:37:30 2006 From: python-checkins at python.org (andrew.kuchling) Date: Wed, 27 Sep 2006 21:37:30 +0200 (CEST) Subject: [Python-checkins] r52021 - in python/branches/release24-maint: Lib/gzip.py Misc/NEWS Message-ID: <20060927193730.5438D1E4006@bag.python.org> Author: andrew.kuchling Date: Wed Sep 27 21:37:27 2006 New Revision: 52021 Modified: python/branches/release24-maint/Lib/gzip.py python/branches/release24-maint/Misc/NEWS Log: [Backport rev. 38534 by loewis] [Possibly controversial because it adds a parameter to a method. This parameter isn't documented, however, so arguably it's a private detail, and the fix is necessary to make GzipFile.flush() behave more similarly to regular file object.] Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. Partially fixes #1110242. Modified: python/branches/release24-maint/Lib/gzip.py ============================================================================== --- python/branches/release24-maint/Lib/gzip.py (original) +++ python/branches/release24-maint/Lib/gzip.py Wed Sep 27 21:37:27 2006 @@ -332,7 +332,10 @@ return self.close() - def flush(self): + def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH): + if self.mode == WRITE: + # Ensure the compressor's buffer is flushed + self.fileobj.write(self.compress.flush(zlib_mode)) self.fileobj.flush() def fileno(self): Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Wed Sep 27 21:37:27 2006 @@ -176,6 +176,7 @@ - Bug #1472827: correctly escape newlines and tabs in attribute values in the saxutils.XMLGenerator class. +- Patch #1110248: SYNC_FLUSH the zlib buffer for GZipFile.flush. Tools/Demos ----------- From buildbot at python.org Wed Sep 27 22:08:09 2006 From: buildbot at python.org (buildbot at python.org) Date: Wed, 27 Sep 2006 20:08:09 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060927200809.862161E4022@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/164 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Wed Sep 27 23:32:27 2006 From: python-checkins at python.org (brett.cannon) Date: Wed, 27 Sep 2006 23:32:27 +0200 (CEST) Subject: [Python-checkins] r52022 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060927213227.113A71E4006@bag.python.org> Author: brett.cannon Date: Wed Sep 27 23:32:26 2006 New Revision: 52022 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Add notes about making sure inheriting abilities is kept secure and no escalation of abilities occurs. 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 27 23:32:26 2006 @@ -40,9 +40,9 @@ - mini 'sys' module (`Making the ``sys`` Module Safe`_) - 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) + - thread (only if worried about thread resource starvation, + interrupt_main() not per-interpreter, and stack_size() + considered dangerous) + Create sandboxed interpreter stdlib module - Be able to specify built-ins [done] - Set 'sys' module settings [done] @@ -53,6 +53,9 @@ - Securely handle exceptions being raised in sub-interpreter [done] - Redirect output [done] + - Inherit abilities provided by creating interpreter ONLY + * Only get importers as provided by creating interpreter. + * Only get built-ins as provided by creating interpreter. + Tear out old restricted mode code. From python-checkins at python.org Thu Sep 28 06:47:53 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 28 Sep 2006 06:47:53 +0200 (CEST) Subject: [Python-checkins] r52023 - sandbox/trunk/setuptools/setuptools/command/bdist_egg.py Message-ID: <20060928044753.384E31E4008@bag.python.org> Author: phillip.eby Date: Thu Sep 28 06:47:52 2006 New Revision: 52023 Modified: sandbox/trunk/setuptools/setuptools/command/bdist_egg.py Log: Fix problem generating "eggsecutable" header if dist/ dir doesn't exst yet. Modified: sandbox/trunk/setuptools/setuptools/command/bdist_egg.py ============================================================================== --- sandbox/trunk/setuptools/setuptools/command/bdist_egg.py (original) +++ sandbox/trunk/setuptools/setuptools/command/bdist_egg.py Thu Sep 28 06:47:52 2006 @@ -319,13 +319,13 @@ ) % locals() if not self.dry_run: + mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run) f = open(self.egg_output, 'w') f.write(header) f.close() return 'a' - def copy_metadata_to(self, target_dir): prefix = os.path.join(self.egg_info,'') for path in self.ei_cmd.filelist.files: From python-checkins at python.org Thu Sep 28 06:50:22 2006 From: python-checkins at python.org (phillip.eby) Date: Thu, 28 Sep 2006 06:50:22 +0200 (CEST) Subject: [Python-checkins] r52024 - sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py Message-ID: <20060928045022.B822E1E4007@bag.python.org> Author: phillip.eby Date: Thu Sep 28 06:50:22 2006 New Revision: 52024 Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py Log: Fix problem generating "eggsecutable" header if dist/ dir doesn't exist yet. (backport from trunk) Modified: sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py ============================================================================== --- sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py (original) +++ sandbox/branches/setuptools-0.6/setuptools/command/bdist_egg.py Thu Sep 28 06:50:22 2006 @@ -319,13 +319,13 @@ ) % locals() if not self.dry_run: + mkpath(os.path.dirname(self.egg_output), dry_run=self.dry_run) f = open(self.egg_output, 'w') f.write(header) f.close() return 'a' - def copy_metadata_to(self, target_dir): prefix = os.path.join(self.egg_info,'') for path in self.ei_cmd.filelist.files: From python-checkins at python.org Thu Sep 28 19:05:19 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 28 Sep 2006 19:05:19 +0200 (CEST) Subject: [Python-checkins] r52028 - in python/branches/release24-maint: Misc/NEWS Modules/threadmodule.c Message-ID: <20060928170519.66B391E4041@bag.python.org> Author: andrew.kuchling Date: Thu Sep 28 19:05:18 2006 New Revision: 52028 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/threadmodule.c Log: [Backport rev. 39012 by mwh] Add a missing incref. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Thu Sep 28 19:05:18 2006 @@ -54,6 +54,8 @@ Extension Modules ----------------- +- threadmodule: add a missing incref. + - Bug #1551427: fix a wrong NULL pointer check in the win32 version of os.urandom(). Modified: python/branches/release24-maint/Modules/threadmodule.c ============================================================================== --- python/branches/release24-maint/Modules/threadmodule.c (original) +++ python/branches/release24-maint/Modules/threadmodule.c Thu Sep 28 19:05:18 2006 @@ -661,6 +661,7 @@ Py_INCREF(&Locktype); PyDict_SetItemString(d, "LockType", (PyObject *)&Locktype); + Py_INCREF(&localtype); if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0) return; From python-checkins at python.org Thu Sep 28 19:08:01 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 28 Sep 2006 19:08:01 +0200 (CEST) Subject: [Python-checkins] r52029 - in python/branches/release24-maint: Misc/NEWS Modules/gcmodule.c Message-ID: <20060928170801.DFB501E4006@bag.python.org> Author: andrew.kuchling Date: Thu Sep 28 19:08:01 2006 New Revision: 52029 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/gcmodule.c Log: [Backport rev.39030 by nascheme] Add missing INCREF. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Thu Sep 28 19:08:01 2006 @@ -54,6 +54,8 @@ Extension Modules ----------------- +- gcmodule: add a missing incref. + - threadmodule: add a missing incref. - Bug #1551427: fix a wrong NULL pointer check in the win32 version Modified: python/branches/release24-maint/Modules/gcmodule.c ============================================================================== --- python/branches/release24-maint/Modules/gcmodule.c (original) +++ python/branches/release24-maint/Modules/gcmodule.c Thu Sep 28 19:08:01 2006 @@ -1169,6 +1169,7 @@ if (garbage == NULL) return; } + Py_INCREF(garbage); if (PyModule_AddObject(m, "garbage", garbage) < 0) return; #define ADD_INT(NAME) if (PyModule_AddIntConstant(m, #NAME, NAME) < 0) return From python-checkins at python.org Thu Sep 28 19:16:26 2006 From: python-checkins at python.org (andrew.kuchling) Date: Thu, 28 Sep 2006 19:16:26 +0200 (CEST) Subject: [Python-checkins] r52030 - in python/branches/release24-maint: Misc/NEWS Modules/posixmodule.c Message-ID: <20060928171626.742651E4006@bag.python.org> Author: andrew.kuchling Date: Thu Sep 28 19:16:25 2006 New Revision: 52030 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/posixmodule.c Log: [Backport rev. 39135 by mwh] Fix bug [ 1232517 ] OverflowError in time.utime() causes strange traceback A needed error check was missing. (Actually, this error check may only have become necessary in fairly recent Python, not sure). Backport candidate. [A few lines below the code in 2.4 touched by the patch, there's already a similar check of (intval == -1 && PyErr_Occurred()), so I think this function can already report such errors, and therefore the fix still applies. Perhaps Michael can clarify what he was referring to. --amk] Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Thu Sep 28 19:16:25 2006 @@ -27,6 +27,9 @@ - Bug #1524310: Properly report errors from FindNextFile in os.listdir. +- Bug #1232517: An overflow error was not detected properly when + attempting to convert a large float to an int in os.utime(). + - Bug #927248: Recursive method-wrapper objects can now safely be released. Modified: python/branches/release24-maint/Modules/posixmodule.c ============================================================================== --- python/branches/release24-maint/Modules/posixmodule.c (original) +++ python/branches/release24-maint/Modules/posixmodule.c Thu Sep 28 19:16:25 2006 @@ -2004,6 +2004,8 @@ return -1; intval = PyInt_AsLong(intobj); Py_DECREF(intobj); + if (intval == -1 && PyErr_Occurred()) + return -1; *sec = intval; *usec = (long)((tval - intval) * 1e6); /* can't exceed 1000000 */ if (*usec < 0) From mwh at python.net Thu Sep 28 20:18:20 2006 From: mwh at python.net (Michael Hudson) Date: Thu, 28 Sep 2006 19:18:20 +0100 Subject: [Python-checkins] r52030 - in python/branches/release24-maint: Misc/NEWS Modules/posixmodule.c In-Reply-To: <20060928171626.742651E4006@bag.python.org> (andrew kuchling's message of "Thu, 28 Sep 2006 19:16:26 +0200 (CEST)") References: <20060928171626.742651E4006@bag.python.org> Message-ID: <2my7s3g8ib.fsf@starship.python.net> "andrew.kuchling" writes: > Author: andrew.kuchling > Date: Thu Sep 28 19:16:25 2006 > New Revision: 52030 > > Modified: > python/branches/release24-maint/Misc/NEWS > python/branches/release24-maint/Modules/posixmodule.c > Log: > [Backport rev. 39135 by mwh] > > Fix bug > > [ 1232517 ] OverflowError in time.utime() causes strange traceback > > A needed error check was missing. > > (Actually, this error check may only have become necessary in fairly > recent Python, not sure). > > Backport candidate. > > [A few lines below the code in 2.4 touched by the patch, there's already > a similar check of (intval == -1 && PyErr_Occurred()), so I think > this function can already report such errors, and therefore the fix > still applies. Perhaps Michael can clarify what he was referring to. --amk] I think what changed to prompt the "only recent Python" comment was that int(some large float) returns a long, rather than raising an error by itself. This change is in 2.4 (it seems to be a 2.2->2.3 change) so this is indeed a valid back port. Thanks! Cheers, mwh -- On the other hand, the following areas are subject to boycott in reaction to the rampant impurity of design or execution, as determined after a period of study, in no particular order: ... http://www.naggum.no/profile.html From python-checkins at python.org Thu Sep 28 23:39:28 2006 From: python-checkins at python.org (brett.cannon) Date: Thu, 28 Sep 2006 23:39:28 +0200 (CEST) Subject: [Python-checkins] r52031 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060928213928.81A391E400A@bag.python.org> Author: brett.cannon Date: Thu Sep 28 23:39:27 2006 New Revision: 52031 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Clean up section on securing imports. 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 28 23:39:27 2006 @@ -444,18 +444,8 @@ ------- A proxy for protecting imports will be provided. This is done by -setting the ``__import__()`` function in the built-in namespace of the -sandboxed interpreter to a proxied version of the function. - -The planned proxy will take in a passed-in function to use for the -import and a whitelist of C extension modules and built-in modules to -allow importation of. If an import would lead to loading an extension -or built-in module, it is checked against the whitelist and allowed -to be imported based on that list. All .pyc and .pyo file will not -be imported. All .py files will be imported. - -XXX perhaps augment 'sys' so that you list the extension of files that -can be used for importing? It is returned by ``imp.get_suffixes()``. +setting the proper values in 'sys' that involve imports: +sys.path, sys.meta_path, sys.path_hooks, and sys.path_importer.cache. It must be warned that importing any C extension module is dangerous. Not only are they able to circumvent security measures by executing C @@ -468,12 +458,35 @@ acting on behalf of the sandboxed interpreter. This violates the perimeter defence. No one should import extension modules blindly. +Bytecode files will be flat-out disallowed. Because malicious +bytecode can be created that can crash the interpreter all bytecode +files will be ignored. + + +Implementing Phase 2 of PEP 302 ++++++++++++++++++++++++++++++++ + +Currently Python's built-in importer is monolithic in that __import__ +will automatically import a .py, .pyc, extension modules, or built-in +modules if a custom importer does handle the import. This does not +give one the flexibility needed to control imports at the level of +file type. + +In order to be able to prevent extension module imports and .pyc file +imports, the current import machinery will be refactored to be PEP +302 importers. This will allow for better control over what can and +cannot be imported. + + Implementing Import in Python +++++++++++++++++++++++++++++ -To help facilitate in the exposure of more of what importation -requires (and thus make implementing a proxy easier), the import -machinery should be rewritten in Python. This will require some +The import machinery should be rewritten in Python. The C code is +considered delicate and does not lend itself to being read. There is +also not a very strong definition of the import rules. Rewriting +import in Python would help clarify the semantics of imports. + +This rewrite will require some bootstrapping in order for the code to be loaded into the process without itself requiring importation, but that should be doable. Plus some care must be taken to not lead to circular dependency on @@ -482,8 +495,8 @@ Interaction with another interpreter that might provide an import function must also be dealt with. One cannot expose the importation -of a needed module for the import machinery as it might not be allowed -by a proxy. This can be handled by allowing the powerbox's import +of a needed module for the import machinery as. +This can be handled by allowing the powerbox's import function to have modules directly injected into its global namespace. But there is also the issue of using the proper ``sys.modules`` for storing the modules already imported. You do not want to inject the @@ -493,9 +506,6 @@ function create a new import function based on an interpreter passed in, etc.). -One can also implement a PEP 302 import object that takes the proper -precautions of not exposing power needlessly. - Sanitizing Built-In Types ------------------------- From python-checkins at python.org Fri Sep 29 00:10:14 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 29 Sep 2006 00:10:14 +0200 (CEST) Subject: [Python-checkins] r52032 - python/trunk/Python/import.c Message-ID: <20060928221014.D5CE51E4006@bag.python.org> Author: brett.cannon Date: Fri Sep 29 00:10:14 2006 New Revision: 52032 Modified: python/trunk/Python/import.c Log: Very minor grammatical fix in a comment. Modified: python/trunk/Python/import.c ============================================================================== --- python/trunk/Python/import.c (original) +++ python/trunk/Python/import.c Fri Sep 29 00:10:14 2006 @@ -1029,7 +1029,7 @@ /* Return an importer object for a sys.path/pkg.__path__ item 'p', possibly by fetching it from the path_importer_cache dict. If it - wasn't yet cached, traverse path_hooks until it a hook is found + wasn't yet cached, traverse path_hooks until a hook is found that can handle the path item. Return None if no hook could; this tells our caller it should fall back to the builtin import mechanism. Cache the result in path_importer_cache. From buildbot at python.org Fri Sep 29 00:53:30 2006 From: buildbot at python.org (buildbot at python.org) Date: Thu, 28 Sep 2006 22:53:30 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060928225330.7152B1E4008@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/1200 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: andrew.kuchling,brett.cannon Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri Sep 29 02:02:45 2006 From: python-checkins at python.org (brett.cannon) Date: Fri, 29 Sep 2006 02:02:45 +0200 (CEST) Subject: [Python-checkins] r52033 - python/branches/bcannon-objcap/securing_python.txt Message-ID: <20060929000245.DADBB1E4009@bag.python.org> Author: brett.cannon Date: Fri Sep 29 02:02:45 2006 New Revision: 52033 Modified: python/branches/bcannon-objcap/securing_python.txt Log: Add notes about what it would take to take the existing import machinery and make it work with PEP 302. 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 29 02:02:45 2006 @@ -507,6 +507,55 @@ in, etc.). +Python/import.c Notes for PEP 302 Phase 2 ++++++++++++++++++++++++++++++++++++++++++ + +__import__ -> PyImport_ImportModuleLevel() -> import_module_level() + +import_module_level() + -> get_parent() + Find out if import is occurring in a package and return the + parent module in the package. + -> load_next() + Find out next module to import in chain in dotted name (e.g., + ``b`` in ``a.b.c`` if ``a`` already imported but not ``b``). + +load_next() -> import_submodule() + +import_submodule() + -> find_module() * + Check meta_path, path_hooks/path_importer_cache, else file + location for built-in import. + -> load_module() * + Execute loading of code based on type of import: + * PY_SOURCE -> path_hook + * PY_COMPILED -> path_hook + * C_EXTENSION -> path_hook + * PKG_DIRECTORY -> path_hook + Could it be worked so that if package found put in an + empty module in sys.modules and then import pkg.__init__? + * C_BUILTIN -> meta_path + * PY_FROZEN -> meta_path + * IMP_HOOK = importer -> path_hook + +Changes to find_module() + * Make only use PEP 302 resolution. + * Rip out part that finds file/directory and make it the importer + that finds files. Then have different file types register their + file extension and a factory function to call to get the + importer to return (if proper file type found). + objects for py source, bytecode, packages, and extension + modules. (path_hooks factory function comes from part that just + verifies that sys.path entry is a directory). + +Changes to load_module() + * Rip out switch and have only do loaders. + * Change py source, bytecode, packages, and extension module + loaders be individual loaders. + * Change built-ins and frozen module loaders to be meta_path + loaders. + + Sanitizing Built-In Types ------------------------- From python-checkins at python.org Fri Sep 29 14:41:37 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 14:41:37 +0200 (CEST) Subject: [Python-checkins] r52035 - python/branches/release24-maint/Doc/lib/asttable.tex Message-ID: <20060929124137.41A8D1E4008@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 14:41:36 2006 New Revision: 52035 Modified: python/branches/release24-maint/Doc/lib/asttable.tex Log: [Backport rev. 39645 by nnorwitz] SF patch #1227568, bug #1219273, Expression AST node not documented. Backport candidate if anyone cares. Modified: python/branches/release24-maint/Doc/lib/asttable.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/asttable.tex (original) +++ python/branches/release24-maint/Doc/lib/asttable.tex Fri Sep 29 14:41:36 2006 @@ -89,6 +89,8 @@ \lineiii{Ellipsis}{}{} \hline +\lineiii{Expression}{\member{node}}{} + \lineiii{Exec}{\member{expr}}{} \lineiii{}{\member{locals}}{} \lineiii{}{\member{globals}}{} From python-checkins at python.org Fri Sep 29 14:44:27 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 14:44:27 +0200 (CEST) Subject: [Python-checkins] r52036 - python/branches/release24-maint/Modules/ld_so_aix Message-ID: <20060929124427.1C1381E400A@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 14:44:26 2006 New Revision: 52036 Modified: python/branches/release24-maint/Modules/ld_so_aix Log: [Backport rev 39653 by nnorwitz] SF Bug # 941346, AIX shared library fix Since I can't test this, I'm just adding a comment. If we get access to AIX boxes, we can test this and really resolve. Anyone from IBM want to offer help? Backport candidate I suppose. Modified: python/branches/release24-maint/Modules/ld_so_aix ============================================================================== --- python/branches/release24-maint/Modules/ld_so_aix (original) +++ python/branches/release24-maint/Modules/ld_so_aix Fri Sep 29 14:44:26 2006 @@ -168,6 +168,10 @@ CCOPT="-Wl,-e$entry -Wl,-bE:$expfile -Wl,-bI:$impfile -Wl,-bhalt:4" CCOPT="$CCOPT -Wl,-bM:SRE -Wl,-T512 -Wl,-H512 -lm -o $objfile" +# Note: to use dynamic libraries like libtcl8.4.so and libtk8.4.so +# you may need to replace the second CCOPT line above with the following: +# CCOPT="$CCOPT -Wl,-bM:SRE -Wl,-T512 -Wl,-H512 -brtl -bnortllib -lm -o $objfile" + CCARGS="$args" # Export list generation. From python-checkins at python.org Fri Sep 29 14:47:00 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 14:47:00 +0200 (CEST) Subject: [Python-checkins] r52037 - python/branches/release24-maint/Doc/lib/libos.tex Message-ID: <20060929124700.AB9C91E401D@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 14:47:00 2006 New Revision: 52037 Modified: python/branches/release24-maint/Doc/lib/libos.tex Log: [Backport rev.39739 by nnorwitz] SF bug #1328915, try to word kill a bit more generically. Backport candidate. Modified: python/branches/release24-maint/Doc/lib/libos.tex ============================================================================== --- python/branches/release24-maint/Doc/lib/libos.tex (original) +++ python/branches/release24-maint/Doc/lib/libos.tex Fri Sep 29 14:47:00 2006 @@ -1462,7 +1462,7 @@ \begin{funcdesc}{kill}{pid, sig} \index{process!killing} \index{process!signalling} -Kill the process \var{pid} with signal \var{sig}. Constants for the +Send signal \var{sig} to the process \var{pid}. Constants for the specific signals available on the host platform are defined in the \refmodule{signal} module. Availability: Macintosh, \UNIX. @@ -1471,7 +1471,7 @@ \begin{funcdesc}{killpg}{pgid, sig} \index{process!killing} \index{process!signalling} -Kill the process group \var{pgid} with the signal \var{sig}. +Send the signal \var{sig} to the process group \var{pgid}. Availability: Macintosh, \UNIX. \versionadded{2.3} \end{funcdesc} From python-checkins at python.org Fri Sep 29 19:42:32 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 19:42:32 +0200 (CEST) Subject: [Python-checkins] r52040 - in python/branches/release24-maint: Misc/NEWS Parser/tokenizer.c Message-ID: <20060929174232.839601E4008@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 19:42:30 2006 New Revision: 52040 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Parser/tokenizer.c Log: [Backport rev39767 by nnorwitz] Free coding spec (cs) if there was an error to prevent mem leak. Maybe backport candidate. [Bugfix seems applicable to 2.4 to me. --amk] Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Fri Sep 29 19:42:30 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Fix memory leak of coding spec in Parser/tokenizer.c. + - Overflow checking code in integer division ran afoul of new gcc optimizations. Changed to be more standard-conforming. Modified: python/branches/release24-maint/Parser/tokenizer.c ============================================================================== --- python/branches/release24-maint/Parser/tokenizer.c (original) +++ python/branches/release24-maint/Parser/tokenizer.c Fri Sep 29 19:42:30 2006 @@ -277,11 +277,14 @@ tok->encoding = cs; tok->decoding_state = -1; } + else + PyMem_DEL(cs); #else /* Without Unicode support, we cannot process the coding spec. Since there won't be any Unicode literals, that won't matter. */ + PyMem_DEL(cs); #endif } } else { /* then, compare cs with BOM */ From python-checkins at python.org Fri Sep 29 19:52:34 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 19:52:34 +0200 (CEST) Subject: [Python-checkins] r52041 - in python/branches/release24-maint: Misc/NEWS Python/bltinmodule.c Message-ID: <20060929175234.396051E4008@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 19:52:32 2006 New Revision: 52041 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Python/bltinmodule.c Log: [Backport rev. 41696 by neal.norwitz] Fix an int/long mismatch identified here: http://www.tortall.net/mu/blog/2005/12/01 Pointed out from SF #1365916. Backport candidate. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Fri Sep 29 19:52:32 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #1365916: Fix an int/long mismatch in the sorted() built-in. + - Fix memory leak of coding spec in Parser/tokenizer.c. - Overflow checking code in integer division ran afoul of new gcc Modified: python/branches/release24-maint/Python/bltinmodule.c ============================================================================== --- python/branches/release24-maint/Python/bltinmodule.c (original) +++ python/branches/release24-maint/Python/bltinmodule.c Fri Sep 29 19:52:32 2006 @@ -1811,9 +1811,10 @@ PyObject *newlist, *v, *seq, *compare=NULL, *keyfunc=NULL, *newargs; PyObject *callable; static char *kwlist[] = {"iterable", "cmp", "key", "reverse", 0}; - long reverse; + int reverse; if (args != NULL) { + /* args 1-4 should match listsort in Objects/listobject.c */ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOi:sorted", kwlist, &seq, &compare, &keyfunc, &reverse)) return NULL; From python-checkins at python.org Fri Sep 29 19:57:59 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 19:57:59 +0200 (CEST) Subject: [Python-checkins] r52042 - in python/branches/release24-maint: Misc/NEWS Objects/unicodeobject.c Message-ID: <20060929175759.BD12E1E4008@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 19:57:58 2006 New Revision: 52042 Modified: python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Objects/unicodeobject.c Log: [Backport rev. 39743 by lemburg] Bug fix for [ 1331062 ] utf 7 codec broken. Backport candidate. Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Fri Sep 29 19:57:58 2006 @@ -12,6 +12,8 @@ Core and builtins ----------------- +- Bug #1331062: Fix error in UTF-7 codec. + - Bug #1365916: Fix an int/long mismatch in the sorted() built-in. - Fix memory leak of coding spec in Parser/tokenizer.c. Modified: python/branches/release24-maint/Objects/unicodeobject.c ============================================================================== --- python/branches/release24-maint/Objects/unicodeobject.c (original) +++ python/branches/release24-maint/Objects/unicodeobject.c Fri Sep 29 19:57:58 2006 @@ -845,15 +845,23 @@ }; +/* Note: The comparison (c) <= 0 is a trick to work-around gcc + warnings about the comparison always being false; since + utf7_special[0] is 1, we can safely make that one comparison + true */ + #define SPECIAL(c, encodeO, encodeWS) \ - (((c)>127 || utf7_special[(c)] == 1) || \ + ((c) > 127 || (c) <= 0 || utf7_special[(c)] == 1 || \ (encodeWS && (utf7_special[(c)] == 2)) || \ (encodeO && (utf7_special[(c)] == 3))) -#define B64(n) ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(n) & 0x3f]) -#define B64CHAR(c) (isalnum(c) || (c) == '+' || (c) == '/') -#define UB64(c) ((c) == '+' ? 62 : (c) == '/' ? 63 : (c) >= 'a' ? \ - (c) - 71 : (c) >= 'A' ? (c) - 65 : (c) + 4) +#define B64(n) \ + ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(n) & 0x3f]) +#define B64CHAR(c) \ + (isalnum(c) || (c) == '+' || (c) == '/') +#define UB64(c) \ + ((c) == '+' ? 62 : (c) == '/' ? 63 : (c) >= 'a' ? \ + (c) - 71 : (c) >= 'A' ? (c) - 65 : (c) + 4 ) #define ENCODE(out, ch, bits) \ while (bits >= 6) { \ @@ -866,8 +874,8 @@ Py_UNICODE outCh = (Py_UNICODE) ((ch >> (bits-16)) & 0xffff); \ bits -= 16; \ if (surrogate) { \ - /* We have already generated an error for the high surrogate - so let's not bother seeing if the low surrogate is correct or not */\ + /* We have already generated an error for the high surrogate \ + so let's not bother seeing if the low surrogate is correct or not */ \ surrogate = 0; \ } else if (0xDC00 <= outCh && outCh <= 0xDFFF) { \ /* This is a surrogate pair. Unfortunately we can't represent \ @@ -878,7 +886,7 @@ } else { \ *out++ = outCh; \ } \ - } \ + } PyObject *PyUnicode_DecodeUTF7(const char *s, int size, From buildbot at python.org Fri Sep 29 20:16:51 2006 From: buildbot at python.org (buildbot at python.org) Date: Fri, 29 Sep 2006 18:16:51 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060929181651.E1CB11E4008@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/169 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: andrew.kuchling Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Fri Sep 29 20:22:08 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 20:22:08 +0200 (CEST) Subject: [Python-checkins] r52043 - python/branches/release24-maint/Objects/listobject.c Message-ID: <20060929182208.C33681E4008@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 20:22:07 2006 New Revision: 52043 Modified: python/branches/release24-maint/Objects/listobject.c Log: [Backport rev. 46878 by neal.norwitz] Don't leak the list object if there's an error allocating the item storage. Backport candidate. Modified: python/branches/release24-maint/Objects/listobject.c ============================================================================== --- python/branches/release24-maint/Objects/listobject.c (original) +++ python/branches/release24-maint/Objects/listobject.c Fri Sep 29 20:22:07 2006 @@ -108,8 +108,10 @@ op->ob_item = NULL; else { op->ob_item = (PyObject **) PyMem_MALLOC(nbytes); - if (op->ob_item == NULL) + if (op->ob_item == NULL) { + Py_DECREF(op); return PyErr_NoMemory(); + } memset(op->ob_item, 0, nbytes); } op->ob_size = size; From python-checkins at python.org Fri Sep 29 20:23:34 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 20:23:34 +0200 (CEST) Subject: [Python-checkins] r52044 - python/branches/release24-maint/configure.in Message-ID: <20060929182334.96FDE1E4008@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 20:23:33 2006 New Revision: 52044 Modified: python/branches/release24-maint/configure.in Log: Typo fix from rev. 46879 Modified: python/branches/release24-maint/configure.in ============================================================================== --- python/branches/release24-maint/configure.in (original) +++ python/branches/release24-maint/configure.in Fri Sep 29 20:23:33 2006 @@ -174,7 +174,7 @@ # On Mac OS X 10.4, defining _POSIX_C_SOURCE or _XOPEN_SOURCE # disables platform specific features beyond repair. # On Mac OS X 10.3, defining _POSIX_C_SOURCE or _XOPEN_SOURCE - # has no effect, don't bother defineing them + # has no effect, don't bother defining them Darwin/@<:@78@:>@.*) define_xopen_source=no ;; From python-checkins at python.org Fri Sep 29 20:31:01 2006 From: python-checkins at python.org (andrew.kuchling) Date: Fri, 29 Sep 2006 20:31:01 +0200 (CEST) Subject: [Python-checkins] r52045 - in python/branches/release24-maint: Lib/test/test_socket.py Lib/test/test_socket_ssl.py Lib/test/test_socketserver.py Lib/test/test_support.py Misc/NEWS Message-ID: <20060929183101.AFA5C1E400A@bag.python.org> Author: andrew.kuchling Date: Fri Sep 29 20:30:59 2006 New Revision: 52045 Modified: python/branches/release24-maint/Lib/test/test_socket.py python/branches/release24-maint/Lib/test/test_socket_ssl.py python/branches/release24-maint/Lib/test/test_socketserver.py python/branches/release24-maint/Lib/test/test_support.py python/branches/release24-maint/Misc/NEWS Log: [Backport rev. 46882 by neal.norwitz] Fix the socket tests so they can be run concurrently. Backport candidate Modified: python/branches/release24-maint/Lib/test/test_socket.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_socket.py (original) +++ python/branches/release24-maint/Lib/test/test_socket.py Fri Sep 29 20:30:59 2006 @@ -20,7 +20,8 @@ def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.serv.bind((HOST, PORT)) + global PORT + PORT = test_support.bind_port(self.serv, HOST, PORT) self.serv.listen(1) def tearDown(self): @@ -32,7 +33,8 @@ def setUp(self): self.serv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.serv.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - self.serv.bind((HOST, PORT)) + global PORT + PORT = test_support.bind_port(self.serv, HOST, PORT) def tearDown(self): self.serv.close() Modified: python/branches/release24-maint/Lib/test/test_socket_ssl.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_socket_ssl.py (original) +++ python/branches/release24-maint/Lib/test/test_socket_ssl.py Fri Sep 29 20:30:59 2006 @@ -72,10 +72,10 @@ return # some random port to connect to - PORT = 9934 + PORT = [9934] def listener(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.bind(('', PORT)) + PORT[0] = test_support.bind_port(s, '', PORT[0]) s.listen(5) s.accept() del s @@ -83,7 +83,7 @@ def connector(): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.connect(('localhost', PORT)) + s.connect(('localhost', PORT[0])) try: ssl_sock = socket.ssl(s) except socket.sslerror: Modified: python/branches/release24-maint/Lib/test/test_socketserver.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_socketserver.py (original) +++ python/branches/release24-maint/Lib/test/test_socketserver.py Fri Sep 29 20:30:59 2006 @@ -6,6 +6,7 @@ from SocketServer import * import socket +import errno import select import time import threading @@ -77,6 +78,11 @@ pass if verbose: print "thread: creating server" svr = svrcls(self.__addr, self.__hdlrcls) + # pull the address out of the server in case it changed + # this can happen if another process is using the port + addr = getattr(svr, 'server_address') + if addr: + self.__addr = addr if verbose: print "thread: serving three times" svr.serve_a_few() if verbose: print "thread: done" @@ -136,7 +142,25 @@ t.join() if verbose: print "done" -tcpservers = [TCPServer, ThreadingTCPServer] +class ForgivingTCPServer(TCPServer): + # prevent errors if another process is using the port we want + def server_bind(self): + host, default_port = self.server_address + # this code shamelessly stolen from test.test_support + # the ports were changed to protect the innocent + import sys + for port in [default_port, 3434, 8798, 23833]: + try: + self.server_address = host, port + TCPServer.server_bind(self) + break + except socket.error, (err, msg): + if err != errno.EADDRINUSE: + raise + print >>sys.__stderr__, \ + ' WARNING: failed to listen on port %d, trying another' % port + +tcpservers = [ForgivingTCPServer, ThreadingTCPServer] if hasattr(os, 'fork') and os.name not in ('os2',): tcpservers.append(ForkingTCPServer) udpservers = [UDPServer, ThreadingUDPServer] Modified: python/branches/release24-maint/Lib/test/test_support.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_support.py (original) +++ python/branches/release24-maint/Lib/test/test_support.py Fri Sep 29 20:30:59 2006 @@ -86,6 +86,24 @@ msg = "Use of the `%s' resource not enabled" % resource raise ResourceDenied(msg) +def bind_port(sock, host='', preferred_port=54321): + """Try to bind the sock to a port. If we are running multiple + tests and we don't try multiple ports, the test can fails. This + makes the test more robust.""" + + import socket, errno + # some random ports that hopefully no one is listening on. + for port in [preferred_port, 9907, 10243, 32999]: + try: + sock.bind((host, port)) + return port + except socket.error, (err, msg): + if err != errno.EADDRINUSE: + raise + print >>sys.__stderr__, \ + ' WARNING: failed to listen on port %d, trying another' % port + raise TestFailed, 'unable to find port to listen on' + FUZZ = 1e-6 def fcmp(x, y): # fuzzy comparison function Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Fri Sep 29 20:30:59 2006 @@ -228,6 +228,8 @@ - Patch #1529686: test_iterlen and test_email_codecs are now actually run by regrtest.py. +- Fix the socket tests so they can be run concurrently. + What's New in Python 2.4.3? =========================== From python-checkins at python.org Fri Sep 29 21:24:10 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Sep 2006 21:24:10 +0200 (CEST) Subject: [Python-checkins] r52046 - sandbox/trunk/setuptools/setuptools/command/easy_install.py Message-ID: <20060929192410.C1D1F1E4008@bag.python.org> Author: phillip.eby Date: Fri Sep 29 21:24:10 2006 New Revision: 52046 Modified: sandbox/trunk/setuptools/setuptools/command/easy_install.py Log: Use cross-platform relative paths in .pth if target is anywhere inside the .pth file's directory. 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 Fri Sep 29 21:24:10 2006 @@ -1393,9 +1393,19 @@ def make_relative(self,path): - if normalize_path(os.path.dirname(path))==self.basedir: - return os.path.join(os.curdir, os.path.basename(path)) - return path + npath, last = os.path.split(normalize_path(path)) + baselen = len(self.basedir) + parts = [last] + sep = os.altsep=='/' and '/' or os.sep + while len(npath)>=baselen: + if npath==self.basedir: + parts.append(os.curdir) + parts.reverse() + return sep.join(parts) + npath, last = os.path.split(npath) + parts.append(last) + else: + return path def get_script_header(script_text, executable=sys_executable): @@ -1420,6 +1430,9 @@ hdr = "#!%(executable)s%(options)s\n" % locals() return hdr + + + def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': os.chmod(arg, stat.S_IWRITE) @@ -1452,6 +1465,15 @@ 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. """ @@ -1474,6 +1496,25 @@ 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 Fri Sep 29 21:26:56 2006 From: python-checkins at python.org (phillip.eby) Date: Fri, 29 Sep 2006 21:26:56 +0200 (CEST) Subject: [Python-checkins] r52047 - in sandbox/branches/setuptools-0.6: setuptools.txt setuptools/command/easy_install.py Message-ID: <20060929192656.23EEE1E401D@bag.python.org> Author: phillip.eby Date: Fri Sep 29 21:26:55 2006 New Revision: 52047 Modified: sandbox/branches/setuptools-0.6/setuptools.txt sandbox/branches/setuptools-0.6/setuptools/command/easy_install.py Log: Use cross-platform relative paths in ``easy-install.pth`` when doing ``develop`` and the source directory is a subdirectory of the installation target directory. (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 Fri Sep 29 21:26:55 2006 @@ -2612,6 +2612,10 @@ * Fix problem with empty revision numbers in Subversion 1.4 ``entries`` files + * Use cross-platform relative paths in ``easy-install.pth`` when doing + ``develop`` and the source directory is a subdirectory of the installation + target directory. + 0.6c3 * Fixed breakages caused by Subversion 1.4's new "working copy" format 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 Fri Sep 29 21:26:55 2006 @@ -1393,9 +1393,19 @@ def make_relative(self,path): - if normalize_path(os.path.dirname(path))==self.basedir: - return os.path.join(os.curdir, os.path.basename(path)) - return path + npath, last = os.path.split(normalize_path(path)) + baselen = len(self.basedir) + parts = [last] + sep = os.altsep=='/' and '/' or os.sep + while len(npath)>=baselen: + if npath==self.basedir: + parts.append(os.curdir) + parts.reverse() + return sep.join(parts) + npath, last = os.path.split(npath) + parts.append(last) + else: + return path def get_script_header(script_text, executable=sys_executable): @@ -1420,6 +1430,9 @@ hdr = "#!%(executable)s%(options)s\n" % locals() return hdr + + + def auto_chmod(func, arg, exc): if func is os.remove and os.name=='nt': os.chmod(arg, stat.S_IWRITE) @@ -1452,6 +1465,15 @@ 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. """ @@ -1474,6 +1496,25 @@ 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 Sat Sep 30 07:14:03 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 30 Sep 2006 07:14:03 +0200 (CEST) Subject: [Python-checkins] r52048 - python/trunk/Doc/tut/tut.tex Message-ID: <20060930051403.AF6AE1E4008@bag.python.org> Author: george.yoshida Date: Sat Sep 30 07:14:02 2006 New Revision: 52048 Modified: python/trunk/Doc/tut/tut.tex Log: SF bug #1567976 : fix typo Will backport to 2.5. Modified: python/trunk/Doc/tut/tut.tex ============================================================================== --- python/trunk/Doc/tut/tut.tex (original) +++ python/trunk/Doc/tut/tut.tex Sat Sep 30 07:14:02 2006 @@ -3539,7 +3539,7 @@ But use of \code{.args} is discouraged. Instead, the preferred use is to pass a single argument to an exception (which can be a tuple if multiple arguments -are needed) and have it bound to the \code{message} attribute. One my also +are needed) and have it bound to the \code{message} attribute. One may also instantiate an exception first before raising it and add any attributes to it as desired. From python-checkins at python.org Sat Sep 30 07:22:24 2006 From: python-checkins at python.org (george.yoshida) Date: Sat, 30 Sep 2006 07:22:24 +0200 (CEST) Subject: [Python-checkins] r52049 - python/branches/release25-maint/Doc/tut/tut.tex Message-ID: <20060930052224.C47241E4008@bag.python.org> Author: george.yoshida Date: Sat Sep 30 07:22:23 2006 New Revision: 52049 Modified: python/branches/release25-maint/Doc/tut/tut.tex Log: SF bug #1567976 : fix typo(backport from r52048) Since this paragraph is about exception's message attribute(2.5 feature), I will not backport to 2.4 branch. 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 30 07:22:23 2006 @@ -3539,7 +3539,7 @@ But use of \code{.args} is discouraged. Instead, the preferred use is to pass a single argument to an exception (which can be a tuple if multiple arguments -are needed) and have it bound to the \code{message} attribute. One my also +are needed) and have it bound to the \code{message} attribute. One may also instantiate an exception first before raising it and add any attributes to it as desired. From python-checkins at python.org Sat Sep 30 08:05:08 2006 From: python-checkins at python.org (gregory.p.smith) Date: Sat, 30 Sep 2006 08:05:08 +0200 (CEST) Subject: [Python-checkins] r52050 - in python/branches/release25-maint: Misc/NEWS Modules/_bsddb.c Message-ID: <20060930060508.380821E4026@bag.python.org> Author: gregory.p.smith Date: Sat Sep 30 08:05:07 2006 New Revision: 52050 Modified: python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/_bsddb.c Log: fix: DB.stat flags and txn keyword arguments were backwards. Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 08:05:07 2006 @@ -22,6 +22,8 @@ - Allow exception instances to be directly sliced again. +- fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments + were transposed. Extension Modules ----------------- Modified: python/branches/release25-maint/Modules/_bsddb.c ============================================================================== --- python/branches/release25-maint/Modules/_bsddb.c (original) +++ python/branches/release25-maint/Modules/_bsddb.c Sat Sep 30 08:05:07 2006 @@ -98,7 +98,7 @@ #error "eek! DBVER can't handle minor versions > 9" #endif -#define PY_BSDDB_VERSION "4.4.5" +#define PY_BSDDB_VERSION "4.4.5.1" static char *rcs_id = "$Id$"; @@ -2430,7 +2430,7 @@ #if (DBVER >= 43) PyObject* txnobj = NULL; DB_TXN *txn = NULL; - static char* kwnames[] = { "txn", "flags", NULL }; + static char* kwnames[] = { "flags", "txn", NULL }; #else static char* kwnames[] = { "flags", NULL }; #endif From python-checkins at python.org Sat Sep 30 08:08:21 2006 From: python-checkins at python.org (gregory.p.smith) Date: Sat, 30 Sep 2006 08:08:21 +0200 (CEST) Subject: [Python-checkins] r52051 - python/trunk/Misc/NEWS Message-ID: <20060930060821.29CBD1E4009@bag.python.org> Author: gregory.p.smith Date: Sat Sep 30 08:08:20 2006 New Revision: 52051 Modified: python/trunk/Misc/NEWS Log: wording change Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 08:08:20 2006 @@ -81,7 +81,7 @@ - Bug #1531862: Do not close standard file descriptors in subprocess. -- fixed a bug with bsddb.DB.stat: its flags and txn keyword arguments +- fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments were transposed. Extension Modules From python-checkins at python.org Sat Sep 30 08:09:07 2006 From: python-checkins at python.org (gregory.p.smith) Date: Sat, 30 Sep 2006 08:09:07 +0200 (CEST) Subject: [Python-checkins] r52052 - python/branches/release24-maint/Misc/NEWS Message-ID: <20060930060907.A275A1E4009@bag.python.org> Author: gregory.p.smith Date: Sat Sep 30 08:09:07 2006 New Revision: 52052 Modified: python/branches/release24-maint/Misc/NEWS Log: wording change Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 08:09:07 2006 @@ -57,7 +57,7 @@ - iso2022_jp_3 and iso2022_jp_2004 codec can encode JIS X 2013:2 codepoints now. -- fixed a bug with bsddb.DB.stat: its flags and txn keyword arguments +- fixed a bug with bsddb.DB.stat: the flags and txn keyword arguments were transposed. Extension Modules From python-checkins at python.org Sat Sep 30 09:24:50 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 09:24:50 +0200 (CEST) Subject: [Python-checkins] r52053 - python/trunk/Doc/tut/tut.tex Message-ID: <20060930072450.683801E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 09:24:48 2006 New Revision: 52053 Modified: python/trunk/Doc/tut/tut.tex Log: Bug #1567375: a minor logical glitch in example description. Modified: python/trunk/Doc/tut/tut.tex ============================================================================== --- python/trunk/Doc/tut/tut.tex (original) +++ python/trunk/Doc/tut/tut.tex Sat Sep 30 09:24:48 2006 @@ -3060,6 +3060,7 @@ 8 64 512 9 81 729 10 100 1000 + >>> for x in range(1,11): ... print '%2d %3d %4d' % (x, x*x, x*x*x) ... @@ -3075,8 +3076,9 @@ 10 100 1000 \end{verbatim} -(Note that one space between each column was added by the way -\keyword{print} works: it always adds spaces between its arguments.) +(Note that in the first example, one space between each column was +added by the way \keyword{print} works: it always adds spaces between +its arguments.) This example demonstrates the \method{rjust()} method of string objects, which right-justifies a string in a field of a given width by padding From python-checkins at python.org Sat Sep 30 09:24:53 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 09:24:53 +0200 (CEST) Subject: [Python-checkins] r52054 - python/branches/release24-maint/Doc/tut/tut.tex Message-ID: <20060930072453.CDC7C1E4018@bag.python.org> Author: georg.brandl Date: Sat Sep 30 09:24:53 2006 New Revision: 52054 Modified: python/branches/release24-maint/Doc/tut/tut.tex Log: Bug #1567375: a minor logical glitch in example description. (backport from rev. 52053) Modified: python/branches/release24-maint/Doc/tut/tut.tex ============================================================================== --- python/branches/release24-maint/Doc/tut/tut.tex (original) +++ python/branches/release24-maint/Doc/tut/tut.tex Sat Sep 30 09:24:53 2006 @@ -3017,6 +3017,7 @@ 8 64 512 9 81 729 10 100 1000 + >>> for x in range(1,11): ... print '%2d %3d %4d' % (x, x*x, x*x*x) ... @@ -3032,8 +3033,9 @@ 10 100 1000 \end{verbatim} -(Note that one space between each column was added by the way -\keyword{print} works: it always adds spaces between its arguments.) +(Note that in the first example, one space between each column was +added by the way \keyword{print} works: it always adds spaces between +its arguments.) This example demonstrates the \method{rjust()} method of string objects, which right-justifies a string in a field of a given width by padding From python-checkins at python.org Sat Sep 30 09:24:56 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 09:24:56 +0200 (CEST) Subject: [Python-checkins] r52055 - python/branches/release25-maint/Doc/tut/tut.tex Message-ID: <20060930072456.AFC7F1E4010@bag.python.org> Author: georg.brandl Date: Sat Sep 30 09:24:56 2006 New Revision: 52055 Modified: python/branches/release25-maint/Doc/tut/tut.tex Log: Bug #1567375: a minor logical glitch in example description. (backport from rev. 52053) 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 30 09:24:56 2006 @@ -3060,6 +3060,7 @@ 8 64 512 9 81 729 10 100 1000 + >>> for x in range(1,11): ... print '%2d %3d %4d' % (x, x*x, x*x*x) ... @@ -3075,8 +3076,9 @@ 10 100 1000 \end{verbatim} -(Note that one space between each column was added by the way -\keyword{print} works: it always adds spaces between its arguments.) +(Note that in the first example, one space between each column was +added by the way \keyword{print} works: it always adds spaces between +its arguments.) This example demonstrates the \method{rjust()} method of string objects, which right-justifies a string in a field of a given width by padding From python-checkins at python.org Sat Sep 30 09:31:57 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 09:31:57 +0200 (CEST) Subject: [Python-checkins] r52056 - in python/trunk: Lib/webbrowser.py Misc/NEWS Message-ID: <20060930073157.953231E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 09:31:57 2006 New Revision: 52056 Modified: python/trunk/Lib/webbrowser.py python/trunk/Misc/NEWS Log: Bug #1565661: in webbrowser, split() the command for the default GNOME browser in case it is a command with args. Modified: python/trunk/Lib/webbrowser.py ============================================================================== --- python/trunk/Lib/webbrowser.py (original) +++ python/trunk/Lib/webbrowser.py Sat Sep 30 09:31:57 2006 @@ -447,7 +447,7 @@ # if successful, register it if retncode is None and commd: - register("gnome", None, BackgroundBrowser(commd)) + register("gnome", None, BackgroundBrowser(commd.split())) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 09:31:57 2006 @@ -56,6 +56,9 @@ Library ------- +- Bug #1565661: in webbrowser, split() the command for the default + GNOME browser in case it is a command with args. + - Made the error message for time.strptime when the data data and format do match be more clear. From python-checkins at python.org Sat Sep 30 09:32:00 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 09:32:00 +0200 (CEST) Subject: [Python-checkins] r52057 - in python/branches/release25-maint: Lib/webbrowser.py Misc/NEWS Message-ID: <20060930073200.93E9B1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 09:32:00 2006 New Revision: 52057 Modified: python/branches/release25-maint/Lib/webbrowser.py python/branches/release25-maint/Misc/NEWS Log: Bug #1565661: in webbrowser, split() the command for the default GNOME browser in case it is a command with args. (backport from rev. 52056) Modified: python/branches/release25-maint/Lib/webbrowser.py ============================================================================== --- python/branches/release25-maint/Lib/webbrowser.py (original) +++ python/branches/release25-maint/Lib/webbrowser.py Sat Sep 30 09:32:00 2006 @@ -447,7 +447,7 @@ # if successful, register it if retncode is None and commd: - register("gnome", None, BackgroundBrowser(commd)) + register("gnome", None, BackgroundBrowser(commd.split())) # First, the Mozilla/Netscape browsers for browser in ("mozilla-firefox", "firefox", Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 09:32:00 2006 @@ -34,6 +34,9 @@ Library ------- +- Bug #1565661: in webbrowser, split() the command for the default + GNOME browser in case it is a command with args. + - Fix a bug in traceback.format_exception_only() that led to an error being raised when print_exc() was called without an exception set. In version 2.4, this printed "None", restored that behavior. From buildbot at python.org Sat Sep 30 10:27:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 08:27:01 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper trunk Message-ID: <20060930082701.8554C1E4009@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/112 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch trunk] HEAD Blamelist: georg.brandl,george.yoshida,gregory.p.smith Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat Sep 30 10:43:32 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 10:43:32 +0200 (CEST) Subject: [Python-checkins] r52058 - in python/trunk: Lib/test/test_descr.py Lib/test/test_new.py Misc/NEWS Objects/classobject.c Objects/typeobject.c Message-ID: <20060930084332.1B7FD1E400A@bag.python.org> Author: georg.brandl Date: Sat Sep 30 10:43:30 2006 New Revision: 52058 Modified: python/trunk/Lib/test/test_descr.py python/trunk/Lib/test/test_new.py python/trunk/Misc/NEWS python/trunk/Objects/classobject.c python/trunk/Objects/typeobject.c Log: Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). Modified: python/trunk/Lib/test/test_descr.py ============================================================================== --- python/trunk/Lib/test/test_descr.py (original) +++ python/trunk/Lib/test/test_descr.py Sat Sep 30 10:43:30 2006 @@ -2142,6 +2142,13 @@ veris(Sub.test(), Base.aProp) + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + raise TestFailed, "super shouldn't accept keyword args" def inherits(): if verbose: print "Testing inheritance from basic types..." Modified: python/trunk/Lib/test/test_new.py ============================================================================== --- python/trunk/Lib/test/test_new.py (original) +++ python/trunk/Lib/test/test_new.py Sat Sep 30 10:43:30 2006 @@ -57,6 +57,14 @@ else: raise TestFailed, "dangerous instance method creation allowed" +# Verify that instancemethod() doesn't allow keyword args +try: + new.instancemethod(break_yolks, c, kw=1) +except TypeError: + pass +else: + raise TestFailed, "instancemethod shouldn't accept keyword args" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 10:43:30 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Patch #1567691: super() and new.instancemethod() now don't accept + keyword arguments any more (previously they accepted them, but didn't + use them). + - Fix a bug in the parser's future statement handling that led to "with" not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement Modified: python/trunk/Objects/classobject.c ============================================================================== --- python/trunk/Objects/classobject.c (original) +++ python/trunk/Objects/classobject.c Sat Sep 30 10:43:30 2006 @@ -2256,6 +2256,8 @@ PyObject *self; PyObject *classObj = NULL; + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, &func, &self, &classObj)) return NULL; Modified: python/trunk/Objects/typeobject.c ============================================================================== --- python/trunk/Objects/typeobject.c (original) +++ python/trunk/Objects/typeobject.c Sat Sep 30 10:43:30 2006 @@ -5762,6 +5762,8 @@ PyObject *obj = NULL; PyTypeObject *obj_type = NULL; + if (!_PyArg_NoKeywords("super", kwds)) + return -1; if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) return -1; if (obj == Py_None) From python-checkins at python.org Sat Sep 30 10:43:37 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 10:43:37 +0200 (CEST) Subject: [Python-checkins] r52059 - in python/branches/release24-maint: Lib/test/test_descr.py Lib/test/test_new.py Misc/NEWS Objects/classobject.c Objects/typeobject.c Message-ID: <20060930084337.49D5F1E400A@bag.python.org> Author: georg.brandl Date: Sat Sep 30 10:43:35 2006 New Revision: 52059 Modified: python/branches/release24-maint/Lib/test/test_descr.py python/branches/release24-maint/Lib/test/test_new.py python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Objects/classobject.c python/branches/release24-maint/Objects/typeobject.c Log: Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). (backport from rev. 52058) Modified: python/branches/release24-maint/Lib/test/test_descr.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_descr.py (original) +++ python/branches/release24-maint/Lib/test/test_descr.py Sat Sep 30 10:43:35 2006 @@ -2077,6 +2077,13 @@ veris(Sub.test(), Base.aProp) + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + raise TestFailed, "super shouldn't accept keyword args" def inherits(): if verbose: print "Testing inheritance from basic types..." Modified: python/branches/release24-maint/Lib/test/test_new.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_new.py (original) +++ python/branches/release24-maint/Lib/test/test_new.py Sat Sep 30 10:43:35 2006 @@ -57,6 +57,14 @@ else: raise TestFailed, "dangerous instance method creation allowed" +# Verify that instancemethod() doesn't allow keyword args +try: + new.instancemethod(break_yolks, c, kw=1) +except TypeError: + pass +else: + raise TestFailed, "instancemethod shouldn't accept keyword args" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 10:43:35 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Patch #1567691: super() and new.instancemethod() now don't accept + keyword arguments any more (previously they accepted them, but didn't + use them). + - Bug #1331062: Fix error in UTF-7 codec. - Bug #1365916: Fix an int/long mismatch in the sorted() built-in. Modified: python/branches/release24-maint/Objects/classobject.c ============================================================================== --- python/branches/release24-maint/Objects/classobject.c (original) +++ python/branches/release24-maint/Objects/classobject.c Sat Sep 30 10:43:35 2006 @@ -2211,6 +2211,8 @@ PyObject *self; PyObject *classObj = NULL; + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, &func, &self, &classObj)) return NULL; Modified: python/branches/release24-maint/Objects/typeobject.c ============================================================================== --- python/branches/release24-maint/Objects/typeobject.c (original) +++ python/branches/release24-maint/Objects/typeobject.c Sat Sep 30 10:43:35 2006 @@ -5706,6 +5706,8 @@ PyObject *obj = NULL; PyTypeObject *obj_type = NULL; + if (!_PyArg_NoKeywords("super", kwds)) + return -1; if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) return -1; if (obj == Py_None) From python-checkins at python.org Sat Sep 30 10:43:51 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 10:43:51 +0200 (CEST) Subject: [Python-checkins] r52060 - in python/branches/release25-maint: Lib/test/test_descr.py Lib/test/test_new.py Misc/NEWS Objects/classobject.c Objects/typeobject.c Message-ID: <20060930084351.D515E1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 10:43:50 2006 New Revision: 52060 Modified: python/branches/release25-maint/Lib/test/test_descr.py python/branches/release25-maint/Lib/test/test_new.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Objects/classobject.c python/branches/release25-maint/Objects/typeobject.c Log: Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). (backport from rev. 52058) Modified: python/branches/release25-maint/Lib/test/test_descr.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_descr.py (original) +++ python/branches/release25-maint/Lib/test/test_descr.py Sat Sep 30 10:43:50 2006 @@ -2142,6 +2142,13 @@ veris(Sub.test(), Base.aProp) + # Verify that super() doesn't allow keyword args + try: + super(Base, kw=1) + except TypeError: + pass + else: + raise TestFailed, "super shouldn't accept keyword args" def inherits(): if verbose: print "Testing inheritance from basic types..." Modified: python/branches/release25-maint/Lib/test/test_new.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_new.py (original) +++ python/branches/release25-maint/Lib/test/test_new.py Sat Sep 30 10:43:50 2006 @@ -57,6 +57,14 @@ else: raise TestFailed, "dangerous instance method creation allowed" +# Verify that instancemethod() doesn't allow keyword args +try: + new.instancemethod(break_yolks, c, kw=1) +except TypeError: + pass +else: + raise TestFailed, "instancemethod shouldn't accept keyword args" + # It's unclear what the semantics should be for a code object compiled at # module scope, but bound and run in a function. In CPython, `c' is global # (by accident?) while in Jython, `c' is local. The intent of the test Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 10:43:50 2006 @@ -12,6 +12,10 @@ Core and builtins ----------------- +- Patch #1567691: super() and new.instancemethod() now don't accept + keyword arguments any more (previously they accepted them, but didn't + use them). + - Fix a bug in the parser's future statement handling that led to "with" not being recognized as a keyword after, e.g., this statement: from __future__ import division, with_statement Modified: python/branches/release25-maint/Objects/classobject.c ============================================================================== --- python/branches/release25-maint/Objects/classobject.c (original) +++ python/branches/release25-maint/Objects/classobject.c Sat Sep 30 10:43:50 2006 @@ -2256,6 +2256,8 @@ PyObject *self; PyObject *classObj = NULL; + if (!_PyArg_NoKeywords("instancemethod", kw)) + return NULL; if (!PyArg_UnpackTuple(args, "instancemethod", 2, 3, &func, &self, &classObj)) return NULL; Modified: python/branches/release25-maint/Objects/typeobject.c ============================================================================== --- python/branches/release25-maint/Objects/typeobject.c (original) +++ python/branches/release25-maint/Objects/typeobject.c Sat Sep 30 10:43:50 2006 @@ -5762,6 +5762,8 @@ PyObject *obj = NULL; PyTypeObject *obj_type = NULL; + if (!_PyArg_NoKeywords("super", kwds)) + return -1; if (!PyArg_ParseTuple(args, "O!|O:super", &PyType_Type, &type, &obj)) return -1; if (obj == Py_None) From python-checkins at python.org Sat Sep 30 11:03:42 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:03:42 +0200 (CEST) Subject: [Python-checkins] r52061 - in python/trunk: Lib/test/test_exceptions.py Misc/NEWS Objects/exceptions.c Message-ID: <20060930090342.E740C1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:03:42 2006 New Revision: 52061 Modified: python/trunk/Lib/test/test_exceptions.py python/trunk/Misc/NEWS python/trunk/Objects/exceptions.c Log: Bug #1566800: make sure that EnvironmentError can be called with any number of arguments, as was the case in Python 2.4. 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 30 11:03:42 2006 @@ -196,11 +196,16 @@ (SystemExit, ('foo',), {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), + {'message' : 'foo', 'args' : ('foo',), 'filename' : None, + 'errno' : None, 'strerror' : None}), (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, + 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', + 'errno' : 'foo', 'strerror' : 'bar'}), + (IOError, ('foo', 'bar', 'baz', 'quux'), + {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}), (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 11:03:42 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1566800: make sure that EnvironmentError can be called with any + number of arguments, as was the case in Python 2.4. + - Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). Modified: python/trunk/Objects/exceptions.c ============================================================================== --- python/trunk/Objects/exceptions.c (original) +++ python/trunk/Objects/exceptions.c Sat Sep 30 11:03:42 2006 @@ -510,7 +510,7 @@ if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (PyTuple_GET_SIZE(args) <= 1) { + if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) { return 0; } From python-checkins at python.org Sat Sep 30 11:03:45 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:03:45 +0200 (CEST) Subject: [Python-checkins] r52062 - in python/branches/release25-maint: Lib/test/test_exceptions.py Misc/NEWS Objects/exceptions.c Message-ID: <20060930090345.E11671E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:03:45 2006 New Revision: 52062 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 #1566800: make sure that EnvironmentError can be called with any number of arguments, as was the case in Python 2.4. (backport from rev. 52061) 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 30 11:03:45 2006 @@ -196,11 +196,16 @@ (SystemExit, ('foo',), {'message' : 'foo', 'args' : ('foo',), 'code' : 'foo'}), (IOError, ('foo',), - {'message' : 'foo', 'args' : ('foo',)}), + {'message' : 'foo', 'args' : ('foo',), 'filename' : None, + 'errno' : None, 'strerror' : None}), (IOError, ('foo', 'bar'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : None, + 'errno' : 'foo', 'strerror' : 'bar'}), (IOError, ('foo', 'bar', 'baz'), - {'message' : '', 'args' : ('foo', 'bar')}), + {'message' : '', 'args' : ('foo', 'bar'), 'filename' : 'baz', + 'errno' : 'foo', 'strerror' : 'bar'}), + (IOError, ('foo', 'bar', 'baz', 'quux'), + {'message' : '', 'args' : ('foo', 'bar', 'baz', 'quux')}), (EnvironmentError, ('errnoStr', 'strErrorStr', 'filenameStr'), {'message' : '', 'args' : ('errnoStr', 'strErrorStr'), 'strerror' : 'strErrorStr', 'errno' : 'errnoStr', Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 11:03:45 2006 @@ -12,6 +12,9 @@ Core and builtins ----------------- +- Bug #1566800: make sure that EnvironmentError can be called with any + number of arguments, as was the case in Python 2.4. + - Patch #1567691: super() and new.instancemethod() now don't accept keyword arguments any more (previously they accepted them, but didn't use them). 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 30 11:03:45 2006 @@ -510,7 +510,7 @@ if (BaseException_init((PyBaseExceptionObject *)self, args, kwds) == -1) return -1; - if (PyTuple_GET_SIZE(args) <= 1) { + if (PyTuple_GET_SIZE(args) <= 1 || PyTuple_GET_SIZE(args) > 3) { return 0; } From python-checkins at python.org Sat Sep 30 11:06:46 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:06:46 +0200 (CEST) Subject: [Python-checkins] r52063 - in python/trunk: Doc/lib/libdatetime.tex Misc/NEWS Message-ID: <20060930090646.2DE461E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:06:45 2006 New Revision: 52063 Modified: python/trunk/Doc/lib/libdatetime.tex python/trunk/Misc/NEWS Log: Bug #1566663: remove obsolete example from datetime docs. Modified: python/trunk/Doc/lib/libdatetime.tex ============================================================================== --- python/trunk/Doc/lib/libdatetime.tex (original) +++ python/trunk/Doc/lib/libdatetime.tex Sat Sep 30 11:06:45 2006 @@ -1421,19 +1421,21 @@ varies across platforms. Regardless of platform, years before 1900 cannot be used. -\subsection{Examples} - -\subsubsection{Creating Datetime Objects from Formatted Strings} - -The \class{datetime} class does not directly support parsing formatted time -strings. You can use \function{time.strptime} to do the parsing and create -a \class{datetime} object from the tuple it returns: - -\begin{verbatim} ->>> s = "2005-12-06T12:13:14" ->>> from datetime import datetime ->>> from time import strptime ->>> datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6]) -datetime.datetime(2005, 12, 6, 12, 13, 14) -\end{verbatim} - +%%% This example is obsolete, since strptime is now supported by datetime. +% +% \subsection{Examples} +% +% \subsubsection{Creating Datetime Objects from Formatted Strings} +% +% The \class{datetime} class does not directly support parsing formatted time +% strings. You can use \function{time.strptime} to do the parsing and create +% a \class{datetime} object from the tuple it returns: +% +% \begin{verbatim} +% >>> s = "2005-12-06T12:13:14" +% >>> from datetime import datetime +% >>> from time import strptime +% >>> datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6]) +% datetime.datetime(2005, 12, 6, 12, 13, 14) +% \end{verbatim} +% Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 11:06:45 2006 @@ -131,6 +131,8 @@ Documentation ------------- +- Bug #1566663: remove obsolete example from datetime docs. + - Bug #1541682: Fix example in the "Refcount details" API docs. Additionally, remove a faulty example showing PySequence_SetItem applied to a newly created list object and add notes that this isn't a good idea. From python-checkins at python.org Sat Sep 30 11:06:49 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:06:49 +0200 (CEST) Subject: [Python-checkins] r52064 - in python/branches/release25-maint: Doc/lib/libdatetime.tex Misc/NEWS Message-ID: <20060930090649.B318C1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:06:49 2006 New Revision: 52064 Modified: python/branches/release25-maint/Doc/lib/libdatetime.tex python/branches/release25-maint/Misc/NEWS Log: Bug #1566663: remove obsolete example from datetime docs. (backport from rev. 52063) Modified: python/branches/release25-maint/Doc/lib/libdatetime.tex ============================================================================== --- python/branches/release25-maint/Doc/lib/libdatetime.tex (original) +++ python/branches/release25-maint/Doc/lib/libdatetime.tex Sat Sep 30 11:06:49 2006 @@ -1421,19 +1421,21 @@ varies across platforms. Regardless of platform, years before 1900 cannot be used. -\subsection{Examples} - -\subsubsection{Creating Datetime Objects from Formatted Strings} - -The \class{datetime} class does not directly support parsing formatted time -strings. You can use \function{time.strptime} to do the parsing and create -a \class{datetime} object from the tuple it returns: - -\begin{verbatim} ->>> s = "2005-12-06T12:13:14" ->>> from datetime import datetime ->>> from time import strptime ->>> datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6]) -datetime.datetime(2005, 12, 6, 12, 13, 14) -\end{verbatim} - +%%% This example is obsolete, since strptime is now supported by datetime. +% +% \subsection{Examples} +% +% \subsubsection{Creating Datetime Objects from Formatted Strings} +% +% The \class{datetime} class does not directly support parsing formatted time +% strings. You can use \function{time.strptime} to do the parsing and create +% a \class{datetime} object from the tuple it returns: +% +% \begin{verbatim} +% >>> s = "2005-12-06T12:13:14" +% >>> from datetime import datetime +% >>> from time import strptime +% >>> datetime(*strptime(s, "%Y-%m-%dT%H:%M:%S")[0:6]) +% datetime.datetime(2005, 12, 6, 12, 13, 14) +% \end{verbatim} +% Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 11:06:49 2006 @@ -151,6 +151,8 @@ Documentation ------------- +- Bug #1566663: remove obsolete example from datetime docs. + - Bug #1541682: Fix example in the "Refcount details" API docs. Additionally, remove a faulty example showing PySequence_SetItem applied to a newly created list object and add notes that this isn't a good idea. From python-checkins at python.org Sat Sep 30 11:13:22 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:13:22 +0200 (CEST) Subject: [Python-checkins] r52065 - in python/trunk: Lib/posixpath.py Misc/NEWS Message-ID: <20060930091322.76C301E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:13:21 2006 New Revision: 52065 Modified: python/trunk/Lib/posixpath.py python/trunk/Misc/NEWS Log: Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. Modified: python/trunk/Lib/posixpath.py ============================================================================== --- python/trunk/Lib/posixpath.py (original) +++ python/trunk/Lib/posixpath.py Sat Sep 30 11:13:21 2006 @@ -259,8 +259,7 @@ except KeyError: return path userhome = pwent.pw_dir - if userhome.endswith('/'): - i += 1 + userhome = userhome.rstrip('/') return userhome + path[i:] Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 11:13:21 2006 @@ -63,6 +63,9 @@ Library ------- +- Bug #1566602: correct failure of posixpath unittest when $HOME ends + with a slash. + - Bug #1565661: in webbrowser, split() the command for the default GNOME browser in case it is a command with args. From python-checkins at python.org Sat Sep 30 11:13:26 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:13:26 +0200 (CEST) Subject: [Python-checkins] r52066 - in python/branches/release24-maint: Lib/posixpath.py Misc/NEWS Message-ID: <20060930091326.47D5B1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:13:25 2006 New Revision: 52066 Modified: python/branches/release24-maint/Lib/posixpath.py python/branches/release24-maint/Misc/NEWS Log: Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. (backport from rev. 52065) Modified: python/branches/release24-maint/Lib/posixpath.py ============================================================================== --- python/branches/release24-maint/Lib/posixpath.py (original) +++ python/branches/release24-maint/Lib/posixpath.py Sat Sep 30 11:13:25 2006 @@ -328,8 +328,7 @@ except KeyError: return path userhome = pwent.pw_dir - if userhome.endswith('/'): - i += 1 + userhome = userhome.rstrip('/') return userhome + path[i:] Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 11:13:25 2006 @@ -119,6 +119,9 @@ Library ------- +- Bug #1566602: correct failure of posixpath unittest when $HOME ends + with a slash. + - Reverted patch #1504333 because it introduced an infinite loop. - Fix missing import of the types module in logging.config. From python-checkins at python.org Sat Sep 30 11:13:29 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 11:13:29 +0200 (CEST) Subject: [Python-checkins] r52067 - in python/branches/release25-maint: Lib/posixpath.py Misc/NEWS Message-ID: <20060930091329.9D23D1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 11:13:29 2006 New Revision: 52067 Modified: python/branches/release25-maint/Lib/posixpath.py python/branches/release25-maint/Misc/NEWS Log: Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. (backport from rev. 52065) Modified: python/branches/release25-maint/Lib/posixpath.py ============================================================================== --- python/branches/release25-maint/Lib/posixpath.py (original) +++ python/branches/release25-maint/Lib/posixpath.py Sat Sep 30 11:13:29 2006 @@ -328,8 +328,7 @@ except KeyError: return path userhome = pwent.pw_dir - if userhome.endswith('/'): - i += 1 + userhome = userhome.rstrip('/') return userhome + path[i:] Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 11:13:29 2006 @@ -41,6 +41,9 @@ Library ------- +- Bug #1566602: correct failure of posixpath unittest when $HOME ends + with a slash. + - Bug #1565661: in webbrowser, split() the command for the default GNOME browser in case it is a command with args. From buildbot at python.org Sat Sep 30 11:23:39 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 09:23:39 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20060930092339.664081E4009@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/42 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 Sat Sep 30 12:26:11 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 10:26:11 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk 2.4 Message-ID: <20060930102611.A7D601E4009@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%25202.4/builds/20 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl,gregory.p.smith Build Had Warnings: warnings test sincerely, -The Buildbot From python-checkins at python.org Sat Sep 30 12:58:03 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 12:58:03 +0200 (CEST) Subject: [Python-checkins] r52068 - in python/trunk: Lib/cgi.py Misc/NEWS Message-ID: <20060930105803.21CC51E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 12:58:01 2006 New Revision: 52068 Modified: python/trunk/Lib/cgi.py python/trunk/Misc/NEWS Log: Bug #1457823: cgi.(Sv)FormContentDict's constructor now takes keep_blank_values and strict_parsing keyword arguments. Modified: python/trunk/Lib/cgi.py ============================================================================== --- python/trunk/Lib/cgi.py (original) +++ python/trunk/Lib/cgi.py Sat Sep 30 12:58:01 2006 @@ -807,8 +807,10 @@ form.dict == {key: [val, val, ...], ...} """ - def __init__(self, environ=os.environ): - self.dict = self.data = parse(environ=environ) + def __init__(self, environ=os.environ, keep_blank_values=0, strict_parsing=0): + self.dict = self.data = parse(environ=environ, + keep_blank_values=keep_blank_values, + strict_parsing=strict_parsing) self.query_string = environ['QUERY_STRING'] Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 12:58:01 2006 @@ -63,6 +63,9 @@ Library ------- +- Bug #1457823: cgi.(Sv)FormContentDict's constructor now takes + keep_blank_values and strict_parsing keyword arguments. + - Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. From python-checkins at python.org Sat Sep 30 13:06:48 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:06:48 +0200 (CEST) Subject: [Python-checkins] r52069 - in python/trunk: Lib/pyclbr.py Lib/test/test_pyclbr.py Misc/NEWS Message-ID: <20060930110648.0F68F1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:06:47 2006 New Revision: 52069 Modified: python/trunk/Lib/pyclbr.py python/trunk/Lib/test/test_pyclbr.py python/trunk/Misc/NEWS Log: Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. Modified: python/trunk/Lib/pyclbr.py ============================================================================== --- python/trunk/Lib/pyclbr.py (original) +++ python/trunk/Lib/pyclbr.py Sat Sep 30 13:06:47 2006 @@ -172,7 +172,7 @@ # else it's a nested def else: # it's a function - dict[meth_name] = Function(module, meth_name, file, lineno) + dict[meth_name] = Function(fullmodule, meth_name, file, lineno) stack.append((None, thisindent)) # Marker for nested fns elif token == 'class': lineno, thisindent = start Modified: python/trunk/Lib/test/test_pyclbr.py ============================================================================== --- python/trunk/Lib/test/test_pyclbr.py (original) +++ python/trunk/Lib/test/test_pyclbr.py Sat Sep 30 13:06:47 2006 @@ -93,6 +93,9 @@ py_item = getattr(module, name) if isinstance(value, pyclbr.Function): self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType))) + if py_item.__module__ != moduleName: + continue # skip functions that came from somewhere else + self.assertEquals(py_item.__module__, value.module) else: self.failUnless(isinstance(py_item, (ClassType, type))) if py_item.__module__ != moduleName: Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 13:06:47 2006 @@ -63,6 +63,9 @@ Library ------- +- Bug #1560617: in pyclbr, return full module name not only for classes, + but also for functions. + - Bug #1457823: cgi.(Sv)FormContentDict's constructor now takes keep_blank_values and strict_parsing keyword arguments. From python-checkins at python.org Sat Sep 30 13:06:52 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:06:52 +0200 (CEST) Subject: [Python-checkins] r52070 - in python/branches/release24-maint: Lib/pyclbr.py Lib/test/test_pyclbr.py Misc/NEWS Message-ID: <20060930110652.8F11E1E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:06:51 2006 New Revision: 52070 Modified: python/branches/release24-maint/Lib/pyclbr.py python/branches/release24-maint/Lib/test/test_pyclbr.py python/branches/release24-maint/Misc/NEWS Log: Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. (backport from rev. 52069) Modified: python/branches/release24-maint/Lib/pyclbr.py ============================================================================== --- python/branches/release24-maint/Lib/pyclbr.py (original) +++ python/branches/release24-maint/Lib/pyclbr.py Sat Sep 30 13:06:51 2006 @@ -172,7 +172,7 @@ # else it's a nested def else: # it's a function - dict[meth_name] = Function(module, meth_name, file, lineno) + dict[meth_name] = Function(fullmodule, meth_name, file, lineno) stack.append((None, thisindent)) # Marker for nested fns elif token == 'class': lineno, thisindent = start Modified: python/branches/release24-maint/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_pyclbr.py (original) +++ python/branches/release24-maint/Lib/test/test_pyclbr.py Sat Sep 30 13:06:51 2006 @@ -93,6 +93,9 @@ py_item = getattr(module, name) if isinstance(value, pyclbr.Function): self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType))) + if py_item.__module__ != moduleName: + continue # skip functions that came from somewhere else + self.assertEquals(py_item.__module__, value.module) else: self.failUnless(isinstance(py_item, (ClassType, type))) real_bases = [base.__name__ for base in py_item.__bases__] Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 13:06:51 2006 @@ -119,6 +119,9 @@ Library ------- +- Bug #1560617: in pyclbr, return full module name not only for classes, + but also for functions. + - Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. From python-checkins at python.org Sat Sep 30 13:06:56 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:06:56 +0200 (CEST) Subject: [Python-checkins] r52071 - in python/branches/release25-maint: Lib/pyclbr.py Lib/test/test_pyclbr.py Misc/NEWS Message-ID: <20060930110656.736381E4011@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:06:55 2006 New Revision: 52071 Modified: python/branches/release25-maint/Lib/pyclbr.py python/branches/release25-maint/Lib/test/test_pyclbr.py python/branches/release25-maint/Misc/NEWS Log: Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. (backport from rev. 52069) Modified: python/branches/release25-maint/Lib/pyclbr.py ============================================================================== --- python/branches/release25-maint/Lib/pyclbr.py (original) +++ python/branches/release25-maint/Lib/pyclbr.py Sat Sep 30 13:06:55 2006 @@ -172,7 +172,7 @@ # else it's a nested def else: # it's a function - dict[meth_name] = Function(module, meth_name, file, lineno) + dict[meth_name] = Function(fullmodule, meth_name, file, lineno) stack.append((None, thisindent)) # Marker for nested fns elif token == 'class': lineno, thisindent = start Modified: python/branches/release25-maint/Lib/test/test_pyclbr.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_pyclbr.py (original) +++ python/branches/release25-maint/Lib/test/test_pyclbr.py Sat Sep 30 13:06:55 2006 @@ -93,6 +93,9 @@ py_item = getattr(module, name) if isinstance(value, pyclbr.Function): self.assert_(isinstance(py_item, (FunctionType, BuiltinFunctionType))) + if py_item.__module__ != moduleName: + continue # skip functions that came from somewhere else + self.assertEquals(py_item.__module__, value.module) else: self.failUnless(isinstance(py_item, (ClassType, type))) if py_item.__module__ != moduleName: Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 13:06:55 2006 @@ -41,6 +41,9 @@ Library ------- +- Bug #1560617: in pyclbr, return full module name not only for classes, + but also for functions. + - Bug #1566602: correct failure of posixpath unittest when $HOME ends with a slash. From buildbot at python.org Sat Sep 30 13:08:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 11:08:35 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060930110835.7FB251E4009@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/1185 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 python-checkins at python.org Sat Sep 30 13:17:35 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:17:35 +0200 (CEST) Subject: [Python-checkins] r52072 - in python/trunk: Lib/test/test_datetime.py Misc/NEWS Modules/datetimemodule.c Message-ID: <20060930111735.A17901E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:17:34 2006 New Revision: 52072 Modified: python/trunk/Lib/test/test_datetime.py python/trunk/Misc/NEWS python/trunk/Modules/datetimemodule.c Log: Bug #1556784: allow format strings longer than 127 characters in datetime's strftime function. Modified: python/trunk/Lib/test/test_datetime.py ============================================================================== --- python/trunk/Lib/test/test_datetime.py (original) +++ python/trunk/Lib/test/test_datetime.py Sat Sep 30 13:17:34 2006 @@ -844,6 +844,7 @@ t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") self.assertEqual(t.strftime(""), "") # SF bug #761337 + self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 13:17:34 2006 @@ -106,6 +106,9 @@ Extension Modules ----------------- +- Bug #1556784: allow format strings longer than 127 characters in + datetime's strftime function. + - Fix itertools.count(n) to work with negative numbers again. - RLIMIT_SBSIZE was added to the resource module where available. Modified: python/trunk/Modules/datetimemodule.c ============================================================================== --- python/trunk/Modules/datetimemodule.c (original) +++ python/trunk/Modules/datetimemodule.c Sat Sep 30 13:17:34 2006 @@ -1149,9 +1149,9 @@ PyObject *newfmt = NULL; /* py string, the output format */ char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, + int totalnew; /* number bytes total in output format buffer, exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ + int usednew; /* number bytes used so far in output format buffer */ char *ptoappend; /* pointer to string to append to output buffer */ int ntoappend; /* # of bytes to append to output buffer */ From python-checkins at python.org Sat Sep 30 13:17:40 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:17:40 +0200 (CEST) Subject: [Python-checkins] r52073 - in python/branches/release24-maint: Lib/test/test_datetime.py Misc/NEWS Modules/datetimemodule.c Message-ID: <20060930111740.BD2F31E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:17:39 2006 New Revision: 52073 Modified: python/branches/release24-maint/Lib/test/test_datetime.py python/branches/release24-maint/Misc/NEWS python/branches/release24-maint/Modules/datetimemodule.c Log: Bug #1556784: allow format strings longer than 127 characters in datetime's strftime function. (backport from rev. 52072) Modified: python/branches/release24-maint/Lib/test/test_datetime.py ============================================================================== --- python/branches/release24-maint/Lib/test/test_datetime.py (original) +++ python/branches/release24-maint/Lib/test/test_datetime.py Sat Sep 30 13:17:39 2006 @@ -844,6 +844,7 @@ t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") self.assertEqual(t.strftime(""), "") # SF bug #761337 + self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 13:17:39 2006 @@ -67,6 +67,9 @@ Extension Modules ----------------- +- Bug #1556784: allow format strings longer than 127 characters in + datetime's strftime function. + - gcmodule: add a missing incref. - threadmodule: add a missing incref. Modified: python/branches/release24-maint/Modules/datetimemodule.c ============================================================================== --- python/branches/release24-maint/Modules/datetimemodule.c (original) +++ python/branches/release24-maint/Modules/datetimemodule.c Sat Sep 30 13:17:39 2006 @@ -1149,9 +1149,9 @@ PyObject *newfmt = NULL; /* py string, the output format */ char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, + int totalnew; /* number bytes total in output format buffer, exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ + int usednew; /* number bytes used so far in output format buffer */ char *ptoappend; /* pointer to string to append to output buffer */ int ntoappend; /* # of bytes to append to output buffer */ From python-checkins at python.org Sat Sep 30 13:17:44 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:17:44 +0200 (CEST) Subject: [Python-checkins] r52074 - in python/branches/release25-maint: Lib/test/test_datetime.py Misc/NEWS Modules/datetimemodule.c Message-ID: <20060930111744.D93B11E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:17:43 2006 New Revision: 52074 Modified: python/branches/release25-maint/Lib/test/test_datetime.py python/branches/release25-maint/Misc/NEWS python/branches/release25-maint/Modules/datetimemodule.c Log: Bug #1556784: allow format strings longer than 127 characters in datetime's strftime function. (backport from rev. 52072) Modified: python/branches/release25-maint/Lib/test/test_datetime.py ============================================================================== --- python/branches/release25-maint/Lib/test/test_datetime.py (original) +++ python/branches/release25-maint/Lib/test/test_datetime.py Sat Sep 30 13:17:43 2006 @@ -844,6 +844,7 @@ t = self.theclass(2005, 3, 2) self.assertEqual(t.strftime("m:%m d:%d y:%y"), "m:03 d:02 y:05") self.assertEqual(t.strftime(""), "") # SF bug #761337 + self.assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 self.assertRaises(TypeError, t.strftime) # needs an arg self.assertRaises(TypeError, t.strftime, "one", "two") # too many args Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 13:17:43 2006 @@ -35,6 +35,9 @@ Extension Modules ----------------- +- Bug #1556784: allow format strings longer than 127 characters in + datetime's strftime function. + - Fix itertools.count(n) to work with negative numbers again. Modified: python/branches/release25-maint/Modules/datetimemodule.c ============================================================================== --- python/branches/release25-maint/Modules/datetimemodule.c (original) +++ python/branches/release25-maint/Modules/datetimemodule.c Sat Sep 30 13:17:43 2006 @@ -1149,9 +1149,9 @@ PyObject *newfmt = NULL; /* py string, the output format */ char *pnew; /* pointer to available byte in output format */ - char totalnew; /* number bytes total in output format buffer, + int totalnew; /* number bytes total in output format buffer, exclusive of trailing \0 */ - char usednew; /* number bytes used so far in output format buffer */ + int usednew; /* number bytes used so far in output format buffer */ char *ptoappend; /* pointer to string to append to output buffer */ int ntoappend; /* # of bytes to append to output buffer */ From python-checkins at python.org Sat Sep 30 13:22:28 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:22:28 +0200 (CEST) Subject: [Python-checkins] r52075 - in python/trunk: Lib/encodings/__init__.py Misc/NEWS Message-ID: <20060930112228.985C41E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:22:28 2006 New Revision: 52075 Modified: python/trunk/Lib/encodings/__init__.py python/trunk/Misc/NEWS Log: Bug #1446043: correctly raise a LookupError if an encoding name given to encodings.search_function() contains a dot. Modified: python/trunk/Lib/encodings/__init__.py ============================================================================== --- python/trunk/Lib/encodings/__init__.py (original) +++ python/trunk/Lib/encodings/__init__.py Sat Sep 30 13:22:28 2006 @@ -90,7 +90,7 @@ else: modnames = [norm_encoding] for modname in modnames: - if not modname: + if not modname or '.' in modname: continue try: mod = __import__('encodings.' + modname, Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 13:22:28 2006 @@ -63,6 +63,9 @@ Library ------- +- Bug #1446043: correctly raise a LookupError if an encoding name given + to encodings.search_function() contains a dot. + - Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. From python-checkins at python.org Sat Sep 30 13:22:32 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:22:32 +0200 (CEST) Subject: [Python-checkins] r52076 - in python/branches/release24-maint: Lib/encodings/__init__.py Misc/NEWS Message-ID: <20060930112232.0B1241E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:22:31 2006 New Revision: 52076 Modified: python/branches/release24-maint/Lib/encodings/__init__.py python/branches/release24-maint/Misc/NEWS Log: Bug #1446043: correctly raise a LookupError if an encoding name given to encodings.search_function() contains a dot. (backport from rev. 52075) Modified: python/branches/release24-maint/Lib/encodings/__init__.py ============================================================================== --- python/branches/release24-maint/Lib/encodings/__init__.py (original) +++ python/branches/release24-maint/Lib/encodings/__init__.py Sat Sep 30 13:22:31 2006 @@ -89,7 +89,7 @@ else: modnames = [norm_encoding] for modname in modnames: - if not modname: + if not modname or '.' in modname: continue try: mod = __import__(modname, Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 13:22:31 2006 @@ -122,6 +122,9 @@ Library ------- +- Bug #1446043: correctly raise a LookupError if an encoding name given + to encodings.search_function() contains a dot. + - Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. From python-checkins at python.org Sat Sep 30 13:22:35 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 13:22:35 +0200 (CEST) Subject: [Python-checkins] r52077 - in python/branches/release25-maint: Lib/encodings/__init__.py Misc/NEWS Message-ID: <20060930112235.D11971E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 13:22:35 2006 New Revision: 52077 Modified: python/branches/release25-maint/Lib/encodings/__init__.py python/branches/release25-maint/Misc/NEWS Log: Bug #1446043: correctly raise a LookupError if an encoding name given to encodings.search_function() contains a dot. (backport from rev. 52075) Modified: python/branches/release25-maint/Lib/encodings/__init__.py ============================================================================== --- python/branches/release25-maint/Lib/encodings/__init__.py (original) +++ python/branches/release25-maint/Lib/encodings/__init__.py Sat Sep 30 13:22:35 2006 @@ -90,7 +90,7 @@ else: modnames = [norm_encoding] for modname in modnames: - if not modname: + if not modname or '.' in modname: continue try: mod = __import__('encodings.' + modname, Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 13:22:35 2006 @@ -44,6 +44,9 @@ Library ------- +- Bug #1446043: correctly raise a LookupError if an encoding name given + to encodings.search_function() contains a dot. + - Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. From buildbot at python.org Sat Sep 30 13:28:35 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 11:28:35 +0000 Subject: [Python-checkins] buildbot warnings in x86 OpenBSD 2.4 Message-ID: <20060930112835.8C5B91E4009@bag.python.org> The Buildbot has detected a new failure of x86 OpenBSD 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520OpenBSD%25202.4/builds/173 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 Sat Sep 30 14:02:58 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 14:02:58 +0200 (CEST) Subject: [Python-checkins] r52078 - in python/trunk: Doc/api/concrete.tex Misc/NEWS Message-ID: <20060930120258.E32911E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 14:02:57 2006 New Revision: 52078 Modified: python/trunk/Doc/api/concrete.tex python/trunk/Misc/NEWS Log: Bug #1546052: clarify that PyString_FromString(AndSize) copies the string pointed to by its parameter. Modified: python/trunk/Doc/api/concrete.tex ============================================================================== --- python/trunk/Doc/api/concrete.tex (original) +++ python/trunk/Doc/api/concrete.tex Sat Sep 30 14:02:57 2006 @@ -602,15 +602,15 @@ \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromString}{const char *v} - Return a new string object with the value \var{v} on success, and - \NULL{} on failure. The parameter \var{v} must not be \NULL{}; it - will not be checked. + Return a new string object with a copy of the string \var{v} as value + on success, and \NULL{} on failure. The parameter \var{v} must not be + \NULL{}; it will not be checked. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromStringAndSize}{const char *v, Py_ssize_t len} - Return a new string object with the value \var{v} and length - \var{len} on success, and \NULL{} on failure. If \var{v} is + Return a new string object with a copy of the string \var{v} as value + and length \var{len} on success, and \NULL{} on failure. If \var{v} is \NULL{}, the contents of the string are uninitialized. \end{cfuncdesc} Modified: python/trunk/Misc/NEWS ============================================================================== --- python/trunk/Misc/NEWS (original) +++ python/trunk/Misc/NEWS Sat Sep 30 14:02:57 2006 @@ -146,6 +146,9 @@ Documentation ------------- +- Bug #1546052: clarify that PyString_FromString(AndSize) copies the + string pointed to by its parameter. + - Bug #1566663: remove obsolete example from datetime docs. - Bug #1541682: Fix example in the "Refcount details" API docs. From python-checkins at python.org Sat Sep 30 14:03:03 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 14:03:03 +0200 (CEST) Subject: [Python-checkins] r52079 - in python/branches/release25-maint: Doc/api/concrete.tex Misc/NEWS Message-ID: <20060930120303.09CE41E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 14:03:02 2006 New Revision: 52079 Modified: python/branches/release25-maint/Doc/api/concrete.tex python/branches/release25-maint/Misc/NEWS Log: Bug #1546052: clarify that PyString_FromString(AndSize) copies the string pointed to by its parameter. (backport from rev. 52078) Modified: python/branches/release25-maint/Doc/api/concrete.tex ============================================================================== --- python/branches/release25-maint/Doc/api/concrete.tex (original) +++ python/branches/release25-maint/Doc/api/concrete.tex Sat Sep 30 14:03:02 2006 @@ -602,15 +602,15 @@ \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromString}{const char *v} - Return a new string object with the value \var{v} on success, and - \NULL{} on failure. The parameter \var{v} must not be \NULL{}; it - will not be checked. + Return a new string object with a copy of the string \var{v} as value + on success, and \NULL{} on failure. The parameter \var{v} must not be + \NULL{}; it will not be checked. \end{cfuncdesc} \begin{cfuncdesc}{PyObject*}{PyString_FromStringAndSize}{const char *v, Py_ssize_t len} - Return a new string object with the value \var{v} and length - \var{len} on success, and \NULL{} on failure. If \var{v} is + Return a new string object with a copy of the string \var{v} as value + and length \var{len} on success, and \NULL{} on failure. If \var{v} is \NULL{}, the contents of the string are uninitialized. \end{cfuncdesc} Modified: python/branches/release25-maint/Misc/NEWS ============================================================================== --- python/branches/release25-maint/Misc/NEWS (original) +++ python/branches/release25-maint/Misc/NEWS Sat Sep 30 14:03:02 2006 @@ -163,6 +163,9 @@ Documentation ------------- +- Bug #1546052: clarify that PyString_FromString(AndSize) copies the + string pointed to by its parameter. + - Bug #1566663: remove obsolete example from datetime docs. - Bug #1541682: Fix example in the "Refcount details" API docs. From python-checkins at python.org Sat Sep 30 14:16:04 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 14:16:04 +0200 (CEST) Subject: [Python-checkins] r52080 - python/trunk/Lib/test/test_import.py Message-ID: <20060930121604.3B0851E4009@bag.python.org> Author: georg.brandl Date: Sat Sep 30 14:16:03 2006 New Revision: 52080 Modified: python/trunk/Lib/test/test_import.py Log: Convert test_import to unittest. Modified: python/trunk/Lib/test/test_import.py ============================================================================== --- python/trunk/Lib/test/test_import.py (original) +++ python/trunk/Lib/test/test_import.py Sat Sep 30 14:16:03 2006 @@ -1,21 +1,11 @@ -from test.test_support import TESTFN, TestFailed +from test.test_support import TESTFN, run_unittest +import unittest import os import random import sys import py_compile -# Brief digression to test that import is case-sensitive: if we got this -# far, we know for sure that "random" exists. -try: - import RAnDoM -except ImportError: - pass -else: - raise TestFailed("import of RAnDoM should have failed (case mismatch)") - -# Another brief digression to test the accuracy of manifest float constants. -from test import double_const # don't blink -- that *was* the test def remove_files(name): for f in (name + os.extsep + "py", @@ -26,199 +16,206 @@ if os.path.exists(f): os.remove(f) -def test_with_extension(ext): # ext normally ".py"; perhaps ".pyw" - source = TESTFN + ext - pyo = TESTFN + os.extsep + "pyo" - if sys.platform.startswith('java'): - pyc = TESTFN + "$py.class" - else: - pyc = TESTFN + os.extsep + "pyc" - - f = open(source, "w") - print >> f, "# This tests Python's ability to import a", ext, "file." - a = random.randrange(1000) - b = random.randrange(1000) - print >> f, "a =", a - print >> f, "b =", b - f.close() - try: +class ImportTest(unittest.TestCase): + + def testCaseSensitivity(self): + # Brief digression to test that import is case-sensitive: if we got this + # far, we know for sure that "random" exists. try: - mod = __import__(TESTFN) - except ImportError, err: - raise ValueError("import from %s failed: %s" % (ext, err)) + import RAnDoM + except ImportError: + pass + else: + self.fail("import of RAnDoM should have failed (case mismatch)") - if mod.a != a or mod.b != b: - print a, "!=", mod.a - print b, "!=", mod.b - raise ValueError("module loaded (%s) but contents invalid" % mod) - finally: - os.unlink(source) + def testDoubleConst(self): + # Another brief digression to test the accuracy of manifest float constants. + from test import double_const # don't blink -- that *was* the test + + def testImport(self): + def test_with_extension(ext): + # ext normally ".py"; perhaps ".pyw" + source = TESTFN + ext + pyo = TESTFN + os.extsep + "pyo" + if sys.platform.startswith('java'): + pyc = TESTFN + "$py.class" + else: + pyc = TESTFN + os.extsep + "pyc" - try: - try: - reload(mod) - except ImportError, err: - raise ValueError("import from .pyc/.pyo failed: %s" % err) - finally: - try: - os.unlink(pyc) - except os.error: - pass - try: - os.unlink(pyo) - except os.error: - pass - del sys.modules[TESTFN] + f = open(source, "w") + print >> f, "# This tests Python's ability to import a", ext, "file." + a = random.randrange(1000) + b = random.randrange(1000) + print >> f, "a =", a + print >> f, "b =", b + f.close() -sys.path.insert(0, os.curdir) -try: - test_with_extension(os.extsep + "py") - if sys.platform.startswith("win"): - for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": - test_with_extension(ext) -finally: - del sys.path[0] - -# Verify that the imp module can correctly load and find .py files -import imp -x = imp.find_module("os") -os = imp.load_module("os", *x) - -def test_module_with_large_stack(module): - # create module w/list of 65000 elements to test bug #561858 - filename = module + os.extsep + 'py' - - # create a file with a list of 65000 elements - f = open(filename, 'w+') - f.write('d = [\n') - for i in range(65000): - f.write('"",\n') - f.write(']') - f.close() - - # compile & remove .py file, we only need .pyc (or .pyo) - f = open(filename, 'r') - py_compile.compile(filename) - f.close() - os.unlink(filename) - - # need to be able to load from current dir - sys.path.append('') - - # this used to crash - exec 'import ' + module - - # cleanup - del sys.path[-1] - for ext in 'pyc', 'pyo': - fname = module + os.extsep + ext - if os.path.exists(fname): - os.unlink(fname) - -test_module_with_large_stack('longlist') - -def test_failing_import_sticks(): - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print >> f, "a = 1/0" - f.close() - - # New in 2.4, we shouldn't be able to import that no matter how often - # we try. - sys.path.insert(0, os.curdir) - try: - for i in 1, 2, 3: try: - mod = __import__(TESTFN) - except ZeroDivisionError: - if TESTFN in sys.modules: - raise TestFailed("damaged module in sys.modules", i) - else: - raise TestFailed("was able to import a damaged module", i) - finally: - sys.path.pop(0) - remove_files(TESTFN) - -test_failing_import_sticks() - -def test_failing_reload(): - # A failing reload should leave the module object in sys.modules. - source = TESTFN + os.extsep + "py" - f = open(source, "w") - print >> f, "a = 1" - print >> f, "b = 2" - f.close() - - sys.path.insert(0, os.curdir) - try: - mod = __import__(TESTFN) - if TESTFN not in sys.modules: - raise TestFailed("expected module in sys.modules") - if mod.a != 1 or mod.b != 2: - raise TestFailed("module has wrong attribute values") - - # On WinXP, just replacing the .py file wasn't enough to - # convince reload() to reparse it. Maybe the timestamp didn't - # move enough. We force it to get reparsed by removing the - # compiled file too. - remove_files(TESTFN) + try: + mod = __import__(TESTFN) + except ImportError, err: + self.fail("import from %s failed: %s" % (ext, err)) + + self.assertEquals(mod.a, a, + "module loaded (%s) but contents invalid" % mod) + self.assertEquals(mod.b, b, + "module loaded (%s) but contents invalid" % mod) + finally: + os.unlink(source) + + try: + try: + reload(mod) + except ImportError, err: + self.fail("import from .pyc/.pyo failed: %s" % err) + finally: + try: + os.unlink(pyc) + except OSError: + pass + try: + os.unlink(pyo) + except OSError: + pass + del sys.modules[TESTFN] + + sys.path.insert(0, os.curdir) + try: + test_with_extension(os.extsep + "py") + if sys.platform.startswith("win"): + for ext in ".PY", ".Py", ".pY", ".pyw", ".PYW", ".pYw": + test_with_extension(ext) + finally: + del sys.path[0] + + def testImpModule(self): + # Verify that the imp module can correctly load and find .py files + import imp + x = imp.find_module("os") + os = imp.load_module("os", *x) + + def test_module_with_large_stack(self, module='longlist'): + # create module w/list of 65000 elements to test bug #561858 + filename = module + os.extsep + 'py' + + # create a file with a list of 65000 elements + f = open(filename, 'w+') + f.write('d = [\n') + for i in range(65000): + f.write('"",\n') + f.write(']') + f.close() + + # compile & remove .py file, we only need .pyc (or .pyo) + f = open(filename, 'r') + py_compile.compile(filename) + f.close() + os.unlink(filename) + + # need to be able to load from current dir + sys.path.append('') - # Now damage the module. + # this used to crash + exec 'import ' + module + + # cleanup + del sys.path[-1] + for ext in 'pyc', 'pyo': + fname = module + os.extsep + ext + if os.path.exists(fname): + os.unlink(fname) + + def test_failing_import_sticks(self): + source = TESTFN + os.extsep + "py" f = open(source, "w") - print >> f, "a = 10" - print >> f, "b = 20//0" + print >> f, "a = 1/0" f.close() + + # New in 2.4, we shouldn't be able to import that no matter how often + # we try. + sys.path.insert(0, os.curdir) try: - reload(mod) - except ZeroDivisionError: - pass - else: - raise TestFailed("was able to reload a damaged module") + for i in 1, 2, 3: + try: + mod = __import__(TESTFN) + except ZeroDivisionError: + if TESTFN in sys.modules: + self.fail("damaged module in sys.modules on %i. try" % i) + else: + self.fail("was able to import a damaged module on %i. try" % i) + finally: + sys.path.pop(0) + remove_files(TESTFN) + + def test_failing_reload(self): + # A failing reload should leave the module object in sys.modules. + source = TESTFN + os.extsep + "py" + f = open(source, "w") + print >> f, "a = 1" + print >> f, "b = 2" + f.close() + + sys.path.insert(0, os.curdir) + try: + mod = __import__(TESTFN) + self.assert_(TESTFN in sys.modules, "expected module in sys.modules") + self.assertEquals(mod.a, 1, "module has wrong attribute values") + self.assertEquals(mod.b, 2, "module has wrong attribute values") + + # On WinXP, just replacing the .py file wasn't enough to + # convince reload() to reparse it. Maybe the timestamp didn't + # move enough. We force it to get reparsed by removing the + # compiled file too. + remove_files(TESTFN) + + # Now damage the module. + f = open(source, "w") + print >> f, "a = 10" + print >> f, "b = 20//0" + f.close() + + self.assertRaises(ZeroDivisionError, reload, mod) + + # But we still expect the module to be in sys.modules. + mod = sys.modules.get(TESTFN) + self.failIf(mod is None, "expected module to still be in sys.modules") + + # We should have replaced a w/ 10, but the old b value should + # stick. + self.assertEquals(mod.a, 10, "module has wrong attribute values") + self.assertEquals(mod.b, 2, "module has wrong attribute values") + + finally: + sys.path.pop(0) + remove_files(TESTFN) + if TESTFN in sys.modules: + del sys.modules[TESTFN] + + def test_import_name_binding(self): + # import x.y.z binds x in the current namespace + import test as x + import test.test_support + self.assert_(x is test, x.__name__) + self.assert_(hasattr(test.test_support, "__file__")) + + # import x.y.z as w binds z as w + import test.test_support as y + self.assert_(y is test.test_support, y.__name__) + + def test_import_initless_directory_warning(self): + import warnings + oldfilters = warnings.filters[:] + warnings.simplefilter('error', ImportWarning); + try: + # Just a random non-package directory we always expect to be + # somewhere in sys.path... + self.assertRaises(ImportWarning, __import__, "site-packages") + finally: + warnings.filters = oldfilters - # But we still expect the module to be in sys.modules. - mod = sys.modules.get(TESTFN) - if mod is None: - raise TestFailed("expected module to still be in sys.modules") - # We should have replaced a w/ 10, but the old b value should - # stick. - if mod.a != 10 or mod.b != 2: - raise TestFailed("module has wrong attribute values") - - finally: - sys.path.pop(0) - remove_files(TESTFN) - if TESTFN in sys.modules: - del sys.modules[TESTFN] - -test_failing_reload() - -def test_import_name_binding(): - # import x.y.z binds x in the current namespace - import test as x - import test.test_support - assert x is test, x.__name__ - assert hasattr(test.test_support, "__file__") - - # import x.y.z as w binds z as w - import test.test_support as y - assert y is test.test_support, y.__name__ - -test_import_name_binding() - -def test_import_initless_directory_warning(): - import warnings - oldfilters = warnings.filters[:] - warnings.simplefilter('error', ImportWarning); - try: - # Just a random non-package directory we always expect to be - # somewhere in sys.path... - __import__("site-packages") - except ImportWarning: - pass - else: - raise AssertionError - finally: - warnings.filters = oldfilters +def test_main(verbose=None): + run_unittest(ImportTest) -test_import_initless_directory_warning() +if __name__ == '__main__': + test_main() From buildbot at python.org Sat Sep 30 14:23:19 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 12:23:19 +0000 Subject: [Python-checkins] buildbot warnings in x86 gentoo 2.4 Message-ID: <20060930122319.3D3B71E4009@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/233 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 Sat Sep 30 14:25:00 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 12:25:00 +0000 Subject: [Python-checkins] buildbot warnings in amd64 gentoo 2.4 Message-ID: <20060930122500.58FE11E4009@bag.python.org> The Buildbot has detected a new failure of amd64 gentoo 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/amd64%2520gentoo%25202.4/builds/234 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 Sat Sep 30 15:04:41 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 13:04:41 +0000 Subject: [Python-checkins] buildbot warnings in PPC64 Debian 2.4 Message-ID: <20060930130441.6A83B1E4009@bag.python.org> The Buildbot has detected a new failure of PPC64 Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/PPC64%2520Debian%25202.4/builds/77 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 Sat Sep 30 15:34:34 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 13:34:34 +0000 Subject: [Python-checkins] buildbot warnings in g4 osx.4 2.4 Message-ID: <20060930133434.651181E400A@bag.python.org> The Buildbot has detected a new failure of g4 osx.4 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/g4%2520osx.4%25202.4/builds/222 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 Sat Sep 30 15:56:56 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 13:56:56 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable trunk Message-ID: <20060930135656.D49D51E400A@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/1205 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 Sat Sep 30 16:19:04 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 14:19:04 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060930141905.386551E400A@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/150 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 Sat Sep 30 16:21:15 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 14:21:15 +0000 Subject: [Python-checkins] buildbot warnings in ppc Debian unstable 2.4 Message-ID: <20060930142115.267551E400A@bag.python.org> The Buildbot has detected a new failure of ppc Debian unstable 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/ppc%2520Debian%2520unstable%25202.4/builds/158 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 Sat Sep 30 16:44:25 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 14:44:25 +0000 Subject: [Python-checkins] buildbot warnings in ia64 Ubuntu trunk 2.4 Message-ID: <20060930144425.884451E400A@bag.python.org> The Buildbot has detected a new failure of ia64 Ubuntu trunk 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/ia64%2520Ubuntu%2520trunk%25202.4/builds/22 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 Sat Sep 30 16:48:04 2006 From: python-checkins at python.org (georg.brandl) Date: Sat, 30 Sep 2006 16:48:04 +0200 (CEST) Subject: [Python-checkins] r52081 - in python/branches/release24-maint: Lib/encodings/__init__.py Misc/NEWS Message-ID: <20060930144804.538F51E400A@bag.python.org> Author: georg.brandl Date: Sat Sep 30 16:48:03 2006 New Revision: 52081 Modified: python/branches/release24-maint/Lib/encodings/__init__.py python/branches/release24-maint/Misc/NEWS Log: Back out r52076, it's causing the buildbots to fail because of test_charmapcodec. Modified: python/branches/release24-maint/Lib/encodings/__init__.py ============================================================================== --- python/branches/release24-maint/Lib/encodings/__init__.py (original) +++ python/branches/release24-maint/Lib/encodings/__init__.py Sat Sep 30 16:48:03 2006 @@ -89,7 +89,7 @@ else: modnames = [norm_encoding] for modname in modnames: - if not modname or '.' in modname: + if not modname: continue try: mod = __import__(modname, Modified: python/branches/release24-maint/Misc/NEWS ============================================================================== --- python/branches/release24-maint/Misc/NEWS (original) +++ python/branches/release24-maint/Misc/NEWS Sat Sep 30 16:48:03 2006 @@ -122,9 +122,6 @@ Library ------- -- Bug #1446043: correctly raise a LookupError if an encoding name given - to encodings.search_function() contains a dot. - - Bug #1560617: in pyclbr, return full module name not only for classes, but also for functions. From buildbot at python.org Sat Sep 30 17:30:45 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 15:30:45 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.5 Message-ID: <20060930153045.427731E400A@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/44 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 Sat Sep 30 17:57:14 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 15:57:14 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 2.4 Message-ID: <20060930155714.4C4FA1E4025@bag.python.org> The Buildbot has detected a new failure of alpha Tru64 5.1 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Tru64%25205.1%25202.4/builds/178 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 Sat Sep 30 19:01:55 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 17:01:55 +0000 Subject: [Python-checkins] buildbot warnings in alpha Tru64 5.1 trunk Message-ID: <20060930170156.099F71E400A@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/1187 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 Sat Sep 30 19:30:59 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 17:30:59 +0000 Subject: [Python-checkins] buildbot warnings in hppa Ubuntu dapper 2.4 Message-ID: <20060930173059.3F05A1E401A@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/21 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 Sat Sep 30 19:50:10 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 17:50:10 +0000 Subject: [Python-checkins] buildbot warnings in x86 Ubuntu dapper (icc) trunk Message-ID: <20060930175010.E71CB1E4011@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/974 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 Sat Sep 30 19:51:25 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 17:51:25 +0000 Subject: [Python-checkins] buildbot failure in x86 Ubuntu dapper (icc) 2.4 Message-ID: <20060930175125.454631E400B@bag.python.org> The Buildbot has detected a new failure of x86 Ubuntu dapper (icc) 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/x86%2520Ubuntu%2520dapper%2520%2528icc%2529%25202.4/builds/151 Buildbot URL: http://www.python.org/dev/buildbot/all/ Build Reason: Build Source Stamp: [branch branches/release24-maint] HEAD Blamelist: georg.brandl BUILD FAILED: failed configure sincerely, -The Buildbot From buildbot at python.org Sat Sep 30 21:50:01 2006 From: buildbot at python.org (buildbot at python.org) Date: Sat, 30 Sep 2006 19:50:01 +0000 Subject: [Python-checkins] buildbot warnings in alpha Debian 2.4 Message-ID: <20060930195001.BF5531E400C@bag.python.org> The Buildbot has detected a new failure of alpha Debian 2.4. Full details are available at: http://www.python.org/dev/buildbot/all/alpha%2520Debian%25202.4/builds/29 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 Sat Sep 30 22:33:34 2006 From: python-checkins at python.org (brett.cannon) Date: Sat, 30 Sep 2006 22:33:34 +0200 (CEST) Subject: [Python-checkins] r52082 - peps/trunk/pep-0352.txt Message-ID: <20060930203334.E2D9D1E400A@bag.python.org> Author: brett.cannon Date: Sat Sep 30 22:33:33 2006 New Revision: 52082 Modified: peps/trunk/pep-0352.txt Log: Reword a rather awkward sentence. Modified: peps/trunk/pep-0352.txt ============================================================================== --- peps/trunk/pep-0352.txt (original) +++ peps/trunk/pep-0352.txt Sat Sep 30 22:33:33 2006 @@ -172,9 +172,7 @@ is needed. The goal is to end up with the new semantics being used in Python 3.0 while providing a smooth transition for 2.x code. All deprecations mentioned in the plan will lead to the removal of the -semantics starting in the version following the introduction of the -deprecation and the raising of a DeprecationWarning for the version -specifically listed. +semantics starting in the version following the initial deprecation. Here is BaseException as implemented in the 2.x series::