GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — os module: reject bytes-like strings for paths, only accept the exact bytes type · Issue #98393 · python/cpython

os module: reject bytes-like strings for paths, only accept the exact bytes type #98393

New issue
Copy link
New issue
Copy link
Closed
Closed
os module: reject bytes-like strings for paths, only accept the exact bytes type#98393
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@vstinner
vstinner
opened on Oct 18, 2022
Issue body actions

In Python 3.6, the support for "bytes-like" paths was deprecated (commit d73c318): see issue #70987 for the rationale.

I propose to remove the support for bytes-like paths in Python 3.12. The feature was deprecated in 6 Python releases (PEP 387 is respected). In practice, the two most common "bytes-like" types are: bytearray and memoryview.

  • PR: gh-98393: Update test_os for bytes-like types #98487
Reacted by Serhiy Storchaka

Activity

  1. vstinner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Oct 18, 2022
  2. vstinner commented on Oct 18, 2022

    @vstinner
    vstinner
    on Oct 18, 2022
    MemberAuthor
    More actions

    In Python 3.2, I removed support for bytearray in PyUnicode_FSConverter(): issue #52731, commit dcb2403.

    commit dcb2403022520028a633143602359a30080ed257
    Author: Victor Stinner <[email protected]>
    Date:   Thu Apr 22 12:08:36 2010 +0000
    
        Issue #8485: PyUnicode_FSConverter() doesn't accept bytearray object anymore,
        you have to convert your bytearray filenames to bytes
    

    It seems like support for bytes-like object was added again in Python 3.4 with commit a2ad5c3 (issue #60176):

    +        if (PyObject_CheckBuffer(o))
    +            bytes = PyBytes_FromObject(o);
    

    Or maybe this change is unrelated, and Python 3.2 and 3.3 already accepted bytes-like types indirectly.

  3. vstinner commented on Oct 18, 2022

    @vstinner
    vstinner
    on Oct 18, 2022
    MemberAuthor
    More actions

    I created PR #98394 to implement this change.

  4. vstinner commented on Oct 18, 2022

    @vstinner
    vstinner
    on Oct 18, 2022
    MemberAuthor
    More actions

    It seems like support for bytes-like object was added again in Python 3.4 with commit a2ad5c3 (issue #60176):

    Ah no, it was reintroduced in Python 3.3 with "the big path_converter changes": #70987 (comment)

  5. vstinner
    added a commit that references this issue on Oct 18, 2022

    gh-98393: os module reject bytes-like, only accept bytes (#98394)

    db03c80
  6. vstinner
    added a commit that references this issue on Nov 2, 2022

    gh-98393: Update test_os for bytes-like types (#98487)

    f3007ac
  7. vstinner commented on Nov 3, 2022

    @vstinner
    vstinner
    on Nov 3, 2022
    MemberAuthor
    More actions

    Fixed by db03c80 (with f3007ac cleanup).

  8. vstinner
    closed this as completedon Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.