Skip to content
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

FileCookieJar constructor don't accept PathLike #80224

Closed
kapsh mannequin opened this issue Feb 19, 2019 · 6 comments
Closed

FileCookieJar constructor don't accept PathLike #80224

kapsh mannequin opened this issue Feb 19, 2019 · 6 comments
Labels
3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@kapsh
Copy link
Mannequin

kapsh mannequin commented Feb 19, 2019

BPO 36043
Nosy @matrixise, @miss-islington, @tirkarthi
PRs
  • bpo-36043: FileCookieJar supports os.PathLike #11945
  • Files
  • cookiejar_straightforward_convert.patch: one minute patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-03-01.20:41:46.833>
    created_at = <Date 2019-02-19.18:26:02.661>
    labels = ['3.7', '3.8', 'type-feature', 'library']
    title = "FileCookieJar constructor don't accept PathLike"
    updated_at = <Date 2019-03-01.20:41:46.833>
    user = 'https://bugs.python.org/kapsh'

    bugs.python.org fields:

    activity = <Date 2019-03-01.20:41:46.833>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-03-01.20:41:46.833>
    closer = 'brett.cannon'
    components = ['Library (Lib)']
    creation = <Date 2019-02-19.18:26:02.661>
    creator = 'kapsh'
    dependencies = []
    files = ['48156']
    hgrepos = []
    issue_num = 36043
    keywords = ['patch']
    message_count = 6.0
    messages = ['335993', '335996', '335997', '335998', '336238', '336955']
    nosy_count = 4.0
    nosy_names = ['matrixise', 'miss-islington', 'xtreak', 'kapsh']
    pr_nums = ['11945']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue36043'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

    @kapsh
    Copy link
    Mannequin Author

    kapsh mannequin commented Feb 19, 2019

    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.

    @kapsh kapsh mannequin added 3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Feb 19, 2019
    @tirkarthi
    Copy link
    Member

    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.

    @tirkarthi tirkarthi removed the 3.7 (EOL) end of life label Feb 19, 2019
    @matrixise
    Copy link
    Member

    @XTreak

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

    can I publish my PR?

    @matrixise matrixise added the 3.7 (EOL) end of life label Feb 19, 2019
    @matrixise
    Copy link
    Member

    in fact, I have published my PR because I have already the tests and I have another approach for this issue.

    @kapsh
    Copy link
    Mannequin Author

    kapsh mannequin commented Feb 21, 2019

    Oh sorry, I just thought that everybody has forgotten about this part of library. Nevermind my patch then, your work is certainly better, matrixise.

    @miss-islington
    Copy link
    Contributor

    New changeset 4b219ce by Miss Islington (bot) (Stéphane Wirtel) in branch 'master':
    bpo-36043: FileCookieJar supports os.PathLike (GH-11945)
    4b219ce

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life 3.8 only security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants