libgit2 / libgit2/pygit2

AttributeError: type object Signature has no attribute _encoding

未关闭
#1,224 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Python
星标
1.7k
派生
408
平均合并
2 天 57 分钟
30 天内合并 PR
7

描述

Hi folks!

I'm running into this weird error when running my python code with ray.
Basically I get AttributeError: type object 'Signature' has no attribute '_encoding'.
But it works fine when I run my script without ray...

pygit2 version: v1.12.2
environment: python:3.9.16 docker container.

The error can be reproduced with the code below.
Ray can be installed from PyPi: pip install ray

import pygit2
import ray
from pygit2 import Signature


def function_without_ray():
    org_name = "libgit2"
    repo_name = "pygit2"
    repo = pygit2.clone_repository(
        f"https://github.com/{org_name}/{repo_name}",
        f"/tmp/{repo_name}.git",
    )
    new_branch = repo.branches.create(
        "dummy-branch", repo.revparse_single("HEAD")
    )
    repo.checkout(new_branch)

    index = repo.index
    index.add_all()
    index.write()

    author = Signature("John Doe", "john@doe.com")

    ref = repo.head.name
    tree = index.write_tree()
    parents = [repo.head.target]

    repo.create_commit(
        ref,
        author,
        author,
        "Just a dummy commit",
        tree,
        parents,
    )


@ray.remote
def function_with_ray():
    function_without_ray()

# Comment out one of these function calls to check if it works:
ray.get(function_with_ray.remote())

function_without_ray()

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,在安装了 Python 3.9.16、pygit2 v1.12.2 和从 PyPI 安装的 Ray 的 Docker 环境中运行所提供的复现,并比较有 Ray 和没有 Ray 时的执行情况。跟踪 Signature 何时丢失 _encoding,并确定一个针对性强的回归测试;完成的标准是复现的 Ray 用例不再引发 AttributeError。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。