From 82bba9540774db9d0bcbc1c3d88d46e8b23806f7 Mon Sep 17 00:00:00 2001 From: "Eugene M. Kim" Date: Sat, 14 Oct 2017 01:45:22 -0700 Subject: Let NetworkAddress be cloned from another NetworkAddress (#93) This is to meet the basic clone() contract and unbreak round-trip index conversions. Previously only IPAddress values were allowed as the clone source. --- pysnmp/proto/rfc1155.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pysnmp/proto') diff --git a/pysnmp/proto/rfc1155.py b/pysnmp/proto/rfc1155.py index 35f6110b..65c450ef 100644 --- a/pysnmp/proto/rfc1155.py +++ b/pysnmp/proto/rfc1155.py @@ -66,9 +66,11 @@ class NetworkAddress(univ.Choice): """ cloned = univ.Choice.clone(self, **kwargs) if value is not univ.noValue: - # IpAddress is the only supported type, perhaps forever because - # this is SNMPv1. - if not isinstance(value, IpAddress): + if isinstance(value, NetworkAddress): + value = value.getComponent() + elif not isinstance(value, IpAddress): + # IpAddress is the only supported type, perhaps forever because + # this is SNMPv1. value = IpAddress(value) try: tagSet = value.tagSet -- cgit v1.2.1