[pypy-svn] r62494 - in pypy/trunk/pypy/module: _codecs _file

afa at codespeak.net afa at codespeak.net
Tue Mar 3 19:27:31 CET 2009


Author: afa
Date: Tue Mar  3 19:27:30 2009
New Revision: 62494

Modified:
   pypy/trunk/pypy/module/_codecs/__init__.py
   pypy/trunk/pypy/module/_file/__init__.py
Log:
Remove from the cli translation function and methods that are implemented with rffi


Modified: pypy/trunk/pypy/module/_codecs/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/_codecs/__init__.py	(original)
+++ pypy/trunk/pypy/module/_codecs/__init__.py	Tue Mar  3 19:27:30 2009
@@ -46,9 +46,16 @@
          'readbuffer_encode': 'interp_codecs.buffer_encode',
     }
 
-    if hasattr(runicode, 'str_decode_mbcs'):
-        interpleveldefs['mbcs_encode'] = 'interp_codecs.mbcs_encode'
-        interpleveldefs['mbcs_decode'] = 'interp_codecs.mbcs_decode'
+    def __init__(self, space, *args):
+        "NOT_RPYTHON"
+
+        # mbcs codec is Windows specific, and based on rffi.
+        if (hasattr(runicode, 'str_decode_mbcs') and
+            space.config.translation.type_system != 'ootype'):
+            self.interpleveldefs['mbcs_encode'] = 'interp_codecs.mbcs_encode'
+            self.interpleveldefs['mbcs_decode'] = 'interp_codecs.mbcs_decode'
+
+        MixedModule.__init__(self, space, *args)
 
     def setup_after_space_initialization(self):
         "NOT_RPYTHON"

Modified: pypy/trunk/pypy/module/_file/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/_file/__init__.py	(original)
+++ pypy/trunk/pypy/module/_file/__init__.py	Tue Mar  3 19:27:30 2009
@@ -1,6 +1,7 @@
 
 # Package initialisation
 from pypy.interpreter.mixedmodule import MixedModule
+import sys
 
 class Module(MixedModule):
     appleveldefs = {
@@ -10,6 +11,18 @@
         "file": "interp_file.W_File",
     }
 
+    def __init__(self, space, *args):
+        "NOT_RPYTHON"
+
+        # on windows with oo backends, remove file.truncate,
+        # because the implementation is based on rffi
+        if (sys.platform == 'win32' and
+            space.config.translation.type_system == 'ootype'):
+            from pypy.module._file.interp_file import W_File
+            del W_File.typedef.rawdict['truncate']
+
+        MixedModule.__init__(self, space, *args)
+
     def shutdown(self, space):
         # at shutdown, flush all open streams
         from pypy.module._file.interp_file import getopenstreams



More information about the Pypy-commit mailing list