Make a number of small changes to ease the backport to distutils2

This commit is contained in:
Éric Araujo 2011-09-18 20:11:48 +02:00
parent 41479450ec
commit 229011d949
19 changed files with 104 additions and 125 deletions

View file

@ -40,6 +40,7 @@ from xmlrpc.server import SimpleXMLRPCServer
from packaging.tests import unittest
PYPI_DEFAULT_STATIC_PATH = os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'pypiserver')
@ -219,7 +220,7 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
relative_path += "index.html"
if relative_path.endswith('.tar.gz'):
with open(fs_path + relative_path, 'br') as file:
with open(fs_path + relative_path, 'rb') as file:
data = file.read()
headers = [('Content-type', 'application/x-gtar')]
else:
@ -260,8 +261,8 @@ class PyPIRequestHandler(SimpleHTTPRequestHandler):
self.send_header(header, value)
self.end_headers()
if type(data) is str:
data = data.encode()
if isinstance(data, str):
data = data.encode('utf-8')
self.wfile.write(data)