Commits

Tobias Pape  committed ba703e7

Exit status masking is not done by close but by its caller

  • Participants
  • Parent commits 7cccc90
  • Branches popen-pclose

Comments (0)

Files changed (2)

File rpython/rlib/rfile.py

         """Closes the described file.
 
         Attention! Unlike Python semantics, `close' does not return `None' upon
-        success but `0', to be able to return an exit code for popen'ed files
+        success but `0', to be able to return an exit code for popen'ed files.
+
+        The actual return value may be determined with os.WEXITSTATUS.
         """
         ll_f = self.ll_file
         res = 0
             if res == -1:
                 errno = rposix.get_errno()
                 raise OSError(errno, os.strerror(errno))
-        return os.WEXITSTATUS(res)
+        return res
 
     _do_close = staticmethod(c_close)    # overridden in RPopenFile
 

File rpython/rlib/test/test_rfile.py

         s = f.read()
         r = f.close()
         assert s == "%s\n" % printval
-        assert r == retval
+        assert os.WEXITSTATUS(r) == retval
 
 class TestPopenR(BaseRtypingTest):
     def setup_class(cls):
             assert s == "%s\n" % printval
             return f.close()
         r = self.interpret(f, [])
-        assert r == retval
+        assert os.WEXITSTATUS(r) == retval