Restore the old pickler in a `try/finally`
Just what it says on the tin.
@@ -219,14 +219,13 @@ def serialize_provider(provider: ResourceProvider) -> str:
pickle.Pickler.save_dict = save_dict_sorted
# Use dill to recursively pickle the provider and store base64 encoded form
+ try:
byts = dill.dumps(provider, protocol=pickle.DEFAULT_PROTOCOL, recurse=True)
- serialized = base64.b64encode(byts).decode('utf-8')
-
+ return base64.b64encode(byts).decode('utf-8')
+ finally:
# Restore the original pickler
pickle.Pickler = old_pickler
- return serialized
-
class Resource(CustomResource):
"""
Resource represents a Pulumi Resource that incorporates an inline implementation of the Resource's CRUD operations.
