diff options
author | Eugene M. Kim <astralblue@gmail.com> | 2017-10-14 01:45:22 -0700 |
---|---|---|
committer | Ilya Etingof <etingof@gmail.com> | 2017-10-14 10:45:22 +0200 |
commit | 82bba9540774db9d0bcbc1c3d88d46e8b23806f7 (patch) | |
tree | ed68a22629854bc0d838451c5cefbcaf4a5e852f /pysnmp | |
parent | cd8d66f8a164a3bc7bf584826fd17c79fac6d428 (diff) | |
download | pysnmp-git-82bba9540774db9d0bcbc1c3d88d46e8b23806f7.tar.gz |
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.
Diffstat (limited to 'pysnmp')
-rw-r--r-- | pysnmp/proto/rfc1155.py | 8 |
1 files changed, 5 insertions, 3 deletions
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 |