FormerLurker / Octolapse

Stabilized timelapses for Octoprint
GNU Affero General Public License v3.0
639 stars 99 forks source link

Python 3.10 compatibility #804

Closed jaketri closed 2 years ago

jaketri commented 2 years ago

Move Iterable to collections.abc (from collections) to fix following error with python 3.10:

2022-01-12 19:52:53,512 - octoprint.plugin - ERROR - Error while calling plugin octolapse
Traceback (most recent call last):
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint/plugin/__init__.py", line 271, in call_plugin
    result = getattr(plugin, method)(*args, **kwargs)
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint/util/__init__.py", line 1737, in wrapper
    return f(*args, **kwargs)
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/__init__.py", line 2362, in on_startup
    raise e
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/__init__.py", line 2311, in on_startup
    self.load_settings()
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/__init__.py", line 1999, in load_settings
    new_settings, defaults_loaded = OctolapseSettings.load(
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/settings.py", line 2378, in load
    new_settings = OctolapseSettings.create_from_iterable(
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/settings.py", line 2528, in create_from_iterable
    new_object.update(iterable)
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/settings.py", line 108, in update
    Settings._update(self, iterable)
  File "/home/octoprint/venv/lib/python3.10/site-packages/octoprint_octolapse/settings.py", line 116, in _update
    if not isinstance(iterable, collections.Iterable):
AttributeError: module 'collections' has no attribute 'Iterable'
FormerLurker commented 2 years ago

A fix is already included in the devel branch here:

https://github.com/FormerLurker/Octolapse/blob/7d9479091232ed88e8789754cce6ce9f5a03a398/octoprint_octolapse/settings.py#L37-L41

But thanks for the PR! Am trying to work time in to get this to master. There are other important changes that need to be pushed.

jaketri commented 2 years ago

Great! Sorry for not checking first the devel branch. I'll remove my PR as your fix is cleaner and maintain support for older Python versions (2.7).

lettore commented 2 years ago

Not sure why but I'm on Python 3.10 and still have this problem. For using the plugin I had to add .abc to line 116 if not isinstance(iterable, collections.abc.Iterable):