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

Commit597fb58

Browse files
committed
fix File opened without the with statement
1 parent5eb8289 commit597fb58

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

‎git/refs/log.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -217,23 +217,24 @@ def entry_at(cls, filepath, index):
217217
the index is negative
218218
"""
219219
fp=open(filepath,'rb')
220-
ifindex<0:
221-
returnRefLogEntry.from_line(fp.readlines()[index].strip())
222-
else:
223-
# read until index is reached
224-
foriinxrange(index+1):
225-
line=fp.readline()
226-
ifnotline:
227-
break
228-
# END abort on eof
229-
# END handle runup
230-
231-
ifi!=indexornotline:# skipcq:PYL-W0631
232-
raiseIndexError
233-
# END handle exception
234-
235-
returnRefLogEntry.from_line(line.strip())
236-
# END handle index
220+
withopen(filepath,'rb')asfp:
221+
ifindex<0:
222+
returnRefLogEntry.from_line(fp.readlines()[index].strip())
223+
else:
224+
# read until index is reached
225+
foriinxrange(index+1):
226+
line=fp.readline()
227+
ifnotline:
228+
break
229+
# END abort on eof
230+
# END handle runup
231+
232+
ifi!=indexornotline:# skipcq:PYL-W0631
233+
raiseIndexError
234+
# END handle exception
235+
236+
returnRefLogEntry.from_line(line.strip())
237+
# END handle index
237238

238239
defto_file(self,filepath):
239240
"""Write the contents of the reflog instance to a file at the given filepath.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp