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
Treat __init__.pyc same as __init__.py in module_list #2469
Conversation
There are some circumstances where packages on disk could only have a .pyc version of __init__.py. It would be nice if ipython would autocomplete them as well. I've been using this in a production environment for several weeks now.
Looks good to me, but we might want to make this properly generic. I haven't looked closely at the code. Just based off what's shown in the diff view it'd be something like: if any(isfile(pjoin(path, p, '__init__' + suffix[0])) for suffix in imp.get_suffixes()) (But we may want to make this a function, or preprocess the list of Unfortunately, in the long term this isn't going to be a valid check because of (implicit) namespace packages. I haven't digested that logic, and since it only applies to 3.3 or later, I think we don't need to worry (much) about it yet. |
|
Actually, To refresh your memory, the list of extension suffixes in Python 3.3: >>> from importlib._bootstrap import EXTENSION_SUFFIXES
>>> EXTENSION_SUFFIXES
['.cpython-33m.so', '.abi3.so', '.so'] Also, here can be other regular source extensions in some cases, like |
If I try copying a Python .so module to a init.so file, I can't import |
Extension modules need to have a C function named |
Actually, for Python 3.3.0, the function needs to be named |
That's probably down to the new import system based on importlib. In that |
There are some circumstances where packages on disk could only have a .pyc version of __init__.py. It would be nice if ipython would autocomplete them as well. I've been using this in a production environment for several weeks now.
Conflicts: IPython/core/completerlib.py
Oy, sorry, this is my first pull request on github, so feel free to throw pointers at me. I modified with @bfroehle's suggestion, tested, and (I think) updated. Now we're future-proof! ;) |
Thanks Andrew. For future reference, try to avoid merging branches within a pull request. The code change looks fine, though. I'm just running the tests, because the merge seems to have confused travis-ci. |
@rkern: As an aside I think you need an (empty) |
Treat `__init__.pyc` same as `__init__.py` in module_list
Treat `__init__.pyc` same as `__init__.py` in module_list
Treat `__init__.pyc` same as `__init__.py` in module_list
There are some circumstances where packages on disk could only have a .pyc
version of
__init__.py
. It would be nice if ipython would autocomplete them aswell. I've been using this in a production environment for several weeks now.
Test plan:
autocomplete worked. Also tested with
__init__.py
to verify no regression.