Add more error checking in subclass creation (#64746)
authorAlban Desmaison <albandes@fb.com>
Fri, 10 Sep 2021 20:07:37 +0000 (13:07 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 10 Sep 2021 23:49:10 +0000 (16:49 -0700)
commitd8ae3cc31889a151ae1c1b61bf179cc25915eadc
treedb3e6c0cf0c201abf6173992b623462216335d7f
parent89f94fc15f672725f5ce2cdc109c8b3310e58de7
Add more error checking in subclass creation (#64746)

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

This extracts the error checking that used to be in the PR above.
We are not going to land the proposed fix there, but I think we want this error checking in right now as these would lead to respectively a memory leak and arbitrary memory read/write.

Test Plan: Imported from OSS

Reviewed By: ngimel

Differential Revision: D30867569

Pulled By: albanD

fbshipit-source-id: bf468033fb8b49fcb26eed423f5fad82b4a46c56
test/test_python_dispatch.py
test/test_torch.py
torch/csrc/autograd/python_variable.cpp