You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-overlay/profiles/patches/net-p2p/bittorrent-5.2.2-unicode.patch

35 lines
1.2 KiB

diff --git a/BitTorrent/HTTPHandler.py b/BitTorrent/HTTPHandler.py
index afabc63..91a745d 100644
--- a/BitTorrent/HTTPHandler.py
+++ b/BitTorrent/HTTPHandler.py
@@ -110,6 +110,8 @@ class HTTPConnector(object):
#this is nasty but i'm unsure of a better way at the moment
compressed = StringIO()
gz = GzipFile(fileobj = compressed, mode = 'wb', compresslevel = 9)
+ if type(data) == unicode:
+ data = data.encode("utf8")
gz.write(data)
gz.close()
compressed.seek(0,0)
@@ -151,6 +153,8 @@ class HTTPConnector(object):
r.write(key + ': ' + str(value) + '\r\n')
r.write('\r\n')
if self.command != 'HEAD':
+ if type(data)==unicode:
+ data=data.encode("utf8")
r.write(data)
self.connection.write(r.getvalue())
if self.connection.is_flushed():
diff --git a/BitTorrent/track.py b/BitTorrent/track.py
index ebedb70..4995b9c 100644
--- a/BitTorrent/track.py
+++ b/BitTorrent/track.py
@@ -54,6 +54,7 @@ import threading
import traceback
NOISY = False
+_ = lambda x:x
def quote(x):
return urllib.quote(x, safe='')