Skip to content

Python 3.14 tests failing with AssertionError: assert '(?s:foo[^/]*)\\z' == '(?s:foo[^/]*)\\Z' #381

@Avasam

Description

@Avasam

Recently noticed that all CI runs using Python 3.14 are failing with AssertionError: assert '(?s:foo[^/]*)\\z' == '(?s:foo[^/]*)\\Z'.

This includes the jobs test (3.14, ubuntu-latest) and collateral (diffcov).

Complete error:

_________________________ TestFileList.test_glob_to_re _________________________

self = <distutils.tests.test_filelist.TestFileList object at 0x7f78b4447390>

    def test_glob_to_re(self):
        sep = os.sep
        if os.sep == '\\':
            sep = re.escape(os.sep)
    
        for glob, regex in (
            # simple cases
            ('foo*', r'(?s:foo[^%(sep)s]*)\Z'),
            ('foo?', r'(?s:foo[^%(sep)s])\Z'),
            ('foo??', r'(?s:foo[^%(sep)s][^%(sep)s])\Z'),
            # special cases
            (r'foo\\*', r'(?s:foo\\\\[^%(sep)s]*)\Z'),
            (r'foo\\\*', r'(?s:foo\\\\\\[^%(sep)s]*)\Z'),
            ('foo????', r'(?s:foo[^%(sep)s][^%(sep)s][^%(sep)s][^%(sep)s])\Z'),
            (r'foo\\??', r'(?s:foo\\\\[^%(sep)s][^%(sep)s])\Z'),
        ):
            regex = regex % {'sep': sep}
>           assert glob_to_re(glob) == regex
E           AssertionError: assert '(?s:foo[^/]*)\\z' == '(?s:foo[^/]*)\\Z'
E             
E             - (?s:foo[^/]*)\Z
E             ?               ^
E             + (?s:foo[^/]*)\z
E             ?               ^

distutils/tests/test_filelist.py:64: AssertionError

Looks like https://docs.python.org/3/library/fnmatch.html#fnmatch.translate changed in an undocumented way in 3.14:

> uvx --python=3.13 python -c "import fnmatch; print(fnmatch.translate('foo*'))"
(?s:foo.*)\Z
> uvx --python=3.14 python -c "import fnmatch; print(fnmatch.translate('foo*'))"
(?s:foo.*)\z

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions