Opened 10 years ago

Last modified 3 weeks ago

#23919 closed Cleanup/optimization

Cleanups for when we drop Python 2 compatibility — at Version 24

Reported by: Tim Graham Owned by: nobody
Component: Core (Other) Version:
Severity: Normal Keywords:
Cc: cmawebsite@…, Tom Forbes Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no
Pull Requests:19162 merged, 16178 merged, 7869 merged, 7890 merged, 14058 merged, 12939 merged, 12211 merged, 12098 merged, 11711 merged, 10905 unmerged, 7906 unmerged, 10515 merged, 7897 merged, 7899 unmerged, 8944 unmerged, 8825 unmerged, 8797 merged, 9511 merged, 9803 merged, 9441 merged, 7867 merged, 9312 merged, 9182 merged, 9317 merged, 8795 merged, 8739 merged, 8719 merged, 8675 merged, 8621 merged, 8622 merged

Description (last modified by Jon Dufresne)

This is a tracking ticket of things that we can remove when we drop Python 2 compatibility in Django 2.0. Please edit the description of the ticket as you come across new items.

  • django.core.mail.message.make_msgid() #23905
  • django.dispatch.weakref_backports
  • django.http.cookie workarounds
  • django.utils.2to3_fixes
  • django.utils.decorators.ContextDecorator
  • django.utils.encoding
    • @python_2_unicode_compatible
    • force/smart _unicode
    • either force/smart _text or force/smart _str
  • django.utils.html_parser.use_workaround
  • django.utils.http functions like urlquote_plus -- I think the versions of these functions on Python 3 don't have the unicode characters bug we are working around.
  • django.utils.lru_cache
  • django.utils.six
  • from __future__ import unicode_literals
  • str() stuff for environment variables, e.g. 0bfb53866199f366ed140d49938fd185e5898156
  • Inheriting from object in django.core.servers.basehttp (and perhaps other places) ala 4ee06ec3fc8e94d164afbd2f9c880c60c658a9ac
  • git grep 'long int' (mostly docs)
  • django.utils._os [npath,upath]
  • In tests: contextlib.closing(self.urlopen (contextlib.closing no longer needed)
  • Support for pysqlite (doesn't support Python 3)
  • Replace super(ClassName, self) with super()
  • Remove # -*- coding: utf-8 -*- source file encoding (that's the default on Python 3)
  • Evaluate replacement of custom __del__ methods by weakref.finalize
  • Remove __ne__ from objects already defining a __eq__
  • Remove note about PYTHONHASHSEED (see #26243)
  • Remove Field.creation_counter (replace by metaclass __prepare__ returning OrderedDict(), https://docs.python.org/3/reference/datamodel.html#preparing-the-class-namespace)
  • django.test.utils.reset_warning_registry()
  • Replace errno checks by IOError subclasses defined by PEP 3151
  • django.utils.glob
  • django.utils.cookies.SimpleCookie
  • django.test.mock
  • Replace tempfile.mkdtemp + remove with tempfile.TemporaryDirectory context manager

Change History (24)

comment:1 by Wojtek Ruszczewski, 10 years ago

Various nonlocal workarounds (example).

comment:2 by Collin Anderson, 10 years ago

Description: modified (diff)

comment:3 by Tim Graham, 10 years ago

Description: modified (diff)

comment:4 by Anssi Kääriäinen, 10 years ago

I believe we can get rid of the Field.creation_counter hack. In Python 3 it is possible to store the attrs in a sorted dictionary. See http://stackoverflow.com/questions/4459531/how-to-read-class-attributes-in-the-same-order-as-declared.

comment:5 by Collin Anderson, 10 years ago

Description: modified (diff)

comment:6 by Tim Graham, 10 years ago

Description: modified (diff)

comment:7 by Tim Graham, 10 years ago

Description: modified (diff)

comment:8 by Collin Anderson, 10 years ago

Cc: cmawebsite@… added
Description: modified (diff)

comment:9 by Collin Anderson, 10 years ago

Description: modified (diff)

comment:10 by Curtis Maloney, 10 years ago

In far too many tests we rely on the fact six aliases builtins [like input] instead of using mock.

I submitted a patch recently to clean up a couple of these I found, but I am finding more.

comment:11 by Curtis Maloney, 10 years ago

Description: modified (diff)

comment:12 by Tim Graham, 10 years ago

Description: modified (diff)

comment:13 by Tim Graham, 9 years ago

Description: modified (diff)

comment:14 by Moritz Sichert, 9 years ago

Description: modified (diff)

comment:15 by Tim Graham, 9 years ago

Description: modified (diff)

comment:16 by Claude Paroz, 9 years ago

Description: modified (diff)

comment:17 by Simon Charette, 9 years ago

Description: modified (diff)

comment:18 by Collin Anderson, 9 years ago

Description: modified (diff)

comment:19 by Anssi Kääriäinen, 9 years ago

Description: modified (diff)

comment:20 by Tim Graham, 9 years ago

Description: modified (diff)

comment:21 by Jon Dufresne, 9 years ago

Description: modified (diff)

comment:22 by Curtis Maloney, 8 years ago

Description: modified (diff)

comment:23 by Curtis Maloney, 8 years ago

Description: modified (diff)

comment:24 by Jon Dufresne, 8 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.
Back to Top