summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2005-12-19 07:28:20 +0000
committerBob Halley <halley@dnspython.org>2005-12-19 07:28:20 +0000
commitc3564754b283c7f3446bc940ec7b259e15e5ffe1 (patch)
tree3c53a657cb402b403056ee6809c25c172dfb4f6f
parent0f015b7e7483bbdbfc49691b0ac75a29ec21c9d0 (diff)
downloaddnspython-c3564754b283c7f3446bc940ec7b259e15e5ffe1.tar.gz
float_latitude and float_longitude returned the wrong sign on values
for south latitudes and west longitudes.
-rw-r--r--ChangeLog6
-rw-r--r--dns/rdtypes/ANY/LOC.py2
-rw-r--r--tests/bugs.py31
3 files changed, 38 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 336cc7e..d468dc1 100644
--- 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()
diff --git a/dns/rdtypes/ANY/LOC.py b/dns/rdtypes/ANY/LOC.py
index 30db17a..b7a15df 100644
--- a/dns/rdtypes/ANY/LOC.py
+++ b/dns/rdtypes/ANY/LOC.py
@@ -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
index 0000000..8fa9cb5
--- /dev/null
+++ b/tests/bugs.py
@@ -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()