jenkins-bot has submitted this change and it was merged.
Change subject: Fix Site() properly ......................................................................
Fix Site() properly
If767d6fd5367d0e52ccacf7f2229112ed1c0933d caused a build breakage. I5eb9d2b39768b047290ac8c14e0201114630daed was an interim fix.
This changeset reverts the interim fix, as that is a preformance regression, and fixes the initial problem by not looking in a dict for a key unnecessarily.
Bug: 68560 Change-Id: I10ad12bc70088bf0924ba0664c3fc01db45785da --- M pywikibot/__init__.py M pywikibot/family.py 2 files changed, 10 insertions(+), 6 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index de518b8..fb452c7 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -463,14 +463,15 @@ # Fallback to config defaults code = code or config.mylang fam = fam or config.family - if hasattr(fam, 'name'): - fam = fam.name interface = interface or config.site_interface
- user = user or config.usernames[fam].get(code, None) \ - or config.usernames[fam].get('*', None) - sysop = sysop or config.sysopnames[fam].get(code, None) \ - or config.sysopnames[fam].get('*', None) + # config.usernames is initialised with a dict for each family name + family_name = str(fam) + if family_name in config.usernames: + user = user or config.usernames[family_name].get(code) \ + or config.usernames[family_name].get('*') + sysop = sysop or config.sysopnames[family_name].get(code) \ + or config.sysopnames[family_name].get('*')
try: tmp = __import__('pywikibot.site', fromlist=[interface]) diff --git a/pywikibot/family.py b/pywikibot/family.py index c70965d..e4c02a3 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -1021,6 +1021,9 @@ def __hash__(self): return hash(self.name)
+ def __str__(self): + return self.name + def __repr__(self): return 'Family("%s")' % self.name
pywikibot-commits@lists.wikimedia.org