New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #24139 -- Evaluate reason_phrase on demand based on status_code. #3903
Conversation
buildbot, test this please. |
@@ -141,6 +137,16 @@ def charset(self): | |||
def charset(self, value): | |||
self._charset = value | |||
|
|||
@property | |||
def reason_phrase(self): | |||
if self._reason_phrase is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't set self._reason_phrase
anywhere in here if the lookup fails. I don't think that's intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to me that you would leave it unset unless self.reason_phase
explicitly sets it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have that as a comment then, please.
Added comment as suggested. Let me know if you had something else in mind. |
Rebased after the merge of #3902 and resolved conflicts. |
|
||
Unless :attr:`reason_phrase` is explicitly set, modifying the value of | ||
``status_code`` outside the constructor will also modify the value of | ||
`reason_phrase`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:attr:reason_phrase
or reason_phrase
Do you mind expanding on what you're requesting? Are you saying Or are you saying the Sorry, but I'm not sure precisely what "status attributes" is referring to. I'm happy to cleanup whatever needs it, I'm just not sure exactly what you're asking me to change. I suppose one potential fix would be to fix the Version in master (if charset changes outside the constructor, the
|
Sorry for being unclear.
That's what I meant to say. However, adding a new |
Thanks. Will do. |
I believe I have implemented what you had in mind. Let me know how you feel about the results. |
self.assertEqual(response['content-type'], 'application/json') | ||
self.assertEqual(response.status_code, 504) | ||
|
||
def test_args(self): | ||
response = TemplateResponse(self.factory.get('/'), '', {}, | ||
'application/json', None, None, None, 504) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This raises an error:
Traceback (most recent call last):
File "/home/jenkins/workspace/pull-requests-trusty/database/mysql/label/trusty-pr/python/python2.7/tests/template_tests/test_response.py", line 265, in test_args
'application/json', None, None, None, 504)
File "/home/jenkins/workspace/pull-requests-trusty/database/mysql/label/trusty-pr/python/python2.7/django/template/response.py", line 201, in __init__
RemovedInDjango20Warning, stacklevel=2)
RemovedInDjango20Warning: The current_app argument of TemplateResponse is deprecated. Set the current_app attribute of its request instead.
This change seems to have gotten a bit unwieldy as far as the scope of the original ticket goes. Is there really a need to deprecate |
I think I agree. In my opinion, there is no pressing need to deprecate I originally went down this path at the request of @berkerpeksag. As a core contributor and Django Fellow I interpret his review as authoritative. If there is disagreement about the 2nd commit, please let me know how to proceed. |
OK, I've dropped the rename kwargs commit. If that is still desirable I can move it to another ticket. This will change will simply cover the goals of the original ticket. |
merged in d861f95, thanks! |
No description provided.