[pypy-commit] pypy py3.5: os.sync()

arigo pypy.commits at gmail.com
Tue Sep 13 13:09:51 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: py3.5
Changeset: r87087:eb88834f82b2
Date: 2016-09-13 19:09 +0200
http://bitbucket.org/pypy/pypy/changeset/eb88834f82b2/

Log:	os.sync()

diff --git a/pypy/module/posix/__init__.py b/pypy/module/posix/__init__.py
--- a/pypy/module/posix/__init__.py
+++ b/pypy/module/posix/__init__.py
@@ -200,6 +200,9 @@
     if rposix.HAVE_PIPE2:
         interpleveldefs['pipe2'] = 'interp_posix.pipe2'
 
+    if not rposix._WIN32:
+        interpleveldefs['sync'] = 'interp_posix.sync'
+
     def startup(self, space):
         from pypy.module.posix import interp_posix
         from pypy.module.imp import importing
diff --git a/pypy/module/posix/interp_posix.py b/pypy/module/posix/interp_posix.py
--- a/pypy/module/posix/interp_posix.py
+++ b/pypy/module/posix/interp_posix.py
@@ -347,6 +347,10 @@
     except OSError as e:
         raise wrap_oserror(space, e)
 
+def sync(space):
+    """Force write of everything to disk."""
+    rposix.sync()
+
 def fchdir(space, w_fd):
     """Change to the directory of the given file descriptor.  fildes must be
 opened on a directory, not a file."""
diff --git a/pypy/module/posix/test/test_posix2.py b/pypy/module/posix/test/test_posix2.py
--- a/pypy/module/posix/test/test_posix2.py
+++ b/pypy/module/posix/test/test_posix2.py
@@ -1134,6 +1134,10 @@
         assert os.get_inheritable(fd) == False
         os.close(fd)
 
+    if sys.platform != 'win32':
+        def test_sync(self):
+            self.posix.sync()   # does not raise
+
     def test_urandom(self):
         os = self.posix
         s = os.urandom(5)


More information about the pypy-commit mailing list