This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Documentation confusion in CookieJar functions
Type: enhancement Stage: patch review
Components: Documentation Versions: Python 3.8
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: andrei.avk, docs@python, eric.araujo, markus, python-dev
Priority: normal Keywords: patch

Created on 2020-10-14 15:23 by markus, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 23112 open python-dev, 2020-11-02 15:39
Messages (10)
msg378624 - (view) Author: Markus Israelsson (markus) * Date: 2020-10-14 15:23
The documentation in https://docs.python.org/3.8/library/http.cookiejar.html#http.cookiejar.CookieJar
claims the following for functions add_cookie_header and extract_cookies.

***
The request object (usually a urllib.request.Request instance) must support the methods get_full_url(), get_host(), get_type(), unverifiable(), has_header(), get_header(), header_items(), add_unredirected_header() and origin_req_host attribute as documented by urllib.request.
***


When reading the documentation for Request Objects https://docs.python.org/3.8/library/urllib.request.html?highlight=requests#request-objects
there is this:
***
Changed in version 3.4: The request methods add_data, has_data, get_data, get_type, get_host, get_selector, get_origin_req_host and is_unverifiable that were deprecated since 3.3 have been removed.
***

So basically the documentation claims that if the request object does not support functions that are removed then the headers will not be added. The code itself seem to do the correct thing however and add the header.
msg379013 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2020-10-19 20:41
Hello!  I don’t see the problem that you are mentioning: the request methods removed from Request objects are not in the list of methods required by the CookieJar methods.
msg379088 - (view) Author: Markus Israelsson (markus) * Date: 2020-10-20 05:45
The way I read the documentation for add_cookie_header is:

These methods must exist in the Request object:
- get_full_url()
- get_host()
- get_type()
- unverifiable... and so on.


The documentation for the request objects claims however that:
These methods are removed since version 3.4:
- add_data
- has_data
- get_data
- get_type
- get_host - This method , and some others, are listed as requirements for the add_cookie_header and extract_cookies functions. See list above or link I posted above to the correct places in the docs.


So it is only the documentation that is inconsistent. Not the code.
Unless, like I said, I misunderstand something in the documentation.
msg379138 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2020-10-20 14:54
Ah, I see it now: get_host and get_type are in both lists!

Would you like to contribute a fix for the docs?
If yes, help is here: https://devguide.python.org/docquality/
msg379198 - (view) Author: Markus Israelsson (markus) * Date: 2020-10-21 07:12
Sure.

But I will need to get an ok from my company to spend some time on this because I really am not very used to git yet (recently switched).

Also, is it possible to make the request/changes through the company github account or must that in that case be tied directly to this bug report account?
msg379199 - (view) Author: Markus Israelsson (markus) * Date: 2020-10-21 07:13
I guess due to something having to be signed I would have to create a personal github account :/
msg379200 - (view) Author: Markus Israelsson (markus) * Date: 2020-10-21 08:30
I got ok from the higherups.
Will plan this into next sprint so it will take a week or 2 before I get to it.
msg379358 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2020-10-22 21:33
Yes, you will need a github account linked to a bpo (this site) account so that the contributor agreement bot can do its job.
msg380204 - (view) Author: Markus Israelsson (markus) * Date: 2020-11-02 10:51
I am currently updating the documentation source code.
On the cookiejar page it describes 'unverifiable' as a method.
I can however not find that method on the request page because it seems to be just a normal attribute.

I will make updates for that as well if that is ok with you?
msg391153 - (view) Author: Andrei Kulakov (andrei.avk) * (Python triager) Date: 2021-04-15 20:52
I can confirm `unverifiable` is an attr: https://github.com/python/cpython/blob/master/Lib/urllib/request.py#L333

and so is incorrectly listed as a method in cookie jar docs.
History
Date User Action Args
2022-04-11 14:59:36adminsetgithub: 86203
2021-04-15 20:52:38andrei.avksetnosy: + andrei.avk
messages: + msg391153
2020-11-02 15:39:07python-devsetkeywords: + patch
nosy: + python-dev

pull_requests: + pull_request22029
stage: patch review
2020-11-02 10:51:56markussetmessages: + msg380204
2020-10-22 21:33:25eric.araujosetmessages: + msg379358
2020-10-21 08:30:54markussetmessages: + msg379200
2020-10-21 07:13:55markussetmessages: + msg379199
2020-10-21 07:12:45markussetmessages: + msg379198
2020-10-20 14:54:55eric.araujosetmessages: + msg379138
2020-10-20 05:45:04markussetmessages: + msg379088
2020-10-19 20:41:41eric.araujosetnosy: + eric.araujo
messages: + msg379013
2020-10-14 15:23:42markuscreate