jenkins-bot has submitted this change and it was merged.
Change subject: Always use except Exception as e instead of Exception, e
......................................................................
Always use except Exception as e instead of Exception, e
Change-Id: Iab67e2c79c9ace74cbf1d55fcd4dd17e6293f5f1
---
M scripts/add_text.py
M scripts/basic.py
M scripts/blockpageschecker.py
M scripts/category.py
M scripts/category_redirect.py
M scripts/commonscat.py
M scripts/cosmetic_changes.py
M scripts/featured.py
M scripts/harvest_template.py
M scripts/interwiki.py
M scripts/isbn.py
M scripts/movepages.py
M scripts/noreferences.py
M scripts/nowcommons.py
M scripts/pagefromfile.py
M scripts/redirect.py
M scripts/reflinks.py
M scripts/replace.py
M scripts/solve_disambiguation.py
M scripts/upload.py
20 files changed, 45 insertions(+), 45 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py
index c865be8..673f1a5 100644
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -257,12 +257,12 @@
continue
else:
raise pywikibot.ServerError(u'Fifth Server Error!')
- except pywikibot.SpamfilterError, e:
+ except pywikibot.SpamfilterError as e:
pywikibot.output(
u'Cannot change %s because of blacklist entry %s'
% (page.title(), e.url))
return (False, False, always)
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u'Error putting page: %s' % error.args)
return (False, False, always)
except pywikibot.LockedPage:
diff --git a/scripts/basic.py b/scripts/basic.py
index 4d73deb..96285e6 100755
--- a/scripts/basic.py
+++ b/scripts/basic.py
@@ -122,7 +122,7 @@
pywikibot.output(
u'Skipping %s because of edit conflict'
% (page.title()))
- except pywikibot.SpamfilterError, error:
+ except pywikibot.SpamfilterError as error:
pywikibot.output(
u'Cannot change %s because of spam blacklist entry
%s'
% (page.title(), error.url))
diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index d6a5677..186c8c3 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -462,12 +462,12 @@
else:
# Prevent Infinite Loops
raise pywikibot.ServerError(u'Fifth Server Error!')
- except pywikibot.SpamfilterError, e:
+ except pywikibot.SpamfilterError as e:
pywikibot.output(u'Cannot change %s because of '
u'blacklist entry %s'
% (page.title(), e.url))
break
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u'Error putting page: %s'
% (error.args,))
break
diff --git a/scripts/category.py b/scripts/category.py
index 06989ab..ddf5262 100755
--- a/scripts/category.py
+++ b/scripts/category.py
@@ -304,7 +304,7 @@
else:
pywikibot.output(u"Page %s does not exist; skipping."
% page.title(asLink=True))
- except pywikibot.IsRedirectPage, arg:
+ except pywikibot.IsRedirectPage as arg:
redirTarget = pywikibot.Page(self.site, arg.args[0])
if self.follow_redirects:
text = redirTarget.get()
@@ -349,7 +349,7 @@
pywikibot.output(
u'Skipping %s because of edit conflict'
% (page.title()))
- except pywikibot.SpamfilterError, error:
+ except pywikibot.SpamfilterError as error:
pywikibot.output(
u'Cannot change %s because of spam blacklist entry '
u'%s' % (page.title(), error.url))
@@ -435,7 +435,7 @@
newTalkTitle = newCat.toggleTalkPage().title()
try:
talkMoved = oldTalk.move(newTalkTitle, reason)
- except (pywikibot.NoPage, pywikibot.PageNotSaved), e:
+ except (pywikibot.NoPage, pywikibot.PageNotSaved) as e:
#in order :
#Source talk does not exist, or
#Target talk already exists
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py
index a6f54c3..3ec3800 100755
--- a/scripts/category_redirect.py
+++ b/scripts/category_redirect.py
@@ -118,7 +118,7 @@
'title': article.title(asLink=True, textlink=True),
'oldcat': oldCat.title(asLink=True, textlink=True),
'newcat': newCat.title(asLink=True, textlink=True)})
- except pywikibot.SpamfilterError, error:
+ except pywikibot.SpamfilterError as error:
pywikibot.output(
u'Changing page %s blocked by spam filter (URL=%s)'
% (article.title(asLink=True), error.url))
@@ -130,7 +130,7 @@
'title': article.title(asLink=True, textlink=True),
'oldcat': oldCat.title(asLink=True, textlink=True),
'newcat': newCat.title(asLink=True, textlink=True)})
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u"Saving page %s failed: %s"
% (article.title(asLink=True), error))
return False
@@ -298,7 +298,7 @@
% (template_list[0],
page.title(asLink=True,
textlink=True)))
- except pywikibot.Error, e:
+ except pywikibot.Error as e:
self.log_text.append(u"* Failed to add {{tl|%s}} to %s"
% (template_list[0],
page.title(asLink=True,
@@ -423,7 +423,7 @@
i18n.twtranslate(self.site.lang,
self.dbl_redir_comment),
minorEdit=True)
- except pywikibot.Error, e:
+ except pywikibot.Error as e:
self.log_text.append("** Failed: %s" % e)
continue
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index 441aa62..e03d7cd 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -309,7 +309,7 @@
pywikibot.output(
u'Skipping %s because of edit conflict'
% (page.title()))
- except pywikibot.SpamfilterError, error:
+ except pywikibot.SpamfilterError as error:
pywikibot.output(
u'Cannot change %s because of spam blacklist entry %s'
% (page.title(), error.url))
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index 557873e..1e50762 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -191,7 +191,7 @@
text = self.fixArabicLetters(text)
try:
text = isbn.hyphenateIsbnNumbers(text)
- except isbn.InvalidIsbnException, error:
+ except isbn.InvalidIsbnException as error:
pywikibot.log(u"ISBN error: %s" % error)
pass
if self.debug:
diff --git a/scripts/featured.py b/scripts/featured.py
index 2a24c43..eeccd09 100644
--- a/scripts/featured.py
+++ b/scripts/featured.py
@@ -603,7 +603,7 @@
except pywikibot.LockedPage:
pywikibot.output(u'Page %s is locked!'
% atrans.title())
- except pywikibot.PageNotSaved, e:
+ except pywikibot.PageNotSaved as e:
pywikibot.output(u"Page not saved")
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index dbdb9ac..ea01b18 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -80,7 +80,7 @@
for page in self.generator:
try:
self.procesPage(page)
- except Exception, e:
+ except Exception as e:
pywikibot.exception(tb=True)
def getTemplateSynonyms(self, title):
diff --git a/scripts/interwiki.py b/scripts/interwiki.py
index 74fd13b..d0c7b85 100755
--- a/scripts/interwiki.py
+++ b/scripts/interwiki.py
@@ -1995,15 +1995,15 @@
pywikibot.output(
u'ERROR putting page: An edit conflict occurred. Giving
up.')
raise SaveError(u'Edit conflict')
- except (pywikibot.SpamfilterError), error:
+ except (pywikibot.SpamfilterError) as error:
pywikibot.output(
u'ERROR putting page: %s blacklisted by spamfilter. Giving
up.'
% (error.url,))
raise SaveError(u'Spam filter')
- except (pywikibot.PageNotSaved), error:
+ except (pywikibot.PageNotSaved) as error:
pywikibot.output(u'ERROR putting page: %s' % (error.args,))
raise SaveError(u'PageNotSaved')
- except (socket.error, IOError), error:
+ except (socket.error, IOError) as error:
if timeout > 3600:
raise
pywikibot.output(u'ERROR putting page: %s' % (error.args,))
diff --git a/scripts/isbn.py b/scripts/isbn.py
index 9af931e..32d18dd 100755
--- a/scripts/isbn.py
+++ b/scripts/isbn.py
@@ -1349,10 +1349,10 @@
def getIsbn(code):
try:
i = ISBN13(code)
- except InvalidIsbnException, e13:
+ except InvalidIsbnException as e13:
try:
i = ISBN10(code)
- except InvalidIsbnException, e10:
+ except InvalidIsbnException as e10:
raise InvalidIsbnException(u'ISBN-13: %s / ISBN-10: %s'
% (e13, e10))
return i
@@ -1415,7 +1415,7 @@
code = match.group('code')
try:
getIsbn(code)
- except InvalidIsbnException, e:
+ except InvalidIsbnException as e:
pywikibot.output(e)
newText = oldText
@@ -1456,7 +1456,7 @@
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% (page.title(),))
- except pywikibot.SpamfilterError, e:
+ except pywikibot.SpamfilterError as e:
pywikibot.output(
u'Cannot change %s because of blacklist entry %s'
% (page.title(), e.url))
diff --git a/scripts/movepages.py b/scripts/movepages.py
index 24d8434..5a94858 100644
--- a/scripts/movepages.py
+++ b/scripts/movepages.py
@@ -77,7 +77,7 @@
pywikibot.output(u'Page %s is a redirect; skipping.' % page.title())
except pywikibot.LockedPage:
pywikibot.output(u'Page %s is locked!' % page.title())
- except pywikibot.PageNotSaved, e:
+ except pywikibot.PageNotSaved as e:
#target newPageTitle already exists
pywikibot.output(e.message)
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 791fb27..e3f556a 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -603,7 +603,7 @@
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% (page.title(),))
- except pywikibot.SpamfilterError, e:
+ except pywikibot.SpamfilterError as e:
pywikibot.output(
u'Cannot change %s because of blacklist entry %s'
% (page.title(), e.url))
diff --git a/scripts/nowcommons.py b/scripts/nowcommons.py
index ed90214..af33690 100644
--- a/scripts/nowcommons.py
+++ b/scripts/nowcommons.py
@@ -453,7 +453,7 @@
else:
pywikibot.output(
u'The image is not identical to the one on
Commons.')
- except (pywikibot.NoPage, pywikibot.IsRedirectPage), e:
+ except (pywikibot.NoPage, pywikibot.IsRedirectPage) as e:
pywikibot.output(u'%s' % e[0])
continue
diff --git a/scripts/pagefromfile.py b/scripts/pagefromfile.py
index 02f1fc5..2a8c56c 100644
--- a/scripts/pagefromfile.py
+++ b/scripts/pagefromfile.py
@@ -231,7 +231,7 @@
pywikibot.output(u"Page %s is locked; skipping." % title)
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict' % title)
- except pywikibot.SpamfilterError, error:
+ except pywikibot.SpamfilterError as error:
pywikibot.output(
u'Cannot change %s because of spam blacklist entry %s'
% (title, error.url))
@@ -258,7 +258,7 @@
try:
f = codecs.open(self.filename, 'r',
encoding=config.textfile_encoding)
- except IOError, err:
+ except IOError as err:
print err
return
@@ -274,7 +274,7 @@
else:
pywikibot.output(u'End of file.')
break
- except NoTitle, err:
+ except NoTitle as err:
pywikibot.output(u'\nNo title found - skipping a page.')
position += err.offset
continue
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 3c1272c..5027ecc 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -467,14 +467,14 @@
pywikibot.warning(
u"Redirect target section %s doesn't exist."
% newRedir.title(asLink=True))
- except pywikibot.CircularRedirect, e:
+ except pywikibot.CircularRedirect as e:
try:
pywikibot.warning(u"Skipping circular redirect: [[%s]]"
% str(e))
except UnicodeDecodeError:
pywikibot.warning(u"Skipping circular redirect")
break
- except pywikibot.BadTitle, e:
+ except pywikibot.BadTitle as e:
# str(e) is in the format 'BadTitle: [[Foo]]'
pywikibot.warning(
u'Redirect target %s is not a valid page title.'
@@ -589,18 +589,18 @@
redir.put(text, summary)
except pywikibot.LockedPage:
pywikibot.output(u'%s is locked.' % redir.title())
- except pywikibot.SpamfilterError, error:
+ except pywikibot.SpamfilterError as error:
pywikibot.output(
u"Saving page [[%s]] prevented by spam filter: %s"
% (redir.title(), error.url))
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u"Saving page [[%s]] failed: %s"
% (redir.title(), error))
except pywikibot.NoUsername:
pywikibot.output(
u"Page [[%s]] not saved; sysop privileges required."
% redir.title())
- except pywikibot.Error, error:
+ except pywikibot.Error as error:
pywikibot.output(
u"Unexpected error occurred trying to save [[%s]]: %s"
% (redir.title(), error))
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 6a024cd..9320ab6 100644
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -471,16 +471,16 @@
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% (page.title(),))
- except pywikibot.SpamfilterError, e:
+ except pywikibot.SpamfilterError as e:
pywikibot.output(
u'Cannot change %s because of blacklist entry %s'
% (page.title(), e.url))
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.error(u'putting page: %s' % (error.args,))
except pywikibot.LockedPage:
pywikibot.output(u'Skipping %s (locked page)'
% (page.title(),))
- except pywikibot.ServerError, e:
+ except pywikibot.ServerError as e:
pywikibot.output(u'Server Error : %s' % e)
def httpError(self, err_num, link, pagetitleaslink):
@@ -632,7 +632,7 @@
u'\03{lightred}Bad link\03{default} : %s in %s'
% (ref.url, page.title(asLink=True)))
continue
- except urllib2.HTTPError, e:
+ except urllib2.HTTPError as e:
pywikibot.output(u'HTTP error (%s) for %s on %s'
% (e.code, ref.url,
page.title(asLink=True)),
@@ -647,7 +647,7 @@
except (urllib2.URLError,
socket.error,
IOError,
- httplib.error), e:
+ httplib.error) as e:
pywikibot.output(u'Can\'t retrieve page %s : %s'
% (ref.url, e))
continue
diff --git a/scripts/replace.py b/scripts/replace.py
index e02cb0c..e95a3c1 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -408,11 +408,11 @@
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% (page.title(),))
- except pywikibot.SpamfilterError, e:
+ except pywikibot.SpamfilterError as e:
pywikibot.output(
u'Cannot change %s because of blacklist entry %s'
% (page.title(), e.url))
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u'Error putting page: %s'
% (error.args,))
except pywikibot.LockedPage:
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 9dc6d77..b435cba 100644
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -567,7 +567,7 @@
% (self.mysite.redirect(default=True), target)
try:
refPage.put_async(redir_text, comment=self.comment)
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u'Page not saved: %s' % error.args)
else:
choice = pywikibot.inputChoice(
@@ -832,7 +832,7 @@
refPage.put_async(text, comment=self.comment)
except pywikibot.LockedPage:
pywikibot.output(u'Page not saved: page is locked')
- except pywikibot.PageNotSaved, error:
+ except pywikibot.PageNotSaved as error:
pywikibot.output(u'Page not saved: %s' % error.args)
return True
diff --git a/scripts/upload.py b/scripts/upload.py
index f913e38..476841e 100755
--- a/scripts/upload.py
+++ b/scripts/upload.py
@@ -214,7 +214,7 @@
site.upload(imagepage, source_filename=temp,
ignore_warnings=self.ignoreWarning)
- except pywikibot.UploadWarning, warn:
+ except pywikibot.UploadWarning as warn:
pywikibot.output(u"We got a warning message: ", newline=False)
pywikibot.output(str(warn))
answer = pywikibot.inputChoice(u"Do you want to ignore?",
@@ -227,7 +227,7 @@
pywikibot.output(u"Upload aborted.")
return
- except Exception, e:
+ except Exception as e:
pywikibot.error("Upload error: ", exc_info=True)
else:
--
To view, visit
https://gerrit.wikimedia.org/r/98278
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iab67e2c79c9ace74cbf1d55fcd4dd17e6293f5f1
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot