cms
cms copied to clipboard
Drop support for Python 2
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).
- [x] Change the shebang to explicitly refer to
python3 - [x] Remove the
# -*- coding: utf-8 -*-line - [x] Remove
__future__,futureandsiximports (and replace their usages appropriately, e.g., usedict.foo()instead ofiterfoo(dict),self.assertBar(...)instead ofsix.assertBar(self, ...), ...) - [x] Remove leftover explicit unicode literals (i.e., the
u"foo") - [x] Replace all usages of
io.openwith justopen - [x] Replace
IOErrorandEnvironmentErrorwithOSErroras they are now the same - [x] Use the most appropriate subclasses of
OSError(e.g.,FileNotFoundError) instead of checking theerrnoof the exception - [x] Import from
unittest.mockrather than frommock(and removemockfrom thedev-requirements) - [ ] Use the
TestCase'sassertLogsmethod instead of mocking loggers - [x] Update the
setup.py,.travis.yml, the doc, the website, etc. - [x] Use the
1_000_000syntax for big numerical constants (replace1000000and1000 * 1000) - [x] Look for the strings
py2,py3,Python 2, etc. in the code that we used to annotate specific issues - [x] Clean up the monotonic clock in
cmscommon.datetime - [x] Use
subprocess.DEVNULLwhere applicable - [x] Refactor
rmtreeto make it immune to symlink attacks - [ ] Use type annotations!
- [x] Use
shlex.quote - [x] Remove
ipaddressfrom the requirements - [x] 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). - [x] Don't have classes extend
objectexplicitly.
Feel free to add to this list.