python / python/cpython

3.15.0b2 test_shutil failure on FreeBSD in a "poudriere jail" mounted atop ZFS file system

未关闭
#150,984 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

OS-freebsd tests type-bug
主要语言
Python
星标
77.2k
派生
35.9k
PR 合并指标
PR 指标待抓取

描述

Bug report

Bug description:

Greetings,

building Python 3.15.0b2 (beta 2) on FreeBSD in a poudriere jail mounted atop a ZFS file system, where poudriere is the tool that FreeBSD uses for package building, and a jail is a stricter companion of a chroot, we get this make test failure in test_shutil. Note that the OSError 45 (aka EOPNOTSUPP) relates to the test_tempfile failure reported in gh-150982, #150982.

It is not clear to me why a jail or how poudriere mounts the underlying filesystem would NOT support UF_OPAQUE because outside poudriere (albeit on a different minor version of the operating system), I don't get OSError [Errno 45] exceptions on the same test.

As suggested in #150982, I am wondering whether it would be useful to map this particular errno (EOPNOTSUPP) to a NotImplementedError exception and handle that.

This is the test with offending lines marked with python comments in three (3) places,
followed by the unittest output.

    def test_move_dir_permission_denied(self):
        # bpo-42782: shutil.move should not create destination directories
        # if the source directory cannot be removed.
        try:
            os.mkdir(TESTFN_SRC)
            os.lchflags(TESTFN_SRC, stat.SF_IMMUTABLE)

            # Testing on an empty immutable directory
            # TESTFN_DST should not exist if shutil.move failed
            self.assertRaises(PermissionError, shutil.move, TESTFN_SRC, TESTFN_DST)
            self.assertFalse(TESTFN_DST in os.listdir())

            # Create a file and keep the directory immutable
            os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)   # <-- offender #1
            os_helper.create_empty_file(os.path.join(TESTFN_SRC, 'child'))
            os.lchflags(TESTFN_SRC, stat.SF_IMMUTABLE)

            # Testing on a non-empty immutable directory
            # TESTFN_DST should not exist if shutil.move failed
            self.assertRaises(PermissionError, shutil.move, TESTFN_SRC, TESTFN_DST)
            self.assertFalse(TESTFN_DST in os.listdir())
        finally:
            if os.path.exists(TESTFN_SRC):
                os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)   # <-- offender #2
                os_helper.rmtree(TESTFN_SRC)
            if os.path.exists(TESTFN_DST):
                os.lchflags(TESTFN_DST, stat.UF_OPAQUE)   # <-- not reached, but would be offender #3.
                os_helper.rmtree(TESTFN_DST)
ERROR: test_move_dir_permission_denied (test.test_shutil.TestMove.test_move_dir_permission_denied)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_shutil.py", line 3051, in test_move_dir_permission_denied
    os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 45] Operation not supported: '@test_22085_tmpæ_SRC'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/wrkdirs/usr/ports/lang/python315/work/Python-3.15.0b2/Lib/test/test_shutil.py", line 3061, in test_move_dir_permission_denied
    os.lchflags(TESTFN_SRC, stat.UF_OPAQUE)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 45] Operation not supported: '@test_22085_tmpæ_SRC'

----------------------------------------------------------------------
Ran 225 tests in 1.029s

FAILED (errors=1, skipped=69)
Warning -- files was modified by test_shutil
Warning --   Before: []
Warning --   After:  ['@test_22085_tmpæ_SRC/'] 
CPython versions tested on:

3.15

Operating systems tested on:

Other

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 test/test_shutil.py 和 TestMove.test_move_dir_permission_denied 开始,然后在所报告的 ZFS 上的 FreeBSD poudriere jail 中重现该故障。调查 os.lchflags 使用 UF_OPAQUE 时出现的 EOPNOTSUPP 故障,包括清理过程,并确认 test 完成时不会留下临时文件。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
operating-systems, testing-qa
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。