Skip to content

Commit d556f3e

Browse files
committed
update
1 parent 86b53cc commit d556f3e

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

Mailman/Archiver/HyperArch.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,15 @@ def __init__(self, maillist):
671671
d = pickle.loads(d, fix_imports=True, encoding='latin1')
672672

673673
# Only update attributes that don't conflict with our initialization
674+
safe_attrs = {
675+
'type', 'archive', 'firstdate', 'lastdate', 'archivedate',
676+
'size', 'version', 'subjectIndex', 'authorIndex', 'dateIndex',
677+
'articleIndex', 'threadIndex'
678+
}
674679
for key, value in list(d.items()):
675-
if key not in ('archives', '_dirty_archives', 'sequence', 'update_TOC',
676-
'maillist', '_lock_file', 'lang', 'charset', 'database'):
680+
if key in safe_attrs:
677681
setattr(self, key, value)
678-
except (IOError, EOFError, pickle.UnpicklingError) as e:
682+
except (IOError, EOFError, pickle.UnpicklingError, RecursionError) as e:
679683
syslog('error', 'Error loading archive state: %s', e)
680684
# Continue with default initialization
681685

@@ -1008,8 +1012,20 @@ def close(self):
10081012
f = open(os.path.join(self.basedir, 'pipermail.pck'), 'wb')
10091013
finally:
10101014
os.umask(omask)
1015+
1016+
# Only save safe attributes
1017+
safe_state = {}
1018+
safe_attrs = {
1019+
'type', 'archive', 'firstdate', 'lastdate', 'archivedate',
1020+
'size', 'version', 'subjectIndex', 'authorIndex', 'dateIndex',
1021+
'articleIndex', 'threadIndex'
1022+
}
1023+
for key in safe_attrs:
1024+
if hasattr(self, key):
1025+
safe_state[key] = getattr(self, key)
1026+
10111027
# Use protocol 4 for Python 2/3 compatibility
1012-
pickle.dump(self.getstate(), f, protocol=4, fix_imports=True)
1028+
pickle.dump(safe_state, f, protocol=4, fix_imports=True)
10131029
f.close()
10141030

10151031
def getstate(self):

0 commit comments

Comments
 (0)