[pypy-dev] Django DateField default value and migrations fail

Armin Rigo arigo at tunes.org
Thu Aug 18 09:05:13 EDT 2016


Hi William,

On 17 August 2016 at 10:04, William ML Leslie
<william.leslie.ttg at gmail.com> wrote:
> There's code for serialising methods in Django that checks `if
> isinstance(value, (types.FunctionType, types.BuiltinFunctionType))`
> which succeeds on cpython because datetime.date.today is a
> BuiltinFunctionType, wheras it's a types.MethodType on pypy.  Maybe
> that check could be expanded to include MethodType.

Yes, that's the right fix.  The problem is that ``date.today`` returns
a "built-in bound classmethod" object, which on CPython is identified as
``types.BuiltinFunctionType`` but on PyPy is identified as
``types.MethodType``.  We can't add a workaround in PyPy, either:
``date.today`` cannot return a plain function, because ``Date.today``
is a class method, not a static method.


A bientôt,

Armin.


More information about the pypy-dev mailing list