Skip to content

Commit

Permalink
Extra checks for reading pickle-Format files (cctbx#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
phyy-nx authored Aug 16, 2024
1 parent 6c83b6e commit 38c95db
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/744.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add fix for pickle files
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatPYmultitile.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def understand(image_file):
with FormatPYmultitile.open_file(image_file, "rb") as fh:
data = pickle.load(fh, encoding="bytes")
data = image_dict_to_unicode(data)
except OSError:
except (AttributeError, OSError):
return False

wanted_header_items = ["TILES", "METROLOGY"]
Expand Down
2 changes: 1 addition & 1 deletion src/dxtbx/format/FormatPYunspecified.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def understand(image_file):
with FormatPYunspecified.open_file(image_file, "rb") as fh:
data = pickle.load(fh, encoding="bytes")
data = image_dict_to_unicode(data)
except OSError:
except (AttributeError, OSError):
return False

headers = set(data)
Expand Down

0 comments on commit 38c95db

Please sign in to comment.