cms-dev / cms-dev/cms

Drop support for Python 2

Open
#956 0 comments 0 reactions 1 assignee View on GitHub

@lw is already working on this.

Since May 2, 2018.

Dominant language
Python
Stars
1k
Forks
412
Avg merge
6d 10h
Merged PRs (30d)
3

Description

Despite the alluring title, this is just a tracking issue listing things to do to the code when we will drop support for Python 2 (which won't happen before the next release).

  • Change the shebang to explicitly refer to python3
  • Remove the # -*- coding: utf-8 -*- line
  • Remove __future__, future and six imports (and replace their usages appropriately, e.g., use dict.foo() instead of iterfoo(dict), self.assertBar(...) instead of six.assertBar(self, ...), ...)
  • Remove leftover explicit unicode literals (i.e., the u"foo")
  • Replace all usages of io.open with just open
  • Replace IOError and EnvironmentError with OSError as they are now the same
  • Use the most appropriate subclasses of OSError (e.g., FileNotFoundError) instead of checking the errno of the exception
  • Import from unittest.mock rather than from mock (and remove mock from the dev-requirements)
  • Use the TestCase's assertLogs method instead of mocking loggers
  • Update the setup.py, .travis.yml, the doc, the website, etc.
  • Use the 1_000_000 syntax for big numerical constants (replace 1000000 and 1000 * 1000)
  • Look for the strings py2, py3, Python 2, etc. in the code that we used to annotate specific issues
  • Clean up the monotonic clock in cmscommon.datetime
  • Use subprocess.DEVNULL where applicable
  • Refactor rmtree to make it immune to symlink attacks
  • Use type annotations!
  • Use shlex.quote
  • Remove ipaddress from the requirements
  • Check uses of str(...) that are no-ops in py3 but were used to convert py2-str to py2-unicode when they contained only ASCII (because some libraries return unicode only when it is non-ASCII, and str otherwise).
  • Don't have classes extend object explicitly.

Feel free to add to this list.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.