Skip to content

Exception when querying user dirs in sandboxed Windows environments [regression in 4.7.0] #421

@yoerg

Description

@yoerg

platformdirs 4.7.0 throws FileNotFoundError on Windows when USERPROFILE points to a directory without AppData\Local. In 4.6.0 it just returns a nonexistent path.

import os
import tempfile

os.environ["USERPROFILE"] = tempfile.mkdtemp()

from platformdirs import user_cache_dir

print(user_cache_dir("myapp"))
# platformdirs 4.6.0: prints ".\myapp\myapp\Cache"
# platformdirs 4.7.0: FileNotFoundError: [WinError -2147024893]

This is most likely caused by PR #380, because SHGetKnownFolderPath verifies the folder's existence by default. So the easiest fix would probably be to pass KF_FLAG_DONT_VERIFY.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions