diff --git a/CHANGES.md b/CHANGES.md index f795c797bf5..34fa1a2092a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ ### _Black_ +- Fix handling of .gitignore files containing non-ASCII characters on Windows (#2229) - Respect `.gitignore` files in all levels, not only `root/.gitignore` file (apply `.gitignore` rules like `git` does) (#2225) - Restored compatibility with Click 8.0 on Python 3.6 when LANG=C used (#2227) diff --git a/src/black/files.py b/src/black/files.py index a0c92e8c415..de516156605 100644 --- a/src/black/files.py +++ b/src/black/files.py @@ -118,7 +118,7 @@ def get_gitignore(root: Path) -> PathSpec: gitignore = root / ".gitignore" lines: List[str] = [] if gitignore.is_file(): - with gitignore.open() as gf: + with gitignore.open(encoding="utf-8") as gf: lines = gf.readlines() return PathSpec.from_lines("gitwildmatch", lines)