Skip to content

Commit 1aef10e

Browse files
committed
[fea] py3 support and bump
1 parent 9b2d815 commit 1aef10e

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

pypi_server/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
("Dmitry Orlov", "me@mosquito.su")
1010
]
1111

12-
version_info = (0, 3, 11)
12+
version_info = (0, 3, 12)
1313

1414
__version__ = ".".join(map(str, version_info))
1515
__author__ = ", ".join("{0} <{1}>".format(*author) for author in author_info)

pypi_server/handlers/pypi/package.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from pypi_server import PY2
99
from pypi_server.db import DB
1010
from pypi_server.handlers.pypi.proxy.client import PYPIClient
11+
from six import b
1112
from tornado.gen import coroutine, Task, maybe_future, Return
1213
from tornado.web import asynchronous, HTTPError
1314
from tornado.httpclient import AsyncHTTPClient
@@ -136,7 +137,7 @@ def wrap(self, *args, **kwargs):
136137
if auth_type.lower() != 'basic':
137138
raise Return(self.send_error(400))
138139

139-
username, password = map(unquote_plus, base64.b64decode(data).split(":"))
140+
username, password = map(lambda x: unquote_plus(x.decode("utf-8")), base64.b64decode(b(data)).split(b(":")))
140141
try:
141142
self.current_user = yield check_password(username, password)
142143
except LookupError:
@@ -179,7 +180,7 @@ class XmlRPC(BaseHandler):
179180

180181
@coroutine
181182
def prepare(self):
182-
if self.request.method.upper() == 'POST' and not self.request.body.startswith("\r\n"):
183+
if self.request.method.upper() == 'POST' and not self.request.body.startswith(b("\r\n")):
183184
boundary = dict(
184185
filter(
185186
lambda x: x[0] == 'boundary',
@@ -194,19 +195,19 @@ def prepare(self):
194195
raise HTTPError(400)
195196

196197
def normalize(chunk):
197-
if '\n\n' not in chunk:
198-
return '\r\n' + chunk[1:]
198+
if b('\n\n') not in chunk:
199+
return b('\r\n') + chunk[1:]
199200

200-
ret = ''
201-
ret += '\r\n'
202-
data, content = chunk.split('\n\n', 1)
201+
ret = b('')
202+
ret += b('\r\n')
203+
data, content = chunk.split(b('\n\n'), 1)
203204
ret += data[1:]
204-
ret += '\r\n\r\n'
205+
ret += b('\r\n\r\n')
205206
ret += content[:-1]
206-
ret += '\r\n'
207+
ret += b('\r\n')
207208
return ret
208209

209-
boundary = "--{0}".format(boundary)
210+
boundary = b("--{0}".format(boundary))
210211

211212
new_body = boundary.join(
212213
map(
@@ -216,7 +217,7 @@ def normalize(chunk):
216217
)
217218

218219
new_body = new_body[:-4]
219-
new_body += '--\r\n'
220+
new_body += b('--\r\n')
220221

221222
self.request.body = new_body
222223
self.request._parse_body()

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ def walker(base, *paths):
8585
'bcrypt',
8686
'lxml',
8787
'futures',
88+
'six',
8889
),
8990
extras_require={
9091
'mysql': ['mysql-python'],

0 commit comments

Comments
 (0)