[issue36043] FileCookieJar constructor don't accept PathLike

Alexander Kapshuna report at bugs.python.org
Tue Feb 19 13:26:02 EST 2019


New submission from Alexander Kapshuna <kapshuna at gmail.com>:

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.

----------
components: Library (Lib)
files: cookiejar_straightforward_convert.patch
keywords: patch
messages: 335993
nosy: Alexander Kapshuna
priority: normal
severity: normal
status: open
title: FileCookieJar constructor don't accept PathLike
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8
Added file: https://bugs.python.org/file48156/cookiejar_straightforward_convert.patch

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36043>
_______________________________________


More information about the Python-bugs-list mailing list