mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-23 11:18:54 +00:00
Squash deprecation warning related to array.array(..).tostring()
In version 3.2+, `array.array(..).tostring()` was renamed to `array.array(..).tobytes()`. Conditionally call `array.array(..).tobytes()` if the python version is 3.2+. PR: 237403 MFC after: 1 week
This commit is contained in:
parent
b2775610c0
commit
8c02634818
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348031
@ -38,6 +38,7 @@
|
||||
import random
|
||||
import signal
|
||||
from struct import pack as _pack
|
||||
import sys
|
||||
import time
|
||||
|
||||
import dpkt
|
||||
@ -151,6 +152,11 @@ def _findop(crid, name):
|
||||
|
||||
return fop.crid, name
|
||||
|
||||
def array_tobytes(array_obj):
|
||||
if sys.version_info[:2] >= (3, 2):
|
||||
return array_obj.tobytes()
|
||||
return array_obj.tostring()
|
||||
|
||||
class Crypto:
|
||||
@staticmethod
|
||||
def findcrid(name):
|
||||
@ -218,9 +224,9 @@ def _doop(self, op, src, iv):
|
||||
#print('cop:', cop)
|
||||
ioctl(_cryptodev, CIOCCRYPT, str(cop))
|
||||
|
||||
s = s.tostring()
|
||||
s = array_tobytes(s)
|
||||
if self._maclen is not None:
|
||||
return s, m.tostring()
|
||||
return s, array_tobytes(m)
|
||||
|
||||
return s
|
||||
|
||||
@ -255,9 +261,9 @@ def _doaead(self, op, src, aad, iv, tag=None):
|
||||
|
||||
ioctl(_cryptodev, CIOCCRYPTAEAD, str(caead))
|
||||
|
||||
s = s.tostring()
|
||||
s = array_tobytes(s)
|
||||
|
||||
return s, tag.tostring()
|
||||
return s, array_tobytes(tag)
|
||||
|
||||
def perftest(self, op, size, timeo=3):
|
||||
inp = array.array('B', (random.randint(0, 255) for x in range(size)))
|
||||
|
Loading…
Reference in New Issue
Block a user