From 12b45cc948e4d2261b7947ffcfb4ae7893c9a756 Mon Sep 17 00:00:00 2001
From: Adam Williamson <awilliam@redhat.com>
Date: Mon, 26 Aug 2024 16:37:45 -0700
Subject: [PATCH] guess_namespace: drop odd fallback to default_namespaces

This fallback seems broken and weird. I can't see why:

1) We do it at all
2) Given that we do it, we do it only for namespace IDs in
   site.namespaces

It's existed since the first version of mwclient, but I really
can't see how it's valid. A `Site` instance's `self.namespaces`
starts out as `default_namespaces`, then in `site_init`, we read
in the real namespace configuration of the specific wiki. If the
wiki changes the default namespaces, we should respect that. So
it seems to me we should just trust `self.namespaces`. I don't
see how any kind of fallback to `self.default_namespaces` is ever
going to give a more useful result than not doing it.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
---
 mwclient/listing.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/mwclient/listing.py b/mwclient/listing.py
index 1873bde..0283cef 100644
--- a/mwclient/listing.py
+++ b/mwclient/listing.py
@@ -275,10 +275,6 @@ class PageList(GeneratorList):
             namespace = f'{self.site.namespaces[ns].replace(" ", "_")}:'
             if name.startswith(namespace):
                 return ns
-            elif ns in self.site.default_namespaces:
-                namespace = f'{self.site.default_namespaces[ns].replace(" ", "_")}:'
-                if name.startswith(namespace):
-                    return ns
         return 0
 
 
-- 
GitLab