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

Module with __file__=None is not supported #475

Closed
jeffery9 opened this issue Nov 20, 2020 · 4 comments
Closed

Module with __file__=None is not supported #475

jeffery9 opened this issue Nov 20, 2020 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@jeffery9
Copy link

Environment data

  • VS Code version: 1.51.1
  • Extension version (available under the Extensions sidebar): XXX
  • OS and version: Darwin x64 19.6.0
  • Python version (& distribution if applicable, e.g. Anaconda): python 3.7.3
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): 8.3.110.13-electron.0
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Value of the python.languageServer setting: "python.languageServer": "Pylance",

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

XXX

Actual behaviour

can't launch debug...
report

 /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf 
~/git-repo/odoo(master ✗)  /usr/bin/env /usr/bin/python3 /Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/launcher 60731 -- odoo-bin -c odoo.conf 
Traceback (most recent call last):
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/__main__.py", line 43, in <module>
    from debugpy.server import cli
  File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/server/__init__.py", line 9, in <module>
    import debugpy._vendored.force_pydevd  # noqa
  File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/force_pydevd.py", line 15, in <module>
    prefix_matcher('pydev', '_pydev'))
  File "/Users/jeffery/.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/../debugpy/_vendored/__init__.py", line 106, in check_modules
    elif not mod.__file__.startswith(root):
AttributeError: 'NoneType' object has no attribute 'startswith'

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. clone Odoo code.
  2. open it in vscode, and create launch.json for it
  3. launch debug. not success

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

@karthiknadig karthiknadig transferred this issue from microsoft/vscode-python Nov 20, 2020
@int19h
Copy link
Contributor

int19h commented Nov 23, 2020

It seems to be a rather weird corner case - there's some module present in sys.modules that has the __file__ attribute present, but it is set to None. We check using hasattr(), and then assume that if it's there, it's a string-like object.

This is an easy fix - we should also check the type - but there may be other similar bugs in the debugger that are masked by this early failure.

@int19h int19h added the bug Something isn't working label Nov 23, 2020
@int19h int19h changed the title can't launch debug Module with __file__=None is not supported Nov 23, 2020
@scraber
Copy link

scraber commented Nov 24, 2020

I got same problem

VS Code version: 1.51.1
Extension version (available under the Extensions sidebar): Python v2020.11.371526539 (tried several older versions)
OS and version: Ubuntu 20.04.1 LTS
Python version: python 3.8.3 && 3.8.5
Value of the python.languageServer setting: "python.languageServer": "Pylance"

Run without debugging works, so the launch.json is fine, however debug is causing mentioned problem

@gdgellatly
Copy link

It seems to be a rather weird corner case - there's some module present in sys.modules that has the __file__ attribute present, but it is set to None. We check using hasattr(), and then assume that if it's there, it's a string-like object.

This is an easy fix - we should also check the type - but there may be other similar bugs in the debugger that are masked by this early failure.

@int19h I suspect it may be an implementation detail or difference in python 3.8 compared to previous python versions as we have same issue and it only occurs with 3.8. From memory this particular part of debugpy is during loading pydevd extensions at start. We can run exact same debugpy / vscode / pydevd extensions and py3.7 and not have this error.

@fabioz fabioz self-assigned this Nov 26, 2020
@fabioz
Copy link
Collaborator

fabioz commented Nov 26, 2020

I'll take a look into fixing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants