diff --git a/wikitools3/api.py b/wikitools3/api.py index 6ba2e5a..35414e8 100644 --- a/wikitools3/api.py +++ b/wikitools3/api.py @@ -96,7 +96,7 @@ def __init__(self, wiki, data, write=False, multipart=False): self.response = False if wiki.auth: self.headers["Authorization"] = "Basic {0}".format( - base64.encodestring(f"{wiki.auth}:{wiki.httppass}") + base64.encodebytes(f"{wiki.auth}:{wiki.httppass}".encode()).decode() ).replace("\n", "") if hasattr(wiki, "passman"): self.opener = urllib.request.build_opener( diff --git a/wikitools3/page.py b/wikitools3/page.py index a79d3c2..138480b 100644 --- a/wikitools3/page.py +++ b/wikitools3/page.py @@ -166,7 +166,7 @@ def setPageInfo(self): params["redirects"] = "" req = api.APIRequest(self.site, params) response = req.query(False) - self.pageid = response["query"]["pages"].keys()[0] + self.pageid = int(list(response["query"]["pages"].keys())[0]) if self.pageid > 0: self.exists = True if "missing" in response["query"]["pages"][str(self.pageid)]: @@ -185,7 +185,7 @@ def setPageInfo(self): self.unprefixedtitle = self.title.split(":", 1)[1] else: self.unprefixedtitle = self.title - self.pageid = int(self.pageid) + self.pageid = self.pageid self.pageid = max(self.pageid, 0) return self diff --git a/wikitools3/wiki.py b/wikitools3/wiki.py index cc4a665..d9d0458 100644 --- a/wikitools3/wiki.py +++ b/wikitools3/wiki.py @@ -375,7 +375,7 @@ def getToken(self, type): token = response["query"]["pages"][pid]["edittoken"] else: pages = response["query"]["pages"] - token = pages.itervalues().next()["edittoken"] + token = next(iter(pages.values()))["edittoken"] return token def __hash__(self):