svn commit: r348031 - head/tests/sys/opencrypto
Enji Cooper
ngie at FreeBSD.org
Tue May 21 02:13:47 UTC 2019
Author: ngie
Date: Tue May 21 02:13:46 2019
New Revision: 348031
URL: https://svnweb.freebsd.org/changeset/base/348031
Log:
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
Modified:
head/tests/sys/opencrypto/cryptodev.py
Modified: head/tests/sys/opencrypto/cryptodev.py
==============================================================================
--- head/tests/sys/opencrypto/cryptodev.py Tue May 21 02:02:09 2019 (r348030)
+++ head/tests/sys/opencrypto/cryptodev.py Tue May 21 02:13:46 2019 (r348031)
@@ -38,6 +38,7 @@ import os
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 @@ class Crypto:
#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 @@ class Crypto:
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)))
More information about the svn-src-head
mailing list