Date: Tue, 21 May 2019 02:13:46 +0000 (UTC) From: Enji Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r348031 - head/tests/sys/opencrypto Message-ID: <201905210213.x4L2DkbQ037565@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905210213.x4L2DkbQ037565>