Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#22350 closed Bug (fixed)

Django 1.7 migration files do not support Python 3.2

Reported by: treyhunner 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 12 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Severity changed from Normal to Release blocker
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 12 months ago by akaariai

  • Component changed from Database layer (models, ORM) to Migrations

comment:3 Changed 12 months ago by loic84

  • Owner changed from nobody to loic84
  • Status changed from new to assigned

comment:4 Changed 12 months 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 12 months ago by charettes

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

comment:6 Changed 12 months ago by Simon Charette <charette.s@…>

  • Resolution set to fixed
  • Status changed from assigned to closed

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 12 months 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