Skip to content

Support path objects in the ntpath module #71371

Closed

Description

@ethanfurman
BPO 27184
Nosy @brettcannon, @pfmoore, @tjguk, @ethanfurman, @zware, @serhiy-storchaka, @eryksun, @zooba
Superseder
  • bpo-27524: Update os.path for PEP 519/fspath()
  • 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 2016-08-05.19:44:45.228>
    created_at = <Date 2016-06-02.17:30:06.979>
    labels = ['type-feature', 'library', 'OS-windows']
    title = 'Support path objects in the ntpath module'
    updated_at = <Date 2016-08-05.19:44:45.227>
    user = 'https://github.com/ethanfurman'

    bugs.python.org fields:

    activity = <Date 2016-08-05.19:44:45.227>
    actor = 'brett.cannon'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-08-05.19:44:45.228>
    closer = 'brett.cannon'
    components = ['Library (Lib)', 'Windows']
    creation = <Date 2016-06-02.17:30:06.979>
    creator = 'ethan.furman'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 27184
    keywords = []
    message_count = 8.0
    messages = ['267019', '267039', '267047', '267104', '267138', '267144', '267163', '272053']
    nosy_count = 8.0
    nosy_names = ['brett.cannon', 'paul.moore', 'tim.golden', 'ethan.furman', 'zach.ware', 'serhiy.storchaka', 'eryksun', 'steve.dower']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'test needed'
    status = 'closed'
    superseder = '27524'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue27184'
    versions = ['Python 3.6']

    Activity

    1. added
      type-bugAn unexpected behavior, bug, or error
      type-featureA feature request or enhancement
      and removed
      type-bugAn unexpected behavior, bug, or error
      on Jun 2, 2016
    2. eryksun commented on Jun 3, 2016

      @eryksun
      Contributor

      nt is the module name for posixmodule.c on Windows, so I'm changing the title to reference ntpath instead.

      Regarding nt, two of its built-in functions are exposed directly in ntpath. _isdir is imported as isdir, so it needs a wrapper to support __fspath__. Only pathlib uses _getfinalpathname, so for now I think it can be handled there. There's also nt._getdiskusage, which is only used by shutil.disk_usage. For some reason the PEP doesn't mention updating shutil to support __fspath__.

    3. added
      stdlibStandard Library Python modules in the Lib/ directory
      on Jun 3, 2016
    4. changed the title [-]Support path objects in the nt module[/-] [+]Support path objects in the ntpath module[/+] on Jun 3, 2016
    5. serhiy-storchaka commented on Jun 3, 2016

      @serhiy-storchaka
      Member

      Please don't change os.path until all other module will be changed. It may be that os.path would not need any change at all.

    6. eryksun commented on Jun 3, 2016

      @eryksun
      Contributor

      Sorry, I must have missed or misunderstood something. PEP-519 discusses modifying os.path. For the os module it only discusses adding fspath and updating fsencode and fsdecode. It also discusses a new PyOS_FSPath C API, but without any discussion regarding its use in the implementation of the posix / nt module, or regarding what built-in os functions should support __fspath__.

    7. ethanfurman commented on Jun 3, 2016

      @ethanfurman
      MemberAuthor

      @Serhy: Isn't that backwards? I would think that by doing os.path first most other libraries would not have to change.

    8. serhiy-storchaka commented on Jun 3, 2016

      @serhiy-storchaka
      Member

      I think that if some high-level function uses os.path, it likely should convert Path argument to str either because the path should be saved as a string, or for performance if multiple os.path functions are called with the same argument. Note, that some os.path functions will implicitly support path objects if the posix module support it.

      Let first find the functions that need path objects support in os.path.

    9. ethanfurman commented on Jun 3, 2016

      @ethanfurman
      MemberAuthor

      The expected scenario, and the purpose of os.fspath(), is to enable high-level libraries to not know or care if they receive a pathlib object or a string.

      In other words, they already have os.path.join() and os.path.split() calls, and currently break noisily if a pathlib.Path is passed in; by enhancing os.path to accept a pathlib.Path object that high-level library can start working with pathlib.Path objects without changing a thing, which means the user of that library can use pathlib.Path painlessly.

      Unless I have seriously misunderstood something, os.path will be changed to work with __fspath__ objects.

    10. brettcannon commented on Jun 3, 2016

      @brettcannon
      Member

      os.path will be updated to work with __fspath__() as specified by Guido as part of the conversation for PEP-519 (IOW listing os.path as being updated in PEP-519 is not an accident).

    11. brettcannon commented on Aug 5, 2016

      @brettcannon
      Member

      I added support for ntpath as part of issue bpo-27524.

    12. transferred this issue fromon Apr 10, 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

      OS-windowsstdlibStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancement

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions