jenkins-bot has submitted this change and it was merged.
Change subject: Fix 'except' syntax ......................................................................
Fix 'except' syntax
Change-Id: I40e1258f9ddee9a8974dc32eccb14eb2c03457ce --- M pywikibot/comms/threadedhttp.py M pywikibot/data/api.py M pywikibot/login.py M pywikibot/page.py M pywikibot/site.py M pywikibot/userinterfaces/terminal_interface_base.py 6 files changed, 20 insertions(+), 20 deletions(-)
Approvals: Merlijn van Deen: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/comms/threadedhttp.py b/pywikibot/comms/threadedhttp.py index 0b6afbc..800af44 100644 --- a/pywikibot/comms/threadedhttp.py +++ b/pywikibot/comms/threadedhttp.py @@ -218,7 +218,7 @@ self, uri, method, body, headers, max_redirects, connection_type ) - except Exception, e: # what types? + except Exception as e: # what types? # return exception instance to be retrieved by the calling thread return e self.follow_redirects = follow_redirects diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 60a4cb5..313f2e2 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -297,7 +297,7 @@ pywikibot.error(traceback.format_exc()) raise #TODO: what other exceptions can occur here? - except Exception, e: + except Exception as e: # for any other error on the http request, wait and retry pywikibot.error(traceback.format_exc()) pywikibot.log(u"%s, %s" % (uri, paramstring)) diff --git a/pywikibot/login.py b/pywikibot/login.py index 536d5ff..e3ecc78 100644 --- a/pywikibot/login.py +++ b/pywikibot/login.py @@ -173,7 +173,7 @@ % {'name': self.username, 'site': self.site}) try: cookiedata = self.getCookie() - except pywikibot.data.api.APIError, e: + except pywikibot.data.api.APIError as e: pywikibot.error(u"Login failed (%s)." % e.code) if retry: self.password = None diff --git a/pywikibot/page.py b/pywikibot/page.py index a533304..de17185 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -304,7 +304,7 @@ or self._revisions[self._revid].text is None: try: self.site.loadrevisions(self, getText=True, sysop=sysop) - except (pywikibot.NoPage, pywikibot.SectionError), e: + except (pywikibot.NoPage, pywikibot.SectionError) as e: self._getexception = e raise
@@ -831,13 +831,13 @@ raise pywikibot.PageNotSaved(link) else: pywikibot.output(u"Page %s saved" % link) - except pywikibot.LockedPage, err: + except pywikibot.LockedPage as err: # re-raise the LockedPage exception so that calling program # can re-try if appropriate if not callback and not async: raise # TODO: other "expected" error types to catch? - except pywikibot.Error, err: + except pywikibot.Error as err: pywikibot.log(u"Error saving page %s (%s)\n" % (link, err), exc_info=True) if not callback and not async: @@ -1288,7 +1288,7 @@ if answer in ['y', 'Y']: try: return self.site.deletepage(self, reason) - except pywikibot.NoUsername, e: + except pywikibot.NoUsername as e: if mark: raise NotImplementedError( "Marking pages for deletion is not yet available.") @@ -1479,7 +1479,7 @@ except pywikibot.EditConflict: pywikibot.output(u'Skipping %s because of edit conflict' % self.title()) - except pywikibot.SpamfilterError, e: + except pywikibot.SpamfilterError as e: pywikibot.output(u'Skipping %s because of blacklist entry %s' % (self.title(), e.url)) except pywikibot.LockedPage: @@ -1488,7 +1488,7 @@ except pywikibot.NoUsername: pywikibot.output(u'Page %s not saved; sysop privileges ' u'required.' % self.title(asLink=True)) - except pywikibot.PageNotSaved, error: + except pywikibot.PageNotSaved as error: pywikibot.output(u'Saving page %s failed: %s' % (self.title(asLink=True), error.message))
@@ -2233,7 +2233,7 @@ try: self.site.blockuser(self, expiry, reason, anononly, nocreate, autoblock, noemail, reblock) - except pywikibot.data.api.APIError, err: + except pywikibot.data.api.APIError as err: if err.code == 'invalidrange': raise ValueError("%s is not a valid IP range." % self.username) else: @@ -3521,7 +3521,7 @@ t = title.encode(enc) t = urllib.unquote(t) return unicode(t, enc) - except UnicodeError, ex: + except UnicodeError as ex: if not firstException: firstException = ex pass diff --git a/pywikibot/site.py b/pywikibot/site.py index 71238b9..6649aed 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -2760,7 +2760,7 @@ result = req.submit() pywikibot.debug(u"editpage response: %s" % result, _logger) - except api.APIError, err: + except api.APIError as err: self.unlock_page(page) if err.code.endswith("anon") and self.logged_in(): pywikibot.debug( @@ -2904,7 +2904,7 @@ result = req.submit() pywikibot.debug(u"movepage response: %s" % result, _logger) - except api.APIError, err: + except api.APIError as err: if err.code.endswith("anon") and self.logged_in(): pywikibot.debug( u"movepage: received '%s' even though bot is logged in" @@ -2981,7 +2981,7 @@ token=token) try: result = req.submit() - except api.APIError, err: + except api.APIError as err: errdata = { 'site': self, 'title': page.title(withSection=False), @@ -3013,7 +3013,7 @@ """ try: self.login(sysop=True) - except pywikibot.NoUsername, e: + except pywikibot.NoUsername as e: raise NoUsername("delete: Unable to login as sysop (%s)" % e.__class__.__name__) if not self.logged_in(sysop=True): @@ -3025,7 +3025,7 @@ reason=summary) try: result = req.submit() - except api.APIError, err: + except api.APIError as err: errdata = { 'site': self, 'title': page.title(withSection=False), @@ -3064,7 +3064,7 @@ """ try: self.login(sysop=True) - except pywikibot.NoUsername, e: + except pywikibot.NoUsername as e: raise NoUsername("protect: Unable to login as sysop (%s)" % e.__class__.__name__) if not self.logged_in(sysop=True): @@ -3077,7 +3077,7 @@ reason=summary) try: result = req.submit() - except api.APIError, err: + except api.APIError as err: errdata = { 'site': self, 'title': page.title(withSection=False), @@ -3257,7 +3257,7 @@ req["ignorewarnings"] = "" try: result = req.submit() - except api.APIError, err: + except api.APIError as err: # TODO: catch and process foreseeable errors raise result = result["upload"] diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py index b1fcbe1..60ca7b9 100755 --- a/pywikibot/userinterfaces/terminal_interface_base.py +++ b/pywikibot/userinterfaces/terminal_interface_base.py @@ -237,7 +237,7 @@ """ try: import gui - except ImportError, e: + except ImportError as e: print 'Could not load GUI modules: %s' % e return text editor = gui.EditBoxWindow()
pywikibot-commits@lists.wikimedia.org