#24779: django-1.8.1 fails test with pypy - FAIL: test_serialize_datetime_safe (migrations.test_writer.WriterTests) ----------------------------+------------------------------------ Reporter: jlec | Owner: nobody Type: Bug | Status: new Component: Migrations | Version: 1.8 Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------+------------------------------------
Comment (by flupzor): I've discovered the problem, I think it's a bug in PyPy. But I don't know if there is any Python API specification where this is specified in. The difference lies in the way the `__repr__` is made for date, time and datetime classes. In pypy the `__repr__` is determined as follows: date: https://bitbucket.org/pypy/pypy/src/5d676752ae6613d0b423f4c1028ac47e1571d5fa/lib_pypy/datetime.py?at=default#cl-790 time: https://bitbucket.org/pypy/pypy/src/5d676752ae6613d0b423f4c1028ac47e1571d5fa/lib_pypy/datetime.py?at=default#cl-1281 datetime: https://bitbucket.org/pypy/pypy/src/5d676752ae6613d0b423f4c1028ac47e1571d5fa/lib_pypy/datetime.py?at=default#cl-1692 While in cpython it is done like this: date: https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L2633 time: https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L3581 datetime: https://github.com/python/cpython/blob/master/Modules/_datetimemodule.c#L4442 Which causes the date, datetime and time classes in datetime_safe module to return the wrong __repr__ value. e.g. in cpython 2 and 3 repr(datetime_safe.date(2015, 1, 1)) would return: date(2015, 1, 1) While in pypy this would return: datetime.date(2015, 1, 1) And the same would happen for datetime and time. There are three solutions I can think of: - Override the ` __repr__` function in datetime_safe.{date,time,datetime} which return the representation consistently for both PyPy and cpython. - Make an hard "if PyPy" condition and then don't prepend the 'datetime' in that case (this would be the ugly solution imo) - Fix it in PyPy. -- Ticket URL: <https://code.djangoproject.com/ticket/24779#comment:3> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/062.0e66391630fda382138f854c90062caf%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.