microsoft / debugpy

An implementation of the Debug Adapter Protocol for Python
https://pypi.org/project/debugpy/
Other
1.86k stars 137 forks source link

Error : TypeError: '>' not supported between instances of 'int' and 'NoneType' #1587

Open sylvainmouquet opened 6 months ago

sylvainmouquet commented 6 months ago

Before creating a new issue, please check the FAQ to see if your question is answered there.

Environment data

Actual behavior

    self._cmd = py_db.cmd_factory.make_get_thread_stack_message(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<project>/.venv/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py", line 278, in make_get_thread_stack_message
    colno, endcolno = line_col_info.map_columns_to_line(line_text)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<project>/.venv/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame_utils.py", line 101, in map_columns_to_line
    colno = _utf8_byte_offset_to_character_offset(original_line, self.colno)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<project>/.venv/lib/python3.12/site-packages/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame_utils.py", line 143, in _utf8_byte_offset_to_character_offset
    if byte_offset > offset:
       ^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'int' and 'NoneType'
nmoreaud commented 2 months ago

Same error here, if I start a connexion3 dev server (uvicorn) and the port is already used. It only happens when justMyCode is set to false. Here is a sample project: connexion3_helloworld.zip It is basically a copy of this project: https://github.com/spec-first/connexion/tree/main/examples/helloworld

`ConnexionMiddleware.run` is optimized for development. For production, run using a dedicated ASGI server.
INFO:     Started server process [1027097]
INFO:     Waiting for application startup.
The swagger_ui directory could not be found.
    Please install connexion with extra install: pip install connexion[swagger-ui]
    or provide the path to your local installation by passing swagger_path=<your path>
INFO:     Application startup complete.
ERROR:    [Errno 98] error while attempting to bind on address ('127.0.0.1', 8080): address already in use
INFO:     Waiting for application shutdown.
INFO:     Application shutdown complete.
Traceback (most recent call last):
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 252, in _on_run
    self.process_net_command_json(self.py_db, json_contents)
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 193, in process_net_command_json
    cmd = on_request(py_db, request)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_process_net_command_json.py", line 981, in on_stacktrace_request
    self.api.request_stack(py_db, request.seq, thread_id, fmt=fmt, start_frame=start_frame, levels=levels)
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_api.py", line 207, in request_stack
    if internal_get_thread_stack.can_be_executed_by(get_current_thread_id(threading.current_thread())):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 655, in can_be_executed_by
    self._cmd = py_db.cmd_factory.make_get_thread_stack_message(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_net_command_factory_json.py", line 278, in make_get_thread_stack_message
    colno, endcolno = line_col_info.map_columns_to_line(line_text)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame_utils.py", line 101, in map_columns_to_line
    colno = _utf8_byte_offset_to_character_offset(original_line, self.colno)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dev/.vscode-server/extensions/ms-python.debugpy-2024.10.0/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_frame_utils.py", line 143, in _utf8_byte_offset_to_character_offset
    if byte_offset > offset:
       ^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'int' and 'NoneType'
ingenarel commented 1 month ago

same here. i'm using neovim and getting this error.

Traceback (most recent call last):
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\_pydevd_sys_monitoring\_pydevd_sys_monitoring.py", line 455,
 in _get_code_line_info
    return _cache[code_obj]
           ~~~~~~^^^^^^^^^^
KeyError: <code object _run_module_as_main at 0x00000299638A0DC0, file "C:\Users
\Saad_Abdullah\scoop\apps\python\current\Lib\runpy.py", line 173>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\runpy.py", line 198
, in _run_module_as_main
    return _run_code(code, main_globals, None,
                     "__main__", mod_spec)
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\runpy.py", line 88,
 in _run_code
    exec(code, run_globals)
    ~~~~^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy\__main__.py", line 71, in <module>
    cli.main()
    ~~~~~~~~^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\cli.py", line 501, in main
    run()
    ~~~^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\cli.py", line 335, in run_file      
    start_debugging(target)
    ~~~~~~~~~~~~~~~^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\cli.py", line 323, in start_debuggin
g
    debugpy.connect(options.address, access_token=options.adapter_access_token) 
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\public_api.py", line 31, in wrapper        
    return wrapped(*args, **kwargs)
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\api.py", line 143, in debug
    log.reraise_exception("{0}() failed:", func.__name__, level="info")
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\api.py", line 141, in debug
    return func(address, settrace_kwargs, **kwargs)
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\api.py", line 297, in connect       
    _settrace(host=host, port=port, client_access_token=access_token, **settrace
_kwargs)
    ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\launcher/../..\debugpy/..\debugpy\server\api.py", line 45, in _settrace      
    return pydevd.settrace(*args, **kwargs)
           ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\pydevd.py", line 3025, in settrace
    _locked_settrace(
    ~~~~~~~~~~~~~~~~^
        host,
        ^^^^^
    ...<14 lines>...
        notify_stdin=notify_stdin,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\pydevd.py", line 3114, in _locked_settrace
    PyDevdAPI().set_dont_trace_start_end_patterns(py_db, dont_trace_start_patter
ns, dont_trace_end_patterns)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\_pydevd_bundle\pydevd_api.py", line 978, in set_dont_trace_s
tart_end_patterns
    py_db.clear_dont_trace_start_end_patterns_caches()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\pydevd.py", line 1346, in clear_dont_trace_start_end_pattern
s_caches
    self.on_breakpoints_changed()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\pydevd.py", line 1205, in on_breakpoints_changed
    self.set_tracing_for_untraced_contexts(breakpoints_changed=True)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\pydevd.py", line 1226, in set_tracing_for_untraced_contexts 
    self.set_trace_for_frame_and_parents(thread_ident, frame)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\pydevd.py", line 2418, in set_trace_for_frame_and_parents   
    pydevd_sys_monitoring.enable_code_tracing(thread_ident, frame.f_code, frame)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\_pydevd_sys_monitoring\_pydevd_sys_monitoring.py", line 701,
 in enable_code_tracing
    func_code_info: FuncCodeInfo = _get_func_code_info(code, frame)
                                   ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\_pydevd_sys_monitoring\_pydevd_sys_monitoring.py", line 525,
 in _get_func_code_info
    code_line_info = _get_code_line_info(code_obj)
  File "C:\Users\Saad_Abdullah\scoop\apps\python\current\Lib\site-packages\debug
py\_vendored\pydevd\_pydevd_sys_monitoring\_pydevd_sys_monitoring.py", line 465,
 in _get_code_line_info
    first_line = min(line_to_offset)
TypeError: '<' not supported between instances of 'NoneType' and 'int'