浏览代码

Forward port #6064: avoid expanding path into LHS of formatting operation

Andrey Bienkowski 3 年之前
父节点
当前提交
d9e923e66f
共有 2 个文件被更改,包括 1 次插入4 次删除
  1. 0 2
      src/borg/testsuite/archiver.py
  2. 1 2
      src/borg/xattr.py

+ 0 - 2
src/borg/testsuite/archiver.py

@@ -3460,7 +3460,6 @@ id: 2 / e29442 3506da 4e1ea7 / 25f62a 5a3d41 - 02
             assert 'Attic repository detected.' in output
             assert 'Attic repository detected.' in output
 
 
     # derived from test_extract_xattrs_errors()
     # derived from test_extract_xattrs_errors()
-    @pytest.mark.xfail(raises=ValueError, strict=True)
     @pytest.mark.skipif(not xattr.XATTR_FAKEROOT, reason='xattr not supported on this system or on this version of'
     @pytest.mark.skipif(not xattr.XATTR_FAKEROOT, reason='xattr not supported on this system or on this version of'
                                                          'fakeroot')
                                                          'fakeroot')
     def test_do_not_fail_when_percent_is_in_xattr_name(self):
     def test_do_not_fail_when_percent_is_in_xattr_name(self):
@@ -3477,7 +3476,6 @@ id: 2 / e29442 3506da 4e1ea7 / 25f62a 5a3d41 - 02
                 self.cmd('extract', self.repository_location + '::test', exit_code=EXIT_WARNING)
                 self.cmd('extract', self.repository_location + '::test', exit_code=EXIT_WARNING)
 
 
     # derived from test_extract_xattrs_errors()
     # derived from test_extract_xattrs_errors()
-    @pytest.mark.xfail(raises=ValueError, strict=True)
     @pytest.mark.skipif(not xattr.XATTR_FAKEROOT, reason='xattr not supported on this system or on this version of'
     @pytest.mark.skipif(not xattr.XATTR_FAKEROOT, reason='xattr not supported on this system or on this version of'
                                                          'fakeroot')
                                                          'fakeroot')
     def test_do_not_fail_when_percent_is_in_file_name(self):
     def test_do_not_fail_when_percent_is_in_file_name(self):

+ 1 - 2
src/borg/xattr.py

@@ -132,7 +132,6 @@ def set_all(path, xattrs, follow_symlinks=False):
                 path_str = '<FD %d>' % path
                 path_str = '<FD %d>' % path
             else:
             else:
                 path_str = os.fsdecode(path)
                 path_str = os.fsdecode(path)
-            msg_format = '%s: when setting extended attribute %s: %%s' % (path_str, k_str)
             if e.errno == errno.E2BIG:
             if e.errno == errno.E2BIG:
                 err_str = 'too big for this filesystem'
                 err_str = 'too big for this filesystem'
             elif e.errno == errno.ENOTSUP:
             elif e.errno == errno.ENOTSUP:
@@ -146,5 +145,5 @@ def set_all(path, xattrs, follow_symlinks=False):
                 # EACCES: permission denied to set this specific xattr (this may happen related to security.* keys)
                 # EACCES: permission denied to set this specific xattr (this may happen related to security.* keys)
                 # EPERM: operation not permitted
                 # EPERM: operation not permitted
                 err_str = os.strerror(e.errno)
                 err_str = os.strerror(e.errno)
-            logger.warning(msg_format % err_str)
+            logger.warning('%s: when setting extended attribute %s: %s', path_str, k_str, err_str)
     return warning
     return warning