Opened 3 years ago

Closed 2 years ago

Last modified 2 years ago

#22350 closed Bug (fixed)

Django 1.7 migration files do not support Python 3.2

Reported by: Trey Hunner Owned by: loic84
Component: Migrations Version: 1.7-beta-1
Severity: Release blocker Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Steps to reproduce:

  1. Run "python manage.py makemigrations appname" on a new app
  2. Run "python3.2 manage.py migrate" (with Django installed in python3.2 site-packages)
  3. View traceback due to syntax error. Example:
  File "/.../django-email-log/email_log/migrations/0001_initial.py", line 14
    (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)),
         ^
SyntaxError: invalid syntax

The syntax error is due to the use of the u prefix in front of string literals.

In my opinion, Python 3.2 support is unimportant because Python 3.3 made so many syntactic improvements. However, Python 3.2 support is currently noted in the documentation.

Change History (7)

comment:1 Changed 3 years ago by Aymeric Augustin

Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 Changed 3 years ago by Anssi Kääriäinen

Component: Database layer (models, ORM)Migrations

comment:3 Changed 3 years ago by loic84

Owner: changed from nobody to loic84
Status: newassigned

comment:4 Changed 3 years ago by loic84

Has patch: set

I'm not too fond of it, but here is a tentative patch, note the generated migrations are hideous.

POC https://github.com/loic/django/tree/ticket22350.

comment:5 Changed 2 years ago by Simon Charette

Created a PR based on Loïc's initial patch relying on from __future__ import unicode_literals.

comment:6 Changed 2 years ago by Simon Charette <charette.s@…>

Resolution: fixed
Status: assignedclosed

In 72d3889db4eb3a14acb94f613edd79f0f27d26e3:

Fixed #22350 -- Consistently serialize bytes and text in migrations.

Thanks to @treyhunner and Loïc for their suggestions and review.

comment:7 Changed 2 years ago by Simon Charette <charette.s@…>

In 9fb61cb64a18924b7f252677166533f747884b48:

[1.7.x] Fixed #22350 -- Consistently serialize bytes and text in migrations.

Thanks to @treyhunner and Loïc for their suggestions and review.

Backport of 72d3889db4 from master

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