#23455: migrations created with python2 break with python3
---------------------------------+---------------------------------------
     Reporter:  brian            |                    Owner:  Markush2010
         Type:  Bug              |                   Status:  closed
    Component:  Migrations       |                  Version:  1.7
     Severity:  Release blocker  |               Resolution:  fixed
     Keywords:                   |             Triage Stage:  Accepted
    Has patch:  1                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+---------------------------------------

Comment (by carljm):

 Thanks to feedback from charettes on
 https://github.com/django/django/pull/3718, I've realized that this needs
 to be fixed somehow, we can't only revert the existing fix - the error
 message is too obscure.

 But I think a better fix would be for Django to just always convert
 `related_name` to text, not to do it specifically on deconstruction for
 migrations. Rationale:

 1) In general, the goal should be as much as possible to maintain uniform
 behavior between Python 2 and Python 3.

 2) With the current fix here, the situation is "on Python 2, related_name
 can be bytes or text; on Python 3 it must be text." Migrations generated
 on Python 2 and run on Python 3 expose this difference. So currently we
 work around it by ensuring that Python 2 stores `related_name` as text in
 migrations.

 3) With my proposed fix, we maintain better consistency. Migrations always
 preserves bytes/text, and Django always (regardless of Python version)
 supports setting `related_name` as either bytes or text, and converts it
 to text internally (since it needs that for interpolation).

 The effect on generated migrations in the end will be the same as the
 current fix; since `related_name` is converted to text, it will still be
 deconstructed as text. The most noticeable difference is that with my
 proposed fix, migrations generated on Django 1.7.0 under Python 2 won't
 need to be manually edited to work under Python 3, they'll just work.

 Is this reasonable, or am I missing something?

--
Ticket URL: <https://code.djangoproject.com/ticket/23455#comment:12>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.8e73b8c9c0246a8e1144a985c71abf40%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to