Fixed removal of signal receivers in Python 3.4

Make use of `weakref.finalize` and `weakref.WeakMethod` on python 3.4.
Simplified the removal of receivers, the old function looked overly
complicated.

Many thanks go to Antoine Pitrou for helping me to debug and explain all
the failures I ran into while writing that patch.
Fixed #21413 -- resolve_columns fields misalignment
Fixed a test isolation issue. Refs #17062.

This test could change settings.DATABASES['default']['TIME_ZONE'] and
didn't restore the previous value.
Fixed #21452 -- Non-autocommit connections to PostgreSQL.

When settings.DATABASES['default']['AUTOCOMMIT'] = False, the connection
wasn't in autocommit mode but Django pretended it was.

Thanks Anssi for analysing this issue.

Refs #17062.
Added license info for the weakref backports
Merge pull request #2163 from apollo13/signals

Signals
Fixed flake8 issues.
Fixed #21453 -- Enabled autocommit before calling init_connection_state.

Also ensured the transaction state is clean on Oracle while I was there.

This change cannot be backported to 1.6 because it's
backwards-incompatible for custom database backends.
Restored a test broken by overzealous PEP8 cleanup
Fixed a test that was failing with PostGIS.

Fixed #21452 again.

Forward-port of 18d75e07 from stable/1.6.x.
Used a regular lock for app registry population.

Since the app registry is always populated before the first request is
processed, the situation described in #18251 for the old app cache
cannot happen any more.

Refs #18251, #21628.
Fixed #21477 -- Renamed db to using in pre/post_migrate signals.
Fixed #21770 -- Updated autocomplete for app-loading.

Thanks dfunckt for the report.
Add further workarounds for HTMLParser with Python 3.4.

Python 3.5 will change the default value of convert_charrefs, so 3.4
gives warnings if it's not present. This is slightly technical as 2.7
doesn't have the kwarg. Thankfully, we already have a bunch of
workarounds for different versions.
Undelete the `return True` removed in 4e0a2fe.

This is quite important otherwise we don't close our connections to the
SMTP server.
Be more careful about closing connections in mail tests.