Debug Flask fails at breakpoints after 2019.2 update

Hi,

All this started after the recent 2019.2 update.

I have a Flask app. It runs normally when not debugging.

If I try to debug it with breakpoints set somewhere in view functions, it never reach a breakpoint and the whole debug process starts throwing exceptions and ends with

Process finished with exit code -1

Before that it throws these exceptions

SystemError: ..\Objects\codeobject.c:851: bad argument to internal function

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 1056, in _pydevd_bundle.pydevd_cython_win32_36_64.fix_top_level_trace_and_get_trace_func
File "C:\Program Files\Python36\lib\ntpath.py", line 235, in basename
File "C:\Program Files\Python36\lib\ntpath.py", line 204, in split
SystemError: <built-in function fspath> returned a result with an error set
Exception ignored in: '_pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.get_bytecode_while_frame_eval'
Traceback (most recent call last):
File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 1056, in _pydevd_bundle.pydevd_cython_win32_36_64.fix_top_level_trace_and_get_trace_func
File "C:\Program Files\Python36\lib\ntpath.py", line 235, in basename
File "C:\Program Files\Python36\lib\ntpath.py", line 204, in split
SystemError: <built-in function fspath> returned a result with an error set
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 729, in __call__
File "C:\Program Files\Python36\lib\threading.py", line 884, in _bootstrap
SystemError: error return without exception set

During handling of the above exception, another exception occurred:

SystemError: ..\Objects\codeobject.c:851: bad argument to internal function

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "_pydevd_frame_eval\pydevd_frame_evaluator_win32_36_64.pyx", line 191, in _pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.get_func_code_info
SystemError: <class '_pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.FuncCodeInfo'> returned a result with an error set
Exception ignored in: '_pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.get_bytecode_while_frame_eval'
Traceback (most recent call last):
File "_pydevd_frame_eval\pydevd_frame_evaluator_win32_36_64.pyx", line 191, in _pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.get_func_code_info
SystemError: <class '_pydevd_frame_eval.pydevd_frame_evaluator_win32_36_64.FuncCodeInfo'> returned a result with an error set
Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace object at 0x0000015DD1193C50>
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 729, in __call__
File "C:\Program Files\Python36\lib\threading.py", line 884, in _bootstrap
SystemError: error return without exception set

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 732, in __call__
File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 1029, in _pydevd_bundle.pydevd_cython_win32_36_64.SafeCallWrapper.__call__
File "_pydevd_bundle\pydevd_cython_win32_36_64.pyx", line 1203, in _pydevd_bundle.pydevd_cython_win32_36_64.TopLevelThreadTracerOnlyUnhandledExceptions.trace_unhandled_exceptions
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 110, in stop_on_unhandled_exception
File "C:\Program Files\JetBrains\PyCharm 2019.2\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 91, in get_exception_breakpoint
SystemError: error return without exception set

What do I do wrong? Have no functioning debug after the 2019.2 update...

Regards,

Vladimir

10 comments
Comment actions Permalink

Hi Vladimir,

Would it be possible to provide some sample project for reproducing?
I tried it with my Flask projects, but it works fine.

You can upload it to https://uploads.services.jetbrains.com/ zipped but please let me know the name of the file so I can find it.

0
Comment actions Permalink

Hi Sergey, thank you for the reply.

The app is quite big, fast attempt to compile a sample project with error did not give results. Unfortunately I cannot spend much time on locating the error now.

0
Comment actions Permalink

After the new update 2019.2.1 of Pycharm I can again use breakpoints in my Flask app.

0
Comment actions Permalink

I have similar problem when using Pycharm Professional 2019.2 or 2019.2.1 .  Using Pycharm Professional 2019.1.3 there is no problem.

operating system: ubuntu 18.04, updated

I am placing breakpoints in the code. If it is non Flask, the debugger stops as usual.

If a Flask app, the breakpoints are ignored. I tried invalidating the cache and restarting.

I created a second run config, changing only the name. In the new run config, there is a printout that the debugger connects and waits forever.

 

0
Comment actions Permalink

An IDE that cannot debug is pathetic. This is a major issue receiving no attention.

0
Comment actions Permalink

@John Bledsoe

Sorry for the inconvenience. The issue does not reproduce with the minimal Flask app, so it's probably project-specific. More specifics about your project would help in identifying the issue.

For example, here's one open issue about dubugging multi-threaded code: https://youtrack.jetbrains.com/issue/PY-30903

It should go without saying, but make sure you're using the latest version (2019.3.3 at the moment), and if your issue does not look similar to the above link, it would help if you submit a new issue with a sample project to reproduce.

0
Comment actions Permalink

I don't have time to attempt to reproduce with a sample project, nor can I ship over our company's entire IP.

Reverting to 2019.1 re-enabled debugging so that's where I will stay.

0
Comment actions Permalink

The issue stills exists with 2019.3.4 using the minimal Flask app. Tried 2019.2.6 and same thing: debugger doesn't stop at breaking point on flask apps.

I reverted back to 2019.1.4 and all good.

 

FYI, code used and breaking point on the return statement:

from flask import Flask
app = Flask(__name__)

@app.route('/test')
def hello_world():
return 'Hello, World!'

if __name__ == '__main__':
app.run()

Didn't stop using 3.7.5 on either local (Win10) or WSL2 interpreter

0
Comment actions Permalink

Are you running the Flask app with gunicorn by any chance?

Please try to disable "gevent compatible" option from [File | Settings | Build, Execution, Deployment | Python Debugger]

https://youtrack.jetbrains.com/issue/PY-15783

0
Comment actions Permalink

Yep - that was it, and on 2020.1 !

Thanks ! 

0

Please sign in to leave a comment.