[pypy-svn] r73824 - in pypy/trunk/pypy: module/sys objspace/std

fijal at codespeak.net fijal at codespeak.net
Fri Apr 16 23:41:37 CEST 2010


Author: fijal
Date: Fri Apr 16 23:41:36 2010
New Revision: 73824

Modified:
   pypy/trunk/pypy/module/sys/__init__.py
   pypy/trunk/pypy/module/sys/interp_encoding.py
   pypy/trunk/pypy/objspace/std/objspace.py
Log:
Store filesystemencoding on space.sys on objspace runtime initialization


Modified: pypy/trunk/pypy/module/sys/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/sys/__init__.py	(original)
+++ pypy/trunk/pypy/module/sys/__init__.py	Fri Apr 16 23:41:36 2010
@@ -10,6 +10,7 @@
         self.recursionlimit = 100
         self.w_default_encoder = None
         self.defaultencoding = "ascii"
+        self.filesystemencoding = None
         
     interpleveldefs = {
         '__name__'              : '(space.wrap("sys"))', 

Modified: pypy/trunk/pypy/module/sys/interp_encoding.py
==============================================================================
--- pypy/trunk/pypy/module/sys/interp_encoding.py	(original)
+++ pypy/trunk/pypy/module/sys/interp_encoding.py	Fri Apr 16 23:41:36 2010
@@ -26,10 +26,7 @@
     space.sys.w_default_encoder = w_encoder    # cache it
     return w_encoder
 
-def getfilesystemencoding(space):
-    """Return the encoding used to convert Unicode filenames in
-    operating system filenames.
-    """
+def _getfilesystemencoding(space):
     if sys.platform == "win32":
         encoding = "mbcs"
     elif sys.platform == "darwin":
@@ -48,4 +45,10 @@
                                         space.wrap(loc_codeset))
             if space.is_true(w_res):
                 encoding = loc_codeset
-    return space.wrap(encoding)
+    return encoding
+
+def getfilesystemencoding(space):
+    """Return the encoding used to convert Unicode filenames in
+    operating system filenames.
+    """
+    return space.wrap(space.sys.filesystemencoding)

Modified: pypy/trunk/pypy/objspace/std/objspace.py
==============================================================================
--- pypy/trunk/pypy/objspace/std/objspace.py	(original)
+++ pypy/trunk/pypy/objspace/std/objspace.py	Fri Apr 16 23:41:36 2010
@@ -367,6 +367,11 @@
             raise UnpackValueError("Expected length %d, got %d" % (expected_length, len(t)))
         return t
 
+    def startup(self):
+        from pypy.module.sys.interp_encoding import _getfilesystemencoding
+        ObjSpace.startup(self)
+        self.sys.filesystemencoding = _getfilesystemencoding(self)
+
     def sliceindices(self, w_slice, w_length):
         if isinstance(w_slice, W_SliceObject):
             a, b, c = w_slice.indices3(self, self.int_w(w_length))



More information about the Pypy-commit mailing list