[Django] #29814: Migrations deconstructing NoneType

8 views
Skip to first unread message

Django

unread,
Oct 2, 2018, 3:50:51 AM10/2/18
to django-...@googlegroups.com
#29814: Migrations deconstructing NoneType
-------------------------------------+-------------------------------------
Reporter: Daanvdk | Owner: nobody
Type: Bug | Status: new
Component: | Version: 2.1
Migrations | Keywords: migration
Severity: Normal | deconstruct nonetype none
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
When in a deconstructible class used in a migration one of the arguments
to instantiate the class is the `NoneType` (aka `type(None)`) this is just
serialized as `NoneType` which will throw a NameError because it is not
defined. The only way to get this value in Python 3 is with `type(None)`
so simply serializing `NoneType` as `type(None)` should already do the
trick.

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

Django

unread,
Oct 2, 2018, 8:30:29 AM10/2/18
to django-...@googlegroups.com
#29814: Allow serializing NoneType in migrations

-------------------------------------+-------------------------------------
Reporter: Daanvdk | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 2.1
Severity: Normal | Resolution:
Keywords: migration | Triage Stage: Accepted
deconstruct nonetype none |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* easy: 1 => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/29814#comment:1>

Django

unread,
Oct 9, 2018, 1:05:55 PM10/9/18
to django-...@googlegroups.com
#29814: Allow serializing NoneType in migrations
-------------------------------------+-------------------------------------
Reporter: Daan van der Kallen | Owner: Patrik
| Sletmo
Type: Bug | Status: assigned

Component: Migrations | Version: 2.1
Severity: Normal | Resolution:
Keywords: migration | Triage Stage: Accepted
deconstruct nonetype none |
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Patrik Sletmo):

* status: new => assigned
* owner: nobody => Patrik Sletmo


Comment:

I've managed to reproduce the issue and will attempt to provide a patch
later this week. If anyone is interested in reproducing the issue on their
own, the following code generates a problematic migration:


{{{
from django.db import models
from django.utils.deconstruct import deconstructible


@deconstructible
class SerializableClass:
def __init__(self, foo):
self.foo = foo


class DemoModel(models.Model):
problematic_field =
models.Field(default=SerializableClass(type(None)))

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29814#comment:2>

Django

unread,
Oct 11, 2018, 8:12:32 AM10/11/18
to django-...@googlegroups.com
#29814: Allow serializing NoneType in migrations
-------------------------------------+-------------------------------------
Reporter: Daan van der Kallen | Owner: Patrik
| Sletmo
Type: Bug | Status: assigned
Component: Migrations | Version: 2.1
Severity: Normal | Resolution:
Keywords: migration | Triage Stage: Accepted
deconstruct nonetype none |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Patrik Sletmo):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/29814#comment:3>

Django

unread,
Oct 11, 2018, 8:46:17 AM10/11/18
to django-...@googlegroups.com
#29814: Allow serializing NoneType in migrations
-------------------------------------+-------------------------------------
Reporter: Daan van der Kallen | Owner: Patrik
| Sletmo
Type: Bug | Status: assigned
Component: Migrations | Version: master
Severity: Normal | Resolution:
Keywords: migration | Triage Stage: Ready for
deconstruct nonetype none | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* version: 2.1 => master
* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/29814#comment:4>

Django

unread,
Oct 11, 2018, 9:22:42 AM10/11/18
to django-...@googlegroups.com
#29814: Allow serializing NoneType in migrations
-------------------------------------+-------------------------------------
Reporter: Daan van der Kallen | Owner: Patrik
| Sletmo
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: fixed

Keywords: migration | Triage Stage: Ready for
deconstruct nonetype none | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"adfdb9f1695d8710456b54282fcc6f306fc918c0" adfdb9f1]:
{{{
#!CommitTicketReference repository=""
revision="adfdb9f1695d8710456b54282fcc6f306fc918c0"
Fixed #29814 -- Added support for NoneType serialization in migrations.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29814#comment:5>

Reply all
Reply to author
Forward
0 new messages