Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Closing file handles/streams#176

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletionsgit/cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -382,6 +382,11 @@ def execute(self, command,
finally:
proc.stdout.close()
proc.stderr.close()
if proc.stdin:
proc.stdin.close()
proc.poll()
if proc.returncode is None:
proc.terminate()

if self.GIT_PYTHON_TRACE == 'full':
cmdstr = " ".join(command)
Expand Down
35 changes: 21 additions & 14 deletionsgit/objects/commit.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -350,24 +350,31 @@ def _iter_from_process_or_stream(cls, odb, proc_or_stream):
:param proc: git-rev-list process instance - one sha per line
:return: iterator returning Commit objects"""
stream = proc_or_stream
close_std_err = False
if not hasattr(stream,'readline'):
stream = proc_or_stream.stdout
close_std_err = True

readline = stream.readline
while True:
line = readline()
if not line:
break
hexsha = line.strip()
if len(hexsha) > 40:
# split additional information, as returned by bisect for instance
hexsha, rest = line.split(None, 1)
# END handle extra info

assert len(hexsha) == 40, "Invalid line: %s" % hexsha
yield cls(odb, hex_to_bin(hexsha))
# END for each line in stream

try:
while True:
line = readline()
if not line:
break
hexsha = line.strip()
if len(hexsha) > 40:
# split additional information, as returned by bisect for instance
hexsha, rest = line.split(None, 1)
# END handle extra info

assert len(hexsha) == 40, "Invalid line: %s" % hexsha
yield cls(odb, hex_to_bin(hexsha))
# END for each line in stream
finally:
stream.close()
if close_std_err:
proc_or_stream.stderr.close()

#{ Serializable Implementation

def _serialize(self, stream):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp