jenkins-bot submitted this change.

View Change

Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
[bugfix] Don't create a Site object if pywikibot is not fully imported

Bug: T298384
Change-Id: I6c703a9f6e37d53bee5782ba8121c02321123f0f
---
M pywikibot/bot.py
1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index d1e3699..8850c77 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -394,17 +394,23 @@
# if user has enabled file logging, configure file handler
if module_name in config.log or '*' in config.log:
pid = ''
- if pywikibot.Site.__doc__ != 'TEST': # set by aspects.DisableSiteMixin
- try: # T286848
- site = pywikibot.Site()
- if site is None: # T289427
- raise ValueError('Running script_test with net=False')
- except ValueError:
- pass
- else: # get PID
- throttle = site.throttle # initialize a Throttle obj
- pid_int = throttle.get_pid(module_name) # get the global PID
- pid = str(pid_int) + '-' if pid_int > 1 else ''
+
+ try: # T286848
+ site = pywikibot.Site()
+ if pywikibot.Site.__doc__ == 'TEST':
+ raise ValueError('Running test with aspects.DisableSiteMixin')
+ if site is None: # T289427
+ raise ValueError('Running script_test with net=False')
+ except ValueError:
+ pass
+ except AttributeError:
+ # Insufficient import, pywikibot.Site not available (T298384)
+ pass
+ else: # get PID
+ throttle = site.throttle # initialize a Throttle obj
+ pid_int = throttle.get_pid(module_name) # get the global PID
+ pid = str(pid_int) + '-' if pid_int > 1 else ''
+
if config.logfilename:
# keep config.logfilename unchanged
logfile = config.datafilepath('logs', config.logfilename)

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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6c703a9f6e37d53bee5782ba8121c02321123f0f
Gerrit-Change-Number: 750698
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia@gmail.com>
Gerrit-Reviewer: Legoktm <legoktm@debian.org>
Gerrit-Reviewer: Majavah <hi@taavi.wtf>
Gerrit-Reviewer: Multichill <maarten@mdammers.nl>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged