Browse Source

raise OSError including the error message derived from errno

also: deal with path being a integer FD
Thomas Waldmann 9 years ago
parent
commit
09dbec99a0
1 changed files with 7 additions and 1 deletions
  1. 7 1
      borg/xattr.py

+ 7 - 1
borg/xattr.py

@@ -102,7 +102,13 @@ def _check(rv, path=None):
         if e == errno.ERANGE:
             raise BufferTooSmallError
         else:
-            raise OSError(e, path)
+            try:
+                msg = os.strerror(e)
+            except ValueError:
+                msg = ''
+            if isinstance(path, int):
+                path = '<FD %d>' % path
+            raise OSError(e, msg, path)
     return rv