HomeFreeBSD

Replace uses of `foo.(de|en)code('hex')` with `binascii.(un)?hexlify(foo)`

Description

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

Details

Committed
ngieMay 20 2019, 4:38 PM
Parents
rS347995: MFC r329348 (by brooks):
Branches
Unknown
Tags
Unknown