[issue21280] shutil.make_archive() with default "root_dir" parameter raises FileNotFoundError: [Errno 2] No such file or directory: ''
Martin Panter
report at bugs.python.org
Thu Apr 17 10:09:59 CEST 2014
New submission from Martin Panter:
>>> from shutil import make_archive; make_archive("a", "tar")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/shutil.py", line 783, in make_archive
filename = func(base_name, base_dir, **kwargs)
File "/usr/lib/python3.4/shutil.py", line 605, in _make_tarball
os.makedirs(archive_dir)
File "/usr/lib/python3.4/os.py", line 244, in makedirs
mkdir(name, mode)
FileNotFoundError: [Errno 2] No such file or directory: ''
Looking at the code, it calls os.path.dirname("a.tar") -> "", which would be the cause of this bug.
The workaround for me was adding an explicit make_archive(root_dir=".") parameter.
I was also surprised to see the code calling os.makedirs(archive_dir). Usually if you try to make a file in a non-existent directory, it fails, rather than automatically creating the directory for you. But maybe that’s just a general spirit of the “shutil” module that I didn’t pick up on.
----------
components: Library (Lib)
messages: 216672
nosy: vadmium
priority: normal
severity: normal
status: open
title: shutil.make_archive() with default "root_dir" parameter raises FileNotFoundError: [Errno 2] No such file or directory: ''
versions: Python 2.7, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21280>
_______________________________________
More information about the Python-bugs-list
mailing list