OpenMediaVault weakref (Python) Error When Updating

When trying to perform apt-get update on OMV 4.1.27-1 (Arrakis), I received the following error

Hit:10 https://packages.openmediavault.org/public arrakis InRelease
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fd4ea277598>
Traceback (most recent call last):
File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fd4ea277598>
Traceback (most recent call last):
File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Reading package lists... Done

The fix is to edit and replace 2 lines in weakref.py

nano /usr/lib/python3.5/weakref.py

Old line 109:
def remove(wr, selfref=ref(self)):
New line 109:

def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):

Old line 117:
_remove_dead_weakref(d, wr.key)
New line 117:

_atomic_removal(d, wr.key)

You must be careful to replace only the specific text and not modify whitespace, otherwise you may receive the following error during the next update:
TabError: inconsistent use of tabs and spaces in indentation

The source for the above fix: https://forum.openmediavault.org/index.php?thread/19658-upgrade-debian-9-and-4-x/&postID=155621#post155621

An alternative way to fix weakref.py is to replace the entire file:

wget -O /usr/lib/python3.5/weakref.py https://raw.githubusercontent.com/python/cpython/9cd7e17640a49635d1c1f8c2989578a8fc2c1de6/Lib/weakref.py

The source is from this post: https://forum.openmediavault.org/index.php?thread/19658-upgrade-debian-9-and-4-x/&postID=196631#post196631

This entry was posted in Uncategorized. Bookmark the permalink.