jceb / vim-orgmode

Text outlining and task management for Vim based on Emacs' Org-Mode
http://www.vim.org/scripts/script.php?script_id=3642
Other
3.1k stars 266 forks source link

fix AttributeError: module 'collections' has no attribute 'Iterable' #373

Closed jbpoittevin closed 2 years ago

jbpoittevin commented 2 years ago

collections.Iterable is deprecated. Replace it with collections.abc.Iterable.

jbpoittevin commented 2 years ago

Error was found with upgrade from Fedora 34 to Fedora 35.

$rpm -q python3
python3-3.10.0-1.fc35.x86_64

$rpm -qf /bin/vimx
vim-X11-8.2.3568-1.fc35.x86_64

Current origin/master for vim-orgmode is at : 4ad432d7da4e01e7fce86d25528a6587efce6ca4

jbpoittevin commented 2 years ago

To reproduce error :

vim todo.org Enter insert mode with 'i'. Exit insert mode with 'Esc'.

Erreur détectée en traitant Autocommandes InsertLeave pour "<buffer=1>" :                                                                                                                              
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/plugins/TagsProperties.py", line 136, in realign_tags
    d = ORGMODE.get_document(allow_dirty=True)
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/_vim.py", line 302, in get_document
    self._documents[bufnr] = VimBuffer(bufnr).init_dom()
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/liborgmode/documents.py", line 151, in init_dom
    h = self.find_heading(heading=heading)
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/liborgmode/documents.py", line 311, in find_heading
    self._content[start:end + 1], self.get_all_todo_states(),
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/liborgmode/documents.py", line 72, in get_all_todo_states
    return flatten_list(self.get_todo_states())
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/liborgmode/base.py", line 41, in flatten_list
    return [i for i in gen_lst(lst)]
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/liborgmode/base.py", line 41, in <listcomp>
    return [i for i in gen_lst(lst)]
  File "/home/jpoittevin/.vim/pack/plugins/opt/vim-orgmode/ftplugin/orgmode/liborgmode/base.py", line 34, in gen_lst
    elif isinstance(item, collections.Iterable):
AttributeError: module 'collections' has no attribute 'Iterable'
craigmjackson commented 2 years ago

Verified this fixes on termux-android.

dusanx commented 2 years ago

Fixes problem on latest Arch.

elig0n commented 2 years ago

Please preserve old import statement for users of older python versions:

try:
    from collections import Iterable
except:
    from collections.abc import Iterable

or

if (sys.version_info.major == 3 and sys.version_info.minor >= 10):
    from collections.abc import Iterable
else:
    from collections import Iterable

and then

elif isinstance(item, Iterable):
konradzdeb commented 2 years ago

Thanks, this is a good fix. A more generic question, @jceb states that this repo is unmaintained. I find it extremely useful and I would like to ask if there is a fork that can be considered 'maintained'. For instance, I would be happy to switch to the repo by @jbpoittevin if this is the one where the fixes are going to be applied.


I'm not opening a separate issue as I reckon this doesn't merit a longer discussion.

jbpoittevin commented 2 years ago

@konradzdeb I use this vim-orgmode plugin on a daily basis, so I do what it takes to keep it working ; it would be presomptuous on my part to pretend to replace jceb’s one however.

konradzdeb commented 2 years ago

it would be presumptuous on my part to pretend to replace jceb’s one however.

Of course, I share your view on that 100%, @jceb made a brilliant contribution with this repo and generously put a massive amount of work into this project. I understand that with work/life/family/other time commitments maintaining open source projects has to be given lower priority, as it often happens. Having said that, purely out of selfish, practical reasons, I may switch to your fork. Thank you for replying.

dusanx commented 2 years ago

@jbpoittevin I would like to help, as others I must have this plugin to keep running. However Python is not on top of my list of skills (had no idea about collections/iterable changes, my temporary 'fix' was using very big hammer) so I could contribute but not nowhere near being able to maintain. If I can help or we are switching to other repo please announce somewhere. Complete respect to @jceb and his work of course.

jbpoittevin commented 2 years ago

I sent a mail to jceb asking for advice. For now, you can use the master branch of jbpoittevin/vim-orgmode repo.

jceb commented 2 years ago

Thanks a lot! @jbpoittevin I added you as a maintainer. Feel free to extend the LICENSE file etc.