#27025 closed New feature (fixed)
Python 3.6 compatibility
Reported by: | Tim Graham | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | 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.6 final is scheduled for December 2016. This is a tracking ticket for compatibility fixes for Django submitted in the meantime.
Change History (31)
comment:1 by , 8 years ago
comment:2 by , 8 years ago
Likely the time zone docs need some small additions to acknowledge the existence of PEP 495 -- even if the code can't rely on it until we drop support for Python < 3.6.
comment:5 by , 8 years ago
Django's test are passing with master @ 2b759c94c562c9ee9b6ca970739be15014050fda and cpython master @ 47f6c10084ed9aa8a08dbac20d5f6b814063c2df.
comment:11 by , 8 years ago
I setup a more complete test environment that includes all of the test suite dependencies and identified a few more failures fixed in the above commits.
2 failures remain as of Django b5aac66b28c615b2bda63548cbd695dbb5a0c381 and cpython d614d687d9db1100d0a4ec8c67e0cb3ce773342b due to a sqlparse incompatibility with Python 3.6. I submitted a PR to fix it and it's merged awaiting the next release.
comment:12 by , 8 years ago
cpython fixed compatibility with sqlparse in https://hg.python.org/cpython/rev/1a2b8398f045/ so a new sqlparse release isn't needed and all tests are passing as of now.
comment:13 by , 8 years ago
just tested with last Django master e044026dce063ec53c16d0f755ec75eb8c84b318 and Python 3.6.0b4 works for me.
BTW where can I find how to add or check test results for Python3.6 and latest version of Django?
I see only Python3.5 http://djangoci.com/job/django-1.10/
comment:14 by , 8 years ago
I have a local Jenkins running with the cpython 3.6 branch and Django master that I check every couple days. I don't think we'll add Python 3.6 compatibility to older versions of Django such as 1.10 but we'll discuss it on the DevelopersMailingList if anyone feel it's important.
comment:15 by , 8 years ago
py3.6 breaks calling super()
(in the python3 style) inside Models with:
RuntimeError: super(): empty __class__ cell
This is also present on 1.8 and 1.10
class ModelToBreak(models.Model): def save(self, *args, **kwargs): return super().save(*args, **kwargs)
>>> m = ModelToBreak() >>> m.save() Traceback (most recent call last): File "/home/cybo/work/3.6-test/testing/d/tests.py", line 9, in test_empty_class_fail m.save() File "/home/cybo/work/3.6-test/testing/d/models.py", line 5, in save return super().save(*args, **kwargs) RuntimeError: super(): empty __class__ cell
comment:16 by , 8 years ago
Thanks, the relevant commit in cpython is https://hg.python.org/cpython/rev/feb1ae9d5381.
I'm not sure if Django or cpython is at fault.
comment:17 by , 8 years ago
After some discussion on the cpython issue, I've created a PR to address the issue, but cpython may also restore backwards-compatibility and add a deprecation path.
comment:18 by , 8 years ago
Thanks. I'll check all other MetaClasses for similar behaviour today or tomorrow.
Will also add Py3 tests for them.
comment:19 by , 8 years ago
I'm not particularly worried about tests since cpython added a deprecation path. Also, when we drop Python 2 compatibility in master in January, we'll probably change all super()
calls to the new style.
comment:22 by , 8 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:28 by , 7 years ago
Would it be possible to backport dd99e69fa8f89263d0396f23e0db9aa8fa667b01 (metaclass magic) to Django 1.8?
I'm seeing quite a few warnings for this, hiding the more useful warnings...
comment:29 by , 7 years ago
No, Django 1.8 doesn't have official support for Python 3.6 and only receives data loss and security fixes its end-of-life in April 2018.
Perhaps you can use warnings.filterwarnings()
to hide the warnings.
comment:30 by , 7 years ago
Okay. For the record: Adding this snippet to my development settings in my otherwise meta-class-free project, works for me:
import warnings warnings.filterwarnings( action="ignore", message=".*Was __classcell__ propagated to type[.]__new__.*")
A couple failures bisected to the implementation of PEP 495 -- Local Time Disambiguation.