From 856ff28c515c35ad35db6661d0b74579f59c3e4c Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Sat, 14 Apr 2012 18:31:52 +0000 Subject: Ensure that the setup.py is generated as bytes on Python 2 and 3 so that the tarfile module will accept it. --HG-- branch : distribute extra : rebase_source : 07afe24875bff3a4892319e02ae66be0d3725c8e --- setuptools/tests/test_easy_install.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'setuptools') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 5577dd6a..cf2f91d6 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -313,14 +313,19 @@ class TestSetupRequires(unittest.TestCase): """ def build_sdist(dir): setup_py = tarfile.TarInfo(name="setup.py") - setup_py_bytes = StringIO.StringIO(textwrap.dedent(""" + try: + # Python 3 (StringIO gets converted to io module) + MemFile = StringIO.BytesIO + except AttributeError: + MemFile = StringIO.StringIO + setup_py_bytes = MemFile(textwrap.dedent(""" import setuptools setuptools.setup( name="distribute-test-fetcher", version="1.0", setup_requires = ['does-not-exist'], ) - """).lstrip()) + """).lstrip().encode('utf-8')) setup_py.size = len(setup_py_bytes.getvalue()) dist_path = os.path.join(dir, 'distribute-test-fetcher-1.0.tar.gz') dist = tarfile.open(dist_path, 'w:gz') -- cgit v1.2.3