From 41626b82dd5026ff3b4ecef99ea77971c9cc0e7f Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sun, 20 Jan 2019 13:00:20 +0000 Subject: [PATCH] issue #408: 2.4 compat: remove ternary if use in master.py. --- mitogen/master.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mitogen/master.py b/mitogen/master.py index 7a9f1dd9..be417a5f 100644 --- a/mitogen/master.py +++ b/mitogen/master.py @@ -145,24 +145,24 @@ LOAD_CONST = dis.opname.index('LOAD_CONST') IMPORT_NAME = dis.opname.index('IMPORT_NAME') +def _getarg(c): + if c < dis.HAVE_ARGUMENT: + return nextb() + return nextb() | (nextb() << 8) + + if sys.version_info < (3, 0): def iter_opcodes(co): # Yield `(op, oparg)` tuples from the code object `co`. ordit = imap(ord, co.co_code) nextb = ordit.next - return ((c, (None - if c < dis.HAVE_ARGUMENT else - (nextb() | (nextb() << 8)))) - for c in ordit) + return ((c, _getarg(c)) for c in ordit) elif sys.version_info < (3, 6): def iter_opcodes(co): # Yield `(op, oparg)` tuples from the code object `co`. ordit = iter(co.co_code) nextb = ordit.__next__ - return ((c, (None - if c < dis.HAVE_ARGUMENT else - (nextb() | (nextb() << 8)))) - for c in ordit) + return ((c, _getarg(c)) for c in ordit) else: def iter_opcodes(co): # Yield `(op, oparg)` tuples from the code object `co`.