]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 67653,67655,67682-67683,67724,67755,67780-67783,67786,67789,67841...
authorGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:25:33 +0000 (23:25 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 3 Jan 2009 23:25:33 +0000 (23:25 +0000)
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)
........

25 files changed:
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

index c86ae8ab2a31d827dba4a016b842b9bce34f7e3d..5c4fde84644c827653bdee2f842e632fff914522 100644 (file)
@@ -218,11 +218,22 @@ Python extension.  For example::
        {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.
index 8425ff476be3b15908a0a7b0f2c3bf58ab993ddd..17a8110961b23181c33e9f530dc4b911599f587b 100644 (file)
@@ -326,8 +326,8 @@ only non-\ ``static`` item defined in the module file::
        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 @@ satisfactorily. The init function must return the module object to its caller,
 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::
 
index ab77a231844ee546d0dad4ca81639f6afb13560c..1d9b42d7b6c4df5f59428dc53fb30dc4a0210fd3 100644 (file)
@@ -634,7 +634,7 @@ features of generator expressions:
     ...     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 @@ value.
     >>> def is_even(x):
     ...     return (x % 2) == 0
 
-    >>> filter(is_even, range(10))
+    >>> list(filter(is_even, range(10)))
     [0, 2, 4, 6, 8]
 
 
index 26a49a91218745983a6800154a570070c5918113..b6b7d6feda339d8b3dd4365e542812fcac22164e 100644 (file)
@@ -52,4 +52,5 @@ PyInit_noddy(void)
 
     Py_INCREF(&noddy_NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&noddy_NoddyType);
+    return m;
 }
index 5daecf9d8aca3826d0b13d1f051d0044f3f8eef7..db9c7a88d524bd9fda5d127d3d89023c1f4ee544 100644 (file)
@@ -186,4 +186,5 @@ PyInit_noddy2(void)
 
     Py_INCREF(&NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+    return m;
 }
index 39cdfdbea3ebbc8582c6de50cf04911b5be79854..e98b87fdd3953a82ff713c85e2f747a9f30056c0 100644 (file)
@@ -239,4 +239,5 @@ PyInit_noddy3(void)
 
     Py_INCREF(&NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+    return m;
 }
index 94507ecf82eaf675d857ce9c65fb41c66f29026f..5be00a796a96b0f3dc9b4cf8d4401976a1bdeadd 100644 (file)
@@ -221,4 +221,5 @@ PyInit_noddy4(void)
 
     Py_INCREF(&NoddyType);
     PyModule_AddObject(m, "Noddy", (PyObject *)&NoddyType);
+    return m;
 }
index 03807489e9d2707f265ec7a1d8fbdeea96062703..877d9b66ecadae2cad6347d637de3fbec5754b42 100644 (file)
@@ -289,7 +289,7 @@ are always available.  They are listed here in alphabetical order.
    :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
index 5668623ed34565dbe35d757612ba520443f3a8ff..68e8dbafdb3aa586be632af0425c5ccbd22d4739 100644 (file)
@@ -1090,12 +1090,9 @@ functions based on regular expressions.
    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::
 
index 1e43128582108af09f7ac3a9fa11fbd3c0cd7e9b..83d3b8ba2d08dc4fc726d747da7c105960a8c5b2 100644 (file)
@@ -174,14 +174,18 @@ Leading whitespace (spaces and tabs) at the beginning of a logical line is used
 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
index 84e731d90b2899f0466cae3206d4e3b351b3c0c2..ca6de17ba0d041cd43eb5050d87626b8842115dd 100644 (file)
@@ -440,9 +440,9 @@ pair with ``del``. If you store using a key that is already in use, the old
 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 @@ Here is a small example using a dictionary::
    >>> tel
    {'guido': 4127, 'irv': 4127, 'jack': 4098}
    >>> list(tel.keys())
+   ['irv', 'guido', 'jack']
+   >>> sorted(tel.keys())
    ['guido', 'irv', 'jack']
    >>> 'guido' in tel
    True
index 1b3cbc556e1cc94dae63e8337597ea119b11ff4b..aca553dbc22ccb172b3e0c4e7144348129f7f621 100644 (file)
@@ -112,7 +112,7 @@ you have already defined.
    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:
index f2d9362039817f5bdd0c160073379b4714258eb6..678ad805be844cc6d5ad8c28444769e798039989 100644 (file)
@@ -696,15 +696,15 @@ new powerful features added:
 * 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.
 
index 99d560e4322f18f05b1b20608a9e930656b15cfe..34bf6a9395c313b4a13d7a50fad469d670d0ddeb 100644 (file)
@@ -359,8 +359,8 @@ class HTTPResponse:
 
         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 @@ class HTTPResponse:
         # 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 @@ class HTTPResponse:
         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")
index 5a505de7ec29f5c1008f940b535e41f1ac495f7b..2b80a7d041056035be80d286b9e01622474380a0 100755 (executable)
@@ -7,7 +7,7 @@ import unittest
 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 @@ class BaseTest(unittest.TestCase):
         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 @@ class BaseTest(unittest.TestCase):
             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))
index 1ac43dad27bfcc7f9a9f268677ee6162bec2915e..7af0803e5d941b0c96b4227644806a62e4fbc05c 100644 (file)
@@ -375,7 +375,7 @@ class TestBasic(unittest.TestCase):
 
     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 @@ class TestBasic(unittest.TestCase):
 ##    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]))
index 054825a5a330d23276ab373ae530edbc1e2f5563..591f95684d9796d58313f40dc12ed5086802f1b0 100644 (file)
@@ -188,7 +188,8 @@ class BasicTest(TestCase):
                 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')
index 07319fc20d1ce1c80c23cd73ca4a2cf9adaf39d8..da3ed0f53a66d36310a064181b7881f6a588c77d 100644 (file)
@@ -219,7 +219,7 @@ class TestJointOps(unittest.TestCase):
         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))
index fac73c4b3e7e2badd00bb55e92496f401262d030..b028db0717386dd69c3da9f992cc74221d497362 100644 (file)
@@ -2,7 +2,6 @@
 
 import linecache
 import sys
-import types
 
 __all__ = ['extract_stack', 'extract_tb', 'format_exception',
            'format_exception_only', 'format_list', 'format_stack',
index 39f9b99390c4ce5b5578713e3a389918ca6dfb8b..fb227fec8d0a8b4e02eac89c9e6221a7d236bac3 100644 (file)
@@ -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 @@ class UnixBrowser(BaseBrowser):
         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 @@ class Konqueror(BaseBrowser):
         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
index abc29dc9f3da7c7f037e43dbdd5c7a0c0cf876e8..dd606d947faaf845d1eafec87ceecba23bd8d0f2 100755 (executable)
@@ -9,8 +9,7 @@ bootstrap issues (/usr/bin/python is Python 2.3 on OSX 10.4)
 
 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 @@ def getFullVersion():
         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 @@ LIBRARY_RECIPES = [
             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 @@ def runCommand(commandline):
     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 @@ def captureCommand(commandline):
     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 @@ def parseOptions(args=None):
     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 @@ def parseOptions(args=None):
             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 @@ def extractArchive(builddir, archiveName):
         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 @@ def downloadURL(url, fname):
         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 @@ def buildRecipe(recipe, basedir, archList):
 
 
     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 @@ def buildRecipe(recipe, basedir, archList):
         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 @@ def buildLibraries():
     """
     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 buildLibraries():
 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 @@ def buildPythonDocs():
     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 buildPythonDocs():
 
 
 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 @@ def buildPython():
     # 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 @@ def buildPython():
                 '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 @@ def packageFromRecipe(targetDir, recipe):
         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 @@ def main():
     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.
index c23d5a3c1636c81a79608bb668ed27519003371b..b892993ae9ad253d6649822484af6c0f8f9f667d 100644 (file)
@@ -55,20 +55,27 @@ PyTypeObject PyFileIO_Type;
 
 #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 @@ fileio_close(PyFileIOObject *self)
                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 @@ dircheck(PyFileIOObject* self)
        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 @@ fileio_dealloc(PyFileIOObject *self)
                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);
index 89eac6466d11508cd0ce37fda2e12f7135811671..20c1eef01468480d41629054b472c56f7af863d6 100644 (file)
@@ -1238,7 +1238,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
         ********************/
 
        /* leading whitespace and optional sign */
-       while (isspace(*s))
+       while (isspace(Py_CHARMASK(*s)))
                s++;
        if (*s == '-') {
                s++;
@@ -1308,7 +1308,7 @@ float_fromhex(PyObject *cls, PyObject *arg)
                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;
index ce8129ddd123f0406ef9e88c932a4e24813489e8..3d52bedc0e675291da79401977c2e6989c42fc74 100644 (file)
@@ -452,8 +452,8 @@ fp_setreadl(struct tok_state *tok, const char* enc)
                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;
 
index a63aa43641d50352c77c9d07b5de6d1931e36dbe..3ab59b3e42d87ed1af3b38d8811de1cdae109cbf 100644 (file)
@@ -1392,7 +1392,7 @@ getbuffer(PyObject *arg, Py_buffer *view, char **errmsg)
        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) {