[Python-3000-checkins] r58481 - in python/branches/py3k-importlib: Doc/library/locale.rst Include/code.h Include/memoryobject.h Include/object.h Include/unicodeobject.h Lib/bsddb/dbshelve.py Lib/bsddb/test/test_dbshelve.py Lib/distutils/dist.py Lib/doctest.py Lib/idlelib/IOBinding.py Lib/io.py Lib/test/test_frozen.py Misc/ACKS Misc/NEWS Modules/_ctypes/callbacks.c Modules/_sre.c Modules/arraymodule.c Modules/posixmodule.c Modules/pyexpat.c Objects/abstract.c Objects/codeobject.c Objects/memoryobject.c Objects/moduleobject.c Objects/unicodeobject.c PC/VC6/pythoncore.dsp PC/config.c PC/os2emx/Makefile PC/os2emx/config.c PCbuild8/pythoncore/pythoncore.vcproj Python/bltinmodule.c Python/ceval.c Python/compile.c Python/frozen.c Python/getargs.c Python/import.c Python/importdl.c Python/pythonrun.c Python/traceback.c Tools/scripts/README configure configure.in pyconfig.h.in

brett.cannon python-3000-checkins at python.org
Mon Oct 15 21:39:59 CEST 2007


Author: brett.cannon
Date: Mon Oct 15 21:39:57 2007
New Revision: 58481

Modified:
   python/branches/py3k-importlib/   (props changed)
   python/branches/py3k-importlib/Doc/library/locale.rst
   python/branches/py3k-importlib/Include/code.h
   python/branches/py3k-importlib/Include/memoryobject.h
   python/branches/py3k-importlib/Include/object.h
   python/branches/py3k-importlib/Include/unicodeobject.h
   python/branches/py3k-importlib/Lib/bsddb/dbshelve.py
   python/branches/py3k-importlib/Lib/bsddb/test/test_dbshelve.py
   python/branches/py3k-importlib/Lib/distutils/dist.py
   python/branches/py3k-importlib/Lib/doctest.py
   python/branches/py3k-importlib/Lib/idlelib/IOBinding.py
   python/branches/py3k-importlib/Lib/io.py
   python/branches/py3k-importlib/Lib/test/test_frozen.py
   python/branches/py3k-importlib/Misc/ACKS
   python/branches/py3k-importlib/Misc/NEWS
   python/branches/py3k-importlib/Modules/_ctypes/callbacks.c
   python/branches/py3k-importlib/Modules/_sre.c
   python/branches/py3k-importlib/Modules/arraymodule.c
   python/branches/py3k-importlib/Modules/posixmodule.c
   python/branches/py3k-importlib/Modules/pyexpat.c
   python/branches/py3k-importlib/Objects/abstract.c
   python/branches/py3k-importlib/Objects/codeobject.c
   python/branches/py3k-importlib/Objects/memoryobject.c
   python/branches/py3k-importlib/Objects/moduleobject.c
   python/branches/py3k-importlib/Objects/unicodeobject.c
   python/branches/py3k-importlib/PC/VC6/pythoncore.dsp
   python/branches/py3k-importlib/PC/config.c
   python/branches/py3k-importlib/PC/os2emx/Makefile
   python/branches/py3k-importlib/PC/os2emx/config.c
   python/branches/py3k-importlib/PCbuild8/pythoncore/pythoncore.vcproj
   python/branches/py3k-importlib/Python/bltinmodule.c
   python/branches/py3k-importlib/Python/ceval.c
   python/branches/py3k-importlib/Python/compile.c
   python/branches/py3k-importlib/Python/frozen.c
   python/branches/py3k-importlib/Python/getargs.c
   python/branches/py3k-importlib/Python/import.c
   python/branches/py3k-importlib/Python/importdl.c
   python/branches/py3k-importlib/Python/pythonrun.c
   python/branches/py3k-importlib/Python/traceback.c
   python/branches/py3k-importlib/Tools/scripts/README
   python/branches/py3k-importlib/configure
   python/branches/py3k-importlib/configure.in
   python/branches/py3k-importlib/pyconfig.h.in
Log:
Merged revisions 58416-58479 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k



Modified: python/branches/py3k-importlib/Doc/library/locale.rst
==============================================================================
--- python/branches/py3k-importlib/Doc/library/locale.rst	(original)
+++ python/branches/py3k-importlib/Doc/library/locale.rst	Mon Oct 15 21:39:57 2007
@@ -498,26 +498,23 @@
 before the settings have been restored.
 
 If, when coding a module for general use, you need a locale independent version
-of an operation that is affected by the locale (such as :func:`string.lower`, or
+of an operation that is affected by the locale (such as
 certain formats used with :func:`time.strftime`), you will have to find a way to
 do it without using the standard library routine.  Even better is convincing
 yourself that using locale settings is okay.  Only as a last resort should you
 document that your module is not compatible with non-\ ``C`` locale settings.
 
-.. index:: module: string
-
-The case conversion functions in the :mod:`string` module are affected by the
-locale settings.  When a call to the :func:`setlocale` function changes the
-:const:`LC_CTYPE` settings, the variables ``string.lowercase``,
-``string.uppercase`` and ``string.letters`` are recalculated.  Note that code
-that uses these variable through ':keyword:`from` ... :keyword:`import` ...',
-e.g. ``from string import letters``, is not affected by subsequent
-:func:`setlocale` calls.
-
 The only way to perform numeric operations according to the locale is to use the
 special functions defined by this module: :func:`atof`, :func:`atoi`,
 :func:`format`, :func:`str`.
 
+There is no way to perform case conversions and character classifications
+according to the locale.  For (Unicode) text strings these are done according
+to the character value only, while for byte strings, the conversions and
+classifications are done according to the ASCII value of the byte, and bytes
+whose high bit is set (i.e., non-ASCII bytes) are never converted or considered
+part of a character class such as letter or whitespace.
+
 
 .. _embedding-locale:
 

Modified: python/branches/py3k-importlib/Include/code.h
==============================================================================
--- python/branches/py3k-importlib/Include/code.h	(original)
+++ python/branches/py3k-importlib/Include/code.h	Mon Oct 15 21:39:57 2007
@@ -21,8 +21,8 @@
     PyObject *co_freevars;	/* tuple of strings (free variable names) */
     PyObject *co_cellvars;      /* tuple of strings (cell variable names) */
     /* The rest doesn't count for hash/cmp */
-    PyObject *co_filename;	/* string (where it was loaded from) */
-    PyObject *co_name;		/* string (name, for reference) */
+    PyObject *co_filename;	/* unicode (where it was loaded from) */
+    PyObject *co_name;		/* unicode (name, for reference) */
     int co_firstlineno;		/* first source line number */
     PyObject *co_lnotab;	/* string (encoding addr<->lineno mapping) */
     void *co_zombieframe;     /* for optimization only (see frameobject.c) */

Modified: python/branches/py3k-importlib/Include/memoryobject.h
==============================================================================
--- python/branches/py3k-importlib/Include/memoryobject.h	(original)
+++ python/branches/py3k-importlib/Include/memoryobject.h	Mon Oct 15 21:39:57 2007
@@ -8,9 +8,9 @@
 #endif
 
 typedef struct {
-        PyObject_HEAD
-        PyObject *base;
-        Py_buffer view;
+	PyObject_HEAD
+	PyObject *base;
+	Py_buffer view;
 } PyMemoryViewObject;
 
 
@@ -21,39 +21,40 @@
 
 #define Py_END_OF_MEMORY	(-1)
 
-PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, int buffertype, 
-                                                  char fort);
+PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, 
+						  int buffertype, 
+						  char fort);
 
 	/* Return a contiguous chunk of memory representing the buffer
 	   from an object in a memory view object.  If a copy is made then the
-           base object for the memory view will be a *new* bytes object. 
-           
-           Otherwise, the base-object will be the object itself and no 
-           data-copying will be done. 
-
-           The buffertype argument can be PyBUF_READ, PyBUF_WRITE,
-           PyBUF_UPDATEIFCOPY to determine whether the returned buffer
-           should be READONLY, WRITABLE, or set to update the
-           original buffer if a copy must be made.  If buffertype is
-           PyBUF_WRITE and the buffer is not contiguous an error will
-           be raised.  In this circumstance, the user can use
-           PyBUF_UPDATEIFCOPY to ensure that a a writable temporary
-           contiguous buffer is returned.  The contents of this
-           contiguous buffer will be copied back into the original
-           object after the memoryview object is deleted as long as
-           the original object is writable and allows setting its
-           memory to "readonly".  If this is not allowed by the
-           original object, then a BufferError is raised.
+	   base object for the memory view will be a *new* bytes object. 
 	   
-           If the object is multi-dimensional and if fortran is 'F',
-           the first dimension of the underlying array will vary the
-           fastest in the buffer.  If fortran is 'C', then the last
-           dimension will vary the fastest (C-style contiguous).  If
-           fortran is 'A', then it does not matter and you will get
-           whatever the object decides is more efficient.  
+	   Otherwise, the base-object will be the object itself and no 
+	   data-copying will be done. 
 
-           A new reference is returned that must be DECREF'd when finished.
-        */
+	   The buffertype argument can be PyBUF_READ, PyBUF_WRITE,
+	   PyBUF_SHADOW to determine whether the returned buffer
+	   should be READONLY, WRITABLE, or set to update the
+	   original buffer if a copy must be made.  If buffertype is
+	   PyBUF_WRITE and the buffer is not contiguous an error will
+	   be raised.  In this circumstance, the user can use
+	   PyBUF_SHADOW to ensure that a a writable temporary
+	   contiguous buffer is returned.  The contents of this
+	   contiguous buffer will be copied back into the original
+	   object after the memoryview object is deleted as long as
+	   the original object is writable and allows setting an
+	   exclusive write lock. If this is not allowed by the
+	   original object, then a BufferError is raised.
+	   
+	   If the object is multi-dimensional and if fortran is 'F',
+	   the first dimension of the underlying array will vary the
+	   fastest in the buffer.  If fortran is 'C', then the last
+	   dimension will vary the fastest (C-style contiguous).  If
+	   fortran is 'A', then it does not matter and you will get
+	   whatever the object decides is more efficient.  
+
+	   A new reference is returned that must be DECREF'd when finished.
+	*/
 
 PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base);
 

Modified: python/branches/py3k-importlib/Include/object.h
==============================================================================
--- python/branches/py3k-importlib/Include/object.h	(original)
+++ python/branches/py3k-importlib/Include/object.h	Mon Oct 15 21:39:57 2007
@@ -160,34 +160,39 @@
 
         /* Flags for getting buffers */
 #define PyBUF_SIMPLE 0
-#define PyBUF_CHARACTER 1
-#define PyBUF_WRITABLE 0x0002
+#define PyBUF_WRITABLE 0x0001
 /*  we used to include an E, backwards compatible alias  */
 #define PyBUF_WRITEABLE PyBUF_WRITABLE
-#define PyBUF_LOCKDATA 0x0004
-#define PyBUF_FORMAT 0x0008
-#define PyBUF_ND 0x0010
-#define PyBUF_STRIDES (0x0020 | PyBUF_ND)
-#define PyBUF_C_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
-#define PyBUF_F_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
-#define PyBUF_ANY_CONTIGUOUS (0x0100 | PyBUF_STRIDES)
-#define PyBUF_INDIRECT (0x0200 | PyBUF_STRIDES)
+#define PyBUF_LOCK 0x0002
+#define PyBUF_FORMAT 0x0004
+#define PyBUF_ND 0x0008
+#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
 
 #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
 #define PyBUF_CONTIG_RO (PyBUF_ND)
-#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCKDATA)
+#define PyBUF_CONTIG_LCK (PyBUF_ND | PyBUF_LOCK)
+#define PyBUF_CONTIG_XLCK (PyBUF_ND | PyBUF_LOCK | PyBUF_WRITABLE)
 
 #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
 #define PyBUF_STRIDED_RO (PyBUF_STRIDES)
-#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA)
+#define PyBUF_STRIDED_LCK (PyBUF_STRIDES | PyBUF_LOCK)
+#define PyBUF_STRIDED_XLCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_WRITABLE)
 
 #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
 #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
-#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCKDATA | PyBUF_FORMAT)
+#define PyBUF_RECORDS_LCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_FORMAT)
+#define PyBUF_RECORDS_XLCK (PyBUF_STRIDES | PyBUF_LOCK | PyBUF_WRITABLE \
+			    | PyBUF_FORMAT)
 
 #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
 #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
-#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCKDATA | PyBUF_FORMAT)
+#define PyBUF_FULL_LCK (PyBUF_INDIRECT | PyBUF_LOCK | PyBUF_FORMAT)
+#define PyBUF_FULL_XLCK (PyBUF_INDIRECT | PyBUF_LOCK | PyBUF_WRITABLE \
+			 | PyBUF_FORMAT)
 
 
 #define PyBUF_READ  0x100

Modified: python/branches/py3k-importlib/Include/unicodeobject.h
==============================================================================
--- python/branches/py3k-importlib/Include/unicodeobject.h	(original)
+++ python/branches/py3k-importlib/Include/unicodeobject.h	Mon Oct 15 21:39:57 2007
@@ -154,6 +154,7 @@
 # define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII
 # define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap
 # define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1
+# define PyUnicode_DecodeFSDefault PyUnicodeUCS2_DecodeFSDefault
 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape
 # define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32
 # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful
@@ -245,6 +246,7 @@
 # define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII
 # define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap
 # define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1
+# define PyUnicode_DecodeFSDefault PyUnicodeUCS4_DecodeFSDefault
 # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape
 # define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32
 # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful
@@ -641,6 +643,20 @@
 PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
     PyObject *, const char *);
 
+/* Decode a null-terminated string using Py_FileSystemDefaultEncoding.
+
+   If the encoding is supported by one of the built-in codecs (i.e., UTF-8,
+   UTF-16, UTF-32, Latin-1 or MBCS), otherwise fallback to UTF-8 and replace
+   invalid characters with '?'.
+
+   The function is intended to be used for paths and file names only
+   during bootstrapping process where the codecs are not set up.
+*/
+
+PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefault(
+    const char *s               /* encoded string */
+    );
+
 /* Return a char* holding the UTF-8 encoded value of the
    Unicode object.
 

Modified: python/branches/py3k-importlib/Lib/bsddb/dbshelve.py
==============================================================================
--- python/branches/py3k-importlib/Lib/bsddb/dbshelve.py	(original)
+++ python/branches/py3k-importlib/Lib/bsddb/dbshelve.py	Mon Oct 15 21:39:57 2007
@@ -77,12 +77,16 @@
 
 #---------------------------------------------------------------------------
 
+class DBShelveError(db.DBError): pass
+
+
 class DBShelf(DictMixin):
     """A shelf to hold pickled objects, built upon a bsddb DB object.  It
     automatically pickles/unpickles data objects going to/from the DB.
     """
     def __init__(self, dbenv=None):
         self.db = db.DB(dbenv)
+        self._closed = True
         self.binary = 1
 
 
@@ -125,6 +129,23 @@
             return self.db.keys()
 
 
+    def open(self, *args, **kwargs):
+        self.db.open(*args, **kwargs)
+        self._closed = False
+
+
+    def close(self, *args, **kwargs):
+        self.db.close(*args, **kwargs)
+        self._closed = True
+
+
+    def __repr__(self):
+        if self._closed:
+            return '<DBShelf @ 0x%x - closed>' % (id(self))
+        else:
+            return repr(dict(self.iteritems()))
+
+
     def items(self, txn=None):
         if txn != None:
             items = self.db.items(txn)
@@ -152,10 +173,9 @@
         return self.db.append(data, txn)
 
     def append(self, value, txn=None):
-        if self.get_type() != db.DB_RECNO:
-            self.append = self.__append
-            return self.append(value, txn=txn)
-        raise db.DBError("append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO")
+        if self.get_type() == db.DB_RECNO:
+            return self.__append(value, txn=txn)
+        raise DBShelveError("append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO")
 
 
     def associate(self, secondaryDB, callback, flags=0):

Modified: python/branches/py3k-importlib/Lib/bsddb/test/test_dbshelve.py
==============================================================================
--- python/branches/py3k-importlib/Lib/bsddb/test/test_dbshelve.py	(original)
+++ python/branches/py3k-importlib/Lib/bsddb/test/test_dbshelve.py	Mon Oct 15 21:39:57 2007
@@ -50,17 +50,22 @@
         except os.error:
             pass
 
+    def mk(self, key):
+        """Turn key into an appropriate key type for this db"""
+        # override in child class for RECNO
+        return key.encode("ascii")
+
     def populateDB(self, d):
         for x in letters:
-            d[('S' + x).encode("ascii")] = 10 * x           # add a string
-            d[('I' + x).encode("ascii")] = ord(x)           # add an integer
-            d[('L' + x).encode("ascii")] = [x] * 10         # add a list
+            d[self.mk('S' + x)] = 10 * x           # add a string
+            d[self.mk('I' + x)] = ord(x)           # add an integer
+            d[self.mk('L' + x)] = [x] * 10         # add a list
 
             inst = DataClass()            # add an instance
             inst.S = 10 * x
             inst.I = ord(x)
             inst.L = [x] * 10
-            d[('O' + x).encode("ascii")] = inst
+            d[self.mk('O' + x)] = inst
 
 
     # overridable in derived classes to affect how the shelf is created/opened
@@ -100,14 +105,14 @@
             print("keys:", k)
             print("stats:", s)
 
-        self.assertFalse(d.has_key(b'bad key'))
-        self.assertTrue(d.has_key(b'IA'), d.keys())
-        self.assertTrue(d.has_key(b'OA'))
-
-        d.delete(b'IA')
-        del d[b'OA']
-        self.assertFalse(d.has_key(b'IA'))
-        self.assertFalse(d.has_key(b'OA'))
+        self.assertFalse(d.has_key(self.mk('bad key')))
+        self.assertTrue(d.has_key(self.mk('IA')), d.keys())
+        self.assertTrue(d.has_key(self.mk('OA')))
+
+        d.delete(self.mk('IA'))
+        del d[self.mk('OA')]
+        self.assertFalse(d.has_key(self.mk('IA')))
+        self.assertFalse(d.has_key(self.mk('OA')))
         self.assertEqual(len(d), l-2)
 
         values = []
@@ -129,18 +134,18 @@
         for key, value in items:
             self.checkrec(key, value)
 
-        self.assertEqual(d.get(b'bad key'), None)
-        self.assertEqual(d.get(b'bad key', None), None)
-        self.assertEqual(d.get(b'bad key', b'a string'), b'a string')
-        self.assertEqual(d.get(b'bad key', [1, 2, 3]), [1, 2, 3])
+        self.assertEqual(d.get(self.mk('bad key')), None)
+        self.assertEqual(d.get(self.mk('bad key'), None), None)
+        self.assertEqual(d.get(self.mk('bad key'), b'a string'), b'a string')
+        self.assertEqual(d.get(self.mk('bad key'), [1, 2, 3]), [1, 2, 3])
 
         d.set_get_returns_none(0)
-        self.assertRaises(db.DBNotFoundError, d.get, b'bad key')
+        self.assertRaises(db.DBNotFoundError, d.get, self.mk('bad key'))
         d.set_get_returns_none(1)
 
-        d.put(b'new key', b'new data')
-        self.assertEqual(d.get(b'new key'), b'new data')
-        self.assertEqual(d[b'new key'], b'new data')
+        d.put(self.mk('new key'), b'new data')
+        self.assertEqual(d.get(self.mk('new key')), b'new data')
+        self.assertEqual(d[self.mk('new key')], b'new data')
 
 
 
@@ -179,12 +184,23 @@
 
         self.assertEqual(count, len(d))
 
-        c.set(b'SS')
+        c.set(self.mk('SS'))
         key, value = c.current()
         self.checkrec(key, value)
         del c
 
+    def test03_append(self):
+        # NOTE: this is overridden in RECNO subclass, don't change its name.
+        if verbose:
+            print('\n', '-=' * 30)
+            print("Running %s.test03_append..." % self.__class__.__name__)
+
+        self.assertRaises(dbshelve.DBShelveError,
+                          self.d.append, b'unit test was here')
+
+
     def checkrec(self, key, value):
+        # override this in a subclass if the key type is different
         x = key[1:]
         if key[0:1] == b'S':
             self.assertEquals(type(value), str)
@@ -289,7 +305,43 @@
 
 
 #----------------------------------------------------------------------
-# TODO:  Add test cases for a DBShelf in a RECNO DB.
+# test cases for a DBShelf in a RECNO DB.
+
+class RecNoShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_RECNO
+    dbflags = db.DB_CREATE
+
+    def setUp(self):
+        BasicShelveTestCase.setUp(self)
+
+        # pool to assign integer key values out of
+        self.key_pool = list(range(1, 5000))
+        self.key_map = {}     # map string keys to the number we gave them
+        self.intkey_map = {}  # reverse map of above
+
+    def mk(self, key):
+        if key not in self.key_map:
+            self.key_map[key] = self.key_pool.pop(0)
+            self.intkey_map[self.key_map[key]] = key.encode('ascii')
+        return self.key_map[key]
+
+    def checkrec(self, intkey, value):
+        key = self.intkey_map[intkey]
+        BasicShelveTestCase.checkrec(self, key, value)
+
+    def test03_append(self):
+        if verbose:
+            print('\n', '-=' * 30)
+            print("Running %s.test03_append..." % self.__class__.__name__)
+
+        self.d[1] = b'spam'
+        self.d[5] = b'eggs'
+        self.assertEqual(6, self.d.append(b'spam'))
+        self.assertEqual(7, self.d.append(b'baked beans'))
+        self.assertEqual(b'spam', self.d.get(6))
+        self.assertEqual(b'spam', self.d.get(1))
+        self.assertEqual(b'baked beans', self.d.get(7))
+        self.assertEqual(b'eggs', self.d.get(5))
 
 
 #----------------------------------------------------------------------
@@ -306,6 +358,7 @@
     suite.addTest(unittest.makeSuite(EnvHashShelveTestCase))
     suite.addTest(unittest.makeSuite(EnvThreadBTreeShelveTestCase))
     suite.addTest(unittest.makeSuite(EnvThreadHashShelveTestCase))
+    suite.addTest(unittest.makeSuite(RecNoShelveTestCase))
 
     return suite
 

Modified: python/branches/py3k-importlib/Lib/distutils/dist.py
==============================================================================
--- python/branches/py3k-importlib/Lib/distutils/dist.py	(original)
+++ python/branches/py3k-importlib/Lib/distutils/dist.py	Mon Oct 15 21:39:57 2007
@@ -280,8 +280,7 @@
         from pprint import pformat
 
         if commands is None:             # dump all command option dicts
-            commands = self.command_options.keys()
-            commands.sort()
+            commands = sorted(self.command_options.keys())
 
         if header is not None:
             print(indent + header)

Modified: python/branches/py3k-importlib/Lib/doctest.py
==============================================================================
--- python/branches/py3k-importlib/Lib/doctest.py	(original)
+++ python/branches/py3k-importlib/Lib/doctest.py	Mon Oct 15 21:39:57 2007
@@ -209,7 +209,8 @@
         filename = _module_relative_path(package, filename)
         if hasattr(package, '__loader__'):
             if hasattr(package.__loader__, 'get_data'):
-                return package.__loader__.get_data(filename).decode('utf-8'), filename
+                return (package.__loader__.get_data(filename).decode(encoding),
+                        filename)
     return open(filename, encoding=encoding).read(), filename
 
 def _indent(s, indent=4):

Modified: python/branches/py3k-importlib/Lib/idlelib/IOBinding.py
==============================================================================
--- python/branches/py3k-importlib/Lib/idlelib/IOBinding.py	(original)
+++ python/branches/py3k-importlib/Lib/idlelib/IOBinding.py	Mon Oct 15 21:39:57 2007
@@ -392,7 +392,7 @@
         text = self.text.get("1.0", "end-1c")
         if self.eol_convention != "\n":
             text = text.replace("\n", self.eol_convention)
-        chars = self.encode(self.text.get("1.0", "end-1c"))
+        chars = self.encode(text)
         try:
             f = open(filename, "wb")
             f.write(chars)

Modified: python/branches/py3k-importlib/Lib/io.py
==============================================================================
--- python/branches/py3k-importlib/Lib/io.py	(original)
+++ python/branches/py3k-importlib/Lib/io.py	Mon Oct 15 21:39:57 2007
@@ -34,7 +34,6 @@
 import sys
 import codecs
 import _fileio
-import io
 import warnings
 
 # open() uses st_blksize whenever we can
@@ -1031,7 +1030,7 @@
         if encoding is None:
             try:
                 encoding = os.device_encoding(buffer.fileno())
-            except (AttributeError, io.UnsupportedOperation):
+            except (AttributeError, UnsupportedOperation):
                 pass
             if encoding is None:
                 try:

Modified: python/branches/py3k-importlib/Lib/test/test_frozen.py
==============================================================================
--- python/branches/py3k-importlib/Lib/test/test_frozen.py	(original)
+++ python/branches/py3k-importlib/Lib/test/test_frozen.py	Mon Oct 15 21:39:57 2007
@@ -38,3 +38,6 @@
 
 def test_main():
     run_unittest(FrozenTests)
+
+if __name__ == "__main__":
+    test_main()

Modified: python/branches/py3k-importlib/Misc/ACKS
==============================================================================
--- python/branches/py3k-importlib/Misc/ACKS	(original)
+++ python/branches/py3k-importlib/Misc/ACKS	Mon Oct 15 21:39:57 2007
@@ -273,6 +273,7 @@
 Shane Hathaway
 Rycharde Hawkes
 Jochen Hayek
+Christian Heimes
 Thomas Heller
 Lance Finn Helsten
 Jonathan Hendry
@@ -667,6 +668,7 @@
 Hector Urtubia
 Atul Varma
 Dmitry Vasiliev
+Alexandre Vassalotti
 Frank Vercruesse
 Mike Verdone
 Jaap Vermeulen

Modified: python/branches/py3k-importlib/Misc/NEWS
==============================================================================
--- python/branches/py3k-importlib/Misc/NEWS	(original)
+++ python/branches/py3k-importlib/Misc/NEWS	Mon Oct 15 21:39:57 2007
@@ -14,6 +14,14 @@
 - The `hotshot` profiler has been removed; use `cProfile` instead.
 
 
+Library
+-------
+
+- When loading an external file using testfile(), the passed-in encoding
+  argument was being ignored if __loader__ is defined and forcing the source to
+  be UTF-8.
+
+
 What's New in Python 3.0a1?
 ==========================
 

Modified: python/branches/py3k-importlib/Modules/_ctypes/callbacks.c
==============================================================================
--- python/branches/py3k-importlib/Modules/_ctypes/callbacks.c	(original)
+++ python/branches/py3k-importlib/Modules/_ctypes/callbacks.c	Mon Oct 15 21:39:57 2007
@@ -34,9 +34,9 @@
 	PyCodeObject *py_code = 0;
 	PyFrameObject *py_frame = 0;
     
-	py_srcfile = PyString_FromString(filename);
+	py_srcfile = PyUnicode_DecodeFSDefault(filename);
 	if (!py_srcfile) goto bad;
-	py_funcname = PyString_FromString(funcname);
+	py_funcname = PyUnicode_FromString(funcname);
 	if (!py_funcname) goto bad;
 	py_globals = PyDict_New();
 	if (!py_globals) goto bad;

Modified: python/branches/py3k-importlib/Modules/_sre.c
==============================================================================
--- python/branches/py3k-importlib/Modules/_sre.c	(original)
+++ python/branches/py3k-importlib/Modules/_sre.c	Mon Oct 15 21:39:57 2007
@@ -1674,6 +1674,15 @@
     void* ptr;
     Py_buffer view;
 
+    /* Unicode objects do not support the buffer API. So, get the data
+       directly instead. */
+    if (PyUnicode_Check(string)) {
+        ptr = (void *)PyUnicode_AS_DATA(string);
+        *p_length = PyUnicode_GET_SIZE(string);
+        *p_charsize = sizeof(Py_UNICODE);
+        return ptr;
+    }
+
     /* get pointer to string buffer */
     view.len = -1;
     buffer = Py_Type(string)->tp_as_buffer;

Modified: python/branches/py3k-importlib/Modules/arraymodule.c
==============================================================================
--- python/branches/py3k-importlib/Modules/arraymodule.c	(original)
+++ python/branches/py3k-importlib/Modules/arraymodule.c	Mon Oct 15 21:39:57 2007
@@ -40,14 +40,6 @@
 
 static PyTypeObject Arraytype;
 
-#ifdef Py_UNICODE_WIDE
-#define PyArr_UNI 'w'
-#define PyArr_UNISTR "w"
-#else
-#define PyArr_UNI 'u'
-#define PyArr_UNISTR "u"
-#endif
-
 #define array_Check(op) PyObject_TypeCheck(op, &Arraytype)
 #define array_CheckExact(op) (Py_Type(op) == &Arraytype)
 
@@ -193,12 +185,14 @@
 	return 0;
 }
 
+
 static PyObject *
 h_getitem(arrayobject *ap, Py_ssize_t i)
 {
 	return PyInt_FromLong((long) ((short *)ap->ob_item)[i]);
 }
 
+
 static int
 h_setitem(arrayobject *ap, Py_ssize_t i, PyObject *v)
 {
@@ -389,9 +383,9 @@
 
 /* Description of types */
 static struct arraydescr descriptors[] = {
-	{'b', sizeof(char), b_getitem, b_setitem, "b"},
-	{'B', sizeof(char), BB_getitem, BB_setitem, "B"},
-	{PyArr_UNI, sizeof(Py_UNICODE), u_getitem, u_setitem, PyArr_UNISTR},
+	{'b', 1, b_getitem, b_setitem, "b"},
+	{'B', 1, BB_getitem, BB_setitem, "B"},
+	{'u', sizeof(Py_UNICODE), u_getitem, u_setitem, "u"},
 	{'h', sizeof(short), h_getitem, h_setitem, "h"},
 	{'H', sizeof(short), HH_getitem, HH_setitem, "H"},
 	{'i', sizeof(int), i_getitem, i_setitem, "i"},
@@ -1418,11 +1412,13 @@
 {
 	Py_UNICODE *ustr;
 	Py_ssize_t n;
+	char typecode;
 
         if (!PyArg_ParseTuple(args, "u#:fromunicode", &ustr, &n))
 		return NULL;
-	if (self->ob_descr->typecode != PyArr_UNI) {
-		PyErr_SetString(PyExc_ValueError,
+	typecode = self->ob_descr->typecode;
+	if ((typecode != 'u')) {
+	        PyErr_SetString(PyExc_ValueError,
 			"fromunicode() may only be called on "
 			"unicode type arrays");
 		return NULL;
@@ -1457,9 +1453,11 @@
 static PyObject *
 array_tounicode(arrayobject *self, PyObject *unused)
 {
-	if (self->ob_descr->typecode != PyArr_UNI) {
+	char typecode;
+	typecode = self->ob_descr->typecode;
+	if ((typecode != 'u')) {
 		PyErr_SetString(PyExc_ValueError,
-			"tounicode() may only be called on unicode type arrays");
+		     "tounicode() may only be called on unicode type arrays");
 		return NULL;
 	}
 	return PyUnicode_FromUnicode((Py_UNICODE *) self->ob_item, Py_Size(self));
@@ -1560,7 +1558,7 @@
 	if (len == 0) {
 		return PyUnicode_FromFormat("array('%c')", typecode);
 	}
-        if (typecode == PyArr_UNI)
+        if ((typecode == 'u'))
 		v = array_tounicode(a, NULL);
 	else
 		v = array_tolist(a, NULL);
@@ -1786,12 +1784,7 @@
 static int
 array_buffer_getbuf(arrayobject *self, Py_buffer *view, int flags)
 {
-        if ((flags & PyBUF_CHARACTER)) {
-                PyErr_SetString(PyExc_TypeError,
-                                "Cannot be a character buffer");
-                return -1;
-        }
-        if ((flags & PyBUF_LOCKDATA)) {
+        if ((flags & PyBUF_LOCK)) {
                 PyErr_SetString(PyExc_BufferError,
                                 "Cannot lock data");
                 return -1;
@@ -1817,6 +1810,11 @@
         view->internal = NULL;
         if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) {
                 view->format = self->ob_descr->formats;
+#ifdef Py_UNICODE_WIDE
+		if (self->ob_descr->typecode == 'u') {
+			view->format = "w";
+		}
+#endif
         }
 
  finish:
@@ -1864,7 +1862,7 @@
 	if (!(initial == NULL || PyList_Check(initial)
 	      || PyBytes_Check(initial)
 	      || PyTuple_Check(initial)
-	      || (c == PyArr_UNI && PyUnicode_Check(initial)))) {
+	      || ((c=='u') && PyUnicode_Check(initial)))) {
 		it = PyObject_GetIter(initial);
 		if (it == NULL)
 			return NULL;
@@ -1966,7 +1964,7 @@
     Type code   C Type             Minimum size in bytes \n\
     'b'         signed integer     1 \n\
     'B'         unsigned integer   1 \n\
-    'u'         Unicode character  2 \n\
+    'u'         Unicode character  2 (see note) \n\
     'h'         signed integer     2 \n\
     'H'         unsigned integer   2 \n\
     'i'         signed integer     2 \n\
@@ -1977,6 +1975,9 @@
     'f'         floating point     4 \n\
     'd'         floating point     8 \n\
 \n\
+NOTE: The 'u' typecode corresponds to Python's unicode character. On \n\
+narrow builds this is 2-bytes on wide builds this is 4-bytes.\n\
+\n\
 The constructor is:\n\
 \n\
 array(typecode [, initializer]) -- create a new array\n\
@@ -2168,6 +2169,10 @@
 initarray(void)
 {
 	PyObject *m;
+	PyObject *typecodes;
+	Py_ssize_t size = 0;
+	register Py_UNICODE *p;
+	struct arraydescr *descr;
 
 	if (PyType_Ready(&Arraytype) < 0)
             return;
@@ -2180,5 +2185,18 @@
 	PyModule_AddObject(m, "ArrayType", (PyObject *)&Arraytype);
         Py_INCREF((PyObject *)&Arraytype);
 	PyModule_AddObject(m, "array", (PyObject *)&Arraytype);
+
+	for (descr=descriptors; descr->typecode != '\0'; descr++) {
+		size++;
+	}
+	
+	typecodes = PyUnicode_FromStringAndSize(NULL, size);
+	p = PyUnicode_AS_UNICODE(typecodes);
+	for (descr = descriptors; descr->typecode != '\0'; descr++) {
+		*p++ = (char)descr->typecode;
+	}
+
+	PyModule_AddObject(m, "typecodes", (PyObject *)typecodes);
+	
 	/* No need to check the error here, the caller will do that */
 }

Modified: python/branches/py3k-importlib/Modules/posixmodule.c
==============================================================================
--- python/branches/py3k-importlib/Modules/posixmodule.c	(original)
+++ python/branches/py3k-importlib/Modules/posixmodule.c	Mon Oct 15 21:39:57 2007
@@ -2135,10 +2135,12 @@
     FILEFINDBUF3   ep;
     APIRET rc;
 
-    if (!PyArg_ParseTuple(args, "t#:listdir", &name, &len))
+    if (!PyArg_ParseTuple(args, "et#:listdir", 
+                          Py_FileSystemDefaultEncoding, &name, &len))
         return NULL;
     if (len >= MAX_PATH) {
-		PyErr_SetString(PyExc_ValueError, "path too long");
+        PyMem_Free(name);
+        PyErr_SetString(PyExc_ValueError, "path too long");
         return NULL;
     }
     strcpy(namebuf, name);
@@ -2149,8 +2151,10 @@
         namebuf[len++] = SEP;
     strcpy(namebuf + len, "*.*");
 
-	if ((d = PyList_New(0)) == NULL)
+    if ((d = PyList_New(0)) == NULL) {
+        PyMem_Free(name);
         return NULL;
+    }
 
     rc = DosFindFirst(namebuf,         /* Wildcard Pattern to Match */
                       &hdir,           /* Handle to Use While Search Directory */
@@ -2161,7 +2165,7 @@
 
     if (rc != NO_ERROR) {
         errno = ENOENT;
-        return posix_error_with_filename(name);
+        return posix_error_with_allocated_filename(name);
     }
 
     if (srchcnt > 0) { /* If Directory is NOT Totally Empty, */
@@ -2191,6 +2195,7 @@
         } while (DosFindNext(hdir, &ep, sizeof(ep), &srchcnt) == NO_ERROR && srchcnt > 0);
     }
 
+    PyMem_Free(name);
     return d;
 #else
 
@@ -5365,7 +5370,7 @@
 #endif
     if (name == NULL)
         return PyErr_NoMemory();
-    result = PyString_FromString(name);
+    result = PyUnicode_DecodeFSDefault(name);
     free(name);
     return result;
 }
@@ -5423,7 +5428,7 @@
 	Py_XDECREF(err);
 	return NULL;
     }
-    return PyString_FromString(buffer);
+    return PyUnicode_DecodeFSDefault(buffer);
 }
 #endif
 

Modified: python/branches/py3k-importlib/Modules/pyexpat.c
==============================================================================
--- python/branches/py3k-importlib/Modules/pyexpat.c	(original)
+++ python/branches/py3k-importlib/Modules/pyexpat.c	Mon Oct 15 21:39:57 2007
@@ -232,13 +232,13 @@
         code = PyString_FromString("");
         if (code == NULL)
             goto failed;
-        name = PyString_FromString(func_name);
+        name = PyUnicode_FromString(func_name);
         if (name == NULL)
             goto failed;
         nulltuple = PyTuple_New(0);
         if (nulltuple == NULL)
             goto failed;
-        filename = PyString_FromString(__FILE__);
+        filename = PyUnicode_DecodeFSDefault(__FILE__);
         handler_info[slot].tb_code =
             PyCode_New(0,		/* argcount */
                        0,       /* kwonlyargcount */

Modified: python/branches/py3k-importlib/Objects/abstract.c
==============================================================================
--- python/branches/py3k-importlib/Objects/abstract.c	(original)
+++ python/branches/py3k-importlib/Objects/abstract.c	Mon Oct 15 21:39:57 2007
@@ -220,11 +220,11 @@
  */
 int
 PyObject_AsCharBuffer(PyObject *obj,
-                      const char **buffer,
-                      Py_ssize_t *buffer_len)
+		      const char **buffer,
+		      Py_ssize_t *buffer_len)
 {
 	PyBufferProcs *pb;
-        Py_buffer view;
+	Py_buffer view;
 
 	if (obj == NULL || buffer == NULL || buffer_len == NULL) {
 		null_error();
@@ -235,30 +235,30 @@
 		PyErr_SetString(PyExc_TypeError,
 				"expected an object with the buffer interface");
 		return -1;
-        }
-        if ((*pb->bf_getbuffer)(obj, &view, PyBUF_CHARACTER)) return -1;
+	}
+	if ((*pb->bf_getbuffer)(obj, &view, PyBUF_SIMPLE)) return -1;
 
 	*buffer = view.buf;
 	*buffer_len = view.len;
-        if (pb->bf_releasebuffer != NULL)
-                (*pb->bf_releasebuffer)(obj, &view);
+	if (pb->bf_releasebuffer != NULL)
+		(*pb->bf_releasebuffer)(obj, &view);
 	return 0;
 }
 
 int
 PyObject_CheckReadBuffer(PyObject *obj)
 {
-	PyBufferProcs *pb = obj->ob_type->tp_as_buffer;                
+	PyBufferProcs *pb = obj->ob_type->tp_as_buffer;		       
 
 	if (pb == NULL ||
 	    pb->bf_getbuffer == NULL)
-                return 0;
-        if ((*pb->bf_getbuffer)(obj, NULL, PyBUF_SIMPLE) == -1) {
-                PyErr_Clear();
-                return 0;
-        }
-        if (*pb->bf_releasebuffer != NULL)
-                (*pb->bf_releasebuffer)(obj, NULL);
+		return 0;
+	if ((*pb->bf_getbuffer)(obj, NULL, PyBUF_SIMPLE) == -1) {
+		PyErr_Clear();
+		return 0;
+	}
+	if (*pb->bf_releasebuffer != NULL)
+		(*pb->bf_releasebuffer)(obj, NULL);
 	return 1;
 }
 
@@ -267,7 +267,7 @@
 			  Py_ssize_t *buffer_len)
 {
 	PyBufferProcs *pb;
-        Py_buffer view;
+	Py_buffer view;
 
 	if (obj == NULL || buffer == NULL || buffer_len == NULL) {
 		null_error();
@@ -275,18 +275,18 @@
 	}
 	pb = obj->ob_type->tp_as_buffer;
 	if (pb == NULL ||
-            pb->bf_getbuffer == NULL) {
+	    pb->bf_getbuffer == NULL) {
 		PyErr_SetString(PyExc_TypeError,
 				"expected an object with a buffer interface");
 		return -1;
 	}
 
-        if ((*pb->bf_getbuffer)(obj, &view, PyBUF_SIMPLE)) return -1;
+	if ((*pb->bf_getbuffer)(obj, &view, PyBUF_SIMPLE)) return -1;
 
 	*buffer = view.buf;
 	*buffer_len = view.len;
-        if (pb->bf_releasebuffer != NULL)
-                (*pb->bf_releasebuffer)(obj, &view);
+	if (pb->bf_releasebuffer != NULL)
+		(*pb->bf_releasebuffer)(obj, &view);
 	return 0;
 }
 
@@ -295,7 +295,7 @@
 			   Py_ssize_t *buffer_len)
 {
 	PyBufferProcs *pb;
-        Py_buffer view;
+	Py_buffer view;
 
 	if (obj == NULL || buffer == NULL || buffer_len == NULL) {
 		null_error();
@@ -303,17 +303,17 @@
 	}
 	pb = obj->ob_type->tp_as_buffer;
 	if (pb == NULL ||
-            pb->bf_getbuffer == NULL ||
-            ((*pb->bf_getbuffer)(obj, &view, PyBUF_WRITABLE) != 0)) {
+	    pb->bf_getbuffer == NULL ||
+	    ((*pb->bf_getbuffer)(obj, &view, PyBUF_WRITABLE) != 0)) {
 		PyErr_SetString(PyExc_TypeError, 
-                                "expected an object with a writable buffer interface");
+				"expected an object with a writable buffer interface");
 		return -1;
 	}
 
 	*buffer = view.buf;
 	*buffer_len = view.len;
-        if (pb->bf_releasebuffer != NULL)
-                (*pb->bf_releasebuffer)(obj, &view);
+	if (pb->bf_releasebuffer != NULL)
+		(*pb->bf_releasebuffer)(obj, &view);
 	return 0;
 }
 
@@ -322,128 +322,128 @@
 int
 PyObject_GetBuffer(PyObject *obj, Py_buffer *view, int flags)
 {
-        if (!PyObject_CheckBuffer(obj)) {
-                PyErr_SetString(PyExc_TypeError,
-                                "object does not have the buffer interface");
-                return -1;
-        }
-        return (*(obj->ob_type->tp_as_buffer->bf_getbuffer))(obj, view, flags);
+	if (!PyObject_CheckBuffer(obj)) {
+		PyErr_SetString(PyExc_TypeError,
+				"object does not have the buffer interface");
+		return -1;
+	}
+	return (*(obj->ob_type->tp_as_buffer->bf_getbuffer))(obj, view, flags);
 }
 
 void
 PyObject_ReleaseBuffer(PyObject *obj, Py_buffer *view)
 {
-        if (obj->ob_type->tp_as_buffer != NULL && 
-            obj->ob_type->tp_as_buffer->bf_releasebuffer != NULL) {
-                (*(obj->ob_type->tp_as_buffer->bf_releasebuffer))(obj, view);
-        }
+	if (obj->ob_type->tp_as_buffer != NULL && 
+	    obj->ob_type->tp_as_buffer->bf_releasebuffer != NULL) {
+		(*(obj->ob_type->tp_as_buffer->bf_releasebuffer))(obj, view);
+	}
 }
 
 
 static int
 _IsFortranContiguous(Py_buffer *view)
 {
-        Py_ssize_t sd, dim;
-        int i;
-        
-        if (view->ndim == 0) return 1;
-        if (view->strides == NULL) return (view->ndim == 1);
-
-        sd = view->itemsize;
-        if (view->ndim == 1) return (view->shape[0] == 1 ||
-                                   sd == view->strides[0]);
-        for (i=0; i<view->ndim; i++) {
-                dim = view->shape[i];
-                if (dim == 0) return 1;
-                if (view->strides[i] != sd) return 0;
-                sd *= dim;
-        }
-        return 1;
+	Py_ssize_t sd, dim;
+	int i;
+	
+	if (view->ndim == 0) return 1;
+	if (view->strides == NULL) return (view->ndim == 1);
+
+	sd = view->itemsize;
+	if (view->ndim == 1) return (view->shape[0] == 1 ||
+				   sd == view->strides[0]);
+	for (i=0; i<view->ndim; i++) {
+		dim = view->shape[i];
+		if (dim == 0) return 1;
+		if (view->strides[i] != sd) return 0;
+		sd *= dim;
+	}
+	return 1;
 }
 
 static int
 _IsCContiguous(Py_buffer *view)
 {
-        Py_ssize_t sd, dim;
-        int i;
-        
-        if (view->ndim == 0) return 1;
-        if (view->strides == NULL) return 1;
-
-        sd = view->itemsize;
-        if (view->ndim == 1) return (view->shape[0] == 1 ||
-                                   sd == view->strides[0]);
-        for (i=view->ndim-1; i>=0; i--) {
-                dim = view->shape[i];
-                if (dim == 0) return 1;
-                if (view->strides[i] != sd) return 0;
-                sd *= dim;
-        }
-        return 1;        
+	Py_ssize_t sd, dim;
+	int i;
+	
+	if (view->ndim == 0) return 1;
+	if (view->strides == NULL) return 1;
+
+	sd = view->itemsize;
+	if (view->ndim == 1) return (view->shape[0] == 1 ||
+				   sd == view->strides[0]);
+	for (i=view->ndim-1; i>=0; i--) {
+		dim = view->shape[i];
+		if (dim == 0) return 1;
+		if (view->strides[i] != sd) return 0;
+		sd *= dim;
+	}
+	return 1;	 
 }
 
 int
 PyBuffer_IsContiguous(Py_buffer *view, char fort)
 {
 
-        if (view->suboffsets != NULL) return 0;
+	if (view->suboffsets != NULL) return 0;
 
-        if (fort == 'C')
-                return _IsCContiguous(view);
-        else if (fort == 'F') 
-                return _IsFortranContiguous(view);
-        else if (fort == 'A')
-                return (_IsCContiguous(view) || _IsFortranContiguous(view));
-        return 0;
+	if (fort == 'C')
+		return _IsCContiguous(view);
+	else if (fort == 'F') 
+		return _IsFortranContiguous(view);
+	else if (fort == 'A')
+		return (_IsCContiguous(view) || _IsFortranContiguous(view));
+	return 0;
 }
 
 
 void* 
 PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices)
 {
-        char* pointer;
-        int i;
-        pointer = (char *)view->buf;
-        for (i = 0; i < view->ndim; i++) {
-                pointer += view->strides[i]*indices[i];
-                if ((view->suboffsets != NULL) && (view->suboffsets[i] >= 0)) {
-                        pointer = *((char**)pointer) + view->suboffsets[i];
-                }
-        }
-        return (void*)pointer;
+	char* pointer;
+	int i;
+	pointer = (char *)view->buf;
+	for (i = 0; i < view->ndim; i++) {
+		pointer += view->strides[i]*indices[i];
+		if ((view->suboffsets != NULL) && (view->suboffsets[i] >= 0)) {
+			pointer = *((char**)pointer) + view->suboffsets[i];
+		}
+	}
+	return (void*)pointer;
 }
 
 
 void 
 _add_one_to_index_F(int nd, Py_ssize_t *index, Py_ssize_t *shape)
 {
-        int k;
-        
-        for (k=0; k<nd; k++) {
-                if (index[k] < shape[k]-1) {
-                        index[k]++;
-                        break;
-                }
-                else {
-                        index[k] = 0;
-                }
-        }
+	int k;
+	
+	for (k=0; k<nd; k++) {
+		if (index[k] < shape[k]-1) {
+			index[k]++;
+			break;
+		}
+		else {
+			index[k] = 0;
+		}
+	}
 }
 
 void 
 _add_one_to_index_C(int nd, Py_ssize_t *index, Py_ssize_t *shape)
 {
-        int k;
+	int k;
 
-        for (k=nd-1; k>=0; k--) {
-                if (index[k] < shape[k]-1) {
-                        index[k]++;
-                        break;
-                }
-                else {
-                        index[k] = 0;
-                }
-        }
+	for (k=nd-1; k>=0; k--) {
+		if (index[k] < shape[k]-1) {
+			index[k]++;
+			break;
+		}
+		else {
+			index[k] = 0;
+		}
+	}
 }
 
   /* view is not checked for consistency in either of these.  It is
@@ -454,235 +454,235 @@
 int 
 PyBuffer_ToContiguous(void *buf, Py_buffer *view, Py_ssize_t len, char fort)
 {
-        int k;
-        void (*addone)(int, Py_ssize_t *, Py_ssize_t *);
-        Py_ssize_t *indices, elements;
-        char *dest, *ptr;
-
-        if (len > view->len) {
-                len = view->len;
-        }
-        
-        if (PyBuffer_IsContiguous(view, fort)) {
-                /* simplest copy is all that is needed */
-                memcpy(buf, view->buf, len);
-                return 0;
-        }
+	int k;
+	void (*addone)(int, Py_ssize_t *, Py_ssize_t *);
+	Py_ssize_t *indices, elements;
+	char *dest, *ptr;
+
+	if (len > view->len) {
+		len = view->len;
+	}
+	
+	if (PyBuffer_IsContiguous(view, fort)) {
+		/* simplest copy is all that is needed */
+		memcpy(buf, view->buf, len);
+		return 0;
+	}
 
-        /* Otherwise a more elaborate scheme is needed */
-        
+	/* Otherwise a more elaborate scheme is needed */
+	
 	/* XXX(nnorwitz): need to check for overflow! */
-        indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*(view->ndim));
-        if (indices == NULL) {
-                PyErr_NoMemory();
-                return -1;
-        }
-        for (k=0; k<view->ndim;k++) {
-                indices[k] = 0;
-        }
-        
-        if (fort == 'F') {
-                addone = _add_one_to_index_F;
-        }
-        else {
-                addone = _add_one_to_index_C;
-        }
-        dest = buf;
-        /* XXX : This is not going to be the fastest code in the world
-                 several optimizations are possible. 
-         */
-        elements = len / view->itemsize;
-        while (elements--) {
-                addone(view->ndim, indices, view->shape);
-                ptr = PyBuffer_GetPointer(view, indices);
-                memcpy(dest, ptr, view->itemsize);
-                dest += view->itemsize;
-        }                
-        PyMem_Free(indices);
-        return 0;
+	indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*(view->ndim));
+	if (indices == NULL) {
+		PyErr_NoMemory();
+		return -1;
+	}
+	for (k=0; k<view->ndim;k++) {
+		indices[k] = 0;
+	}
+	
+	if (fort == 'F') {
+		addone = _add_one_to_index_F;
+	}
+	else {
+		addone = _add_one_to_index_C;
+	}
+	dest = buf;
+	/* XXX : This is not going to be the fastest code in the world
+		 several optimizations are possible. 
+	 */
+	elements = len / view->itemsize;
+	while (elements--) {
+		addone(view->ndim, indices, view->shape);
+		ptr = PyBuffer_GetPointer(view, indices);
+		memcpy(dest, ptr, view->itemsize);
+		dest += view->itemsize;
+	}		 
+	PyMem_Free(indices);
+	return 0;
 }
 
 int
 PyBuffer_FromContiguous(Py_buffer *view, void *buf, Py_ssize_t len, char fort)
 {
-        int k;
-        void (*addone)(int, Py_ssize_t *, Py_ssize_t *);
-        Py_ssize_t *indices, elements;
-        char *src, *ptr;
-
-        if (len > view->len) {
-                len = view->len;
-        }
-
-        if (PyBuffer_IsContiguous(view, fort)) {
-                /* simplest copy is all that is needed */
-                memcpy(view->buf, buf, len);
-                return 0;
-        }
+	int k;
+	void (*addone)(int, Py_ssize_t *, Py_ssize_t *);
+	Py_ssize_t *indices, elements;
+	char *src, *ptr;
+
+	if (len > view->len) {
+		len = view->len;
+	}
 
-        /* Otherwise a more elaborate scheme is needed */
-        
+	if (PyBuffer_IsContiguous(view, fort)) {
+		/* simplest copy is all that is needed */
+		memcpy(view->buf, buf, len);
+		return 0;
+	}
+
+	/* Otherwise a more elaborate scheme is needed */
+	
 	/* XXX(nnorwitz): need to check for overflow! */
-        indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*(view->ndim));
-        if (indices == NULL) {
-                PyErr_NoMemory();
-                return -1;
-        }
-        for (k=0; k<view->ndim;k++) {
-                indices[k] = 0;
-        }
-        
-        if (fort == 'F') {
-                addone = _add_one_to_index_F;
-        }
-        else {
-                addone = _add_one_to_index_C;
-        }
-        src = buf;
-        /* XXX : This is not going to be the fastest code in the world
-                 several optimizations are possible. 
-         */
-        elements = len / view->itemsize;
-        while (elements--) {
-                addone(view->ndim, indices, view->shape);
-                ptr = PyBuffer_GetPointer(view, indices);
-                memcpy(ptr, src, view->itemsize);
-                src += view->itemsize;
-        }
-                
-        PyMem_Free(indices);
-        return 0;
+	indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*(view->ndim));
+	if (indices == NULL) {
+		PyErr_NoMemory();
+		return -1;
+	}
+	for (k=0; k<view->ndim;k++) {
+		indices[k] = 0;
+	}
+	
+	if (fort == 'F') {
+		addone = _add_one_to_index_F;
+	}
+	else {
+		addone = _add_one_to_index_C;
+	}
+	src = buf;
+	/* XXX : This is not going to be the fastest code in the world
+		 several optimizations are possible. 
+	 */
+	elements = len / view->itemsize;
+	while (elements--) {
+		addone(view->ndim, indices, view->shape);
+		ptr = PyBuffer_GetPointer(view, indices);
+		memcpy(ptr, src, view->itemsize);
+		src += view->itemsize;
+	}
+		
+	PyMem_Free(indices);
+	return 0;
 }
 
 int PyObject_CopyData(PyObject *dest, PyObject *src) 
 {
-        Py_buffer view_dest, view_src;
-        int k;
-        Py_ssize_t *indices, elements;
-        char *dptr, *sptr;
-
-        if (!PyObject_CheckBuffer(dest) ||
-            !PyObject_CheckBuffer(src)) {
-                PyErr_SetString(PyExc_TypeError,
-                                "both destination and source must have the "\
-                                "buffer interface");
-                return -1;
-        }
-
-        if (PyObject_GetBuffer(dest, &view_dest, PyBUF_FULL) != 0) return -1;
-        if (PyObject_GetBuffer(src, &view_src, PyBUF_FULL_RO) != 0) {
-                PyObject_ReleaseBuffer(dest, &view_dest);
-                return -1;
-        }
-
-        if (view_dest.len < view_src.len) {
-                PyErr_SetString(PyExc_BufferError, 
-                                "destination is too small to receive data from source");
-                PyObject_ReleaseBuffer(dest, &view_dest);
-                PyObject_ReleaseBuffer(src, &view_src);
-                return -1;
-        }
-
-        if ((PyBuffer_IsContiguous(&view_dest, 'C') && 
-             PyBuffer_IsContiguous(&view_src, 'C')) ||
-            (PyBuffer_IsContiguous(&view_dest, 'F') && 
-             PyBuffer_IsContiguous(&view_src, 'F'))) {
-                /* simplest copy is all that is needed */
-                memcpy(view_dest.buf, view_src.buf, view_src.len);
-                PyObject_ReleaseBuffer(dest, &view_dest);
-                PyObject_ReleaseBuffer(src, &view_src);
-                return 0;
-        }
+	Py_buffer view_dest, view_src;
+	int k;
+	Py_ssize_t *indices, elements;
+	char *dptr, *sptr;
+
+	if (!PyObject_CheckBuffer(dest) ||
+	    !PyObject_CheckBuffer(src)) {
+		PyErr_SetString(PyExc_TypeError,
+				"both destination and source must have the "\
+				"buffer interface");
+		return -1;
+	}
+
+	if (PyObject_GetBuffer(dest, &view_dest, PyBUF_FULL) != 0) return -1;
+	if (PyObject_GetBuffer(src, &view_src, PyBUF_FULL_RO) != 0) {
+		PyObject_ReleaseBuffer(dest, &view_dest);
+		return -1;
+	}
+
+	if (view_dest.len < view_src.len) {
+		PyErr_SetString(PyExc_BufferError, 
+				"destination is too small to receive data from source");
+		PyObject_ReleaseBuffer(dest, &view_dest);
+		PyObject_ReleaseBuffer(src, &view_src);
+		return -1;
+	}
+
+	if ((PyBuffer_IsContiguous(&view_dest, 'C') && 
+	     PyBuffer_IsContiguous(&view_src, 'C')) ||
+	    (PyBuffer_IsContiguous(&view_dest, 'F') && 
+	     PyBuffer_IsContiguous(&view_src, 'F'))) {
+		/* simplest copy is all that is needed */
+		memcpy(view_dest.buf, view_src.buf, view_src.len);
+		PyObject_ReleaseBuffer(dest, &view_dest);
+		PyObject_ReleaseBuffer(src, &view_src);
+		return 0;
+	}
 
-        /* Otherwise a more elaborate copy scheme is needed */
-        
+	/* Otherwise a more elaborate copy scheme is needed */
+	
 	/* XXX(nnorwitz): need to check for overflow! */
-        indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*view_src.ndim);
-        if (indices == NULL) {
-                PyErr_NoMemory();
-                PyObject_ReleaseBuffer(dest, &view_dest);
-                PyObject_ReleaseBuffer(src, &view_src);
-                return -1;
-        }
-        for (k=0; k<view_src.ndim;k++) {
-                indices[k] = 0;
-        }        
-        elements = 1;
-        for (k=0; k<view_src.ndim; k++) {
+	indices = (Py_ssize_t *)PyMem_Malloc(sizeof(Py_ssize_t)*view_src.ndim);
+	if (indices == NULL) {
+		PyErr_NoMemory();
+		PyObject_ReleaseBuffer(dest, &view_dest);
+		PyObject_ReleaseBuffer(src, &view_src);
+		return -1;
+	}
+	for (k=0; k<view_src.ndim;k++) {
+		indices[k] = 0;
+	}	 
+	elements = 1;
+	for (k=0; k<view_src.ndim; k++) {
 		/* XXX(nnorwitz): can this overflow? */
-                elements *= view_src.shape[k];
-        }
-        while (elements--) {
-                _add_one_to_index_C(view_src.ndim, indices, view_src.shape);
-                dptr = PyBuffer_GetPointer(&view_dest, indices);
-                sptr = PyBuffer_GetPointer(&view_src, indices);
-                memcpy(dptr, sptr, view_src.itemsize);
-        }                
-        PyMem_Free(indices);
-        PyObject_ReleaseBuffer(dest, &view_dest);
-        PyObject_ReleaseBuffer(src, &view_src);
-        return 0;
+		elements *= view_src.shape[k];
+	}
+	while (elements--) {
+		_add_one_to_index_C(view_src.ndim, indices, view_src.shape);
+		dptr = PyBuffer_GetPointer(&view_dest, indices);
+		sptr = PyBuffer_GetPointer(&view_src, indices);
+		memcpy(dptr, sptr, view_src.itemsize);
+	}		 
+	PyMem_Free(indices);
+	PyObject_ReleaseBuffer(dest, &view_dest);
+	PyObject_ReleaseBuffer(src, &view_src);
+	return 0;
 }
 
 void
 PyBuffer_FillContiguousStrides(int nd, Py_ssize_t *shape,
-                               Py_ssize_t *strides, int itemsize,
-                               char fort)
+			       Py_ssize_t *strides, int itemsize,
+			       char fort)
 {
-        int k;
-        Py_ssize_t sd;
-        
-        sd = itemsize;
-        if (fort == 'F') {
-                for (k=0; k<nd; k++) {
-                        strides[k] = sd;
-                        sd *= shape[k];
-                }                                      
-        }
-        else {
-                for (k=nd-1; k>=0; k--) {
-                        strides[k] = sd;
-                        sd *= shape[k];
-                }
-        }
-        return;
+	int k;
+	Py_ssize_t sd;
+	
+	sd = itemsize;
+	if (fort == 'F') {
+		for (k=0; k<nd; k++) {
+			strides[k] = sd;
+			sd *= shape[k];
+		}				       
+	}
+	else {
+		for (k=nd-1; k>=0; k--) {
+			strides[k] = sd;
+			sd *= shape[k];
+		}
+	}
+	return;
 }
 
 int
 PyBuffer_FillInfo(Py_buffer *view, void *buf, Py_ssize_t len,
-              int readonly, int flags)
-{        
-        if (view == NULL) return 0;
-        if (((flags & PyBUF_LOCKDATA) == PyBUF_LOCKDATA) && 
-            readonly != -1) {
-                PyErr_SetString(PyExc_BufferError, 
-                                "Cannot make this object read-only.");
-                return -1;
-        }
-        if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
-            readonly == 1) {
-                PyErr_SetString(PyExc_BufferError,
-                                "Object is not writable.");
-                return -1;
-        }
-        
-        view->buf = buf;
-        view->len = len;
-        view->readonly = readonly;
-        view->itemsize = 1;
-        view->format = NULL;
-        if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) 
-                view->format = "B";
-        view->ndim = 1;
-        view->shape = NULL;
-        if ((flags & PyBUF_ND) == PyBUF_ND)
-                view->shape = &(view->len);
-        view->strides = NULL;
-        if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES)
-                view->strides = &(view->itemsize);
-        view->suboffsets = NULL;
-        view->internal = NULL;
-        return 0;
+	      int readonly, int flags)
+{	 
+	if (view == NULL) return 0;
+	if (((flags & PyBUF_LOCK) == PyBUF_LOCK) && 
+	    readonly >= 0) {
+		PyErr_SetString(PyExc_BufferError, 
+				"Cannot lock this object.");
+		return -1;
+	}
+	if (((flags & PyBUF_WRITABLE) == PyBUF_WRITABLE) &&
+	    (readonly == 1)) {
+		PyErr_SetString(PyExc_BufferError,
+				"Object is not writable.");
+		return -1;
+	}
+	
+	view->buf = buf;
+	view->len = len;
+	view->readonly = readonly;
+	view->itemsize = 1;
+	view->format = NULL;
+	if ((flags & PyBUF_FORMAT) == PyBUF_FORMAT) 
+		view->format = "B";
+	view->ndim = 1;
+	view->shape = NULL;
+	if ((flags & PyBUF_ND) == PyBUF_ND)
+		view->shape = &(view->len);
+	view->strides = NULL;
+	if ((flags & PyBUF_STRIDES) == PyBUF_STRIDES)
+		view->strides = &(view->itemsize);
+	view->suboffsets = NULL;
+	view->internal = NULL;
+	return 0;
 }
 
 /* Operations on numbers */
@@ -1025,7 +1025,7 @@
 		Py_DECREF(result);
 		if (m != NULL) {
 			binaryfunc f = NULL;
-                        f = m->sq_inplace_concat;
+			f = m->sq_inplace_concat;
 			if (f == NULL)
 				f = m->sq_concat;
 			if (f != NULL)
@@ -1304,8 +1304,8 @@
 		PyObject *res = m->nb_float(o);
 		if (res && !PyFloat_Check(res)) {
 			PyErr_Format(PyExc_TypeError,
-		          "__float__ returned non-float (type %.200s)",
-		          res->ob_type->tp_name);
+			  "__float__ returned non-float (type %.200s)",
+			  res->ob_type->tp_name);
 			Py_DECREF(res);
 			return NULL;
 		}
@@ -1384,7 +1384,7 @@
 		return m->sq_concat(s, o);
 
 	/* Instances of user classes defining an __add__() method only
-	   have an nb_add slot, not an sq_concat slot.  So we fall back
+	   have an nb_add slot, not an sq_concat slot.	So we fall back
 	   to nb_add if both arguments appear to be sequences. */
 	if (PySequence_Check(s) && PySequence_Check(o)) {
 		PyObject *result = binary_op1(s, o, NB_SLOT(nb_add));
@@ -1629,7 +1629,7 @@
 PySequence_Tuple(PyObject *v)
 {
 	PyObject *it;  /* iter(v) */
-	Py_ssize_t n;         /* guess for result tuple size */
+	Py_ssize_t n;	      /* guess for result tuple size */
 	PyObject *result;
 	Py_ssize_t j;
 
@@ -1662,7 +1662,7 @@
 			return NULL;
 		}
 		PyErr_Clear();
-		n = 10;  /* arbitrary */
+		n = 10;	 /* arbitrary */
 	}
 	result = PyTuple_New(n);
 	if (result == NULL)
@@ -1718,7 +1718,7 @@
 PySequence_List(PyObject *v)
 {
 	PyObject *result;  /* result list */
-	PyObject *rv;      /* return value from PyList_Extend */
+	PyObject *rv;	   /* return value from PyList_Extend */
 
 	if (v == NULL)
 		return null_error();
@@ -1749,7 +1749,7 @@
 		return v;
 	}
 
- 	it = PyObject_GetIter(v);
+	it = PyObject_GetIter(v);
 	if (it == NULL) {
 		if (PyErr_ExceptionMatches(PyExc_TypeError))
 			PyErr_SetString(PyExc_TypeError, m);
@@ -1763,9 +1763,9 @@
 }
 
 /* Iterate over seq.  Result depends on the operation:
-   PY_ITERSEARCH_COUNT:  -1 if error, else # of times obj appears in seq.
-   PY_ITERSEARCH_INDEX:  0-based index of first occurence of obj in seq;
-   	set ValueError and return -1 if none found; also return -1 on error.
+   PY_ITERSEARCH_COUNT:	 -1 if error, else # of times obj appears in seq.
+   PY_ITERSEARCH_INDEX:	 0-based index of first occurence of obj in seq;
+	set ValueError and return -1 if none found; also return -1 on error.
    Py_ITERSEARCH_CONTAINS:  return 1 if obj in seq, else 0; -1 on error.
 */
 Py_ssize_t
@@ -1839,7 +1839,7 @@
 		goto Done;
 
 	PyErr_SetString(PyExc_ValueError,
-		        "sequence.index(x): x not in sequence");
+			"sequence.index(x): x not in sequence");
 	/* fall into failure code */
 Fail:
 	n = -1;
@@ -1865,7 +1865,7 @@
 {
 	Py_ssize_t result;
 	PySequenceMethods *sqm = seq->ob_type->tp_as_sequence;
-        if (sqm != NULL && sqm->sq_contains != NULL)
+	if (sqm != NULL && sqm->sq_contains != NULL)
 		return (*sqm->sq_contains)(seq, ob);
 	result = _PySequence_IterSearch(seq, ob, PY_ITERSEARCH_CONTAINS);
 	return Py_SAFE_DOWNCAST(result, Py_ssize_t, int);
@@ -1890,7 +1890,7 @@
 int
 PyMapping_Check(PyObject *o)
 {
-	return  o && o->ob_type->tp_as_mapping &&
+	return	o && o->ob_type->tp_as_mapping &&
 		o->ob_type->tp_as_mapping->mp_subscript;
 }
 
@@ -2044,7 +2044,7 @@
 PyObject *
 PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
 {
-        ternaryfunc call;
+	ternaryfunc call;
 
 	if ((call = func->ob_type->tp_call) != NULL) {
 		PyObject *result;
@@ -2308,7 +2308,7 @@
  * produce exactly the same results: NULL is returned and no error is set.
  *
  * If some exception other than AttributeError is raised, then NULL is also
- * returned, but the exception is not cleared.  That's because we want the
+ * returned, but the exception is not cleared.	That's because we want the
  * exception to be propagated along.
  *
  * Callers are expected to test for PyErr_Occurred() when the return value
@@ -2336,7 +2336,7 @@
 		return NULL;
 	}
 	if (!PyTuple_Check(bases)) {
-	        Py_DECREF(bases);
+		Py_DECREF(bases);
 		return NULL;
 	}
 	return bases;
@@ -2428,18 +2428,18 @@
 	else if (PyTuple_Check(cls)) {
 		Py_ssize_t i, n;
 
-                if (!recursion_depth) {
-                    PyErr_SetString(PyExc_RuntimeError,
-                                    "nest level of tuple too deep");
-                    return -1;
-                }
+		if (!recursion_depth) {
+		    PyErr_SetString(PyExc_RuntimeError,
+				    "nest level of tuple too deep");
+		    return -1;
+		}
 
 		n = PyTuple_GET_SIZE(cls);
 		for (i = 0; i < n; i++) {
 			retval = recursive_isinstance(
-                                    inst,
-                                    PyTuple_GET_ITEM(cls, i),
-                                    recursion_depth-1);
+				    inst,
+				    PyTuple_GET_ITEM(cls, i),
+				    recursion_depth-1);
 			if (retval != 0)
 				break;
 		}
@@ -2490,12 +2490,12 @@
 	return recursive_isinstance(inst, cls, Py_GetRecursionLimit());
 }
 
-static  int
+static	int
 recursive_issubclass(PyObject *derived, PyObject *cls, int recursion_depth)
 {
 	int retval;
 
-        {
+	{
 		if (!check_class(derived,
 				 "issubclass() arg 1 must be a class"))
 			return -1;
@@ -2504,16 +2504,16 @@
 			Py_ssize_t i;
 			Py_ssize_t n = PyTuple_GET_SIZE(cls);
 
-                        if (!recursion_depth) {
-                            PyErr_SetString(PyExc_RuntimeError,
-                                            "nest level of tuple too deep");
-                            return -1;
-                        }
+			if (!recursion_depth) {
+			    PyErr_SetString(PyExc_RuntimeError,
+					    "nest level of tuple too deep");
+			    return -1;
+			}
 			for (i = 0; i < n; ++i) {
 				retval = recursive_issubclass(
-                                            derived,
-                                            PyTuple_GET_ITEM(cls, i),
-                                            recursion_depth-1);
+					    derived,
+					    PyTuple_GET_ITEM(cls, i),
+					    recursion_depth-1);
 				if (retval != 0) {
 					/* either found it, or got an error */
 					return retval;
@@ -2590,7 +2590,7 @@
  * If the iteration terminates normally, return NULL and clear the
  * PyExc_StopIteration exception (if it was set).  PyErr_Occurred()
  * will be false.
- * Else return the next object.  PyErr_Occurred() will be false.
+ * Else return the next object.	 PyErr_Occurred() will be false.
  */
 PyObject *
 PyIter_Next(PyObject *iter)

Modified: python/branches/py3k-importlib/Objects/codeobject.c
==============================================================================
--- python/branches/py3k-importlib/Objects/codeobject.c	(original)
+++ python/branches/py3k-importlib/Objects/codeobject.c	Mon Oct 15 21:39:57 2007
@@ -50,6 +50,7 @@
 {
 	PyCodeObject *co;
 	Py_ssize_t i;
+
 	/* Check argument types */
 	if (argcount < 0 || nlocals < 0 ||
 	    code == NULL ||
@@ -58,20 +59,16 @@
 	    varnames == NULL || !PyTuple_Check(varnames) ||
 	    freevars == NULL || !PyTuple_Check(freevars) ||
 	    cellvars == NULL || !PyTuple_Check(cellvars) ||
-	    name == NULL || (!PyString_Check(name) && !PyUnicode_Check(name)) ||
-	    filename == NULL || !PyString_Check(filename) ||
+	    name == NULL || !PyUnicode_Check(name) ||
+	    filename == NULL || !PyUnicode_Check(filename) ||
 	    lnotab == NULL || !PyString_Check(lnotab) ||
 	    !PyObject_CheckReadBuffer(code)) {
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	if (PyString_Check(name)) {
-		name = PyUnicode_FromString(PyString_AS_STRING(name));
-		if (name == NULL)
-			return NULL;
-	} else {
-		Py_INCREF(name);
-	}
+	Py_INCREF(name);
+	Py_INCREF(filename);
+
 	intern_strings(names);
 	intern_strings(varnames);
 	intern_strings(freevars);
@@ -299,8 +296,8 @@
 
 	if (co->co_firstlineno != 0)
 		lineno = co->co_firstlineno;
-	if (co->co_filename && PyString_Check(co->co_filename))
-		filename = PyString_AS_STRING(co->co_filename);
+	if (co->co_filename && PyUnicode_Check(co->co_filename))
+		filename = PyUnicode_AsString(co->co_filename);
 	return PyUnicode_FromFormat(
 	                "<code object %.100U at %p, file \"%.300s\", line %d>",
 	                co->co_name, co, filename, lineno);

Modified: python/branches/py3k-importlib/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k-importlib/Objects/memoryobject.c	(original)
+++ python/branches/py3k-importlib/Objects/memoryobject.c	Mon Oct 15 21:39:57 2007
@@ -196,7 +196,9 @@
                 a contiguous buffer if it is not. The view will point to
                 the shadow buffer which can be written to and then
                 will be copied back into the other buffer when the memory
-                view is de-allocated.
+                view is de-allocated.  While the shadow buffer is 
+		being used, it will have an exclusive write lock on 
+		the original buffer. 
  */
 
 PyObject *
@@ -224,7 +226,7 @@
                 flags = PyBUF_FULL;
                 break;
         case PyBUF_SHADOW:
-                flags = PyBUF_FULL_LCK;
+                flags = PyBUF_FULL_XLCK;
                 break;
         }
 
@@ -431,11 +433,7 @@
 static PyObject *
 memory_repr(PyMemoryViewObject *self)
 {
-	/* XXX(nnorwitz): the code should be different or remove condition. */
-	if (self->base == NULL)
-		return PyUnicode_FromFormat("<memory at %p>", self);
-	else
-		return PyUnicode_FromFormat("<memory at %p>", self);
+	return PyUnicode_FromFormat("<memory at %p>", self);
 }
 
 
@@ -502,6 +500,14 @@
 			/* Return a bytes object */
 			char *ptr;
 			ptr = (char *)view->buf;
+			if (result < 0) {
+				result += view->shape[0];
+			}
+			if ((result < 0) || (result > view->shape[0])) {
+				PyErr_SetString(PyExc_IndexError,
+						"index out of bounds");
+				return NULL;
+			}
 			if (view->strides == NULL)
 				ptr += view->itemsize * result;
 			else
@@ -517,14 +523,20 @@
 			/* Return a new memory-view object */
 			Py_buffer newview;
 			memset(&newview, 0, sizeof(newview));
+			/* XXX:  This needs to be fixed so it 
+			         actually returns a sub-view
+			*/
 			return PyMemoryView_FromMemory(&newview);
 		}
 	}
 
+	/* Need to support getting a sliced view */
         Py_INCREF(Py_NotImplemented);
         return Py_NotImplemented;
 }
 
+
+/* Need to support assigning memory if we can */
 static int
 memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value)
 {

Modified: python/branches/py3k-importlib/Objects/moduleobject.c
==============================================================================
--- python/branches/py3k-importlib/Objects/moduleobject.c	(original)
+++ python/branches/py3k-importlib/Objects/moduleobject.c	Mon Oct 15 21:39:57 2007
@@ -86,12 +86,12 @@
 	d = ((PyModuleObject *)m)->md_dict;
 	if (d == NULL ||
 	    (fileobj = PyDict_GetItemString(d, "__file__")) == NULL ||
-	    !PyString_Check(fileobj))
+	    !PyUnicode_Check(fileobj))
 	{
 		PyErr_SetString(PyExc_SystemError, "module filename missing");
 		return NULL;
 	}
-	return PyString_AsString(fileobj);
+	return PyUnicode_AsString(fileobj);
 }
 
 void

Modified: python/branches/py3k-importlib/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k-importlib/Objects/unicodeobject.c	(original)
+++ python/branches/py3k-importlib/Objects/unicodeobject.c	Mon Oct 15 21:39:57 2007
@@ -117,7 +117,11 @@
 
 /* Default encoding to use and assume when NULL is passed as encoding
    parameter; it is fixed to "utf-8".  Always use the
-   PyUnicode_GetDefaultEncoding() API to access this global. */
+   PyUnicode_GetDefaultEncoding() API to access this global.
+
+   Don't forget to alter Py_FileSystemDefaultEncoding() if you change the
+   hard coded default!
+*/
 static const char unicode_default_encoding[] = "utf-8";
 
 Py_UNICODE
@@ -1231,6 +1235,35 @@
     return v;
 }
 
+PyObject*
+PyUnicode_DecodeFSDefault(const char *s)
+{
+    Py_ssize_t size = (Py_ssize_t)strlen(s);
+
+    /* During the early bootstrapping process, Py_FileSystemDefaultEncoding
+       can be undefined. If it is case, decode using UTF-8. The following assumes
+       that Py_FileSystemDefaultEncoding is set to a built-in encoding during the
+       bootstrapping process where the codecs aren't ready yet.
+    */
+    if (Py_FileSystemDefaultEncoding) {
+#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
+        if (strcmp(Py_FileSystemDefaultEncoding, "mbcs")) {
+            return PyUnicode_DecodeMBCS(s, size, "replace");
+        }
+#elif defined(__APPLE__)
+        if (strcmp(Py_FileSystemDefaultEncoding, "utf-8")) {
+            return PyUnicode_DecodeUTF8(s, size, "replace");
+        }
+#endif
+        return PyUnicode_Decode(s, size,
+                                Py_FileSystemDefaultEncoding,
+                                "replace");
+    }
+    else {
+        return PyUnicode_DecodeUTF8(s, size, "replace");
+    }
+}
+
 char*
 PyUnicode_AsStringAndSize(PyObject *unicode, Py_ssize_t *psize)
 {
@@ -8113,19 +8146,6 @@
 };
 
 
-static int
-unicode_buffer_getbuffer(PyUnicodeObject *self, Py_buffer *view, int flags)
-{
-
-    if (flags & PyBUF_CHARACTER) {
-        PyErr_SetString(PyExc_SystemError, "can't use str as char buffer");
-        return -1;
-    }
-    return PyBuffer_FillInfo(view, (void *)self->str,
-                             PyUnicode_GET_DATA_SIZE(self), 1, flags);
-}
-
-
 /* Helpers for PyUnicode_Format() */
 
 static PyObject *
@@ -8819,11 +8839,6 @@
     return NULL;
 }
 
-static PyBufferProcs unicode_as_buffer = {
-    (getbufferproc) unicode_buffer_getbuffer,
-    NULL,
-};
-
 static PyObject *
 unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 
@@ -8907,7 +8922,7 @@
     (reprfunc) unicode_str,	 	/* tp_str */
     PyObject_GenericGetAttr, 		/* tp_getattro */
     0,			 		/* tp_setattro */
-    &unicode_as_buffer,			/* tp_as_buffer */
+    0, 					/* tp_as_buffer */
     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | 
         Py_TPFLAGS_UNICODE_SUBCLASS,	/* tp_flags */
     unicode_doc,			/* tp_doc */

Modified: python/branches/py3k-importlib/PC/VC6/pythoncore.dsp
==============================================================================
--- python/branches/py3k-importlib/PC/VC6/pythoncore.dsp	(original)
+++ python/branches/py3k-importlib/PC/VC6/pythoncore.dsp	Mon Oct 15 21:39:57 2007
@@ -137,10 +137,6 @@
 # End Source File
 # Begin Source File
 
-SOURCE=..\..\Modules\_hotshot.c
-# End Source File
-# Begin Source File
-
 SOURCE=..\..\Modules\_localemodule.c
 # End Source File
 # Begin Source File

Modified: python/branches/py3k-importlib/PC/config.c
==============================================================================
--- python/branches/py3k-importlib/PC/config.c	(original)
+++ python/branches/py3k-importlib/PC/config.c	Mon Oct 15 21:39:57 2007
@@ -99,7 +99,6 @@
 
         {"_codecs", init_codecs},
 	{"_weakref", init_weakref},
-	{"_hotshot", init_hotshot},
 	{"_random", init_random},
         {"_bisect", init_bisect},
         {"_heapq", init_heapq},

Modified: python/branches/py3k-importlib/PC/os2emx/Makefile
==============================================================================
--- python/branches/py3k-importlib/PC/os2emx/Makefile	(original)
+++ python/branches/py3k-importlib/PC/os2emx/Makefile	Mon Oct 15 21:39:57 2007
@@ -437,8 +437,7 @@
 # Python modules to be dynamically loaded that need explicit build rules
 #  (either multiple source files and/or non-standard module naming)
 #  (NOTE: use shortened names for modules affected by 8 char name limit)
-HARDEXTMODULES=	_hotshot \
-		_socket \
+HARDEXTMODULES=	_socket \
 		_testcap \
 		unicoded
 
@@ -567,9 +566,6 @@
 # awkward handling (due e.g. to non-std naming, or multiple source files)
 # - standard modules
 
-_hotshot$(MODULE.EXT): $(OUT)_hotshot$O $(OUT)_hotshot_m.def $(PYTHON.IMPLIB)
-	$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
-
 _socket$(MODULE.EXT): $(OUT)socketmodule$O $(OUT)_socket_m.def $(PYTHON.IMPLIB)
 	$(LD) $(LDFLAGS.DLL) -o $@ $(^^) $(L^) $(LIBS)
 

Modified: python/branches/py3k-importlib/PC/os2emx/config.c
==============================================================================
--- python/branches/py3k-importlib/PC/os2emx/config.c	(original)
+++ python/branches/py3k-importlib/PC/os2emx/config.c	Mon Oct 15 21:39:57 2007
@@ -75,7 +75,6 @@
 #if !HAVE_DYNAMIC_LOADING
 extern void init_curses();
 extern void init_curses_panel();
-extern void init_hotshot();
 extern void init_testcapi();
 extern void initbz2();
 extern void initfpectl();
@@ -134,7 +133,6 @@
 #if !HAVE_DYNAMIC_LOADING
 	{"_curses", init_curses},
 	{"_curses_panel", init_curses_panel},
-	{"_hotshot", init_hotshot},
 	{"_testcapi", init_testcapi},
 	{"bz2", initbz2},
 	{"fpectl", initfpectl},

Modified: python/branches/py3k-importlib/PCbuild8/pythoncore/pythoncore.vcproj
==============================================================================
--- python/branches/py3k-importlib/PCbuild8/pythoncore/pythoncore.vcproj	(original)
+++ python/branches/py3k-importlib/PCbuild8/pythoncore/pythoncore.vcproj	Mon Oct 15 21:39:57 2007
@@ -1414,10 +1414,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\Modules\_hotshot.c"
-				>
-			</File>
-			<File
 				RelativePath="..\..\Modules\_localemodule.c"
 				>
 			</File>

Modified: python/branches/py3k-importlib/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k-importlib/Python/bltinmodule.c	(original)
+++ python/branches/py3k-importlib/Python/bltinmodule.c	Mon Oct 15 21:39:57 2007
@@ -10,6 +10,9 @@
 
 /* The default encoding used by the platform file system APIs
    Can remain NULL for all platforms that don't have such a concept
+
+   Don't forget to modify PyUnicode_DecodeFSDefault() if you touch any of the
+   values for Py_FileSystemDefaultEncoding!
 */
 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
 const char *Py_FileSystemDefaultEncoding = "mbcs";

Modified: python/branches/py3k-importlib/Python/ceval.c
==============================================================================
--- python/branches/py3k-importlib/Python/ceval.c	(original)
+++ python/branches/py3k-importlib/Python/ceval.c	Mon Oct 15 21:39:57 2007
@@ -767,7 +767,7 @@
 	lltrace = PyDict_GetItemString(f->f_globals, "__lltrace__") != NULL;
 #endif
 #if defined(Py_DEBUG) || defined(LLTRACE)
-	filename = PyString_AsString(co->co_filename);
+	filename = PyUnicode_AsString(co->co_filename);
 #endif
 
 	why = WHY_NOT;
@@ -2565,7 +2565,7 @@
 		if (argcount > co->co_argcount) {
 			if (!(co->co_flags & CO_VARARGS)) {
 				PyErr_Format(PyExc_TypeError,
-				    "%S() takes %s %d "
+				    "%U() takes %s %d "
 				    "%spositional argument%s (%d given)",
 				    co->co_name,
 				    defcount ? "at most" : "exactly",
@@ -2599,7 +2599,7 @@
 			int j;
 			if (keyword == NULL || !PyUnicode_Check(keyword)) {
 				PyErr_Format(PyExc_TypeError,
-				    "%S() keywords must be strings",
+				    "%U() keywords must be strings",
 				    co->co_name);
 				goto fail;
 			}
@@ -2622,7 +2622,7 @@
 			if (j >= co->co_argcount + co->co_kwonlyargcount) {
 				if (kwdict == NULL) {
 					PyErr_Format(PyExc_TypeError,
-					    "%S() got an unexpected "
+					    "%U() got an unexpected "
 					    "keyword argument '%S'",
 					    co->co_name,
 					    keyword);
@@ -2633,7 +2633,7 @@
 			else {
 				if (GETLOCAL(j) != NULL) {
 					PyErr_Format(PyExc_TypeError,
-					     "%S() got multiple "
+					     "%U() got multiple "
 					     "values for keyword "
 					     "argument '%S'",
 					     co->co_name,
@@ -2661,7 +2661,7 @@
 					continue;
 				}
 				PyErr_Format(PyExc_TypeError,
-					"%S() needs keyword-only argument %S",
+					"%U() needs keyword-only argument %S",
 					co->co_name, name);
 				goto fail;
 			}
@@ -2671,7 +2671,7 @@
 			for (i = argcount; i < m; i++) {
 				if (GETLOCAL(i) == NULL) {
 					PyErr_Format(PyExc_TypeError,
-					    "%S() takes %s %d "
+					    "%U() takes %s %d "
 					    "%spositional argument%s "
 					    "(%d given)",
 					    co->co_name,
@@ -2699,7 +2699,7 @@
 	else {
 		if (argcount > 0 || kwcount > 0) {
 			PyErr_Format(PyExc_TypeError,
-				     "%S() takes no arguments (%d given)",
+				     "%U() takes no arguments (%d given)",
 				     co->co_name,
 				     argcount + kwcount);
 			goto fail;

Modified: python/branches/py3k-importlib/Python/compile.c
==============================================================================
--- python/branches/py3k-importlib/Python/compile.c	(original)
+++ python/branches/py3k-importlib/Python/compile.c	Mon Oct 15 21:39:57 2007
@@ -1247,7 +1247,7 @@
 				PyObject_REPR(name), 
 				PyString_AS_STRING(c->u->u_name), 
 				reftype, arg,
-				PyString_AS_STRING(co->co_name),
+				PyUnicode_AsString(co->co_name),
 				PyObject_REPR(co->co_freevars));
 			Py_FatalError("compiler_make_closure()");
 		}
@@ -4001,7 +4001,7 @@
 	freevars = dict_keys_inorder(c->u->u_freevars, PyTuple_Size(cellvars));
 	if (!freevars)
 	    goto error;
-	filename = PyString_FromString(c->c_filename);
+	filename = PyUnicode_DecodeFSDefault(c->c_filename);
 	if (!filename)
 		goto error;
 

Modified: python/branches/py3k-importlib/Python/frozen.c
==============================================================================
--- python/branches/py3k-importlib/Python/frozen.c	(original)
+++ python/branches/py3k-importlib/Python/frozen.c	Mon Oct 15 21:39:57 2007
@@ -17,7 +17,7 @@
 	131,1,0,1,100,1,0,83,40,2,0,0,0,117,14,0,
 	0,0,72,101,108,108,111,32,119,111,114,108,100,46,46,46,
 	78,40,1,0,0,0,117,5,0,0,0,112,114,105,110,116,
-	40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,115,
+	40,0,0,0,0,40,0,0,0,0,40,0,0,0,0,117,
 	8,0,0,0,104,101,108,108,111,46,112,121,117,8,0,0,
 	0,60,109,111,100,117,108,101,62,1,0,0,0,115,0,0,
 	0,0,

Modified: python/branches/py3k-importlib/Python/getargs.c
==============================================================================
--- python/branches/py3k-importlib/Python/getargs.c	(original)
+++ python/branches/py3k-importlib/Python/getargs.c	Mon Oct 15 21:39:57 2007
@@ -1237,7 +1237,9 @@
                         (*pb->bf_releasebuffer)(arg, &view);
 		break;
 	}
-		
+
+	  /*TEO: This can be eliminated --- here only for backward
+	    compatibility */
 	case 't': { /* 8-bit character buffer, read-only access */
 		char **p = va_arg(*p_va, char **);
 		PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
@@ -1250,10 +1252,10 @@
 				arg, msgbuf, bufsize);
 		if (pb == NULL || pb->bf_getbuffer == NULL)
 			return converterr(
-				"string or read-only character buffer",
+				"bytes or read-only character buffer",
 				arg, msgbuf, bufsize);
 
-		if ((*pb->bf_getbuffer)(arg, &view, PyBUF_CHARACTER) != 0) 
+		if ((*pb->bf_getbuffer)(arg, &view, PyBUF_SIMPLE) != 0) 
 			return converterr("string or single-segment read-only buffer",
                                           arg, msgbuf, bufsize);
 

Modified: python/branches/py3k-importlib/Python/import.c
==============================================================================
--- python/branches/py3k-importlib/Python/import.c	(original)
+++ python/branches/py3k-importlib/Python/import.c	Mon Oct 15 21:39:57 2007
@@ -74,10 +74,11 @@
 		      3040 (added signature annotations)
 		      3050 (print becomes a function)
 		      3060 (PEP 3115 metaclass syntax)
-          3070 (PEP 3109 raise changes)
+		      3070 (PEP 3109 raise changes)
+		      3080 (PEP 3137 make __file__ and __name__ unicode)
 .
 */
-#define MAGIC (3070 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (3080 | ((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
@@ -744,7 +745,7 @@
 	/* Remember the filename as the __file__ attribute */
 	v = NULL;
 	if (pathname != NULL) {
-		v = PyString_FromString(pathname);
+		v = PyUnicode_DecodeFSDefault(pathname);
 		if (v == NULL)
 			PyErr_Clear();
 	}
@@ -1075,7 +1076,7 @@
 		PySys_WriteStderr("import %s # directory %s\n",
 			name, pathname);
 	d = PyModule_GetDict(m);
-	file = PyString_FromString(pathname);
+	file = PyUnicode_DecodeFSDefault(pathname);
 	if (file == NULL)
 		goto error;
 	path = Py_BuildValue("[O]", file);

Modified: python/branches/py3k-importlib/Python/importdl.c
==============================================================================
--- python/branches/py3k-importlib/Python/importdl.c	(original)
+++ python/branches/py3k-importlib/Python/importdl.c	Mon Oct 15 21:39:57 2007
@@ -22,6 +22,7 @@
 _PyImport_LoadDynamicModule(char *name, char *pathname, FILE *fp)
 {
 	PyObject *m;
+	PyObject *path;
 	char *lastdot, *shortname, *packagecontext, *oldcontext;
 	dl_funcptr p;
 
@@ -62,7 +63,8 @@
 		return NULL;
 	}
 	/* Remember the filename as the __file__ attribute */
-	if (PyModule_AddStringConstant(m, "__file__", pathname) < 0)
+	path = PyUnicode_DecodeFSDefault(pathname);
+	if (PyModule_AddObject(m, "__file__", path) < 0)
 		PyErr_Clear(); /* Not important enough to report */
 
 	if (_PyImport_FixupExtension(name, pathname) == NULL)

Modified: python/branches/py3k-importlib/Python/pythonrun.c
==============================================================================
--- python/branches/py3k-importlib/Python/pythonrun.c	(original)
+++ python/branches/py3k-importlib/Python/pythonrun.c	Mon Oct 15 21:39:57 2007
@@ -869,7 +869,8 @@
 		return -1;
 	d = PyModule_GetDict(m);
 	if (PyDict_GetItemString(d, "__file__") == NULL) {
-		PyObject *f = PyString_FromString(filename);
+		PyObject *f;
+		f = PyUnicode_DecodeFSDefault(filename);
 		if (f == NULL)
 			return -1;
 		if (PyDict_SetItemString(d, "__file__", f) < 0) {

Modified: python/branches/py3k-importlib/Python/traceback.c
==============================================================================
--- python/branches/py3k-importlib/Python/traceback.c	(original)
+++ python/branches/py3k-importlib/Python/traceback.c	Mon Oct 15 21:39:57 2007
@@ -229,10 +229,10 @@
 	while (tb != NULL && err == 0) {
 		if (depth <= limit) {
 			err = tb_displayline(f,
-			    PyString_AsString(
+			    PyUnicode_AsString(
 				    tb->tb_frame->f_code->co_filename),
 			    tb->tb_lineno,
-			    PyString_AsString(tb->tb_frame->f_code->co_name));
+			    PyUnicode_AsString(tb->tb_frame->f_code->co_name));
 		}
 		depth--;
 		tb = tb->tb_next;

Modified: python/branches/py3k-importlib/Tools/scripts/README
==============================================================================
--- python/branches/py3k-importlib/Tools/scripts/README	(original)
+++ python/branches/py3k-importlib/Tools/scripts/README	Mon Oct 15 21:39:57 2007
@@ -30,7 +30,6 @@
 google.py		Open a webbrowser with Google.
 gprof2html.py		Transform gprof(1) output into useful HTML.
 h2py.py			Translate #define's into Python assignments
-hotshotmain.py		Main program to run script under control of hotshot
 idle			Main program to start IDLE
 ifdef.py		Remove #if(n)def groups from C sources
 lfcr.py			Change LF line endings to CRLF (Unix to Windows)

Modified: python/branches/py3k-importlib/configure
==============================================================================
--- python/branches/py3k-importlib/configure	(original)
+++ python/branches/py3k-importlib/configure	Mon Oct 15 21:39:57 2007
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 57931 .
+# From configure.in Revision: 58054 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for python 3.0.
 #
@@ -10589,6 +10589,468 @@
 
 fi
 
+{ echo "$as_me:$LINENO: checking for long double support" >&5
+echo $ECHO_N "checking for long double support... $ECHO_C" >&6; }
+have_long_double=no
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+int
+main ()
+{
+long double x; x = (long double)0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_LONG_DOUBLE 1
+_ACEOF
+
+  have_long_double=yes
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $have_long_double" >&5
+echo "${ECHO_T}$have_long_double" >&6; }
+if test "$have_long_double" = yes ; then
+{ echo "$as_me:$LINENO: checking for long double" >&5
+echo $ECHO_N "checking for long double... $ECHO_C" >&6; }
+if test "${ac_cv_type_long_double+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+typedef long double ac__type_new_;
+int
+main ()
+{
+if ((ac__type_new_ *) 0)
+  return 0;
+if (sizeof (ac__type_new_))
+  return 0;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_cv_type_long_double=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_type_long_double=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_type_long_double" >&5
+echo "${ECHO_T}$ac_cv_type_long_double" >&6; }
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ echo "$as_me:$LINENO: checking size of long double" >&5
+echo $ECHO_N "checking size of long double... $ECHO_C" >&6; }
+if test "${ac_cv_sizeof_long_double+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  if test "$cross_compiling" = yes; then
+  # Depending upon the size, compute the lo and hi bounds.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef long double ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef long double ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_hi=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_lo=`expr $ac_mid + 1`
+			if test $ac_lo -le $ac_mid; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			ac_mid=`expr 2 '*' $ac_mid + 1`
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef long double ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef long double ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_lo=$ac_mid; break
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_hi=`expr '(' $ac_mid ')' - 1`
+			if test $ac_mid -le $ac_hi; then
+			  ac_lo= ac_hi=
+			  break
+			fi
+			ac_mid=`expr 2 '*' $ac_mid`
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_lo= ac_hi=
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo`
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef long double ac__type_sizeof_;
+int
+main ()
+{
+static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_hi=$ac_mid
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_lo=`expr '(' $ac_mid ')' + 1`
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in
+?*) ac_cv_sizeof_long_double=$ac_lo;;
+'') if test "$ac_cv_type_long_double" = yes; then
+     { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double)
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long double)
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+   else
+     ac_cv_sizeof_long_double=0
+   fi ;;
+esac
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+   typedef long double ac__type_sizeof_;
+static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); }
+static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (((long int) (sizeof (ac__type_sizeof_))) < 0)
+    {
+      long int i = longval ();
+      if (i != ((long int) (sizeof (ac__type_sizeof_))))
+	return 1;
+      fprintf (f, "%ld\n", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ((long int) (sizeof (ac__type_sizeof_))))
+	return 1;
+      fprintf (f, "%lu\n", i);
+    }
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+  { (case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); }; }; then
+  ac_cv_sizeof_long_double=`cat conftest.val`
+else
+  echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+if test "$ac_cv_type_long_double" = yes; then
+     { { echo "$as_me:$LINENO: error: cannot compute sizeof (long double)
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute sizeof (long double)
+See \`config.log' for more details." >&2;}
+   { (exit 77); exit 77; }; }
+   else
+     ac_cv_sizeof_long_double=0
+   fi
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f conftest.val
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_long_double" >&5
+echo "${ECHO_T}$ac_cv_sizeof_long_double" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG_DOUBLE $ac_cv_sizeof_long_double
+_ACEOF
+
+
+fi
+
+
 { echo "$as_me:$LINENO: checking for _Bool support" >&5
 echo $ECHO_N "checking for _Bool support... $ECHO_C" >&6; }
 have_c99_bool=no

Modified: python/branches/py3k-importlib/configure.in
==============================================================================
--- python/branches/py3k-importlib/configure.in	(original)
+++ python/branches/py3k-importlib/configure.in	Mon Oct 15 21:39:57 2007
@@ -1197,6 +1197,18 @@
 AC_CHECK_SIZEOF(long long, 8)
 fi
 
+AC_MSG_CHECKING(for long double support)
+have_long_double=no
+AC_TRY_COMPILE([], [long double x; x = (long double)0;], [
+  AC_DEFINE(HAVE_LONG_DOUBLE, 1, [Define this if you have the type long double.]) 
+  have_long_double=yes
+])
+AC_MSG_RESULT($have_long_double)
+if test "$have_long_double" = yes ; then
+AC_CHECK_SIZEOF(long double, 16)
+fi
+
+
 AC_MSG_CHECKING(for _Bool support)
 have_c99_bool=no
 AC_TRY_COMPILE([], [_Bool x; x = (_Bool)0;], [

Modified: python/branches/py3k-importlib/pyconfig.h.in
==============================================================================
--- python/branches/py3k-importlib/pyconfig.h.in	(original)
+++ python/branches/py3k-importlib/pyconfig.h.in	Mon Oct 15 21:39:57 2007
@@ -330,6 +330,9 @@
 /* Define to 1 if you have the <linux/netlink.h> header file. */
 #undef HAVE_LINUX_NETLINK_H
 
+/* Define this if you have the type long double. */
+#undef HAVE_LONG_DOUBLE
+
 /* Define this if you have the type long long. */
 #undef HAVE_LONG_LONG
 
@@ -824,6 +827,9 @@
 /* The size of `long', as computed by sizeof. */
 #undef SIZEOF_LONG
 
+/* The size of `long double', as computed by sizeof. */
+#undef SIZEOF_LONG_DOUBLE
+
 /* The size of `long long', as computed by sizeof. */
 #undef SIZEOF_LONG_LONG
 


More information about the Python-3000-checkins mailing list