Skip to content

Update breakpoint module to use python find_spec instead of find_module #1139

Closed

Description

@Toure

Python find_module function has been deprecated as of py3.4 and find_spec is the replacement, it contains the same interface and will fix the error message received when opening a python file in vim-python-mode:

diff --git a/autoload/pymode/breakpoint.vim b/autoload/pymode/breakpoint.vim
index c3189aa..e62c041 100644
--- a/autoload/pymode/breakpoint.vim
+++ b/autoload/pymode/breakpoint.vim
@@ -15,11 +15,11 @@ fun! pymode#breakpoint#init() "{{{
 
         PymodePython << EOF
 
-from imp import find_module
+from importlib.util import find_spec
 
 for module in ('wdb', 'pudb', 'ipdb'):
     try:
-        find_module(module)
+        find_spec(module)
         vim.command('let g:pymode_breakpoint_cmd = "import %s; %s.set_trace()  # XXX BREAKPOINT"' % (module, module))
         break
     except ImportError:

Activity

  1. ghthor commented on Aug 31, 2021

    @ghthor

    I'm getting the following error when I open vim and including this patch eliminates the error.

    Error detected while processing BufRead Autocommands for "*"..script /usr/share/vim/vim82/scripts.vim[123]..FileType Autocommands for "*"..function <SNR>20_LoadFTPlugin[17]..script /home/nobody/.vim/bundle/python-mode/ftplugin/python/pymode.vim[23]..function pymode#breakpoint#init:
    line   27:
    <string>:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    
  2. diraol commented on Nov 10, 2021

    @diraol
    Contributor

    Sorry folks, it's been hard to find time for the project with a newborn at home...
    This is a very simple fix indeed.
    I'm writing from my mobile and as soon as I can sit in my computer I'll try to patch the project with the proposed solution.
    Thanks for the suggestion and also the patience!

  3. self-assigned this
    on Nov 10, 2021
  4. ghthor commented on Nov 10, 2021

    @ghthor

    Sorry folks, it's been hard to find time for the project with a newborn at home... This is a very simple fix indeed. I'm writing from my mobile and as soon as I can sit in my computer I'll try to patch the project with the proposed solution. Thanks for the suggestion and also the patience!

    No worries mate, I've had the same experience. That baby is more important then some open source project.

  5. diraol commented on Nov 14, 2021

    @diraol
    Contributor

    Sorry folks, it's been hard to find time for the project with a newborn at home... This is a very simple fix indeed. I'm writing from my mobile and as soon as I can sit in my computer I'll try to patch the project with the proposed solution. Thanks for the suggestion and also the patience!

    No worries mate, I've had the same experience. That baby is more important then some open source project.

    Hey buddy, checking the codebase, we have already made that change. You probably looked at the wrong branch, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions