jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[bugfix] Use dict for data container instead of defaultdict

Seems defaultdict is changed during iterating but I didn't found
the getter adding defaults.

Also show the traceback in interwiki.py for further informations
if -verbose mode is set.

Bug: T282865
Change-Id: I56724b1f4ed67ca07aa6960f4a610516024e04c1
---
M pywikibot/tools/__init__.py
M scripts/interwiki.py
2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py
index c533af15..2e79cae 100644
--- a/pywikibot/tools/__init__.py
+++ b/pywikibot/tools/__init__.py
@@ -19,7 +19,6 @@
import threading
import time
import types
-from collections import defaultdict
from collections.abc import Container, Iterable, Iterator, Mapping, Sized
from contextlib import suppress
from datetime import datetime
@@ -352,6 +351,8 @@
key = getattr(value, self.keyattr)
if callable(key):
key = key()
+ if key not in self.data:
+ self.data[key] = []
self.data[key].append(value)
self.size += 1

@@ -372,7 +373,7 @@

def clear(self):
"""Remove all elements from SizedKeyCollection."""
- self.data = defaultdict(list)
+ self.data = {} # defaultdict fails (T282865)
self.size = 0

def filter(self, key):
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 7af2748..1a6ae37 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -2478,7 +2478,7 @@
except KeyboardInterrupt:
dump.write_dump(bot.dump_titles, append)
except Exception:
- pywikibot.exception()
+ pywikibot.exception(tb=bool(config.verbose_output))
dump.write_dump(bot.dump_titles, append)
else:
pywikibot.output('Script terminated sucessfully.')

To view, visit change 691167. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I56724b1f4ed67ca07aa6960f4a610516024e04c1
Gerrit-Change-Number: 691167
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki@aol.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged