shawly / docker-nut

Docker container for https://github.com/blawar/NUT. "latest" & "v3" tags use stable release v3.3. "edge" tag uses latest master source code.
GNU General Public License v3.0
63 stars 8 forks source link

AttributeError: module 'collections' has no attribute 'Mapping' #6

Closed gritstub closed 1 year ago

gritstub commented 2 years ago

The docker has an issue running nut.py

The error seems related to Python 3.10+


Traceback (most recent call last):
  File "/nut/./nut.py", line 18, in <module>
    from nut import Title
  File "/nut/nut/__init__.py", line 24, in <module>
    import Fs
  File "/nut/Fs/__init__.py", line 1, in <module>
    from Fs.Xci import Xci
  File "/nut/Fs/Xci.py", line 2, in <module>
    from Fs.File import File
  File "/nut/Fs/File.py", line 4, in <module>
    from nut import Print
  File "/nut/nut/Print.py", line 1, in <module>
    from nut import Status
  File "/nut/nut/Status.py", line 4, in <module>
    from nut import Config
  File "/nut/nut/Config.py", line 871, in <module>
    load('conf/nut.conf')
  File "/nut/nut/Config.py", line 323, in load
    original = dict_merge(original, j)
  File "/nut/nut/Config.py", line 48, in dict_merge
    and isinstance(merge_dct[k], collections.Mapping)):
AttributeError: module 'collections' has no attribute 'Mapping'```
gritstub commented 2 years ago

https://github.com/blawar/nut/pull/392

Maybe it's better to pull from HEAD instead of the old release.

shawly commented 1 year ago

This is a bug that happens with NUT 3.3 when you use a nut.conf NUT seems to have an issue merging the nut.default.conf and your own nut.conf. The workaround for this is to remove the nut.conf file and make your changes in the nut.default.conf.

The latest NUT release does indeed fix this issue. I will update the edge image to use the latest master branch for building.

I'm not sure I will create a release from a master build though, since they could introduce changes that could be breaking, which is why I prefer using stable releases so people using watchtower for auto updating their containers won't have issues.

Noxeus commented 1 year ago

This is because of a change in Python 3.10 and can actually be fixed by changing nut/Config.py:

change

import collections

to

import collections.abc

and change

and isinstance(merge_dct[k], collections.Mapping)):

to

and isinstance(merge_dct[k], collections.abc.Mapping)):