jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/750698 )

Change subject: [bugfix] Don't create a Site object if pywikibot is not fully 
imported
......................................................................

[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(-)

Approvals:
  JJMC89: Looks good to me, approved
  jenkins-bot: Verified



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 https://gerrit.wikimedia.org/r/c/pywikibot/core/+/750698
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I6c703a9f6e37d53bee5782ba8121c02321123f0f
Gerrit-Change-Number: 750698
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: JJMC89 <[email protected]>
Gerrit-Reviewer: Legoktm <[email protected]>
Gerrit-Reviewer: Majavah <[email protected]>
Gerrit-Reviewer: Multichill <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to