From eaa6f4d361863b443c7eb7526523fe1bc5ad8ae5 Mon Sep 17 00:00:00 2001 From: Elizaveta Shashkova Date: Wed, 12 Apr 2017 14:17:45 +0300 Subject: [PATCH] Cython speedups break debugging with Stackless (PY-23283) The problem appears when compiling Cython extensions with Cython 0.25, and it doesn't appear when compiling them with Cython 0.24. It looks like it's Cython bug, but we can't use old version of Cython, because it isn't compatible with Python 3.6 on Windows. So we have to (temporarily) disable Cython extensions for Stackless despite the fact that its implementation is "CPython". --- .../pydev/_pydevd_bundle/pydevd_constants.py | 3 ++- .../_pydevd_bundle/pydevd_trace_dispatch.py | 23 ++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py index cc6fa53ca178..224e9b5acd77 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py @@ -51,6 +51,7 @@ if IS_JYTHON: if sys.version_info[0] == 2 and sys.version_info[1] < 5: IS_JYTH_LESS25 = True +IS_PYTHON_STACKLESS = "stackless" in sys.version.lower() CYTHON_SUPPORTED = False try: @@ -59,7 +60,7 @@ try: except: pass else: - if python_implementation == 'CPython': + if python_implementation == 'CPython' and not IS_PYTHON_STACKLESS: # Only available for CPython! if ( (sys.version_info[0] == 2 and sys.version_info[1] >= 7) diff --git a/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py b/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py index f43a5b0cf2a3..18f579685706 100644 --- a/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py +++ b/python/helpers/pydev/_pydevd_bundle/pydevd_trace_dispatch.py @@ -2,8 +2,16 @@ # Should give warning only here if cython is not available but supported. import os -use_cython = os.getenv('PYDEVD_USE_CYTHON', None) import sys +from _pydevd_bundle.pydevd_constants import CYTHON_SUPPORTED + + +use_cython = os.getenv('PYDEVD_USE_CYTHON', None) +dirname = os.path.dirname(os.path.dirname(__file__)) +# Do not show incorrect warning for .egg files for Remote debugger +if not CYTHON_SUPPORTED or dirname.endswith('.egg'): + # Do not try to import cython extensions if cython isn't supported + use_cython = 'NO' def delete_old_compiled_extensions(): @@ -55,17 +63,10 @@ elif use_cython is None: except ImportError: from _pydevd_bundle.pydevd_additional_thread_info_regular import PyDBAdditionalThreadInfo # @UnusedImport from _pydevd_bundle.pydevd_trace_dispatch_regular import trace_dispatch, global_cache_skips, global_cache_frame_skips # @UnusedImport - from _pydevd_bundle.pydevd_constants import CYTHON_SUPPORTED + from _pydev_bundle.pydev_monkey import log_error_once - dirname = os.path.dirname(os.path.dirname(__file__)) - if dirname.endswith('.egg'): - # Do not show incorrect warning for .egg files for Remote debugger - CYTHON_SUPPORTED = False - - if CYTHON_SUPPORTED: - from _pydev_bundle.pydev_monkey import log_error_once - log_error_once("warning: Debugger speedups using cython not found. Run '\"%s\" \"%s\" build_ext --inplace' to build." % ( - sys.executable, os.path.join(dirname, 'setup_cython.py'))) + log_error_once("warning: Debugger speedups using cython not found. Run '\"%s\" \"%s\" build_ext --inplace' to build." % ( + sys.executable, os.path.join(dirname, 'setup_cython.py'))) else: raise RuntimeError('Unexpected value for PYDEVD_USE_CYTHON: %s (accepted: YES, NO)' % (use_cython,))