]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
Move __str__ to the generic Option code.
authorBrian Wellington <bwelling@xbill.org>
Wed, 8 Jul 2020 17:32:01 +0000 (10:32 -0700)
committerBrian Wellington <bwelling@xbill.org>
Wed, 8 Jul 2020 17:32:01 +0000 (10:32 -0700)
ECSOption and GenericOption both contained a __str__ method that called
to_text(), but the base Option class did not.  Move __str__ to the base
class.

dns/edns.py

index 4ad3a5c1547807e1e6da5697e59ee3482dfcc0cd..28718d523501c7488ef8b35c14764fe3137833d4 100644 (file)
@@ -135,6 +135,9 @@ class Option:
             return NotImplemented
         return self._cmp(other) > 0
 
+    def __str__(self):
+        return self.to_text()
+
 
 class GenericOption(Option):
 
@@ -161,8 +164,6 @@ class GenericOption(Option):
     def from_wire_parser(cls, otype, parser):
         return cls(otype, parser.get_remaining())
 
-    def __str__(self):
-        return self.to_text()
 
 class ECSOption(Option):
     """EDNS Client Subnet (ECS, RFC7871)"""
@@ -291,9 +292,6 @@ class ECSOption(Option):
 
         return cls(addr, src, scope)
 
-    def __str__(self):
-        return self.to_text()
-
 
 _type_to_class = {
     OptionType.ECS: ECSOption