XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/247042

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/42/247042/1

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

-- 
To view, visit https://gerrit.wikimedia.org/r/247042
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe322383a319c57fd20db43758f87864550ea0e4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to