From 10a42be9c35be26f5bf5264976d83cb5a3665ade Mon Sep 17 00:00:00 2001 From: Andrey Lisin Date: Thu, 16 Apr 2020 15:56:27 +0300 Subject: [PATCH] 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 --- .../helpers/pydev/_pydevd_bundle/pydevd_bytecode_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_bytecode_utils.py b/python/helpers/pydev/_pydevd_bundle/pydevd_bytecode_utils.py index 35a19647165b..2a80eef077ca 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_bytecode_utils.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_bytecode_utils.py @@ -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