jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Prevent string comparison for Coordinate ......................................................................
[FIX] Prevent string comparison for Coordinate
When it tries to compare a string to `Coordinate` it previously parsed the string and returned True if the string matched the coordinate. Otherwise it just continued to work on it and compared the object with the string directly which never evaluated to True, so it always returned False.
But with 4f4770f3 `Coordinate` implements `__eq__` and now that method tries to compare a string to a `Coordinate` and that raises a `AttributeError`. So instead of just returning True and falling back to the default comparison otherwise it directly returns False if the comparison with the parsed string failed.
Change-Id: Ibe322383a319c57fd20db43758f87864550ea0e4 --- M pywikibot/page.py 1 file changed, 2 insertions(+), 3 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved Hashar: Looks good to me, but someone else must approve jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py index a69f09a..652773e 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -4428,9 +4428,8 @@ except TypeError: pass
- if (abs(self.target.lat - coord_args[0]) <= precision and - abs(self.target.lon - coord_args[1]) <= precision): - return True + return (abs(self.target.lat - coord_args[0]) <= precision and + abs(self.target.lon - coord_args[1]) <= precision)
if self.target == value: return True
pywikibot-commits@lists.wikimedia.org