Mark Bergsma has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/354685 )
Change subject: Use a bytearray to encode prefixes in BGP.encodePrefixes
......................................................................
Use a bytearray to encode prefixes in BGP.encodePrefixes
Converts back to str before returning, as some depending code
(including Twisted) can't handle bytearrays yet.
Change-Id: I0ccc231cce89ebcaf27f6c340ffea59dec35ed67
---
M pybal/bgp.py
1 file changed, 3 insertions(+), 3 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/operations/debs/pybal
refs/changes/85/354685/1
diff --git a/pybal/bgp.py b/pybal/bgp.py
index 5f186f0..e430cdd 100644
--- a/pybal/bgp.py
+++ b/pybal/bgp.py
@@ -1886,16 +1886,16 @@
def encodePrefixes(prefixes):
"""Encodes a list of IPPrefix"""
- prefixData = ""
+ prefixData = bytearray()
for prefix in prefixes:
octetLen, remainder = len(prefix) / 8, len(prefix) % 8
if remainder > 0:
# prefix length doesn't fall on octet boundary
octetLen += 1
- prefixData += struct.pack('!B', len(prefix)) +
prefix.packed()[:octetLen]
+ prefixData.extend(struct.pack('!B', len(prefix)) +
prefix.packed()[:octetLen])
- return prefixData
+ return str(prefixData)
class BGPFactory(protocol.Factory):
--
To view, visit https://gerrit.wikimedia.org/r/354685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ccc231cce89ebcaf27f6c340ffea59dec35ed67
Gerrit-PatchSet: 1
Gerrit-Project: operations/debs/pybal
Gerrit-Branch: master
Gerrit-Owner: Mark Bergsma <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits