[pypy-svn] r15227 - in pypy/dist/pypy/module: __builtin__ _codecs

tismer at codespeak.net tismer at codespeak.net
Thu Jul 28 11:41:43 CEST 2005


Author: tismer
Date: Thu Jul 28 11:41:36 2005
New Revision: 15227

Modified:
   pypy/dist/pypy/module/__builtin__/importing.py
   pypy/dist/pypy/module/_codecs/app_codecs.py
Log:
made app_codecs suitable for geninterplevel.

changed importing so that it does not crash
but gives up with an error message, if it fails
to marhsal something.

will modify marshal to survive app_codecs now...

hint about aesthetics:
app_codecs could need some cosmetic overhaul.
There are mixed tab/spaces, C style comments,
missing spaces after commas.


Modified: pypy/dist/pypy/module/__builtin__/importing.py
==============================================================================
--- pypy/dist/pypy/module/__builtin__/importing.py	(original)
+++ pypy/dist/pypy/module/__builtin__/importing.py	Thu Jul 28 11:41:36 2005
@@ -488,12 +488,16 @@
         pass
         #XXX debug
         #print "indeed writing", cpathname
+    w_M = space.getattr(w_marshal, space.wrap('dumps'))
+    try:
+        w_str = space.call_method(w_marshal, 'dumps', space.wrap(co))
+    except OperationError:
+        print "Problem while marshalling %s, skipping" % cpathname
+        return
     fd = os.open(cpathname, BIN_WRITEMASK, 0666)
     osfile = OsFileWrapper(fd)
     _w_long(osfile, pyc_magic)
     _w_long(osfile, mtime)
-    w_M = space.getattr(w_marshal, space.wrap('dumps'))
-    w_str = space.call_method(w_marshal, 'dumps', space.wrap(co))
     strbuf = space.str_w(w_str)
     osfile.write(strbuf)
     os.close(fd)

Modified: pypy/dist/pypy/module/_codecs/app_codecs.py
==============================================================================
--- pypy/dist/pypy/module/_codecs/app_codecs.py	(original)
+++ pypy/dist/pypy/module/_codecs/app_codecs.py	Thu Jul 28 11:41:36 2005
@@ -1,4 +1,3 @@
-"NOT_RPYTHON"
 """
 
    _codecs -- Provides access to the codec registry and the builtin
@@ -902,17 +901,21 @@
 	
     return p
 
-def PyUnicode_EncodeUTF16(s,size,errors,byteorder='little'):
+# moved out of local scope, especially because it didn't
+# have any nested variables.
+
+def STORECHAR(CH, byteorder):
+    hi = chr(((CH) >> 8) & 0xff)
+    lo = chr((CH) & 0xff)
+    if byteorder == 'little':
+        return [lo, hi]
+    else:
+        return [hi, lo]
+
+def PyUnicode_EncodeUTF16(s, size, errors, byteorder='little'):
 
 #    /* Offsets from p for storing byte pairs in the right order. */
 
-    def STORECHAR(CH,byteorder):
-        hi = chr(((CH) >> 8) & 0xff)
-        lo = chr((CH) & 0xff)
-        if byteorder == 'little':
-            return [lo,hi]
-        else:
-            return [hi,lo]
         
     p = []
     bom = sys.byteorder



More information about the Pypy-commit mailing list