From 7637bcd46b4a4fdb2c0fb89a736f2fa78d19c4d8 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Thu, 29 Mar 2018 18:21:50 +0300 Subject: [PATCH] Fix debugging for IronPython (PY-20959) --- python/helpers/pydev/_pydevd_bundle/pydevd_comm.py | 8 +++++++- .../helpers/pydev/_pydevd_bundle/pydevd_constants.py | 12 ++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py b/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py index 03069d2e6b7f..a355d7c1f02a 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py @@ -67,12 +67,18 @@ from _pydev_imps._pydev_saved_modules import threading from _pydev_imps._pydev_saved_modules import socket from socket import socket, AF_INET, SOCK_STREAM, SHUT_RD, SHUT_WR, SOL_SOCKET, SO_REUSEADDR, SHUT_RDWR, timeout from _pydevd_bundle.pydevd_constants import DebugInfoHolder, get_thread_id, IS_JYTHON, IS_PY2, IS_PY3K, \ - IS_PY36_OR_GREATER, STATE_RUN, dict_keys, ASYNC_EVAL_TIMEOUT_SEC + IS_PY36_OR_GREATER, STATE_RUN, dict_keys, ASYNC_EVAL_TIMEOUT_SEC, IS_IRONPYTHON try: from urllib import quote_plus, unquote, unquote_plus except: from urllib.parse import quote_plus, unquote, unquote_plus #@Reimport @UnresolvedImport + +if IS_IRONPYTHON: + # redefine `unquote` for IronPython, since we use it only for logging messages, but it leads to SOF with IronPython + def unquote(s): + return s + import pydevconsole from _pydevd_bundle import pydevd_vars from _pydevd_bundle import pydevd_xml diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py index 000ae410336d..e3da2bc02085 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py @@ -20,8 +20,18 @@ class DebugInfoHolder: #Hold a reference to the original _getframe (because psyco will change that as soon as it's imported) import sys #Note: the sys import must be here anyways (others depend on it) +IS_IRONPYTHON = sys.platform == 'cli' try: get_frame = sys._getframe + if IS_IRONPYTHON: + def get_frame(): + try: + return sys._getframe() + except ValueError: + if IS_IRONPYTHON: + pass + else: + raise except AttributeError: def get_frame(): raise AssertionError('sys._getframe not available (possible causes: enable -X:Frames on IronPython?)') @@ -38,8 +48,6 @@ import os from _pydevd_bundle import pydevd_vm_type IS_JYTHON = pydevd_vm_type.get_vm_type() == pydevd_vm_type.PydevdVmType.JYTHON -IS_IRONPYTHON = sys.platform == 'cli' - IS_JYTH_LESS25 = False if IS_JYTHON: if sys.version_info[0] == 2 and sys.version_info[1] < 5: