[issue22021] shutil.make_archive() root_dir do not work
Weinan Li
report at bugs.python.org
Mon Jul 21 11:50:13 CEST 2014
New submission from Weinan Li:
set root_dir do not work
output:
=====================================================
Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import shutil
>>> shutil.make_archive("tmp.tar.gz", "gztar", "c:/xjtu", "c:/tmp")
'C:\\Python34\\tmp.tar.gz.tar.gz'
=====================================================
source code of make_archive()
=====================================================
756 save_cwd = os.getcwd()
757 if root_dir is not None:
758 if logger is not None:
759 logger.debug("changing into '%s'", root_dir)
760 base_name = os.path.abspath(base_name)
761 if not dry_run:
762 os.chdir(root_dir)
...
...
782 try:
783 filename = func(base_name, base_dir, **kwargs)
784 finally:
=====================================================
base_name is set before chdir, so the archive always be created in cwd, whether set root_dir or not.
so, line 760 should be move below line 762
----------
components: Library (Lib)
messages: 223568
nosy: DemoHT
priority: normal
severity: normal
status: open
title: shutil.make_archive() root_dir do not work
type: behavior
versions: Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22021>
_______________________________________
More information about the Python-bugs-list
mailing list