]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Replace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`
authorngie <ngie@FreeBSD.org>
Mon, 20 May 2019 16:38:12 +0000 (16:38 +0000)
committerngie <ngie@FreeBSD.org>
Mon, 20 May 2019 16:38:12 +0000 (16:38 +0000)
commitb833ad99216678514b7b4d599afb28762444122f
treed83ca5960aac22acbc7bd1158f802a3e7811381f
parent541db26fc3fbcd37988571c423f6e12913f66c4c
Replace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`

Python 3 no longer doesn't support encoding/decoding hexadecimal numbers using
the `str.format` method. The backwards compatible new method (using the
binascii module/methods) is a comparable means of converting to/from
hexadecimal format.

In short, the functional change is the following:
* `foo.decode('hex')` -> `binascii.unhexlify(foo)`
* `foo.encode('hex')` -> `binascii.hexlify(foo)`

While here, move the dpkt import in `cryptodev.py` down per PEP8, so it comes
after the standard library provided imports.

PR: 237403
MFC after: 1 week
tests/sys/opencrypto/cryptodev.py
tests/sys/opencrypto/cryptotest.py