maxcutler / python-wordpress-xmlrpc

Python library for WordPress XML-RPC integration
http://python-wordpress-xmlrpc.rtfd.org
MIT License
382 stars 130 forks source link

Error in Python versions >= 3.8 when trying to use collections.Iterable #149

Closed michaalbert closed 2 years ago

michaalbert commented 2 years ago

When using this library with a Python version newer than 3.7 it throws this error:

In [9]: posts = client.call(posts.GetPosts())
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-6fd7be5e79cd> in <module>
----> 1 posts = client.call(posts.GetPosts())

/usr/local/lib/python3.10/site-packages/wordpress_xmlrpc/base.py in call(self, method)
     44             else:
     45                 raise
---> 46         return method.process_result(raw_result)
     47 
     48 

/usr/local/lib/python3.10/site-packages/wordpress_xmlrpc/base.py in process_result(self, raw_result)
    126             if isinstance(raw_result, dict_type):
    127                 return self.results_class(raw_result)
--> 128             elif isinstance(raw_result, collections.Iterable):
    129                 return [self.results_class(result) for result in raw_result]
    130 

AttributeError: module 'collections' has no attribute 'Iterable'

The problem lies in this line and is fixable by changing the import statement to from collections.abc import Iterable (and of course then also changing collections.Iterable to just Iterable in line 129) but I don't know how to make it backwards compatible - maybe using six?

michaalbert commented 2 years ago

nvm this is already addressed in Pull request #148