Jason R. Coombs avatar Jason R. Coombs committed 7475b77

Ensure that the setup.py is generated as bytes on Python 2 and 3 so that the tarfile module will accept it.

Comments (0)

Files changed (1)

setuptools/tests/test_easy_install.py

         """
         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')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.