jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/526514 )
Change subject: [PY3] Make pywikibot more Python 3 compatible
......................................................................
[PY3] Make pywikibot more Python 3 compatible
Due to PEP 237 short int operations returns a long if sys.maxint is
exceeded instead raising an OverFlowError. This behavior was introduced
with Python 2.2 and therefore it is not necessary to derive Python 3
int to long anymore.
Change-Id: I633d0895409c131183f436fdf15900a3dcb4bc0a
---
M pywikibot/__init__.py
M pywikibot/page.py
M scripts/replace.py
M tests/utils.py
4 files changed, 13 insertions(+), 16 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 662e746..9c9632d 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -74,7 +74,6 @@
if not PY2:
from queue import Queue
- long = int
else:
from Queue import Queue
@@ -507,7 +506,7 @@
to minutes.
@param year: The year as a signed integer of between 1 and 16 digits.
- @type year: long
+ @type year: int
@param month: Month
@type month: int
@param day: Day
@@ -551,7 +550,7 @@
if month is None:
self.precision = self.PRECISION['year']
month = 1
- self.year = long(year)
+ self.year = year
self.month = month
self.day = day
self.hour = hour
@@ -614,7 +613,7 @@
if not match:
raise ValueError("Invalid format: '%s'" % datetimestr)
t = match.groups()
- return cls(long(t[0]), int(t[1]), int(t[2]),
+ return cls(int(t[0]), int(t[1]), int(t[2]),
int(t[3]), int(t[4]), int(t[5]),
precision, before, after, timezone, calendarmodel, site)
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 07fbdbe..c8d3187 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -53,7 +53,6 @@
from pywikibot.tools.ip import is_IP, ip_regexp
if not PY2:
- long = int
from html import entities as htmlentitydefs
from urllib.parse import quote_from_bytes, unquote_to_bytes
else:
@@ -783,7 +782,7 @@
If the page has only one revision, it shall return -1.
- @rtype: long
+ @rtype: int
@raise AssertionError: Use on MediaWiki prior to v1.16.
"""
@@ -797,7 +796,7 @@
DEPRECATED: Use latest_revision.parent_id instead.
- @rtype: long
+ @rtype: int
@raise AssertionError: Use on MediaWiki prior to v1.16.
"""
@@ -3333,11 +3332,11 @@
@param force: if True, forces reloading the data from API
@type force: bool
- @return: long (MediaWiki's internal timestamp format) or 0
- @rtype: int or long
+ @return: int (MediaWiki's internal timestamp format) or 0
+ @rtype: int
"""
if self.registration():
- return long(self.registration().strftime('%Y%m%d%H%M%S'))
+ return int(self.registration().strftime('%Y%m%d%H%M%S'))
else:
return 0
@@ -3365,7 +3364,7 @@
@param force: if True, forces reloading the data from API
@type force: bool
- @rtype: int or long
+ @rtype: int
"""
return self.getprops(force).get('editcount', 0)
@@ -4149,7 +4148,7 @@
"""
Get the revision identifier for the most recent revision of the entity.
- @rtype: long
+ @rtype: int
"""
if not hasattr(self, '_revid'):
self.get()
@@ -5590,7 +5589,7 @@
@param rollbacktoken: rollback token
@type rollbacktoken: str
@param parentid: id of parent Revision (v1.16+)
- @type parentid: long
+ @type parentid: int
@param contentmodel: content model label (v1.21+)
@type contentmodel: str
@param sha1: sha1 of revision text (v1.19+)
@@ -5616,7 +5615,7 @@
Returns 0 if there is no previous revision
@return: id of parent/previous revision
- @rtype: int or long
+ @rtype: int
@raises AssertionError: parent id not supplied to the constructor
"""
assert self._parent_id is not None, (
diff --git a/scripts/replace.py b/scripts/replace.py
index 339dfb5..237c317 100755
--- a/scripts/replace.py
+++ b/scripts/replace.py
@@ -169,7 +169,6 @@
if not PY2:
from queue import Queue
- long = int
else:
from Queue import Queue
diff --git a/tests/utils.py b/tests/utils.py
index 89f54e8..fefff75 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -645,7 +645,7 @@
@type command: list of unicode
"""
if PY2:
- command.insert(1, '-W ignore::FutureWarning:pywikibot:125')
+ command.insert(1, '-W ignore::FutureWarning:pywikibot:124')
if cryptography_version and cryptography_version < [1, 3, 4]:
command.insert(1, '-W ignore:Old version of cryptography:Warning')
# Any environment variables added on Windows must be of type
--
To view, visit
https://gerrit.wikimedia.org/r/526514
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I633d0895409c131183f436fdf15900a3dcb4bc0a
Gerrit-Change-Number: 526514
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)