8000 Update on "Prevent legacy_load when weights_only=True (correctly)" · pytorch/pytorch@b829da8 · GitHub
[go: up one dir, main page]

Skip to content

Commit b829da8

Browse files
Update on "Prevent legacy_load when weights_only=True (correctly)"
Only prevent `legacy_load` (.tar format removed in #713), not the whole of `_legacy_load` (.tar format + _use_new_zipfile_serialization=False) Differential Revision: [D68301405](https://our.internmc.facebook.com/intern/diff/D68301405) [ghstack-poisoned]
1 parent 9699522 commit b829da8

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

torch/serialization.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,9 +1738,7 @@ def persistent_load(saved_id):
17381738
# legacy_load requires that f has fileno()
17391739
# only if offset is zero we can attempt the legacy tar file loader
17401740
try:
1741-
with closing(
1742-
tarfile.open(fileobj=f, mode="r:", format=tarfile.PAX_FORMAT)
1743-
):
1741+
with closing(tarfile.open(fileobj=f, mode="r:", format=tarfile.PAX_FORMAT)):
17441742
if pickle_module is _weights_only_unpickler:
17451743
raise RuntimeError(
17461744
"Cannot use ``weights_only=True`` with files saved in the "

0 commit comments

Comments
 (0)
0