Skip to content

Concurrent stream access causes ValueErrors with confusing message #595

Open
@quantus

Description

@quantus

While playing in Python interpreter and getting the feel of the API I ran into seemingly random issues when reading blob contents from random commits. Having one streams "open" when doing some other function calls leads to ValueErrors being thrown. Because I was working in the interpreter, I didn't understand that I had existing streams "open" and it took some time to understand what was wrong. I also got ValueError: I/O operation on closed file errors in some cases, but I assume the actual root cause is the same.

Example how to reproduce the issue:

  • git clone https://github.com/octocat/Hello-World
  • Try running following python script:
from git import Repo

r = Repo('Hello-World')
stream = r.commit('553c2077f0edc3d5dc5d17262f6aa498e69d6f8e').tree['README'].data_stream.stream
# This will raise ValueError: SHA Hello could not be resolved, git returned: 'Hello World!'
r.commit('762941318ee16e59dabbacb1b4049eec22f0d303').tree['README']

stream.readlines()

I would think the best option would be to allow having multiple streams open at the same time. If that is unfeasible for some reason, then other option would be to warn the user that they are doing something unsupported.

OS: macOS 10.12.3
GitPython: 2.1.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions