diff -r 0f663e0ce1d3 Lib/shutil.py --- a/Lib/shutil.py Tue Nov 18 17:30:50 2014 +0200 +++ b/Lib/shutil.py Tue Nov 18 22:13:10 2014 +0200 @@ -617,7 +617,7 @@ def _make_tarball(base_name, base_dir, c archive_name = base_name + '.tar' + compress_ext.get(compress, '') archive_dir = os.path.dirname(archive_name) - if not os.path.exists(archive_dir): + if archive_dir and not os.path.exists(archive_dir): if logger is not None: logger.info("creating %s", archive_dir) if not dry_run: @@ -662,7 +662,7 @@ def _make_zipfile(base_name, base_dir, v zip_filename = base_name + ".zip" archive_dir = os.path.dirname(base_name) - if not os.path.exists(archive_dir): + if archive_dir and not os.path.exists(archive_dir): if logger is not None: logger.info("creating %s", archive_dir) if not dry_run: diff -r 0f663e0ce1d3 Lib/test/test_shutil.py --- a/Lib/test/test_shutil.py Tue Nov 18 17:30:50 2014 +0200 +++ b/Lib/test/test_shutil.py Tue Nov 18 22:13:10 2014 +0200 @@ -1132,6 +1132,22 @@ class TestShutil(unittest.TestCase): finally: unregister_archive_format('xxx') + def test_make_tarfile_in_curdir(self): + # Issue #21280 + root_dir = self.mkdtemp() + with support.change_cwd(root_dir): + self.assertEqual(make_archive('test', 'tar'), 'test.tar') + self.assertTrue(os.path.isfile('test.tar')) + + @requires_zlib + @unittest.skipUnless(ZIP_SUPPORT, 'Need zip support to run') + def test_make_zipfile_in_curdir(self): + # Issue #21280 + root_dir = self.mkdtemp() + with support.change_cwd(root_dir): + self.assertEqual(make_archive('test', 'zip'), 'test.zip') + self.assertTrue(os.path.isfile('test.zip')) + def test_register_archive_format(self): self.assertRaises(TypeError, register_archive_format, 'xxx', 1)