Skip to content

Commit f228bd7

Browse files
committed
Fixes #102, better handling of forced decompression errors.
1 parent 47e15f9 commit f228bd7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sc2reader/utils.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,13 @@ def extract_data_file(data_file, archive):
460460
try:
461461
file_data = archive.read_file(data_file, force_decompress=True)
462462
except Exception as e:
463-
if str(e) in ("string index out of range", "Unsupported compression type."):
463+
# If it doesn't work with forced decompression, try again without it
464+
exc_info = sys.exc_info()
465+
try:
464466
file_data = archive.read_file(data_file, force_decompress=False)
465-
else:
466-
raise
467+
except Exception:
468+
# raise the original exception
469+
raise exc_info[1], None, exc_info[2]
467470
else:
468471
file_data = archive.read_file(data_file)
469472

0 commit comments

Comments
 (0)