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 — shutil.make_archive now fails with pathlib.Path object in Python 3.11.0b4 · Issue #94844 · python/cpython

shutil.make_archive now fails with pathlib.Path object in Python 3.11.0b4 #94844

New issue
Copy link
New issue
Copy link
Closed
Closed
shutil.make_archive now fails with pathlib.Path object in Python 3.11.0b4#94844
Copy link
Assignees
serhiy-storchaka
Labels
3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-pathlibtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@treyhunner
treyhunner
opened on Jul 14, 2022
Issue body actions

Bug report

This code works on Python 3.10 and Python 3.11.0a5 but raises a TypeError in Python 3.11.0b4:

from pathlib import Path
from shutil import make_archive
path = Path.cwd().resolve()
make_archive(path, 'zip', path.parent, path.name)

Here's the output I see in Python 3.11.0b4:

>>> from pathlib import Path
>>> from shutil import make_archive
>>> path = Path.cwd().resolve()
>>> make_archive(path, 'zip', path.parent, path.name)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/trey/.pyenv/versions/3.11.0b4/lib/python3.11/shutil.py", line 1130, in make_archive
    filename = func(base_name, base_dir, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/trey/.pyenv/versions/3.11.0b4/lib/python3.11/shutil.py", line 977, in _make_zipfile
    zip_filename = base_name + ".zip"
                   ~~~~~~~~~~^~~~~~~~
TypeError: unsupported operand type(s) for +: 'PosixPath' and 'str'

Your environment

  • CPython versions tested on: Python 3.11.0b4
  • Operating system and architecture: 64-bit Ubuntu Linux 20.04

Activity

  1. treyhunner
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jul 14, 2022
  2. kumaraditya303
    added
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    topic-pathlib
    on Jul 14, 2022
  3. tiran
    assigned
    serhiy-storchaka
    on Jul 14, 2022
  4. tiran commented on Jul 14, 2022

    @tiran
    tiran
    on Jul 14, 2022
    Member
    More actions

    It is most likely related to gh-74696 / GH-93160 .

  5. serhiy-storchaka
    added
    3.10 (EOL)end of lifeend of life
    on Jul 14, 2022
  6. serhiy-storchaka commented on Jul 14, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Jul 14, 2022
    Member
    More actions

    It was not documented, and it only worked if root_dir is not None. It was not supported feature, it was a side effect of calling abspath() for base_name. Unsurprisingly, there were no tests for this.

    So we now have several options:

    • Do nothing. No supported feature was broken -- nothing to fix.
    • Add that feature officially (with tests and documentation) in bugfix releases.
    • Only fix what was broken (accept Path-like objects if root_dir is not None), but do not document it. Added tests should contain a comment that it is an implementation detail. In 3.12 we can also either remove this partial feature, or implement it completely and support officially.
    Reacted by Barney Gale
  7. serhiy-storchaka
    added a commit that references this issue on Jul 20, 2022

    gh-94844: Add pathlib support to shutil archive management (GH-94846)

    ed44415
  8. miss-islington
    added 4 commits that reference this issue on Jul 20, 2022

    pythongh-94844: Add pathlib support to shutil archive management (pyt…

    cadf202

    pythongh-94844: Add pathlib support to shutil archive management (pyt…

    c7d812d

    gh-94844: Add pathlib support to shutil archive management (GH-94846)

    6cc9489

    gh-94844: Add pathlib support to shutil archive management (GH-94846)

    cbe3ad5
  9. gvanrossum commented on Oct 4, 2022

    @gvanrossum
    gvanrossum
    on Oct 4, 2022
    Member
    More actions

    IIUC this was reverted and we're trying again for 3.12. See #94251 (PR) and #74696 (issue).

    Shall we close this as fixed? (I don't actually see the commits that reverted this -- how to find those?)

  10. merwok commented on Oct 4, 2022

    @merwok
    merwok
    on Oct 4, 2022
    Member
    More actions

    Don’t see any revert in file history: https://github.com/python/cpython/commits/3.11/Lib/shutil.py

  11. gvanrossum commented on Oct 4, 2022

    @gvanrossum
    gvanrossum
    on Oct 4, 2022
    Member
    More actions

    Yeah, I think I misunderstood (or confused this with another, unrelated issue).

    It looks like this was fixed by GH-94846.

    Reacted by Éric
  12. gvanrossum
    closed this as completedon Oct 4, 2022
  13. serhiy-storchaka commented on Oct 5, 2022

    @serhiy-storchaka
    serhiy-storchaka
    on Oct 5, 2022
    Member
    More actions

    #94846 only restored the old behavior which was an implementation artifact -- undocumented and not consistent. Path-like object as base_name is only accepted if root_dir is not None.

    If we want to make it an official feature, we should document it, cover by tests, and make it working for root_dir=None. Otherwise we can broke it and revert #94846 for 3.12.

    Reacted by Éric
  14. gvanrossum commented on Oct 5, 2022

    @gvanrossum
    gvanrossum
    on Oct 5, 2022
    Member
    More actions

    Then let's do the latter -- make it work for more cases, document it (lightly), and test it (briefly). And it's worth a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @serhiy-storchaka
    serhiy-storchaka

Labels

3.10 (EOL)end of lifeend of life3.11only security fixesonly security fixes3.12only security fixesonly security fixestopic-pathlibtype-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.