]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
float_latitude and float_longitude returned the wrong sign on values
authorBob Halley <halley@dnspython.org>
Mon, 19 Dec 2005 07:28:20 +0000 (07:28 +0000)
committerBob Halley <halley@dnspython.org>
Mon, 19 Dec 2005 07:28:20 +0000 (07:28 +0000)
for south latitudes and west longitudes.

ChangeLog
dns/rdtypes/ANY/LOC.py
tests/bugs.py [new file with mode: 0644]

index 336cc7ebeca73a9714c591f1da85410f30406770..d468dc1abd3d5b58b9d2482188915df7b51ad8de 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2005-12-18  Bob Halley  <halley@dnspython.org>
+
+       * dns/rdtypes/ANY/LOC.py (_tuple_to_float): The sign was lost when
+         converting a tuple into a float, which broke conversions of
+         south latitudes and west longitudes.
+
 2005-11-17  Bob Halley  <halley@dnspython.org>
 
        * dns/zone.py: The 'origin' parameter to from_text() and from_file()
index 30db17a3f2f3c4064cb3cf32287948797f4f9f86..b7a15df544e9b0fa7e1ea396b75bd1ba07e36d67 100644 (file)
@@ -58,7 +58,7 @@ def _tuple_to_float(what):
     value += float(what[1]) / 60.0
     value += float(what[2]) / 3600.0
     value += float(what[3]) / 3600000.0
-    return value
+    return sign * value
 
 def _encode_size(what, desc):
     what = long(what);
diff --git a/tests/bugs.py b/tests/bugs.py
new file mode 100644 (file)
index 0000000..8fa9cb5
--- /dev/null
@@ -0,0 +1,31 @@
+# Copyright (C) 2005 Nominum, Inc.
+#
+# Permission to use, copy, modify, and distribute this software and its
+# documentation for any purpose with or without fee is hereby granted,
+# provided that the above copyright notice and this permission notice
+# appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+import unittest
+
+import dns.rdata
+import dns.rdataclass
+import dns.rdatatype
+
+class BugsTestCase(unittest.TestCase):
+
+    def test_float_LOC(self):
+        rdata = dns.rdata.from_text(dns.rdataclass.IN, dns.rdatatype.LOC,
+                                    "30 30 0.000 N 100 30 0.000 W 10.00m 20m 2000m 20m")
+        self.failUnless(rdata.float_latitude == 30.5)
+        self.failUnless(rdata.float_longitude == -100.5)
+
+if __name__ == '__main__':
+    unittest.main()