Remove (most) Python 2 support from Python code (#35615)

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

Python 2 has reached end-of-life and is no longer supported by PyTorch.
Now we can clean up a lot of cruft that we put in place to support it.
These changes were all done manually, and I skipped anything that seemed
like it would take more than a few seconds, so I think it makes sense to
review it manually as well (though using side-by-side view and ignoring
whitespace change might be helpful).

Test Plan: CI

Differential Revision: D20842886

Pulled By: dreiss

fbshipit-source-id: 8cad4e87c45895e7ce3938a88e61157a79504aed
This commit is contained in:
David Reiss
2020-04-22 09:20:13 -07:00
committed by Facebook GitHub Bot
parent a894fff265
commit e75fb4356b
56 changed files with 144 additions and 645 deletions

View File

@ -6,7 +6,6 @@ import itertools
import functools
import torch
from torch import Tensor
from torch._six import PY2
import torch.nn.functional as F
from multiprocessing.reduction import ForkingPickler
import pickle
@ -162,7 +161,6 @@ class TestNamedTensor(TestCase):
self.assertTrue(partially_named.has_names())
self.assertTrue(fully_named.has_names())
@unittest.skipIf(PY2, "Ellipsis object not supported in python 2")
def test_py3_ellipsis(self):
# Need to exec or else flake8 will complain about invalid python 2.
tensor = torch.randn(2, 3, 5, 7)