From ab093124de0e9b0bb5d5797de7296161a2e62b40 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 21 Oct 2019 20:01:45 +0100 Subject: [PATCH] catacomb/__init__.py: Hack because Python 3 `hex' builtin works differently. In Python 3, the `hex' builtin function converts its operand to an integer (using the new `__index__' special method) and then converts that to hex, rather than calling a special method directly. The new `bytes' type offers a `hex' method for conversion to hex, so we do the same here. --- catacomb/__init__.py | 6 +++--- t/t-passphrase.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/catacomb/__init__.py b/catacomb/__init__.py index 9e4d47f..22b1fdf 100644 --- a/catacomb/__init__.py +++ b/catacomb/__init__.py @@ -180,10 +180,10 @@ class _tmp: def fromhex(x): return ByteString(_unhexify(x)) fromhex = staticmethod(fromhex) - def __hex__(me): - return _hexify(me) + def hex(me): return _hexify(me) + __hex__ = hex def __repr__(me): - return 'bytes(%r)' % hex(me) + return 'bytes(%r)' % me.hex() _augment(ByteString, _tmp) ByteString.__hash__ = str.__hash__ bytes = ByteString.fromhex diff --git a/t/t-passphrase.py b/t/t-passphrase.py index 9cc80a9..d9a985a 100644 --- a/t/t-passphrase.py +++ b/t/t-passphrase.py @@ -46,7 +46,7 @@ class PixieTestCase (U.TestCase): pix = "pixie-py%d.%d%s" % (SYS.version_info[0], SYS.version_info[1], T.DEBUGP and "dbg" or "") - me.token = hex(C.rand.block(8)) + me.token = C.rand.block(8).hex() try: OS.mkdir(OS.path.join("build", pix), int("700", 8)) except OSError: if SYS.exc_info()[1].errno == E.EEXIST: pass -- 2.11.0