libgit2 / libgit2/pygit2

AttributeError: type object Signature has no attribute _encoding

Offen
#1,224 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Python
Sterne
1.7k
Forks
408
Ø Merge
2 T. 57 Min.
Gemergte PRs (30 T.)
7

Beschreibung

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()

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die bereitgestellte Reproduktion in der Docker-Umgebung mit Python 3.9.16, pygit2 v1.12.2 und von PyPI installiertem Ray auszuführen, und vergleiche die Ausführung mit und ohne Ray. Verfolge, wann Signature _encoding verliert, und identifiziere einen fokussierten Regressionstest; abgeschlossen ist die Aufgabe, wenn der reproduzierte Ray-Fall keinen AttributeError mehr auslöst.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
42/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.