Skip to content

Commit a34f1d4

Browse files
committed
Update pickle protocol detection to use loaded data instead of file header
1 parent 9f67bda commit a34f1d4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

bin/check_db

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ def testfile(dbfile, listname=None, verbose=0):
8686
print(' Successfully loaded with latin1 encoding')
8787

8888
if verbose:
89-
# Get pickle version info
90-
fp.seek(0)
91-
version = pickle.format_version
92-
protocol = pickle.HIGHEST_PROTOCOL
93-
print(' Pickle format version: %s' % version)
94-
print(' Pickle protocol: %d' % protocol)
89+
# Get pickle version info from the loaded data
90+
if hasattr(data, '_protocol'):
91+
protocol = data._protocol
92+
print(' Pickle protocol: %d' % protocol)
93+
else:
94+
print(' Pickle protocol: unknown (not stored in data)')
9595
except (EOFError, pickle.UnpicklingError) as e:
9696
print(' Error loading file %s for list %s: %s' %
9797
(os.path.basename(dbfile), listname or 'unknown', str(e)))

0 commit comments

Comments
 (0)