diff --git a/pwiki/wiki.py b/pwiki/wiki.py index 4fcc993..1239858 100644 --- a/pwiki/wiki.py +++ b/pwiki/wiki.py @@ -51,8 +51,8 @@ def __init__(self, domain: str = "en.wikipedia.org", username: str = None, passw self._refresh_rights() - if not self._load_cookies(username): - self.login(username, password) + if username and not (self._load_cookies(username) or self.login(username, password)): + raise RuntimeError(f"Failed to login for '{username}'!") self.ns_manager: NSManager = OQuery.fetch_namespaces(self)