Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326336?usp=email )
Change subject: upload: Close temporary download descriptor
......................................................................
upload: Close temporary download descriptor
Close the descriptor returned by mkstemp before reopening its path.
Remove the seek on the unrelated descriptor used during retries.
Change-Id: I9da2ec0dc9d46a3079f87a05c4477515c416492d
---
M pywikibot/specialbots/_upload.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/specialbots/_upload.py b/pywikibot/specialbots/_upload.py
index e0d0ef1..06715f9 100644
--- a/pywikibot/specialbots/_upload.py
+++ b/pywikibot/specialbots/_upload.py
@@ -142,7 +142,8 @@
"""Return name of temp file in which remote file is saved."""
pywikibot.info('Reading file ' + file_url)
- handle, tempname = tempfile.mkstemp()
+ temp_fd, tempname = tempfile.mkstemp()
+ os.close(temp_fd)
path = Path(tempname)
size = 0
@@ -155,8 +156,7 @@
else:
headers = {}
- with open(path, 'ab') as fd:
- os.lseek(handle, file_len, 0)
+ with path.open('ab') as fd:
try:
response = http.fetch(file_url, stream=True,
headers=headers)
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1326336?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I9da2ec0dc9d46a3079f87a05c4477515c416492d
Gerrit-Change-Number: 1326336
Gerrit-PatchSet: 3
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]