libgit2 / libgit2/pygit2

Possible encoding problem with Repository.file_status

Open
#687 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.7k
Forks
408
Avg merge
2d 57m
Merged PRs (30d)
7

Description

If I try to get the status of a single file using Repository.file_status, I get a "KeyError" when the path contains non-ASCII characters like "ä" or "\u00A0" (non breaking space").

The problem seems to be that "Repository_status_file" uses "py_path_to_c_str" to convert the path. Which encodes the path using the Python file system encoding.

If I encode the string myself using "utf-8", it works fine.

Not sure whether this is a libgit2, pygit2 or Windows problem...

Using pygit-0.24.2 on Python 3.5, running on Windows 7.
sys.getfilesystemencoding() returns "mbcs".

Contributor guide

Open the contributing guide

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.

Research direction

Start by reproducing the Windows Python 3.5 case with Repository.file_status for paths containing ä and a non-breaking space. Trace the path through Repository_status_file and py_path_to_c_str, comparing the filesystem-encoded and UTF-8 inputs; done means the non-ASCII path no longer raises KeyError.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, python
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.