Re: [Django] #31982: Convert max_age to an int in set_cookie()

39 views
Skip to first unread message

Django

unread,
Sep 4, 2020, 12:51:25 AM9/4/20
to django-...@googlegroups.com
#31982: Convert max_age to an int in set_cookie()
--------------------------------------+------------------------------------
Reporter: Matt Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by felixxm):

* cc: Florian Apolloner, Adam (Chainz) Johnson (added)
* type: Uncategorized => Cleanup/optimization
* stage: Unreviewed => Accepted


Comment:

Agreed, we should also mention this in
[https://docs.djangoproject.com/en/3.1/ref/request-
response/#django.http.HttpResponse.set_cookie docs], e.g.:

> `max_age` should be **an integer** number of seconds, ...

Replying to [ticket:31982 Matt Johnson]:
> 1. Do we only convert floats where the decimal part is 0? Or do we round
or truncate?
> 2. If we can't successfully convert to an int, do we throw an exception,
or just pass in the original value?

I would simply call `int(max_age)` without catching exceptions.

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

Django

unread,
Sep 4, 2020, 5:07:06 AM9/4/20
to django-...@googlegroups.com
#31982: Convert max_age to an int in set_cookie()
--------------------------------------+------------------------------------
Reporter: Matt Johnson | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: HTTP handling | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Adam (Chainz) Johnson):

+1 to calling `int()`

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

Django

unread,
Sep 4, 2020, 8:06:33 AM9/4/20
to django-...@googlegroups.com
#31982: Convert max_age to an int in set_cookie()
-------------------------------------+-------------------------------------
Reporter: Matt Johnson | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned

Component: HTTP handling | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Hasan Ramezani):

* owner: nobody => Hasan Ramezani
* status: new => assigned
* has_patch: 0 => 1


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

Django

unread,
Sep 4, 2020, 2:30:38 PM9/4/20
to django-...@googlegroups.com
#31982: Convert max_age to an int in set_cookie()
-------------------------------------+-------------------------------------
Reporter: Matt Johnson | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* needs_tests: 0 => 1


Comment:

[https://github.com/django/django/pull/13386 PR]

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

Django

unread,
Sep 5, 2020, 4:08:48 AM9/5/20
to django-...@googlegroups.com
#31982: Convert max_age to an int in set_cookie()
-------------------------------------+-------------------------------------
Reporter: Matt Johnson | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: assigned
Component: HTTP handling | Version: 3.1
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

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

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

* needs_tests: 1 => 0
* stage: Accepted => Ready for checkin


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

Django

unread,
Sep 5, 2020, 4:42:21 AM9/5/20
to django-...@googlegroups.com
#31982: Convert max_age to an int in set_cookie()
-------------------------------------+-------------------------------------
Reporter: Matt Johnson | Owner: Hasan
Type: | Ramezani
Cleanup/optimization | Status: closed

Component: HTTP handling | Version: 3.1
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: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"d2d08c8cf6ed601d52e25cb8fc7944d39b5ed56e" d2d08c8]:
{{{
#!CommitTicketReference repository=""
revision="d2d08c8cf6ed601d52e25cb8fc7944d39b5ed56e"
Fixed #31982 -- Made HttpResponse.set_cookie() cast max_age argument to an
integer.
}}}

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

Reply all
Reply to author
Forward
0 new messages