summaryrefslogtreecommitdiff
path: root/pysnmp/proto
diff options
context:
space:
mode:
authorEugene M. Kim <astralblue@gmail.com>2017-10-14 01:45:22 -0700
committerIlya Etingof <etingof@gmail.com>2017-10-14 10:45:22 +0200
commit82bba9540774db9d0bcbc1c3d88d46e8b23806f7 (patch)
treeed68a22629854bc0d838451c5cefbcaf4a5e852f /pysnmp/proto
parentcd8d66f8a164a3bc7bf584826fd17c79fac6d428 (diff)
downloadpysnmp-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/proto')
-rw-r--r--pysnmp/proto/rfc1155.py8
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