Author: Carl Friedrich Bolz <[email protected]>
Branch: 
Changeset: r75571:5ce6940b7455
Date: 2015-01-27 17:24 +0100
http://bitbucket.org/pypy/pypy/changeset/5ce6940b7455/

Log:    used the with block version instead of a manual try...finally

diff --git a/rpython/rlib/rfile.py b/rpython/rlib/rfile.py
--- a/rpython/rlib/rfile.py
+++ b/rpython/rlib/rfile.py
@@ -477,8 +477,7 @@
     @enforceargs(None, str)
     def write(self, value):
         self._check_closed()
-        ll_value, is_pinned, is_raw = rffi.get_nonmovingbuffer(value)
-        try:
+        with rffi.scoped_nonmovingbuffer(value) as ll_value:
             # note that since we got a nonmoving buffer, it is either raw
             # or already cannot move, so the arithmetics below are fine
             length = len(value)
@@ -487,8 +486,6 @@
                 errno = rposix.get_saved_errno()
                 c_clearerr(self._ll_file)
                 raise IOError(errno, os.strerror(errno))
-        finally:
-            rffi.free_nonmovingbuffer(value, ll_value, is_pinned, is_raw)
 
     def flush(self):
         self._check_closed()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to