pytorch
28e3dfdc - [JIT] Allow __exit__ to have a return value (#52336)

Commit
4 years ago
[JIT] Allow __exit__ to have a return value (#52336) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/52336 **Summary** In Python, the boolean interpretation of the return value of `__exit__` of objects that are used as context managers with `with` statements is used to determine whether or not to propagate exceptions thrown inside the body of the with statement. This latter feature is not possible to add to TorchScript at the moment, but the current requirement that `__exit__` not have any return values can make it difficult to script a context manager whose `__exit__` *does* have a return value. Accordingly, this commit removes the requirement that `__exit__` must not have any return value. TorchScript does not interpret this return value in the same way Python does (or at all), but this should make it easier to share context managers between eager mode and script code. **Test Plan** This commit adds a return value to one of the context managers used in `TestWith`. Test Plan: Imported from OSS Reviewed By: gmagogsfm Differential Revision: D26504910 Pulled By: SplitInfinity fbshipit-source-id: 2ab635a24d111ac25df4e361b716be8fada5128e
Author
Meghan Lele
Parents
Loading