fnmatch.filter and glob don't match uppercase names under Windows simulation

Open
#1,345 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@sricharanreddycheruku is already working on this.

Since Oct 7, 2026.

  • #1352 by @sricharanreddycheruku — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python

Research direction

Start with the reproduced calls to fnmatch.filter, glob.glob, and the pyfakefs Patcher configured with OSType.WINDOWS. Compare their matching and directory-listing paths with fnmatch.fnmatch, then run the supplied reproduction to verify behavior. Done means uppercase names match case-insensitively for both filter and glob under Windows simulation without changing the already-correct single-name result.

Written by the indexing model from the issue text.

Description

Describe the bug
With Windows simulated on a POSIX host, fnmatch.filter doesn't match names containing uppercase letters, even when the pattern is in the same case. glob.glob misses the same files. fnmatch.fnmatch on a single name gives the right answer.

Expected: matching is case-insensitive, as on Windows.

fnmatch.fnmatch('B.TXT', '*.txt')       -> True   (correct)
fnmatch.filter(['B.TXT'], '*.txt')      -> []     (expected ['B.TXT'])
fnmatch.filter(['B.TXT'], '*.TXT')      -> []     (expected ['B.TXT'])
glob.glob('*.txt', root_dir='C:\\d')    -> []     (expected ['B.TXT'])

I see the same results running from a case-sensitive and from a case-insensitive APFS volume.

How To Reproduce
Run on a POSIX host:

import fnmatch, glob, os
from pyfakefs.fake_filesystem import OSType
from pyfakefs.fake_filesystem_unittest import Patcher

with Patcher() as p:
    p.fs.os = OSType.WINDOWS
    os.makedirs('C:\\d')
    open('C:\\d\\B.TXT', 'w').close()
    print(fnmatch.fnmatch('B.TXT', '*.txt'))
    print(fnmatch.filter(['B.TXT'], '*.txt'))
    print(fnmatch.filter(['B.TXT'], '*.TXT'))
    print(glob.glob('*.txt', root_dir='C:\\d'))

Your environment

macOS-27.0-arm64-arm-64bit-Mach-O
Python 3.14.7 (main, Aug  5 2026, 10:29:49) [Clang 21.0.0 (clang-2100.1.1.101)]
pyfakefs 6.2.0
ModuleNotFoundError: No module named 'pytest'
Dominant language
Python
Stars
756
Forks
111
Avg merge
3d 21h
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pytest-dev/pyfakefs

All issues in pytest-dev/pyfakefs

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.