"invalid config path selector" error when testing on pypy with MacOS arm64
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.7k
- 派生
- 408
- 平均合并
- 2 天 57 分钟
- 30 天内合并 PR
- 7
描述
pytest output
../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/errors.py:67: GitError
__________________ ERROR at setup of test_rebuild_treebuilder __________________
@pytest.fixture(scope='session', autouse=True)
def global_git_config() -> None:
# Do not use global config for better test reproducibility.
# https://github.com/libgit2/pygit2/issues/989
levels = [
pygit2.enums.ConfigLevel.GLOBAL,
pygit2.enums.ConfigLevel.XDG,
pygit2.enums.ConfigLevel.SYSTEM,
]
for level in levels:
> pygit2.settings.search_path[level] = ''
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
test/conftest.py:22:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/settings.py:45: in __setitem__
option(Option.SET_SEARCH_PATH, key, value)
../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/options.py:373: in option
check_error(err)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
err = -1, io = False
def check_error(err: int, io: bool = False) -> None:
if err >= 0:
return
# These are special error codes, they should never reach here
test = err != C.GIT_EUSER and err != C.GIT_PASSTHROUGH
assert test, f'Unexpected error code {err}'
# Error message
giterr = C.git_error_last()
if giterr != ffi.NULL:
message = ffi.string(giterr.message).decode('utf8', errors='surrogateescape')
else:
message = f'err {err} (no message provided)'
# Translate to Python errors
if err in value_errors:
raise ValueError(message)
if err == C.GIT_ENOTFOUND:
if io:
raise IOError(message)
raise KeyError(message)
if err == C.GIT_EINVALIDSPEC:
raise ValueError(message)
if err == C.GIT_ITEROVER:
raise StopIteration()
# Generic Git error
> raise GitError(message)
E _pygit2.GitError: invalid config path selector 0
../venv-test-arm64/lib/pypy3.11/site-packages/pygit2/errors.py:67: GitError
ERROR test/test_treebuilder.py::test_rebuild_treebuilder - _pygit2.GitError: invalid config path selector 0
As far as I can tell, this "invalid config path selector" error seems to be specific to pygit2 on pypy11. It seems that the int(level) passed to git_libgit2_opts()
is not matching up with the libgit2 C constants of the same name:
static int config_level_to_sysdir(int *out, int config_level)
{
switch (config_level) {
case GIT_CONFIG_LEVEL_SYSTEM:
*out = GIT_SYSDIR_SYSTEM;
return 0;
case GIT_CONFIG_LEVEL_XDG:
*out = GIT_SYSDIR_XDG;
return 0;
case GIT_CONFIG_LEVEL_GLOBAL:
*out = GIT_SYSDIR_GLOBAL;
return 0;
case GIT_CONFIG_LEVEL_PROGRAMDATA:
*out = GIT_SYSDIR_PROGRAMDATA;
return 0;
default:
break;
}
git_error_set(
GIT_ERROR_INVALID, "invalid config path selector %d", config_level);
return -1;
}
See libgit2 source
There was a similar issue in https://github.com/libgit2/libgit2sharp/issues/1951 which was fixed by padding the va_args passed to git_libgit2_opts() (https://github.com/libgit2/libgit2sharp/pull/1955).
Originally posted by @2bndy5 in https://github.com/libgit2/pygit2/issues/1441#issuecomment-3610152291
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 pygit2/options.py 第359-374行以及 test/conftest.py 中失败的设置开始;在 PyPy/macOS arm64 上重现 test/test_treebuilder.py::test_rebuild_treebuilder。将传递给 git_libgit2_opts() 的参数与 libgit2 的 settings.c config_level_to_sysdir 以及类似的 libgit2sharp 修复进行比较。当 fixture 的配置搜索路径赋值在该环境中通过时即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c, python
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100