Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugpy.listen() throws exception because sys.argv is missing #473

Closed
abhijit-sawant opened this issue Nov 17, 2020 · 0 comments
Closed

Comments

@abhijit-sawant
Copy link

Environment data

  • debugpy version: 1.0.0b11
  • OS and version: Windows 10
  • Python version : 3.5 ActiveState
  • Using VS Code or Visual Studio: VS Code

Actual behavior

I am using debugpy with embedded python interpreter. As its embedded interpreter I chose not to set argc and argv. But debugpy.listen() method expects sys.argv and throws exception as shown below -

File "<install_location>\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 330, in _on_run
    self.process_net_command_json(self.py_db, json_contents)

File "<install_location>\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 190, in process_net_command_json
    cmd = on_request(py_db, request)

File "<install_location>\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 441, in on_attach_request
    return self._handle_launch_or_attach_request(py_db, request, start_reason='attach')

File "<install_location>\debugpy\debugpy-1.0.0b11\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 424, in _handle_launch_or_attach_request
    self._send_process_event(py_db, start_reason)

File "<install_location>\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_process_net_command_json.py", line 405, in _send_process_event
    if len(sys.argv) > 0:
AttributeError: module 'sys' has no attribute 'argv'

Expected behavior

I would expect debugpy to work even without sys.argv as it can be used with embedded interpreter and setting sys.argv is optional. But I am not certain its practical and how big that change is.

Steps to reproduce:

  1. Write C++/C code that initializes python interpreter (Py_Intialize())
  2. Run following code using python C API in embedded interpreter
    import debugpy
   debugpy.listen(5678)
  1. Have following snippet in launch.json
        {
            "name": "Python: MyAttach",
            "type": "python",
            "request": "attach",
            "connect": {
                "host": "localhost",
                "port": 5678
            }
        }
  1. Build code, launch and attach
  2. Check VS Code debug console. You will see the traceback mentioned above
fabioz added a commit to fabioz/debugpy that referenced this issue Dec 10, 2020
@fabioz fabioz closed this as completed in e573ea7 Dec 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant