jenkins-bot submitted this change.
[bugfix] add an empty data dict to assign variable before reference
- add an empty data dict to assign variable before reference
- use result['result'] if data['result'] is empty
Bug: T310619
Change-Id: Icf5b31844ef3a2a1f94d875f219d877341586ad1
---
M pywikibot/site/_upload.py
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/pywikibot/site/_upload.py b/pywikibot/site/_upload.py
index 9a4bc3d..ad4af5a 100644
--- a/pywikibot/site/_upload.py
+++ b/pywikibot/site/_upload.py
@@ -243,6 +243,7 @@
if file_key and file_size is None:
assert offset is False
+ data = {}
if file_key and offset is False or offset == file_size:
pywikibot.log('Reused already upload file using filekey "{}"'
.format(file_key))
@@ -437,12 +438,13 @@
action='upload', filename=file_page_title, url=self.url,
comment=self.comment, text=self.text, token=token)
- return self.submit(final_request, result, data['result'],
+ return self.submit(final_request, result, data.get('result'),
ignore_warnings, ignore_all_warnings,
report_success, file_key)
- def submit(self, request, result, data_result, ignore_warnings,
- ignore_all_warnings, report_success, file_key) -> bool:
+ def submit(self, request, result, data_result: Optional[str],
+ ignore_warnings, ignore_all_warnings, report_success,
+ file_key) -> bool:
"""Submit request and return whether upload was successful."""
# some warning keys have been changed
warning_keys = {
@@ -534,4 +536,5 @@
self.filepage._load_file_revisions([result['imageinfo']])
return True
- raise Error('Unrecognized result: {}'.format(data_result))
+ raise Error('Unrecognized result: {}'
+ .format(data_result or result['result']))
To view, visit change 805455. To unsubscribe, or for help writing mail filters, visit settings.