Skip to content

Inconsistent pathlib recursive globbing when using Windows 10 case-sensitive filepaths #94537

Closed
@calebthomas259

Description

@calebthomas259

Bug report

Windows now supports marking specific directories on an NTFS filesystem as case sensitive (link). Unfortunately, there seems to be inconsistent behaviour when detecting case-sensitive filenames using pathlib's recursive globbing.

Minimal example

Run these commands in PowerShell:

# create empty directory
mkdir temp1

# mark directory as case-sensitive (this command requires admin privileges)
fsutil.exe file setCaseSensitiveInfo temp1 enable

# make some test files
New-Item temp1/a.txt
New-Item temp1/A.txt

# start interactive python
python

Run these commands in interactive Python:

from pathlib import Path

# define directory
temp1 = Path("temp1")

# count number of files (method 1, standard glob)
len(list(temp1.glob("*.txt")))  # prints 2

# count number of files (method 2, recursive glob)
len(list(temp1.glob("**/*.txt")))  # prints 1

To clean up, return to PowerShell then type:

rm -r temp1

Actual behaviour
Method 1 detects both files, whereas method 2 only detects one file.

Expected behaviour
Both methods should detect the same number of files.

Your environment

  • CPython version tested on: 3.9.5 (installed via miniconda). Full version string is Python 3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32

  • Operating system and architecture: Windows 10, Version 21H1 (OS Build 19043.1766), x86_64 architecture

  • Filesystem: NTFS (set up on solid state drive). Some relevant details (taken from fsutil fsinfo volumeInfo) are:

Max Component Length : 255
File System Name : NTFS
Is ReadWrite
Not Thinly-Provisioned
Supports Case-sensitive filenames
Preserves Case of filenames
Supports Unicode in filenames
Preserves & Enforces ACL's
Supports file-based Compression
Supports Disk Quotas
Supports Sparse files
Supports Reparse Points
Returns Handle Close Result Information
Supports POSIX-style Unlink and Rename
Supports Object Identifiers
Supports Encrypted File System
Supports Named Streams
Supports Transactions
Supports Hard Links
Supports Extended Attributes
Supports Open By FileID
Supports USN Journal

Some more relevant details (taken from fsutil fsinfo ntfsInfo) are:

NTFS Version: 3.1
LFS Version: 2.0

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions