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

Change subject: [IMPR] Ignore Exception when removing an 'File' namespace alias
......................................................................

[IMPR] Ignore Exception when removing an 'File' namespace alias

Change-Id: Ifa19e2b4faaa86fdb83ec90acd8d7131cecf1808
---
M pywikibot/cosmetic_changes.py
1 file changed, 8 insertions(+), 7 deletions(-)

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



diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py
index 522f153..7422bc5 100644
--- a/pywikibot/cosmetic_changes.py
+++ b/pywikibot/cosmetic_changes.py
@@ -55,6 +55,7 @@
 # Distributed under the terms of the MIT license.
 #
 import re
+from contextlib import suppress
 from enum import IntEnum
 from typing import Any, Union
 from urllib.parse import urlparse, urlunparse
@@ -403,17 +404,17 @@
             if namespace == 6 and self.site.family.name == 'wikipedia':
                 if self.site.code in ('en', 'fr'):
                     # do not change "Image" on en-wiki and fr-wiki
-                    assert 'Image' in namespaces
-                    namespaces.remove('Image')
+                    with suppress(ValueError):
+                        namespaces.remove('Image')
                 if self.site.code == 'hu':
                     # do not change "Kép" on hu-wiki
-                    assert 'Kép' in namespaces
-                    namespaces.remove('Kép')
+                    with suppress(ValueError):
+                        namespaces.remove('Kép')
                 elif self.site.code == 'pt':
                     # use "Imagem" by default on pt-wiki (per T57242)
-                    assert 'Imagem' in namespaces
-                    namespaces.insert(
-                        0, namespaces.pop(namespaces.index('Imagem')))
+                    with suppress(ValueError):
+                        namespaces.insert(
+                            0, namespaces.pop(namespaces.index('Imagem')))
             # final namespace variant
             final_ns = namespaces.pop(0)
             if namespace in (2, 3):

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/807508
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: Ifa19e2b4faaa86fdb83ec90acd8d7131cecf1808
Gerrit-Change-Number: 807508
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[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