﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28894	Invalid migrations caused by incorrect serialization of functools.partial()	Nick Pope	Nick Pope	"So this one was interesting... I ended up with a migration that contained something like this (reduced to a trivial example):

{{{
models.CharField(default=functools.partial(int, *('123', ), **None), ...)
}}}

The expected output should have been:

{{{
models.CharField(default=functools.partial(int, *('123', ), **{}), ...)
}}}

It boils down to the following issue:

{{{
# Python 2.7.6: Empty args working, empty keywords broken.
>>> import functools
>>> print(functools.partial(int, base=10).args)
()
>>> print(functools.partial(int, '123').keywords)
None
}}}

{{{
# Python 2.7.14: Empty args working, empty keywords working.
>>> import functools
>>> print(functools.partial(int, base=10).args)
()
>>> print(functools.partial(int, '123').keywords)
{}
}}}

Scouring the release notes for Python, I found the following:

    ""The keywords attribute of functools.partial is now always a dictionary.""

This was resolved in 2.7.10, 3.4.4 & 3.5.0.

As Django 2.1 will only support Python 3.5 or later, this only needs to be backported to 1.11 and 2.0 and need not be applied to master.

Pull request incoming..."	Bug	closed	Migrations	1.9	Normal	wontfix	functools partial migrations serialization		Unreviewed	1	0	0	0	0	0
