소스 검색

Close the temporary file before re-opening it.

On Windows, we cannot reuse the temp.name to
reopen the file *unless* it has been closed
before [0].

This problem in turn made the `move_file`
request to fail, since the file was still
open at the time.

[0] https://docs.python.org/2/library/tempfile.html#tempfile.NamedTemporaryFile
pull/309/head
timotei 10 년 전
committed by William Ting
부모
커밋
c889aa013e
1개의 변경된 파일2개의 추가작업 그리고 0개의 파일을 삭제
  1. +2
    -0
      bin/autojump_data.py

+ 2
- 0
bin/autojump_data.py 파일 보기

@ -121,6 +121,8 @@ def save(config, data):
try:
# write to temp file
temp = NamedTemporaryFile(delete=False)
# prevent Windows errors by closing the file before opening it.
temp.close()
with open(temp.name, 'w', encoding='utf-8', errors='replace') as f:
for path, weight in data.items():

불러오는 중...
취소
저장