Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for EOL Python 2 #732

Merged
merged 8 commits into from
Apr 24, 2020
Merged

Drop support for EOL Python 2 #732

merged 8 commits into from
Apr 24, 2020

Conversation

hugovk
Copy link
Contributor

@hugovk hugovk commented Apr 10, 2020

Fixes #725.

Removes six library and upgrades Python syntax.

Also adds python_requires to setup.py to help pip, and Trove classifiers to show support on PyPI.

@zhangguanheng66
Copy link
Contributor

Thanks for the contribution.

@zhangguanheng66 zhangguanheng66 self-requested a review April 10, 2020 13:48
test/test_vocab.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zhangguanheng66 zhangguanheng66 left a comment

Choose a reason for hiding this comment

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

In general, this PR is expected to remove the supports for python 2.

@hugovk
Copy link
Contributor Author

hugovk commented Apr 14, 2020

I've reverted the changes made by pyupgrade and instead only removed six and __future__.

Please let me know if you'd like any of the other pyupgrade changes re-applied.

@zhangguanheng66
Copy link
Contributor

I've reverted the changes made by pyupgrade and instead only removed six and __future__.

Please let me know if you'd like any of the other pyupgrade changes re-applied.

Thanks for the contribution. LGTM. For now, let's make those necessary changes only.

@zhangguanheng66 zhangguanheng66 merged commit 8833b97 into pytorch:master Apr 24, 2020
@hugovk hugovk deleted the rm-2 branch April 24, 2020 14:01
@@ -246,7 +244,7 @@ def test_csv_dataset_quotechar(self):

with tempfile.NamedTemporaryFile(dir=self.test_dir) as f:
for example in example_data:
f.write(six.b("{}\n".format(",".join(example))))
f.write("{}\n".format(",".join(example)).encode("latin-1"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the need for encode coming from?

Copy link
Contributor

Choose a reason for hiding this comment

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

In particular latin-1 vs. UTF-8?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From the six documentation:

six.b(data)

A “fake” bytes literal. data should always be a normal string literal. ... In Python 3, data is encoded with the latin-1 encoding to bytes.

https://six.readthedocs.io/#six.b

From the six code:

if PY3:
    def b(s):
        return s.encode("latin-1")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[HELP WANTED] Clean up python 2 coding
3 participants