Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#23763 closed New feature (fixed)

Python 3.5 compatibility

Reported by: Tim Graham Owned by: nobody
Component: Core (Other) Version: dev
Severity: Normal Keywords:
Cc: berker.peksag@…, nick.a.sarbicki@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Python 3.5 is not scheduled for final until September 2015, but this is a tracking ticket for compatibility fixes for Django submitted in the meantime.

Change History (24)

comment:1 by Berker Peksag, 10 years ago

Cc: berker.peksag@… added

comment:2 by Tim Graham <timograham@…>, 10 years ago

In b07aa52e8a8e4c7fdc7265f75ce2e7992e657ae9:

Added a dummy class for HTMLParserError; refs #23763.

comment:3 by Tim Graham, 10 years ago

All the tests currently pass except for some ImportError exceptions being reported, likely due to http://bugs.python.org/issue7559.

======================================================================
ERROR: apps.failing_app (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/cpython/Lib/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/home/tim/code/cpython/Lib/unittest/case.py", line 577, in run
    testMethod()
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 36, in testFailure
    raise exception
ImportError: Failed to import test module: apps.failing_app
Traceback (most recent call last):
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 451, in _find_test_path
    package = self._get_module_from_name(name)
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 358, in _get_module_from_name
    __import__(name)
  File "/home/tim/code/django/tests/apps/failing_app/__init__.py", line 1, in <module>
    raise ImportError("Oops")
ImportError: Oops


======================================================================
ERROR: migrations.faulty_migrations.import_error (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/cpython/Lib/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/home/tim/code/cpython/Lib/unittest/case.py", line 577, in run
    testMethod()
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 36, in testFailure
    raise exception
ImportError: Failed to import test module: migrations.faulty_migrations.import_error
Traceback (most recent call last):
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 451, in _find_test_path
    package = self._get_module_from_name(name)
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 358, in _get_module_from_name
    __import__(name)
  File "/home/tim/code/django/tests/migrations/faulty_migrations/import_error/__init__.py", line 1, in <module>
    import fake_python_module  # NOQA
ImportError: No module named 'fake_python_module'

Also, some GIS related exceptions like the following if GIS dependencies aren't installed:

======================================================================
ERROR: django.contrib.gis.admin (unittest.loader.ModuleImportFailure)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/cpython/Lib/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/home/tim/code/cpython/Lib/unittest/case.py", line 577, in run
    testMethod()
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 36, in testFailure
    raise exception
ImportError: Failed to import test module: django.contrib.gis.admin
Traceback (most recent call last):
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 451, in _find_test_path
    package = self._get_module_from_name(name)
  File "/home/tim/code/cpython/Lib/unittest/loader.py", line 358, in _get_module_from_name
    __import__(name)
  File "/home/tim/code/django/django/contrib/gis/admin/__init__.py", line 7, in <module>
    from django.contrib.gis.admin.options import GeoModelAdmin      # NOQA
  File "/home/tim/code/django/django/contrib/gis/admin/options.py", line 2, in <module>
    from django.contrib.gis.admin.widgets import OpenLayersWidget
  File "/home/tim/code/django/django/contrib/gis/admin/widgets.py", line 9, in <module>
    from django.contrib.gis.geos import GEOSGeometry, GEOSException
ImportError: cannot import name 'GEOSGeometry'

comment:4 by Tim Graham <timograham@…>, 10 years ago

In 42b5e4feeacf7cfa57867bf9fd5a6046de8c1cd3:

Fixed #23730 -- Moved support for SimpleCookie HIGHEST_PROTOCOL pickling to http.cookie.

This fix is necessary for Python 3.5 compatibility (refs #23763).

Thanks Berker Peksag for review.

comment:5 by Tim Graham <timograham@…>, 10 years ago

In be1357e70983d4ad029a1ecdd05292f8be917a80:

Fixed a query failure on Python 3.5; refs #23763.

The failure was introduced in Django by
c7fd9b242d2d63406f1de6cc3204e35aaa025233 and the change in
Python 3.5 is https://hg.python.org/cpython/rev/a3c345ba3563.

comment:6 by Tim Graham <timograham@…>, 10 years ago

In cb90d489da4247c1c7ced86a42a2d89488fec67c:

[1.8.x] Fixed a query failure on Python 3.5; refs #23763.

The failure was introduced in Django by
c7fd9b242d2d63406f1de6cc3204e35aaa025233 and the change in
Python 3.5 is https://hg.python.org/cpython/rev/a3c345ba3563.

Backport of be1357e70983d4ad029a1ecdd05292f8be917a80 from master

comment:7 by Tim Graham <timograham@…>, 10 years ago

In 0386b97706052b88cd6fbbf777698810981cfeb6:

Fixed test_runner test failure on Python 3.5; refs #23763.

Python change is http://bugs.python.org/issue22032

comment:8 by Tim Graham <timograham@…>, 10 years ago

In 242c9538c8d252f27581e2b192237301f94a2928:

[1.8.x] Fixed test_runner test failure on Python 3.5; refs #23763.

Python change is http://bugs.python.org/issue22032

Backport of 0386b97706052b88cd6fbbf777698810981cfeb6 from master

comment:9 by Tim Graham <timograham@…>, 10 years ago

In 62df1834b8d60c106c8c16524b275b8a1f47ac3a:

Fixed expressions test on Python 3.5; refs #23763.

comment:10 by Tim Graham <timograham@…>, 10 years ago

In fe770a6452919807bba59c125b02464290feeba1:

[1.8.x] Fixed expressions test on Python 3.5; refs #23763.

Backport of 62df1834b8d60c106c8c16524b275b8a1f47ac3a from master

comment:11 by Tim Graham <timograham@…>, 10 years ago

In c0cc8f69e7abfa8578729031f97ae4b96c5cdafe:

Refactored tests that rely on an ImportError for Python 3.5 compatibility

A change in Python test discovery [1] causes the old packages that raised
an error to be discovered; now we use a common directory that's
ignored during discovery. Refs #23763.

[1] http://bugs.python.org/issue7559

comment:12 by Tim Graham <timograham@…>, 10 years ago

In 3e24ab6f4ca6632c910c684fda3d0f937fade52a:

[1.8.x] Refactored tests that rely on an ImportError for Python 3.5 compatibility

A change in Python test discovery [1] causes the old packages that raised
an error to be discovered; now we use a common directory that's
ignored during discovery. Refs #23763.

[1] http://bugs.python.org/issue7559

Backport of c0cc8f69e7abfa8578729031f97ae4b96c5cdafe from master

comment:13 by Tim Graham <timograham@…>, 10 years ago

In 4e59156c:

Fixed sessions test on Python 3.5; refs #23763.

SimpleCookie.repr() changed in
https://hg.python.org/cpython/rev/88e1151e8e02

comment:14 by Tim Graham <timograham@…>, 10 years ago

In 7b9f7b66:

[1.8.x] Fixed sessions test on Python 3.5; refs #23763.

SimpleCookie.repr() changed in
https://hg.python.org/cpython/rev/88e1151e8e02

Backport of 4e59156c10d36eeb1e6fced4dff0f11157f68264 from master

comment:15 by Tim Graham <timograham@…>, 10 years ago

In c2bc1ce:

Refs #23763 -- Silenced SimpleTestCase.assertRaisesMessage() deprecation warning on Python 3.5.

Deprecation warning was introduced in https://bugs.python.org/issue24134

comment:16 by Tim Graham <timograham@…>, 10 years ago

In 7d97c57:

Refs #23763 -- Fixed SMTPServer Python 3.5 deprecation warning in mail test.

comment:17 by Tim Graham <timograham@…>, 10 years ago

In e89c3a46:

Added backwards compatibility for assertRaisesMessage callable_obj param.

This was broken in c2bc1cefdcbbf074408f4a4cace88b315cf9d652 (refs #23763).

comment:18 by Tim Graham <timograham@…>, 9 years ago

In 3f2de803:

Refs #23763 -- Fixed Python 3.5 PendingDeprecationWarning in LazyStream.

Fixed "PendingDeprecationWarning: generator 'LazyStream.read.<locals>.parts'
raised StopIteration" per PEP 0479.

comment:19 by Barry Warsaw, 9 years ago

Any thoughts on the GEOSGeometry import error on Python 3 only? I think I've applied all the relevant patches here for Ubuntu's build of 1.7.9 for Python 2.7, 3.4, and 3.5, and this is the last failure I can't yet eliminate. Well, I can if I depend on libgeos-dev which gives you the right library, but I don't want to add that dependency because of cross-pocket issues (django-python is in main, but libgeos-dev is in universe, and that would require extra bureaucracy to change).

I've confirmed that HAS_SPACIAL_DB is False in both Python 2 and 3, and django.contrib.gis.tests doesn't get added to discovery_paths (in runtests.py), but yet those tests are still discovered.

Is there some patch not yet attached to this issue, or some other ticket or commit I should be looking at?

comment:20 by Tim Graham, 9 years ago

I don't believe it's a known issue. It doesn't seem related to Python 3.5 compatibility, so please open a new ticket with more specifics, thanks!

comment:21 by Tim Graham, 9 years ago

Resolution: fixed
Status: newclosed

The test suite for master (Django 1.9) passes on Python 3.5.

comment:22 by Nick Sarbicki, 9 years ago

Cc: nick.a.sarbicki@… added

comment:23 by Tim Graham <timograham@…>, 9 years ago

In 2a36a9bb:

[1.8.x] Refs #23763 -- Fixed Python 3.5 PendingDeprecationWarning in LazyStream.

Fixed "PendingDeprecationWarning: generator 'LazyStream.read.<locals>.parts'
raised StopIteration" per PEP 0479.

Backport of 3f2de803181ca3c5526ec9d708b2098b8f683808 from master

comment:24 by Tim Graham <timograham@…>, 9 years ago

In 95b1ae76:

[1.8.x] Refs #23763 -- Fixed SMTPServer Python 3.5 deprecation warning in mail test.

Backport of 7d97c5745e420e3edc22965a2c68c8c9d2eab374 from master

Note: See TracTickets for help on using tickets.
Back to Top