Author: martin.v.loewis
Date: Sat Aug 11 17:36:45 2007
New Revision: 56927

Modified:
   python/branches/py3k/Lib/io.py
Log:
Fall back to ascii if the locale module cannot be loaded.


Modified: python/branches/py3k/Lib/io.py
==============================================================================
--- python/branches/py3k/Lib/io.py      (original)
+++ python/branches/py3k/Lib/io.py      Sat Aug 11 17:36:45 2007
@@ -976,8 +976,13 @@
             except AttributeError:
                 pass
             if encoding is None:
-                import locale
-                encoding = locale.getpreferredencoding()
+                try:
+                    import locale
+                except ImportError:
+                    # Importing locale may fail if Python is being built
+                    encoding = "ascii"
+                else:
+                    encoding = locale.getpreferredencoding()
 
         self.buffer = buffer
         self._encoding = encoding
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to