Skip to content

Commit 2f4da7c

Browse files
dreissfacebook-github-bot
authored andcommitted
Remove a use of exec (#35624)
Summary: Pull Request resolved: #35624 Python 2 has reached end-of-life and is no longer supported by PyTorch. This test case is valid syntax in Python 3. Test Plan: CI Differential Revision: D20842877 Pulled By: dreiss fbshipit-source-id: 856e72171496aa1d517f2f27a8a5066462cf4f76
1 parent 7f7fdb1 commit 2f4da7c

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

test/test_namedtensor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,9 @@ def test_has_names(self):
162162
self.assertTrue(fully_named.has_names())
163163

164164
def test_py3_ellipsis(self):
165-
# Need to exec or else flake8 will complain about invalid python 2.
166165
tensor = torch.randn(2, 3, 5, 7)
167-
scope = {'tensor': tensor}
168-
code_str = "output = tensor.refine_names('N', ..., 'C')"
169-
exec(code_str, globals(), scope)
170-
self.assertEqual(scope['output'].names, ['N', None, None, 'C'])
166+
output = tensor.refine_names('N', ..., 'C')
167+
self.assertEqual(output.names, ['N', None, None, 'C'])
171168

172169
def test_refine_names(self):
173170
# Unnamed tensor -> Unnamed tensor

0 commit comments

Comments
 (0)