[Django] #23950: Adding 'deconstruct' method breaks serialization of type

15 views
Skip to first unread message

Django

unread,
Dec 2, 2014, 6:30:51 PM12/2/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
-------------------------------+--------------------
Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
This is similar to #22951, which I think just didn't fix the problem
entirely. I'm getting the same error, but in a different location, when
adding a deconstruct method:

{{{

Traceback (most recent call last):
File "./manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "django/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "django/core/management/commands/makemigrations.py", line 124, in
handle
self.write_migration_files(changes)
File "django/core/management/commands/makemigrations.py", line 152, in
write_migration_files
migration_string = writer.as_string()
File "django/db/migrations/writer.py", line 131, in as_string
operation_string, operation_imports =
OperationWriter(operation).serialize()
File "django/db/migrations/writer.py", line 88, in serialize
arg_string, arg_imports = MigrationWriter.serialize(arg_value)
File "django/db/migrations/writer.py", line 331, in serialize
return cls.serialize_deconstructed(path, args, kwargs)
File "django/db/migrations/writer.py", line 239, in
serialize_deconstructed
arg_string, arg_imports = cls.serialize(arg)
File "django/db/migrations/writer.py", line 334, in serialize
return cls.serialize_deconstructed(*value.deconstruct())
TypeError: unbound method deconstruct() must be called with FooEnum
instance as first argument (got nothing instead)

}}}

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

Django

unread,
Dec 2, 2014, 6:33:57 PM12/2/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
-------------------------------+--------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

Can you provide code to reproduce the error? A test for Django's test
suite is ideal.

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

Django

unread,
Dec 2, 2014, 8:57:26 PM12/2/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
-------------------------------+--------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by gavinwahl):

It happens when a class is passed to a custom field as an argument. This
is used in the package django-enumfields, where the enum class is passed
to EnumField. It was reported in that project as https://github.com/hzdg
/django-enumfields/issues/22#issuecomment-65325260.

Here's the failing test for django:
https://github.com/fusionbox/django/commit/a133c689903c8df92c6b25d3ae1b50a12bc66543

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

Django

unread,
Dec 2, 2014, 9:02:35 PM12/2/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
-------------------------------+--------------------------------------

Reporter: gavinwahl | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------

Comment (by gavinwahl):

I was able to fix it, here's the PR:
https://github.com/django/django/pull/3668

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

Django

unread,
Dec 3, 2014, 8:17:10 AM12/3/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
----------------------------+---------------------------------------------
Reporter: gavinwahl | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------
Changes (by timgraham):

* has_patch: 0 => 1
* type: Uncategorized => Bug
* stage: Unreviewed => Ready for checkin


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

Django

unread,
Dec 3, 2014, 8:24:20 AM12/3/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
----------------------------+---------------------------------------------
Reporter: gavinwahl | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for 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: new => closed
* resolution: => fixed


Comment:

In [changeset:"dee4d23f7e703aec2d1244e4facbf7f4c88deed5"]:
{{{
#!CommitTicketReference repository=""
revision="dee4d23f7e703aec2d1244e4facbf7f4c88deed5"
Fixed #23950 -- Prevented calling deconstruct on classes in
MigrationWriter.
}}}

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

Django

unread,
Dec 3, 2014, 8:35:45 AM12/3/14
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
----------------------------+---------------------------------------------
Reporter: gavinwahl | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"e9975ed3cd3243d78b89fe2b44a152263ba5a602"]:
{{{
#!CommitTicketReference repository=""
revision="e9975ed3cd3243d78b89fe2b44a152263ba5a602"
[1.7.x] Fixed #23950 -- Prevented calling deconstruct on classes in
MigrationWriter.

Backport of dee4d23f7e703aec2d1244e4facbf7f4c88deed5 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23950#comment:6>

Django

unread,
Nov 25, 2019, 5:31:22 AM11/25/19
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
----------------------------+---------------------------------------------
Reporter: Gavin Wahl | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8008795a3899d979d65832ca7c4946903de206f7" 8008795a]:
{{{
#!CommitTicketReference repository=""
revision="8008795a3899d979d65832ca7c4946903de206f7"
Refs #23950 --- Moved test DeconstructibleInstances class to a module
level.

DeconstructibleInstances was not importable from the asserted path.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23950#comment:7>

Django

unread,
Nov 25, 2019, 5:31:38 AM11/25/19
to django-...@googlegroups.com
#23950: Adding 'deconstruct' method breaks serialization of type
----------------------------+---------------------------------------------
Reporter: Gavin Wahl | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.7

Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Ready for checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+---------------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"ba5760965ed52d1b310097e060f8511f9bad7631" ba57609]:
{{{
#!CommitTicketReference repository=""
revision="ba5760965ed52d1b310097e060f8511f9bad7631"
[3.0.x] Refs #23950 --- Moved test DeconstructibleInstances class to a
module level.

DeconstructibleInstances was not importable from the asserted path.

Backport of 8008795a3899d979d65832ca7c4946903de206f7 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23950#comment:8>

Reply all
Reply to author
Forward
0 new messages