Add compatibility with Python 3.

Review Request #9582 — Created Feb. 4, 2018 and submitted

Information

Django Evolution
master
5336ba3...

Reviewers

This introduces Python 3 compatibility for Django Evolution. Most of the
work needed for compatibility has been introduced in prior commits, and
this change handles the remaining syntactical and string differences.

One of the highlights is that the default Pickle protocol changed
(twice) in Python 3. We now force usage of protocol 0, which is an
ASCII-based payload format and the default in Python 2.

There's also a difference in default string types used for Django field
names. Unless otherwise explicitly set, field names (used for indexes
and other parts of the schema definitions) are based on the attribute
name in the model, which on Python 2 is a byte string and on Python 3 is
a unicode string. To get the right string type on each Python version,
we convert the names to the native string type using str(). We don't
want or need to actually encode or decode -- str() is the most
compatible way here.

The rest of the changes mostly have to do with exception handling, print
statements, and removing/adding prefixes on certain string types.

There's still work that's needed on getting all the management commands
fully tested. That will be part of upcoming changes.

Unit tests pass on Django 1.6 through 1.11, with all database types.

Tested Python 3.4, 3.5, and 3.6 with Django 1.6, 1.7, and 1.11 (aiming
to test a spectrum of the changes).

Description From Last Updated

Why not use the six.moves version for this?

daviddavid

Mind fixing this up to use triple quotes while you're here?

daviddavid

F403 'from django_evolution.tests.db.mysql import *' used; unable to detect undefined names

reviewbotreviewbot

F401 'django_evolution.tests.db.mysql.*' imported but unused

reviewbotreviewbot

F403 'from django_evolution.tests.db.postgresql import *' used; unable to detect undefined names

reviewbotreviewbot

F401 'django_evolution.tests.db.postgresql.*' imported but unused

reviewbotreviewbot

F403 'from django_evolution.tests.db.mysql import *' used; unable to detect undefined names

reviewbotreviewbot

F401 'django_evolution.tests.db.mysql.*' imported but unused

reviewbotreviewbot

F403 'from django_evolution.tests.db.postgresql import *' used; unable to detect undefined names

reviewbotreviewbot

F401 'django_evolution.tests.db.postgresql.*' imported but unused

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

david
  1. 
      
  2. django_evolution/compat/py23.py (Diff revision 1)
     
     
     
     
     

    Why not use the six.moves version for this?

  3. django_evolution/db/common.py (Diff revision 1)
     
     

    Mind fixing this up to use triple quotes while you're here?

    1. This is all going to get some love in a future change. I want to leave it alone for now.

  4. 
      
chipx86
Review request changed

Change Summary:

Used a six.moves import for pickle.

Commit:

-a3c3ce9f7796f61c08d89066887165d521308b0e
+5336ba3f30c91adba5e50ff1199b08cbd51f58f2

Diff:

Revision 2 (+147 -82)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (033ad8a)
Loading...