[Python-checkins] r68252 - in python/branches/release30-maint: Doc/extending/embedding.rst Doc/extending/extending.rst Doc/howto/functional.rst Doc/includes/noddy.c Doc/includes/noddy2.c Doc/includes/noddy3.c Doc/includes/noddy4.c Doc/library/functions.rst Doc/library/stdtypes.rst Doc/reference/lexical_analysis.rst Doc/tutorial/datastructures.rst Doc/tutorial/modules.rst Doc/whatsnew/3.0.rst Lib/http/client.py Lib/test/test_array.py Lib/test/test_deque.py Lib/test/test_httplib.py Lib/test/test_set.py Lib/traceback.py Lib/webbrowser.py Mac/BuildScript/build-installer.py Modules/_fileio.c Objects/floatobject.c Parser/tokenizer.c Python/getargs.c

georg.brandl python-checkins at python.org
Sun Jan 4 00:25:34 CET 2009


Author: georg.brandl
Date: Sun Jan  4 00:25:33 2009
New Revision: 68252

Log:
Merged revisions 67653,67655,67682-67683,67724,67755,67780-67783,67786,67789,67841,67843,67865,67881,67884,67925,67929,67931 via svnmerge from 
svn+ssh://svn.python.org/python/branches/py3k

........
  r67653 | neal.norwitz | 2008-12-07 23:42:03 +0100 (Sun, 07 Dec 2008) | 1 line
  
  Remove unnecessary import
........
  r67655 | georg.brandl | 2008-12-07 23:45:56 +0100 (Sun, 07 Dec 2008) | 2 lines
  
  #4586: fix usage of Py_InitModule.
........
  r67682 | georg.brandl | 2008-12-10 00:48:44 +0100 (Wed, 10 Dec 2008) | 1 line
  
  #4592: fix embedding example with new C API changes.
........
  r67683 | fred.drake | 2008-12-10 07:02:39 +0100 (Wed, 10 Dec 2008) | 2 lines
  
  simplify imports
........
  r67724 | benjamin.peterson | 2008-12-13 04:03:41 +0100 (Sat, 13 Dec 2008) | 1 line
  
  string.maketrans -> str.maketrans
........
  r67755 | benjamin.peterson | 2008-12-14 16:09:34 +0100 (Sun, 14 Dec 2008) | 1 line
  
  tip-toe around dictionary keys view in the tutorial
........
  r67780 | jeremy.hylton | 2008-12-15 04:00:50 +0100 (Mon, 15 Dec 2008) | 2 lines
  
  Use True/False for ints instead of 1/0.  That's so Python 2.0.
........
  r67781 | jeremy.hylton | 2008-12-15 04:08:30 +0100 (Mon, 15 Dec 2008) | 2 lines
  
  Reflow long line.
........
  r67782 | georg.brandl | 2008-12-15 09:28:37 +0100 (Mon, 15 Dec 2008) | 2 lines
  
  #4667: fix some 2.x leftovers in the tutorial.
........
  r67783 | georg.brandl | 2008-12-15 09:29:32 +0100 (Mon, 15 Dec 2008) | 2 lines
  
  #4668: wrap iterator returns in list() in functional howto.
........
  r67786 | georg.brandl | 2008-12-15 09:43:10 +0100 (Mon, 15 Dec 2008) | 2 lines
  
  #4603: Note that inconsistent tab/space use is now illegal.
........
  r67789 | georg.brandl | 2008-12-15 10:16:15 +0100 (Mon, 15 Dec 2008) | 2 lines
  
  Use :samp: role.
........
  r67841 | kristjan.jonsson | 2008-12-18 18:08:57 +0100 (Thu, 18 Dec 2008) | 2 lines
  
  Add missing Py_CHARMASK when calling isspace().
  Found by enabling runtime tests on windows, by disabling the _set_invalid_parameter_handler() fiddling.
........
  r67843 | kristjan.jonsson | 2008-12-18 18:15:54 +0100 (Thu, 18 Dec 2008) | 5 lines
  
  Fix an issue in the tokenizer, where a file is opened by fd, but the underlying PyFileIO object wasn created with the closefd attribute true.
  Also fix error handling for close() int _fileio.c .  It was incorrect, looking for a negative refcount, and so errors weren't raised.  This is why this issue wasn't caught.
  There is a second reason why it isn't seen:  Class IOBase in io.py has a try:/except: around the close() funtion in the __del__() method.  This also masks these error conditions.
  
  This issue was discovered by removing the _set_invalid_parameter_handler() fiddling, thus enabling the C runtime checks on windows.
........
  r67865 | benjamin.peterson | 2008-12-20 04:20:23 +0100 (Sat, 20 Dec 2008) | 1 line
  
  fix syntax
........
  r67881 | benjamin.peterson | 2008-12-20 23:50:25 +0100 (Sat, 20 Dec 2008) | 1 line
  
  unpy3kize this; it require 2.x only Mac modules
........
  r67884 | benjamin.peterson | 2008-12-21 00:06:29 +0100 (Sun, 21 Dec 2008) | 1 line
  
  don't build bsddb anymore
........
  r67925 | benjamin.peterson | 2008-12-24 17:27:25 +0100 (Wed, 24 Dec 2008) | 1 line
  
  return the module object from PyMODINIT_FUNC
........
  r67929 | benjamin.peterson | 2008-12-27 03:58:34 +0100 (Sat, 27 Dec 2008) | 1 line
  
  string -> bytes in error message #4745
........
  r67931 | hirokazu.yamamoto | 2008-12-27 05:21:44 +0100 (Sat, 27 Dec 2008) | 2 lines
  
  Issue #4740: Use HIGHEST_PROTOCOL in pickle test. This enables test for protocol 3
  (== HIGHEST_PROTOCOL in 3.x)
........


Modified:
   python/branches/release30-maint/   (props changed)
   python/branches/release30-maint/Doc/extending/embedding.rst
   python/branches/release30-maint/Doc/extending/extending.rst
   python/branches/release30-maint/Doc/howto/functional.rst
   python/branches/release30-maint/Doc/includes/noddy.c
   python/branches/release30-maint/Doc/includes/noddy2.c
   python/branches/release30-maint/Doc/includes/noddy3.c
   python/branches/release30-maint/Doc/includes/noddy4.c
   python/branches/release30-maint/Doc/library/functions.rst
   python/branches/release30-maint/Doc/library/stdtypes.rst
   python/branches/release30-maint/Doc/reference/lexical_analysis.rst
   python/branches/release30-maint/Doc/tutorial/datastructures.rst
   python/branches/release30-maint/Doc/tutorial/modules.rst
   python/branches/release30-maint/Doc/whatsnew/3.0.rst
   python/branches/release30-maint/Lib/http/client.py
   python/branches/release30-maint/Lib/test/test_array.py
   python/branches/release30-maint/Lib/test/test_deque.py
   python/branches/release30-maint/Lib/test/test_httplib.py
   python/branches/release30-maint/Lib/test/test_set.py
   python/branches/release30-maint/Lib/traceback.py
   python/branches/release30-maint/Lib/webbrowser.py
   python/branches/release30-maint/Mac/BuildScript/build-installer.py
   python/branches/release30-maint/Modules/_fileio.c
   python/branches/release30-maint/Objects/floatobject.c
   python/branches/release30-maint/Parser/tokenizer.c
   python/branches/release30-maint/Python/getargs.c

Modified: python/branches/release30-maint/Doc/extending/embedding.rst
==============================================================================
--- python/branches/release30-maint/Doc/extending/embedding.rst	(original)
+++ python/branches/release30-maint/Doc/extending/embedding.rst	Sun Jan  4 00:25:33 2009
@@ -218,11 +218,22 @@
        {NULL, NULL, 0, NULL}
    };
 
+   static PyModuleDef EmbModule = {
+       PyModuleDef_HEAD_INIT, "emb", NULL, -1, EmbMethods,
+       NULL, NULL, NULL, NULL
+   };
+
+   static PyObject*
+   PyInit_emb(void)
+   {
+       return PyModule_Create(&EmbModule);
+   }
+
 Insert the above code just above the :cfunc:`main` function. Also, insert the
-following two statements directly after :cfunc:`Py_Initialize`::
+following two statements before the call to :cfunc:`Py_Initialize`::
 
    numargs = argc;
-   Py_InitModule("emb", EmbMethods);
+   PyImport_AppendInittab("emb", &PyInit_emb);
 
 These two lines initialize the ``numargs`` variable, and make the
 :func:`emb.numargs` function accessible to the embedded Python interpreter.

Modified: python/branches/release30-maint/Doc/extending/extending.rst
==============================================================================
--- python/branches/release30-maint/Doc/extending/extending.rst	(original)
+++ python/branches/release30-maint/Doc/extending/extending.rst	Sun Jan  4 00:25:33 2009
@@ -326,8 +326,8 @@
        return PyModule_Create(&spammodule);
    }
 
-Note that PyMODINIT_FUNC declares the function as ``void`` return type,
-declares any special linkage declarations required by the platform, and for  C++
+Note that PyMODINIT_FUNC declares the function as ``PyObject *`` return type,
+declares any special linkage declarations required by the platform, and for C++
 declares the function as ``extern "C"``.
 
 When the Python program imports module :mod:`spam` for the first time,
@@ -342,7 +342,7 @@
 so that it then gets inserted into ``sys.modules``.
 
 When embedding Python, the :cfunc:`PyInit_spam` function is not called
-automatically unless there's an entry in the :cdata:`_PyImport_Inittab` table.
+automatically unless there's an entry in the :cdata:`PyImport_Inittab` table.
 To add the module to the initialization table, use :cfunc:`PyImport_AppendInittab`,
 optionally followed by an import of the module::
 

Modified: python/branches/release30-maint/Doc/howto/functional.rst
==============================================================================
--- python/branches/release30-maint/Doc/howto/functional.rst	(original)
+++ python/branches/release30-maint/Doc/howto/functional.rst	Sun Jan  4 00:25:33 2009
@@ -634,7 +634,7 @@
     ...     return s.upper()
 
 
-    >>> map(upper, ['sentence', 'fragment'])
+    >>> list(map(upper, ['sentence', 'fragment']))
     ['SENTENCE', 'FRAGMENT']
     >>> [upper(s) for s in ['sentence', 'fragment']]
     ['SENTENCE', 'FRAGMENT']
@@ -650,7 +650,7 @@
     >>> def is_even(x):
     ...     return (x % 2) == 0
 
-    >>> filter(is_even, range(10))
+    >>> list(filter(is_even, range(10)))
     [0, 2, 4, 6, 8]
 
 

Modified: python/branches/release30-maint/Doc/includes/noddy.c
==============================================================================
--- python/branches/release30-maint/Doc/includes/noddy.c	(original)
+++ python/branches/release30-maint/Doc/includes/noddy.c	Sun Jan  4 00:25:33 2009
@@ -52,4 +52,5 @@
 
     Py_INCREF(&noddy_NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
+    return m;
 }

Modified: python/branches/release30-maint/Doc/includes/noddy2.c
==============================================================================
--- python/branches/release30-maint/Doc/includes/noddy2.c	(original)
+++ python/branches/release30-maint/Doc/includes/noddy2.c	Sun Jan  4 00:25:33 2009
@@ -186,4 +186,5 @@
 
     Py_INCREF(&NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+    return m;
 }

Modified: python/branches/release30-maint/Doc/includes/noddy3.c
==============================================================================
--- python/branches/release30-maint/Doc/includes/noddy3.c	(original)
+++ python/branches/release30-maint/Doc/includes/noddy3.c	Sun Jan  4 00:25:33 2009
@@ -239,4 +239,5 @@
 
     Py_INCREF(&NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+    return m;
 }

Modified: python/branches/release30-maint/Doc/includes/noddy4.c
==============================================================================
--- python/branches/release30-maint/Doc/includes/noddy4.c	(original)
+++ python/branches/release30-maint/Doc/includes/noddy4.c	Sun Jan  4 00:25:33 2009
@@ -221,4 +221,5 @@
 
     Py_INCREF(&NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+    return m;
 }

Modified: python/branches/release30-maint/Doc/library/functions.rst
==============================================================================
--- python/branches/release30-maint/Doc/library/functions.rst	(original)
+++ python/branches/release30-maint/Doc/library/functions.rst	Sun Jan  4 00:25:33 2009
@@ -289,7 +289,7 @@
    :func:`enumerate` is useful for obtaining an indexed series: ``(0, seq[0])``,
    ``(1, seq[1])``, ``(2, seq[2])``, .... For example:
 
-      >>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter')]:
+      >>> for i, season in enumerate(['Spring', 'Summer', 'Fall', 'Winter']):
       ...     print(i, season)
       0 Spring
       1 Summer

Modified: python/branches/release30-maint/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/release30-maint/Doc/library/stdtypes.rst	(original)
+++ python/branches/release30-maint/Doc/library/stdtypes.rst	Sun Jan  4 00:25:33 2009
@@ -1090,12 +1090,9 @@
    ordinals, strings or ``None``.  Unmapped characters are left untouched.
    Characters mapped to ``None`` are deleted.
 
-   A *map* for :meth:`translate` is usually best created by
-   :meth:`str.maketrans`.
-
-   You can use the :func:`maketrans` helper function in the :mod:`string` module to
-   create a translation table. For string objects, set the *table* argument to
-   ``None`` for translations that only delete characters:
+   You can use :meth:`str.maketrans` to create a translation table.  For string
+   objects, set the *table* argument to ``None`` for translations that only
+   delete characters:
 
    .. note::
 

Modified: python/branches/release30-maint/Doc/reference/lexical_analysis.rst
==============================================================================
--- python/branches/release30-maint/Doc/reference/lexical_analysis.rst	(original)
+++ python/branches/release30-maint/Doc/reference/lexical_analysis.rst	Sun Jan  4 00:25:33 2009
@@ -174,14 +174,18 @@
 to compute the indentation level of the line, which in turn is used to determine
 the grouping of statements.
 
-First, tabs are replaced (from left to right) by one to eight spaces such that
-the total number of characters up to and including the replacement is a multiple
-of eight (this is intended to be the same rule as used by Unix).  The total
-number of spaces preceding the first non-blank character then determines the
-line's indentation.  Indentation cannot be split over multiple physical lines
-using backslashes; the whitespace up to the first backslash determines the
+Tabs are replaced (from left to right) by one to eight spaces such that the
+total number of characters up to and including the replacement is a multiple of
+eight (this is intended to be the same rule as used by Unix).  The total number
+of spaces preceding the first non-blank character then determines the line's
+indentation.  Indentation cannot be split over multiple physical lines using
+backslashes; the whitespace up to the first backslash determines the
 indentation.
 
+Indentation is rejected as inconsistent if a source file mixes tabs and spaces
+in a way that makes the meaning dependent on the worth of a tab in spaces; a
+:exc:`TabError` is raised in that case.
+
 **Cross-platform compatibility note:** because of the nature of text editors on
 non-UNIX platforms, it is unwise to use a mixture of spaces and tabs for the
 indentation in a single source file.  It should also be noted that different

Modified: python/branches/release30-maint/Doc/tutorial/datastructures.rst
==============================================================================
--- python/branches/release30-maint/Doc/tutorial/datastructures.rst	(original)
+++ python/branches/release30-maint/Doc/tutorial/datastructures.rst	Sun Jan  4 00:25:33 2009
@@ -440,9 +440,9 @@
 value associated with that key is forgotten.  It is an error to extract a value
 using a non-existent key.
 
-The :meth:`keys` method of a dictionary object returns a list of all the keys
+Performing ``list(d.keys())`` on a dictionary returns a list of all the keys
 used in the dictionary, in arbitrary order (if you want it sorted, just apply
-the :meth:`sort` method to the list of keys).  To check whether a single key is
+the :meth:`sorted` function instead).  To check whether a single key is
 in the dictionary, use the :keyword:`in` keyword.
 
 Here is a small example using a dictionary::
@@ -458,6 +458,8 @@
    >>> tel
    {'guido': 4127, 'irv': 4127, 'jack': 4098}
    >>> list(tel.keys())
+   ['irv', 'guido', 'jack']
+   >>> sorted(tel.keys())
    ['guido', 'irv', 'jack']
    >>> 'guido' in tel
    True

Modified: python/branches/release30-maint/Doc/tutorial/modules.rst
==============================================================================
--- python/branches/release30-maint/Doc/tutorial/modules.rst	(original)
+++ python/branches/release30-maint/Doc/tutorial/modules.rst	Sun Jan  4 00:25:33 2009
@@ -112,7 +112,7 @@
    For efficiency reasons, each module is only imported once per interpreter
    session.  Therefore, if you change your modules, you must restart the
    interpreter -- or, if it's just one module you want to test interactively,
-   use :func:`reload`, e.g. ``reload(modulename)``.
+   use :func:`imp.reload`, e.g. ``import imp; imp.reload(modulename)``.
 
 
 .. _tut-modulesasscripts:

Modified: python/branches/release30-maint/Doc/whatsnew/3.0.rst
==============================================================================
--- python/branches/release30-maint/Doc/whatsnew/3.0.rst	(original)
+++ python/branches/release30-maint/Doc/whatsnew/3.0.rst	Sun Jan  4 00:25:33 2009
@@ -696,15 +696,15 @@
 * Exceptions no longer behave as sequences.  Use the :attr:`args`
   attribute instead.
 
-* :pep:`3109`: Raising exceptions.  You must now use :keyword:`raise`
-  *Exception*(*args*) instead of :keyword:`raise` *Exception*, *args*.
+* :pep:`3109`: Raising exceptions.  You must now use :samp:`raise
+  {Exception}({args})` instead of :samp:`raise {Exception}, {args}`.
   Additionally, you can no longer explicitly specify a traceback;
   instead, if you *have* to do this, you can assign directly to the
   :attr:`__traceback__` attribute (see below).
 
 * :pep:`3110`: Catching exceptions.  You must now use
-  :keyword:`except` *SomeException* :keyword:`as` *variable* instead
-  of :keyword:`except` *SomeException*, *variable*.  Moreover, the
+  :samp:`except {SomeException} as {variable}` instead
+  of :samp:`except {SomeException}, {variable}`.  Moreover, the
   *variable* is explicitly deleted when the :keyword:`except` block
   is left.
 

Modified: python/branches/release30-maint/Lib/http/client.py
==============================================================================
--- python/branches/release30-maint/Lib/http/client.py	(original)
+++ python/branches/release30-maint/Lib/http/client.py	Sun Jan  4 00:25:33 2009
@@ -359,8 +359,8 @@
 
         if self.version == 9:
             self.length = None
-            self.chunked = 0
-            self.will_close = 1
+            self.chunked = False
+            self.will_close = True
             self.msg = email.message_from_string('')
             return
 
@@ -373,10 +373,10 @@
         # are we using the chunked-style of transfer encoding?
         tr_enc = self.msg.get("transfer-encoding")
         if tr_enc and tr_enc.lower() == "chunked":
-            self.chunked = 1
+            self.chunked = True
             self.chunk_left = None
         else:
-            self.chunked = 0
+            self.chunked = False
 
         # will the connection close at the end of the response?
         self.will_close = self._check_close()
@@ -411,7 +411,7 @@
         if (not self.will_close and
             not self.chunked and
             self.length is None):
-            self.will_close = 1
+            self.will_close = True
 
     def _check_close(self):
         conn = self.msg.get("connection")

Modified: python/branches/release30-maint/Lib/test/test_array.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_array.py	(original)
+++ python/branches/release30-maint/Lib/test/test_array.py	Sun Jan  4 00:25:33 2009
@@ -7,7 +7,7 @@
 from test import support
 from weakref import proxy
 import array, io, math
-from pickle import loads, dumps
+from pickle import loads, dumps, HIGHEST_PROTOCOL
 import operator
 
 class ArraySubclass(array.array):
@@ -98,7 +98,7 @@
         self.assertEqual(a, b)
 
     def test_pickle(self):
-        for protocol in (0, 1, 2):
+        for protocol in range(HIGHEST_PROTOCOL + 1):
             a = array.array(self.typecode, self.example)
             b = loads(dumps(a, protocol))
             self.assertNotEqual(id(a), id(b))
@@ -113,7 +113,7 @@
             self.assertEqual(type(a), type(b))
 
     def test_pickle_for_empty_array(self):
-        for protocol in (0, 1, 2):
+        for protocol in range(HIGHEST_PROTOCOL + 1):
             a = array.array(self.typecode)
             b = loads(dumps(a, protocol))
             self.assertNotEqual(id(a), id(b))

Modified: python/branches/release30-maint/Lib/test/test_deque.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_deque.py	(original)
+++ python/branches/release30-maint/Lib/test/test_deque.py	Sun Jan  4 00:25:33 2009
@@ -375,7 +375,7 @@
 
     def test_pickle(self):
         d = deque(range(200))
-        for i in (0, 1, 2):
+        for i in range(pickle.HIGHEST_PROTOCOL + 1):
             s = pickle.dumps(d, i)
             e = pickle.loads(s)
             self.assertNotEqual(id(d), id(e))
@@ -384,7 +384,7 @@
 ##    def test_pickle_recursive(self):
 ##        d = deque('abc')
 ##        d.append(d)
-##        for i in (0, 1, 2):
+##        for i in range(pickle.HIGHEST_PROTOCOL + 1):
 ##            e = pickle.loads(pickle.dumps(d, i))
 ##            self.assertNotEqual(id(d), id(e))
 ##            self.assertEqual(id(e), id(e[-1]))

Modified: python/branches/release30-maint/Lib/test/test_httplib.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_httplib.py	(original)
+++ python/branches/release30-maint/Lib/test/test_httplib.py	Sun Jan  4 00:25:33 2009
@@ -188,7 +188,8 @@
                 resp.close()
 
     def test_negative_content_length(self):
-        sock = FakeSocket('HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n')
+        sock = FakeSocket(
+            'HTTP/1.1 200 OK\r\nContent-Length: -1\r\n\r\nHello\r\n')
         resp = httplib.HTTPResponse(sock, method="GET")
         resp.begin()
         self.assertEquals(resp.read(), b'Hello\r\n')

Modified: python/branches/release30-maint/Lib/test/test_set.py
==============================================================================
--- python/branches/release30-maint/Lib/test/test_set.py	(original)
+++ python/branches/release30-maint/Lib/test/test_set.py	Sun Jan  4 00:25:33 2009
@@ -219,7 +219,7 @@
         self.failIf(set('cbs').issuperset('a'))
 
     def test_pickling(self):
-        for i in (0, 1, 2):
+        for i in range(pickle.HIGHEST_PROTOCOL + 1):
             p = pickle.dumps(self.s, i)
             dup = pickle.loads(p)
             self.assertEqual(self.s, dup, "%s != %s" % (self.s, dup))

Modified: python/branches/release30-maint/Lib/traceback.py
==============================================================================
--- python/branches/release30-maint/Lib/traceback.py	(original)
+++ python/branches/release30-maint/Lib/traceback.py	Sun Jan  4 00:25:33 2009
@@ -2,7 +2,6 @@
 
 import linecache
 import sys
-import types
 
 __all__ = ['extract_stack', 'extract_tb', 'format_exception',
            'format_exception_only', 'format_list', 'format_stack',

Modified: python/branches/release30-maint/Lib/webbrowser.py
==============================================================================
--- python/branches/release30-maint/Lib/webbrowser.py	(original)
+++ python/branches/release30-maint/Lib/webbrowser.py	Sun Jan  4 00:25:33 2009
@@ -2,6 +2,7 @@
 """Interfaces for launching and remotely controlling Web browsers."""
 # Maintained by Georg Brandl.
 
+import io
 import os
 import shlex
 import sys
@@ -223,7 +224,6 @@
         cmdline = [self.name] + raise_opt + args
 
         if remote or self.background:
-            import io
             inout = io.open(os.devnull, "r+")
         else:
             # for TTY browsers, we need stdin/out
@@ -348,7 +348,6 @@
         else:
             action = "openURL"
 
-        import io
         devnull = io.open(os.devnull, "r+")
         # if possible, put browser in separate process group, so
         # keyboard interrupts don't affect browser as well as Python

Modified: python/branches/release30-maint/Mac/BuildScript/build-installer.py
==============================================================================
--- python/branches/release30-maint/Mac/BuildScript/build-installer.py	(original)
+++ python/branches/release30-maint/Mac/BuildScript/build-installer.py	Sun Jan  4 00:25:33 2009
@@ -9,8 +9,7 @@
 
 Usage: see USAGE variable in the script.
 """
-import platform, os, sys, getopt, textwrap, shutil, stat, time, pwd
-import urllib.request
+import platform, os, sys, getopt, textwrap, shutil, urllib2, stat, time, pwd
 import grp
 
 INCLUDE_TIMESTAMP = 1
@@ -55,7 +54,7 @@
         if 'PY_VERSION' in ln:
             return ln.split()[-1][1:-1]
 
-    raise RuntimeError("Cannot find full version??")
+    raise RuntimeError, "Cannot find full version??"
 
 # The directory we'll use to create the build (will be erased and recreated)
 WORKDIR = "/tmp/_py"
@@ -170,17 +169,6 @@
             getVersion(),
             ),
     ),
-    dict(
-        name="Sleepycat DB 4.7.25",
-        url="http://download.oracle.com/berkeley-db/db-4.7.25.tar.gz",
-        #name="Sleepycat DB 4.3.29",
-        #url="http://downloads.sleepycat.com/db-4.3.29.tar.gz",
-        buildDir="build_unix",
-        configure="../dist/configure",
-        configure_pre=[
-            '--includedir=/usr/local/include/db4',
-        ]
-    ),
 ]
 
 
@@ -298,7 +286,7 @@
     xit = fd.close()
     if xit is not None:
         sys.stdout.write(data)
-        raise RuntimeError("command failed: %s"%(commandline,))
+        raise RuntimeError, "command failed: %s"%(commandline,)
 
     if VERBOSE:
         sys.stdout.write(data); sys.stdout.flush()
@@ -309,7 +297,7 @@
     xit = fd.close()
     if xit is not None:
         sys.stdout.write(data)
-        raise RuntimeError("command failed: %s"%(commandline,))
+        raise RuntimeError, "command failed: %s"%(commandline,)
 
     return data
 
@@ -342,17 +330,17 @@
     try:
         options, args = getopt.getopt(args, '?hb',
                 [ 'build-dir=', 'third-party=', 'sdk-path=' , 'src-dir='])
-    except getopt.error as msg:
-        print(msg)
+    except getopt.error, msg:
+        print msg
         sys.exit(1)
 
     if args:
-        print("Additional arguments")
+        print "Additional arguments"
         sys.exit(1)
 
     for k, v in options:
         if k in ('-h', '-?'):
-            print(USAGE)
+            print USAGE
             sys.exit(0)
 
         elif k in ('-d', '--build-dir'):
@@ -368,19 +356,19 @@
             SRCDIR=v
 
         else:
-            raise NotImplementedError(k)
+            raise NotImplementedError, k
 
     SRCDIR=os.path.abspath(SRCDIR)
     WORKDIR=os.path.abspath(WORKDIR)
     SDKPATH=os.path.abspath(SDKPATH)
     DEPSRC=os.path.abspath(DEPSRC)
 
-    print("Settings:")
-    print(" * Source directory:", SRCDIR)
-    print(" * Build directory: ", WORKDIR)
-    print(" * SDK location:    ", SDKPATH)
-    print(" * third-party source:", DEPSRC)
-    print("")
+    print "Settings:"
+    print " * Source directory:", SRCDIR
+    print " * Build directory: ", WORKDIR
+    print " * SDK location:    ", SDKPATH
+    print " * third-party source:", DEPSRC
+    print ""
 
 
 
@@ -425,7 +413,7 @@
         xit = fp.close()
         if xit is not None:
             sys.stdout.write(data)
-            raise RuntimeError("Cannot extract %s"%(archiveName,))
+            raise RuntimeError, "Cannot extract %s"%(archiveName,)
 
         return os.path.join(builddir, retval)
 
@@ -447,9 +435,9 @@
         pass
     else:
         if KNOWNSIZES.get(url) == size:
-            print("Using existing file for", url)
+            print "Using existing file for", url
             return
-    fpIn = urllib.request.urlopen(url)
+    fpIn = urllib2.urlopen(url)
     fpOut = open(fname, 'wb')
     block = fpIn.read(10240)
     try:
@@ -486,14 +474,14 @@
 
 
     if os.path.exists(sourceArchive):
-        print("Using local copy of %s"%(name,))
+        print "Using local copy of %s"%(name,)
 
     else:
-        print("Downloading %s"%(name,))
+        print "Downloading %s"%(name,)
         downloadURL(url, sourceArchive)
-        print("Archive for %s stored as %s"%(name, sourceArchive))
+        print "Archive for %s stored as %s"%(name, sourceArchive)
 
-    print("Extracting archive for %s"%(name,))
+    print "Extracting archive for %s"%(name,)
     buildDir=os.path.join(WORKDIR, '_bld')
     if not os.path.exists(buildDir):
         os.mkdir(buildDir)
@@ -556,14 +544,14 @@
         configure_args.insert(0, configure)
         configure_args = [ shellQuote(a) for a in configure_args ]
 
-        print("Running configure for %s"%(name,))
+        print "Running configure for %s"%(name,)
         runCommand(' '.join(configure_args) + ' 2>&1')
 
-    print("Running install for %s"%(name,))
+    print "Running install for %s"%(name,)
     runCommand('{ ' + install + ' ;} 2>&1')
 
-    print("Done %s"%(name,))
-    print("")
+    print "Done %s"%(name,)
+    print ""
 
     os.chdir(curdir)
 
@@ -571,9 +559,9 @@
     """
     Build our dependencies into $WORKDIR/libraries/usr/local
     """
-    print("")
-    print("Building required libraries")
-    print("")
+    print ""
+    print "Building required libraries"
+    print ""
     universal = os.path.join(WORKDIR, 'libraries')
     os.mkdir(universal)
     os.makedirs(os.path.join(universal, 'usr', 'local', 'lib'))
@@ -587,7 +575,7 @@
 def buildPythonDocs():
     # This stores the documentation as Resources/English.lproj/Docuentation
     # inside the framwork. pydoc and IDLE will pick it up there.
-    print("Install python documentation")
+    print "Install python documentation"
     rootDir = os.path.join(WORKDIR, '_root')
     version = getVersion()
     docdir = os.path.join(rootDir, 'pydocs')
@@ -596,13 +584,13 @@
     name = 'html-%s.tar.bz2'%(getFullVersion(),)
     sourceArchive = os.path.join(DEPSRC, name)
     if os.path.exists(sourceArchive):
-        print("Using local copy of %s"%(name,))
+        print "Using local copy of %s"%(name,)
 
     else:
         print "Downloading %s"%(novername,)
         downloadURL('http://www.python.org/ftp/python/doc/%s/%s'%(
             getFullVersion(), novername), sourceArchive)
-        print("Archive for %s stored as %s"%(name, sourceArchive))
+        print "Archive for %s stored as %s"%(name, sourceArchive)
 
     extractArchive(os.path.dirname(docdir), sourceArchive)
 
@@ -613,7 +601,7 @@
 
 
 def buildPython():
-    print("Building a universal python")
+    print "Building a universal python"
 
     buildDir = os.path.join(WORKDIR, '_bld', 'python')
     rootDir = os.path.join(WORKDIR, '_root')
@@ -636,24 +624,24 @@
     # several paths.
     version = getVersion()
 
-    print("Running configure...")
+    print "Running configure..."
     runCommand("%s -C --enable-framework --enable-universalsdk=%s LDFLAGS='-g -L%s/libraries/usr/local/lib' OPT='-g -O3 -I%s/libraries/usr/local/include' 2>&1"%(
         shellQuote(os.path.join(SRCDIR, 'configure')),
         shellQuote(SDKPATH), shellQuote(WORKDIR)[1:-1],
         shellQuote(WORKDIR)[1:-1]))
 
-    print("Running make")
+    print "Running make"
     runCommand("make")
 
-    print("Running make frameworkinstall")
+    print "Running make frameworkinstall"
     runCommand("make frameworkinstall DESTDIR=%s"%(
         shellQuote(rootDir)))
 
-    print("Running make frameworkinstallextras")
+    print "Running make frameworkinstallextras"
     runCommand("make frameworkinstallextras DESTDIR=%s"%(
         shellQuote(rootDir)))
 
-    print("Copying required shared libraries")
+    print "Copying required shared libraries"
     if os.path.exists(os.path.join(WORKDIR, 'libraries', 'Library')):
         runCommand("mv %s/* %s"%(
             shellQuote(os.path.join(
@@ -664,7 +652,7 @@
                 'Python.framework', 'Versions', getVersion(),
                 'lib'))))
 
-    print("Fix file modes")
+    print "Fix file modes"
     frmDir = os.path.join(rootDir, 'Library', 'Frameworks', 'Python.framework')
     gid = grp.getgrnam('admin').gr_gid
 
@@ -760,7 +748,7 @@
         readme = textwrap.dedent(recipe['readme'])
         isRequired = recipe.get('required', True)
 
-        print("- building package %s"%(pkgname,))
+        print "- building package %s"%(pkgname,)
 
         # Substitute some variables
         textvars = dict(
@@ -1063,9 +1051,9 @@
     shutil.copy('../../LICENSE', os.path.join(WORKDIR, 'installer', 'License.txt'))
 
     fp = open(os.path.join(WORKDIR, 'installer', 'Build.txt'), 'w')
-    print("# BUILD INFO", file=fp)
-    print("# Date:", time.ctime(), file=fp)
-    print("# By:", pwd.getpwuid(os.getuid()).pw_gecos, file=fp)
+    print >> fp, "# BUILD INFO"
+    print >> fp, "# Date:", time.ctime()
+    print >> fp, "# By:", pwd.getpwuid(os.getuid()).pw_gecos
     fp.close()
 
     # Custom icon for the DMG, shown when the DMG is mounted.

Modified: python/branches/release30-maint/Modules/_fileio.c
==============================================================================
--- python/branches/release30-maint/Modules/_fileio.c	(original)
+++ python/branches/release30-maint/Modules/_fileio.c	Sun Jan  4 00:25:33 2009
@@ -55,20 +55,27 @@
 
 #define PyFileIO_Check(op) (PyObject_TypeCheck((op), &PyFileIO_Type))
 
-/* Returns 0 on success, errno (which is < 0) on failure. */
+/* Returns 0 on success, -1 with exception set on failure. */
 static int
 internal_close(PyFileIOObject *self)
 {
-	int save_errno = 0;
+	int err = 0;
+	int save_errno;
 	if (self->fd >= 0) {
 		int fd = self->fd;
 		self->fd = -1;
 		Py_BEGIN_ALLOW_THREADS
-		if (close(fd) < 0)
+		err = close(fd);
+		if (err < 0)
 			save_errno = errno;
 		Py_END_ALLOW_THREADS
 	}
-	return save_errno;
+	if (err < 0) {
+		errno = save_errno;
+		PyErr_SetFromErrno(PyExc_IOError);
+		return -1;
+	}
+	return 0;
 }
 
 static PyObject *
@@ -78,11 +85,8 @@
 		self->fd = -1;
 		Py_RETURN_NONE;
 	}
-	errno = internal_close(self);
-	if (errno < 0) {
-		PyErr_SetFromErrno(PyExc_IOError);
+	if (internal_close(self))
 		return NULL;
-	}
 
 	Py_RETURN_NONE;
 }
@@ -121,7 +125,8 @@
 	if (fstat(self->fd, &buf) == 0 && S_ISDIR(buf.st_mode)) {
 		char *msg = strerror(EISDIR);
 		PyObject *exc;
-		internal_close(self);
+		if (internal_close(self))
+			return -1;
 
 		exc = PyObject_CallFunction(PyExc_IOError, "(is)",
 					    EISDIR, msg);
@@ -306,11 +311,8 @@
 		PyObject_ClearWeakRefs((PyObject *) self);
 
 	if (self->fd >= 0 && self->closefd) {
-		errno = internal_close(self);
-		if (errno < 0) {
-			PySys_WriteStderr("close failed: [Errno %d] %s\n",
-                                          errno, strerror(errno));
-		}
+		if(internal_close(self))
+			PyErr_WriteUnraisable((PyObject*)self);
 	}
 
 	Py_TYPE(self)->tp_free((PyObject *)self);

Modified: python/branches/release30-maint/Objects/floatobject.c
==============================================================================
--- python/branches/release30-maint/Objects/floatobject.c	(original)
+++ python/branches/release30-maint/Objects/floatobject.c	Sun Jan  4 00:25:33 2009
@@ -1238,7 +1238,7 @@
 	 ********************/
 
 	/* leading whitespace and optional sign */
-	while (isspace(*s))
+	while (isspace(Py_CHARMASK(*s)))
 		s++;
 	if (*s == '-') {
 		s++;
@@ -1308,7 +1308,7 @@
 		exp = 0;
 
 	/* optional trailing whitespace leading to the end of the string */
-	while (isspace(*s))
+	while (isspace(Py_CHARMASK(*s)))
 		s++;
 	if (s != s_end)
 		goto parse_error;

Modified: python/branches/release30-maint/Parser/tokenizer.c
==============================================================================
--- python/branches/release30-maint/Parser/tokenizer.c	(original)
+++ python/branches/release30-maint/Parser/tokenizer.c	Sun Jan  4 00:25:33 2009
@@ -452,8 +452,8 @@
 		stream = PyObject_CallMethod(io, "open", "ssis",
 					     tok->filename, "r", -1, enc);
 	else
-		stream = PyObject_CallMethod(io, "open", "isis",
-				fileno(tok->fp), "r", -1, enc);
+		stream = PyObject_CallMethod(io, "open", "isisOOO",
+				fileno(tok->fp), "r", -1, enc, Py_None, Py_None, Py_False);
 	if (stream == NULL)
 		goto cleanup;
 

Modified: python/branches/release30-maint/Python/getargs.c
==============================================================================
--- python/branches/release30-maint/Python/getargs.c	(original)
+++ python/branches/release30-maint/Python/getargs.c	Sun Jan  4 00:25:33 2009
@@ -1392,7 +1392,7 @@
 	Py_ssize_t count;
 	PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
 	if (pb == NULL) {
-		*errmsg = "string or buffer";
+		*errmsg = "bytes or buffer";
 		return -1;
 	}
 	if (pb->bf_getbuffer) {


More information about the Python-checkins mailing list