IDEA-CR-61853: PY-41642 Don't rely on Python version when importing _unpack_args, try and catch error instead

The `_unpack_args` function doesn't seem to be available in early versions of Python 3. So it's better not to rely on the Python version check and just try importing the function and execute the fallback code inside the except clause.

(cherry picked from commit 0b5125e3c00602372528ae545e9d5677939619ee)

GitOrigin-RevId: 294d436d661baf8f8329fb1e2cff755391a49a50
This commit is contained in:
Andrey Lisin
2020-04-23 11:53:06 +00:00
committed by intellij-monorepo-bot
parent e23b287ef8
commit 10a42be9c3
@@ -102,9 +102,11 @@ def _is_make_opname(opname):
Instruction = namedtuple("Instruction", ["opname", "opcode", "arg", "argval", "lineno", "offset"])
if IS_PY3K:
_unpack_opargs = dis._unpack_opargs
long = int
else:
try:
_unpack_opargs = dis._unpack_opargs
except AttributeError:
def _unpack_opargs(code):
n = len(code)
i = 0