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

Implicit namespace package leads to autocompleter crash in IPython #2044

Open
maxalbert opened this issue Jan 2, 2025 · 1 comment
Open
Labels

Comments

@maxalbert
Copy link

Versions:

  • IPython: 8.31.0
  • Jedi: 0.19.2

Given the following directory structure:

$ tree .

.
├── dir1
│   └── foobarpkg
│       └── pkgA
│           └── __init__.py
└── dir2
    └── foobarpkg
        └── pkgB
            └── __init__.py

The following produces an error when trying to use tab completion in step 5:

$ ipython --Completer.debug=True

Python 3.13.1 (main, Dec  3 2024, 17:59:52) [Clang 19.1.5 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.31.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import os, sys

In [2]: curdir = os.getcwd()

In [3]: sys.path = [
    os.path.join(curdir, "dir1"),
    os.path.join(curdir, "dir2")
    ]

In [4]: import foobarpkg

In [5]: foobarpkg.<tab>

Error message:

Oops Jedi has crashed, please report a bug with the following:
   ...: """
   ...: argument should be a str or an os.PathLike object where __fspath__ returns a str, not 'NoneType'
   ...: s"""
@davidhalter davidhalter added the bug label Jan 3, 2025
@maxalbert
Copy link
Author

FYI, the bug is triggered inside the method DirectObjectAccess.py__file__ (here).

It is caused by the fact that in the scenario described above, the value of self._obj.__file__ will be None. This in turn causes Path(self._obj.__file__) to throw a TypeError, which is not handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants