disable dill extension behavior (#53118)

Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/53118

Test Plan: Imported from OSS

Reviewed By: jamesr66a

Differential Revision: D26754878

Pulled By: suo

fbshipit-source-id: e088d1dc841633bfc0902e3d19f151892ac5c38c
This commit is contained in:
Michael Suo
2021-03-02 11:02:40 -08:00
committed by Facebook GitHub Bot
parent 43f810fa96
commit 73a57246d9

View File

@ -5,6 +5,12 @@ from typing import Callable, Dict, Iterator, Optional, Sized, Tuple, TypeVar
try:
import dill
# XXX: By default, dill writes the Pickler dispatch table to inject its
# own logic there. This globally affects the behavior of the standard library
# pickler for any user who transitively depends on this module!
# Undo this extension to avoid altering the behavior of the pickler globally.
dill.extend(use_dill=False)
DILL_AVAILABLE = True
except ImportError:
DILL_AVAILABLE = False