Add compatibility with Python 3.

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

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).

    Loading...