Opened 11 years ago

Closed 11 years ago

Last modified 11 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 by Aymeric Augustin, 11 years ago

Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

comment:2 by Anssi Kääriäinen, 11 years ago

Component: Database layer (models, ORM)Migrations

comment:3 by loic84, 11 years ago

Owner: changed from nobody to loic84
Status: newassigned

comment:4 by loic84, 11 years ago

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 by Simon Charette, 11 years ago

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

comment:6 by Simon Charette <charette.s@…>, 11 years ago

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 by Simon Charette <charette.s@…>, 11 years ago

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