Skip to content

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

Closed
dreiss wants to merge 7 commits intogh/dreiss/32/basefrom
gh/dreiss/32/head
Closed

Remove (most) Python 2 support from Python code#35615
dreiss wants to merge 7 commits intogh/dreiss/32/basefrom
gh/dreiss/32/head

Conversation

@dreiss
Copy link
Copy Markdown
Contributor

@dreiss dreiss commented Mar 28, 2020

Stack from ghstack:

Summary:
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

Summary:
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
@dr-ci
Copy link
Copy Markdown

dr-ci Bot commented Mar 28, 2020

💊 Build failures summary and remediations

As of commit e049414 (more details on the Dr. CI page):


💚 💚 Looks good so far! There are no failures yet. 💚 💚


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

See how this bot performed.

This comment has been revised 45 times.

print(np.max(np.abs(Y2 - Y0)))
self.assertTrue(False)

@unittest.skipIf(sys.version_info.major > 2, "broken in python 3")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably shouldn't delete this, just mark it as expected broken or something? Or maybe the code is moribund and we don't care anyway... I guess probably that is true.


if not PY2:
ops.append(truediv)
ops.append(truediv)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can be moved to the list (don't do it in this PR if everything else is ok)

Comment thread test/run_test.py
from torch.testing._internal.common_utils import TEST_WITH_ROCM, shell
import torch.distributed as dist
PY2 = sys.version_info <= (3,)
PY33 = sys.version_info >= (3, 3)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably axe this one too

Comment thread test/test_jit.py
self.assertExpected(str(ast))

@unittest.skipIf(PY2, "Requires python 3")
def test_python_frontend_py3(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should probably rename the test, but whatever

except ImportError:
return False
elif not PY34: # Python [3, 3.4)
if not PY34: # Python [3, 3.4)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably can get rid of this one (we don't support 3.4)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be comfortable with me adding a check like #35611 for 3.5+?

dreiss added 6 commits April 3, 2020 09:08
Summary:
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
Summary:
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](https://our.internmc.facebook.com/intern/diff/D20842886)
Summary:
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](https://our.internmc.facebook.com/intern/diff/D20842886)
Summary:
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](https://our.internmc.facebook.com/intern/diff/D20842886)

[ghstack-poisoned]
Summary:
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](https://our.internmc.facebook.com/intern/diff/D20842886)

[ghstack-poisoned]
Summary:
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](https://our.internmc.facebook.com/intern/diff/D20842886)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Copy Markdown
Contributor

@dreiss merged this pull request in e75fb43.

@facebook-github-bot facebook-github-bot deleted the gh/dreiss/32/head branch April 26, 2020 14:18
okly366 pushed a commit to okly366/pytorch that referenced this pull request Apr 26, 2020
Summary:
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

ghstack-source-id: c491b81
Pull Request resolved: pytorch/pytorch#35615
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Pull Request resolved: pytorch#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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants