classification
Title: FileCookieJar constructor don't accept PathLike
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: kapsh, matrixise, miss-islington, xtreak
Priority: normal Keywords: patch

Created on 2019-02-19 18:26 by kapsh, last changed 2019-03-01 20:41 by brett.cannon. This issue is now closed.

Files
File name Uploaded Description Edit
cookiejar_straightforward_convert.patch kapsh, 2019-02-19 18:26 one minute patch
Pull Requests
URL Status Linked Edit
PR 11945 merged matrixise, 2019-02-19 18:54
Messages (6)
msg335993 - (view) Author: Alexander Kapshuna (kapsh) Date: 2019-02-19 18:26
FileCookieJar and it's subclasses don't accept Paths and DirEntrys.
Minimal code to reproduce:

===

import pathlib
from http.cookiejar import FileCookieJar

saved_cookies = pathlib.Path('my_cookies.txt')
jar = FileCookieJar(saved_cookies)

===

Results in: "ValueError: filename must be string-like".
Workaround is to convert Path explicitly or call load() which doesn't check for type, but it would be nice to see all APIs in standard library consistent.

I also did quick and dirty patch which silently converts filename argument using os.fspath(). This way it won't break any existing code relying on FileCookieJar.filename being string.
msg335996 - (view) Author: Karthikeyan Singaravelan (xtreak) * (Python triager) Date: 2019-02-19 18:44
This seems like a good change to me. GitHub PRs are accepted please see https://devguide.python.org/ . Since this is an enhancement it can only go as part of Python 3.8 if accepted.
msg335997 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-19 18:52
@xtreak

sorry, but I have already worked on this issue :/

can I publish my PR?
msg335998 - (view) Author: Stéphane Wirtel (matrixise) * (Python committer) Date: 2019-02-19 18:55
in fact, I have published my PR because I have already the tests and I have another approach for this issue.
msg336238 - (view) Author: Alexander Kapshuna (kapsh) Date: 2019-02-21 17:09
Oh sorry, I just thought that everybody has forgotten about this part of library. Nevermind my patch then, your work is certainly better, matrixise.
msg336955 - (view) Author: miss-islington (miss-islington) Date: 2019-03-01 20:40
New changeset 4b219ce81ed04234648a4ce4f0cb0865818abb38 by Miss Islington (bot) (Stéphane Wirtel) in branch 'master':
bpo-36043: FileCookieJar supports os.PathLike (GH-11945)
https://github.com/python/cpython/commit/4b219ce81ed04234648a4ce4f0cb0865818abb38
History
Date User Action Args
2019-03-01 20:41:46brett.cannonsetstatus: open -> closed
resolution: fixed
stage: resolved
2019-03-01 20:40:58miss-islingtonsetnosy: + miss-islington
messages: + msg336955
2019-02-21 17:09:12kapshsetmessages: + msg336238
2019-02-19 18:55:40matrixisesetmessages: + msg335998
stage: patch review -> (no value)
2019-02-19 18:54:44matrixisesetstage: patch review
pull_requests: + pull_request11969
2019-02-19 18:52:28matrixisesetnosy: + matrixise

messages: + msg335997
versions: + Python 3.6, Python 3.7
2019-02-19 18:44:58xtreaksetnosy: + xtreak

messages: + msg335996
versions: - Python 3.6, Python 3.7
2019-02-19 18:26:02kapshcreate