[Django] #29600: Remove usage of django.utils.datetime_safe where possible

6 views
Skip to first unread message

Django

unread,
Jul 26, 2018, 12:32:44 PM7/26/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim | Owner: Tim Graham
Graham |
Type: | Status: assigned
Cleanup/optimization |
Component: Core | Version: master
(Other) |
Severity: Normal | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`django.utils.datetime_safe` was added in #1443 to overcome limitations in
Python 2.7 where `strftime()` doesn't support dates with year < 1900. That
issue is fixed in Python 3, but an issue remains where the result of
`strftime('%Y')` [https://bugs.python.org/issue13305 isn't consistent]
across all platforms. That issue was worked around in #12524.

`strftime()` is no longer used in the JSON serializer as of
9b1cb755a28f020e27d4268c214b25315d4de42e, so using `datetime_safe()` is
obsolete there.

If we remove `dateteime_safe` usage in migrations (it's need is
questionable), that would fix #29595.

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

Django

unread,
Jul 26, 2018, 2:52:23 PM7/26/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
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
-------------------------------------+-------------------------------------
Description changed by Tim Graham:

Old description:

> `django.utils.datetime_safe` was added in #1443 to overcome limitations
> in Python 2.7 where `strftime()` doesn't support dates with year < 1900.
> That issue is fixed in Python 3, but an issue remains where the result of
> `strftime('%Y')` [https://bugs.python.org/issue13305 isn't consistent]
> across all platforms. That issue was worked around in #12524.
>
> `strftime()` is no longer used in the JSON serializer as of
> 9b1cb755a28f020e27d4268c214b25315d4de42e, so using `datetime_safe()` is
> obsolete there.
>
> If we remove `dateteime_safe` usage in migrations (it's need is
> questionable), that would fix #29595.

New description:

`django.utils.datetime_safe` was added in #1443 to overcome limitations in
Python 2.7 where `strftime()` doesn't support dates with year < 1900. That
issue is fixed in Python 3, but an issue remains where the result of
`strftime('%Y')` [https://bugs.python.org/issue13305 isn't consistent]
across all platforms. That issue was worked around in #12524.

`strftime()` and `datetime_safe` are no longer used in the JSON serializer
as of 9b1cb755a28f020e27d4268c214b25315d4de42e but the fix from
03924929ba212368240bd7a26b14208fba965cb9 may still be useful in the other
places that `datetime_safe` is used.

If we remove `dateteime_safe` usage in migrations (its need there is
questionable, I think), that would fix #29595.

--

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

Django

unread,
Jul 26, 2018, 4:49:45 PM7/26/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
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 GitHub <noreply@…>):

In [changeset:"2ac7cd52b466e5090c0479de02c4765b4c483fa3" 2ac7cd5]:
{{{
#!CommitTicketReference repository=""
revision="2ac7cd52b466e5090c0479de02c4765b4c483fa3"
Refs #29600 -- Removed datetime_safe usage in feedgenerator.

The only effect would be if items in Atom feeds had a published date
year of < 1000 (ensuring those years are padded with leading zeros).
}}}

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

Django

unread,
Jul 26, 2018, 5:13:13 PM7/26/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
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 Tim Graham <timograham@…>):

In [changeset:"013d439ff038ca8e750e6d1dcd6965f33ad4cf3e" 013d439f]:
{{{
#!CommitTicketReference repository=""
revision="013d439ff038ca8e750e6d1dcd6965f33ad4cf3e"
Refs #29600 -- Added test for datetime_safe usage in localize_input().
}}}

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

Django

unread,
Jul 26, 2018, 5:13:13 PM7/26/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
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 Tim Graham <timograham@…>):

In [changeset:"76852c398943cf8a3b7a517f05614df3e47970c8" 76852c39]:
{{{
#!CommitTicketReference repository=""
revision="76852c398943cf8a3b7a517f05614df3e47970c8"


Refs #29600 -- Added test for datetime_safe usage in

SelectDateWidget.value_from_datadict().
}}}

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

Django

unread,
Jul 27, 2018, 12:19:33 PM7/27/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: assigned
Component: Core (Other) | Version: master
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 Tim Graham <timograham@…>):

In [changeset:"c72dde41e603093ab0bb12fa24fa69cfda0d35f9" c72dde41]:
{{{
#!CommitTicketReference repository=""
revision="c72dde41e603093ab0bb12fa24fa69cfda0d35f9"
Fixed #29595 -- Allowed using timedelta in migrations questioner.

Refs #29600 -- Removed usage of django.utils.datetime_safe in migrations.
}}}

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

Django

unread,
Jul 27, 2018, 12:48:48 PM7/27/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed

Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

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


Comment:

I audited all usage of `datetime_safe` and added tests or removed usage as
appropriate.

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

Django

unread,
Aug 2, 2018, 10:20:44 AM8/2/18
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Core (Other) | Version: master
Severity: Normal | Resolution: fixed
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 GitHub <noreply@…>):

In [changeset:"2092206bee3281e6809a8fddb5230d80902a02b4" 2092206b]:
{{{
#!CommitTicketReference repository=""
revision="2092206bee3281e6809a8fddb5230d80902a02b4"
Refs #29600 -- Updated django.utils.datetime_safe now that Python 2 is
unsupported.
}}}

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

Django

unread,
May 12, 2021, 9:43:49 AM5/12/21
to django-...@googlegroups.com
#29600: Remove usage of django.utils.datetime_safe where possible
-------------------------------------+-------------------------------------
Reporter: Tim Graham | Owner: Tim
Type: | Graham
Cleanup/optimization | Status: closed
Component: Core (Other) | Version: dev
Severity: Normal | Resolution: fixed

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 Carlton Gibson <carlton.gibson@…>):

In [changeset:"44accb066a51d15f27e38f203c73830eddea16df" 44accb0]:
{{{
#!CommitTicketReference repository=""
revision="44accb066a51d15f27e38f203c73830eddea16df"
Refs #32738, Refs #29600, Refs #29595 -- Removed unused
django.utils.datetime_safe.time().

Unused since c72dde41e603093ab0bb12fa24fa69cfda0d35f9.
}}}

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

Reply all
Reply to author
Forward
0 new messages