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 — Bug report: shutil.make_archive() makes empty archive file even when root_dir does not exists · Issue #99203 · python/cpython

Bug report: shutil.make_archive() makes empty archive file even when root_dir does not exists #99203

New issue
Copy link
New issue
Copy link
Closed
#107998
Closed
Bug report: shutil.make_archive() makes empty archive file even when root_dir does not exists#99203
#107998
Copy link
Labels
3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@mski-iksm
mski-iksm
opened on Nov 7, 2022
Issue body actions

Bug report

In python 3.10+, shutil.make_archive() makes empty archive file and does not raise any error even when root_dir does not exists.
In python -3.9, FileNotFoundError is raised with message [Errno 2] No such file or directory: ‘xxxxxxx’.

import shutil

shutil.make_archive(base_name='aaa_archive', root_dir="not_existing_dir", format="zip")
# This will raise FileNotFoundError in python ~3.9, where it doesn’t in 3.10~

I though making empty archive file is unnatural, so fixing it maybe good for backward compatibility.

I think this problem is caused in this line, where os.chdir(root_dir) is not called anymore.
In the previous code, os.chdir(root_dir) will raise FileNotFoundError when root_dir does not exists.
https://github.com/python/cpython/pull/93160/files#diff-db8ac59326160713929e0e1973aef54f0280fe9f154ef24d14244909a0e0689bL1084

I thought checking the existence of root_dir and raise FileNotFoundError when root_dir is not found, might be a good implementation to fix this problem.

Linked PRs

  • gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior #99802
  • [3.12] gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802) #107998
  • [3.11] gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802) #107999

Activity

  1. mski-iksm
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 7, 2022
  2. sobolevn
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.10 (EOL)end of lifeend of life
    3.9 (EOL)end of lifeend of life
    3.11only security fixesonly security fixes
    3.12only security fixesonly security fixes
    on Nov 9, 2022
  3. 6t8k commented on Jan 29, 2023

    @6t8k
    6t8k
    on Jan 29, 2023
    Contributor
    More actions

    Gentle ping:
    @giampaolo @serhiy-storchaka @merwok

  4. iritkatriel
    removed
    3.10 (EOL)end of lifeend of life
    3.9 (EOL)end of lifeend of life
    on Apr 5, 2023
  5. serhiy-storchaka
    added a commit that references this issue on Aug 16, 2023

    gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 beh…

    a86df29
  6. miss-islington
    added a commit that references this issue on Aug 16, 2023

    pythongh-99203: shutil.make_archive(): restore select CPython <= 3.10…

    49d322b
  7. serhiy-storchaka
    added a commit that references this issue on Aug 16, 2023

    [3.11] pythongh-99203: shutil.make_archive(): restore select CPython …

    a716563
  8. serhiy-storchaka
    closed this as completedon Aug 16, 2023
  9. serhiy-storchaka
    added a commit that references this issue on Aug 16, 2023

    [3.11] gh-99203: shutil.make_archive(): restore select CPython <= 3.1…

    4cfbcff
  10. serhiy-storchaka
    reopened this on Aug 16, 2023
  11. serhiy-storchaka
    linked a pull request that will close this issue[3.12] gh-99203: shutil.make_archive(): restore select CPython <= 3.10.5 behavior (GH-99802) #107998on Aug 16, 2023
  12. Yhg1s
    added a commit that references this issue on Aug 16, 2023

    [3.12] gh-99203: shutil.make_archive(): restore select CPython <= 3.1…

    5d9f20a
  13. serhiy-storchaka
    closed this as completedon Aug 26, 2023
  14. chrkr commented on Apr 30, 2024

    @chrkr
    chrkr
    on Apr 30, 2024
    More actions

    Would it be an idea to backport this fix to 3.10 as well? Because there is now a slight range of Python versions where using '' as the root_path does work (3.10.6 - 3.11.4) and it just so happens that using the 'latest' version of each release this fails in all versions except 3.10.

  15. merwok commented on Apr 30, 2024

    @merwok
    merwok
    on Apr 30, 2024
    Member
    More actions

    Only security fixes are accepted for 3.10

    Reacted by Chris Kruszynski
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

    3.11only security fixesonly security fixes3.12only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-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.