Skip to content

Commit 3095bc3

Browse files
committed
Fix get_pickle_protocol to properly detect protocol version by loading the file instead of reading first byte
1 parent 5f740a4 commit 3095bc3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Mailman/Utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1789,6 +1789,8 @@ def get_pickle_protocol(filename):
17891789
"""
17901790
try:
17911791
with open(filename, 'rb') as fp:
1792-
return ord(fp.read(1))
1793-
except (IOError, IndexError):
1792+
# Try to load the pickle file to get its protocol version
1793+
data = pickle.load(fp, fix_imports=True, encoding='latin1')
1794+
return pickle.format_version
1795+
except (IOError, pickle.UnpicklingError):
17941796
return None

0 commit comments

Comments
 (0)