Commit 6384803
committed
Handle python imports in a plethora of setups
The commit message below is copyed from python-mode#986 and I did some change. And
this commit is to make a traceability commit message and updates comment
in the code commited in previous commit, for detail, reference PR python-mode#985.
There has been many changes in how python import modules across python
versions, specially in 3.3, 3.4 and 3.7.
This has caused many issues with modules importing in vim, and how vim
handles/implements imports from python also have caused many issues.
In python-mode we have tried many alternatives ways to fix this issues,
but they failed for many different conditions.
The main issue in our repo that track the problem solved by this commit
is the python-mode#972, there are lot's of comments and references over there.
As I comment in code:
For python:
* since python 3.3, the `imp.find_module()` is deprecated
* `importlib.util.find_spec()` is new in python 3.4
For vim:
* if it compiled with python 3.7 or newer, then the module 'vim' will
use `find_spec` instead of `find_module` and `load_module`.
* if it compiled with feature `+python3/dyn`, vim can load a python
dynamically. The loaded python maybe has a different version compared
with the python used when compiling vim.
For these reason, it's hard to say we should use `find_spec` or
`find_module`, so here use try/except for the sake of clearness of the
logic.
@diraol says he would like to thank @racterub, @joergsch, @zcodes,
@nineKnight, @lalmeras, @dbeniamine, and everyone else that helped with
this issue. (me too)
Fix python-mode#972
Close python-mode#985
Close python-mode#955
Close python-mode#9861 parent a56dde5 commit 6384803
1 file changed
Lines changed: 15 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2170 | 2170 | | |
2171 | 2171 | | |
2172 | 2172 | | |
| 2173 | + | |
2173 | 2174 | | |
2174 | 2175 | | |
2175 | | - | |
2176 | | - | |
2177 | | - | |
2178 | | - | |
| 2176 | + | |
| 2177 | + | |
| 2178 | + | |
| 2179 | + | |
| 2180 | + | |
| 2181 | + | |
| 2182 | + | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
2179 | 2190 | | |
2180 | 2191 | | |
2181 | 2192 | | |
| |||
0 commit comments