[pypy-svn] pypy default: merge heads

arigo commits-noreply at bitbucket.org
Wed Apr 27 14:37:18 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r43675:f7965308716b
Date: 2011-04-27 14:37 +0200
http://bitbucket.org/pypy/pypy/changeset/f7965308716b/

Log:	merge heads

diff --git a/pypy/module/sys/version.py b/pypy/module/sys/version.py
--- a/pypy/module/sys/version.py
+++ b/pypy/module/sys/version.py
@@ -14,7 +14,7 @@
 
 if platform.name == 'msvc':
     COMPILER_INFO = 'MSC v.%d 32 bit' % (platform.version * 10 + 600)
-elif platform.cc == 'gcc':
+elif platform.cc.startswith('gcc'):
     out = platform.execute(platform.cc, '--version').out
     match = re.search(' (\d+\.\d+(\.\d+)*)', out)
     if match:

diff --git a/pypy/module/mmap/interp_mmap.py b/pypy/module/mmap/interp_mmap.py
--- a/pypy/module/mmap/interp_mmap.py
+++ b/pypy/module/mmap/interp_mmap.py
@@ -5,7 +5,7 @@
 from pypy.interpreter.typedef import TypeDef
 from pypy.interpreter.gateway import interp2app, unwrap_spec, NoneNotWrapped
 from pypy.rlib import rmmap
-from pypy.rlib.rmmap import RValueError, RTypeError, ROverflowError
+from pypy.rlib.rmmap import RValueError, RTypeError, ROverflowError, RSystemError
 import sys
 import os
 import platform
@@ -123,6 +123,9 @@
             self.mmap.resize(newsize)
         except OSError, e:
             raise mmap_error(self.space, e)
+        except RSystemError, e:
+            raise OperationError(self.space.w_SystemError,
+                                 self.space.wrap(e.message))
 
     def __len__(self):
         return self.space.wrap(self.mmap.size)

diff --git a/pypy/module/mmap/test/test_mmap.py b/pypy/module/mmap/test/test_mmap.py
--- a/pypy/module/mmap/test/test_mmap.py
+++ b/pypy/module/mmap/test/test_mmap.py
@@ -363,6 +363,28 @@
         m.close()
         f.close()
 
+    def test_resize_bsd(self):
+        import sys
+        if ("darwin" not in sys.platform) and ("freebsd" not in sys.platform):
+            skip("resize works under not OSX or FreeBSD")
+        
+        import mmap
+        import os
+        
+        f = open(self.tmpname + "p", "w+")
+        f.write("foobar")
+        f.flush()
+        m = mmap.mmap(f.fileno(), 6, access=mmap.ACCESS_READ)
+        raises(TypeError, m.resize, 1)
+        m = mmap.mmap(f.fileno(), 6, access=mmap.ACCESS_COPY)
+        raises(TypeError, m.resize, 1)
+        m = mmap.mmap(f.fileno(), 6, access=mmap.ACCESS_WRITE)
+        f_size = os.fstat(f.fileno()).st_size
+        assert m.size() == f_size == 6
+        raises(SystemError, m.resize, 10)
+        f_size = os.fstat(f.fileno()).st_size
+        assert m.size() == f_size == 6
+
     def test_len(self):
         from mmap import mmap
         

diff --git a/pypy/rlib/rmmap.py b/pypy/rlib/rmmap.py
--- a/pypy/rlib/rmmap.py
+++ b/pypy/rlib/rmmap.py
@@ -27,6 +27,10 @@
     def __init__(self, message):
         self.message = message
 
+class RSystemError(Exception):
+    def __init__(self, message):
+        self.message = message
+
 includes = ["sys/types.h"]
 if _POSIX:
     includes += ['unistd.h', 'sys/mman.h']
@@ -511,7 +515,7 @@
         
         if _POSIX:
             if not has_mremap:
-                raise OSError(-11111, "No mremap available")
+                raise RSystemError("mmap: resizing not available--no mremap()")
             
             # resize the underlying file first
             os.ftruncate(self.fd, self.offset + newsize)


More information about the Pypy-commit mailing list