Skip to content
Snippets Groups Projects
Commit f4de4bf5 authored by Zen Fu's avatar Zen Fu
Browse files

Patch Python's weakref module in translation platform

This is an ugly workaround to get rid of noise in tails-translations
mailing list.

The Python version in Debian Stretch has a bug that leaks memory in some
situations and will spit out the following error:

------------------------------------------------------------------------------
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fe488c03048>
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 0x7fe488c03048>
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 0x7f69c5515ea0>
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 0x7f69c5515ea0>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
------------------------------------------------------------------------------

As our scripts run frequently, we are getting many e-mails that are
actually false positives.

The differences from the original file are:

------------------------------------------------------------------------------
--- weakref.py  2020-07-28 22:54:59.837435324 +0000
+++ /usr/lib/python3.5/weakref.py       2020-07-09 13:00:10.000000000 +0000
@@ -106,7 +106,7 @@
         self, *args = args
         if len(args) > 1:
             raise TypeError('expected at most 1 arguments, got %d' % len(args))
-        def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):
+        def remove(wr, selfref=ref(self)):
             self = selfref()
             if self is not None:
                 if self._iterating:
@@ -114,7 +114,7 @@
                 else:
                     # Atomic removal is necessary since this function
                     # can be called asynchronously by the GC
-                    _atomic_removal(d, wr.key)
+                    _remove_dead_weakref(d, wr.key)
         self._remove = remove
         # A list of keys to be removed
         self._pending_removals = []
------------------------------------------------------------------------------

See the following links for more context:

    https://helpdesk.tetrane.com/hc/en-us/articles/360034629091-I-am-getting-exceptions-from-usr-lib-python3-5-weakref-py-is-it-an-issue-
    https://bugs.python.org/issue29519

This will have to be removed once the machine is upgraded to a newer
Debian version.
parent 07003afc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment