mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +01:00
core: Various Python 3 compatibility fixes.
Conflicts: src/httpserver.py
This commit is contained in:
parent
f8a57b78e4
commit
a55611a49e
@ -870,6 +870,7 @@ class first(context):
|
||||
spec(irc, msg, args, state)
|
||||
return
|
||||
except Exception, e:
|
||||
e2 = e # 'e' is local.
|
||||
errored = state.errored
|
||||
state.errored = False
|
||||
continue
|
||||
@ -877,7 +878,7 @@ class first(context):
|
||||
state.args.append(self.default)
|
||||
else:
|
||||
state.errored = errored
|
||||
raise e
|
||||
raise e2
|
||||
|
||||
class reverse(context):
|
||||
def __call__(self, irc, msg, args, state):
|
||||
|
@ -138,7 +138,7 @@ class SupyHTTPServerCallback:
|
||||
self.send_header('Content_type', 'text/plain; charset=utf-8')
|
||||
self.send_header('Content-Length', len(self.defaultResponse))
|
||||
self.end_headers()
|
||||
self.wfile.write(self.defaultResponse)
|
||||
self.wfile.write(self.defaultResponse.encode())
|
||||
|
||||
doPost = doHead = doGet
|
||||
|
||||
@ -159,7 +159,7 @@ class Supy404(SupyHTTPServerCallback):
|
||||
self.send_header('Content_type', 'text/plain; charset=utf-8')
|
||||
self.send_header('Content-Length', len(self.response))
|
||||
self.end_headers()
|
||||
self.wfile.write(self.response)
|
||||
self.wfile.write(self.response.encode())
|
||||
|
||||
doPost = doHead = doGet
|
||||
|
||||
|
@ -38,7 +38,6 @@ import urllib
|
||||
import httplib
|
||||
import unittest
|
||||
import threading
|
||||
import StringIO
|
||||
|
||||
import supybot.log as log
|
||||
import supybot.i18n as i18n
|
||||
@ -568,8 +567,12 @@ class HTTPPluginTestCase(PluginTestCase):
|
||||
|
||||
def request(self, url, method='GET', read=True, data={}):
|
||||
assert url.startswith('/')
|
||||
wfile = StringIO.StringIO()
|
||||
rfile = StringIO.StringIO()
|
||||
try:
|
||||
from io import BytesIO as StringIO
|
||||
except ImportError:
|
||||
from StringIO import StringIO
|
||||
wfile = StringIO()
|
||||
rfile = StringIO()
|
||||
connection = FakeHTTPConnection(wfile, rfile)
|
||||
connection.putrequest(method, url)
|
||||
connection.endheaders()
|
||||
|
@ -455,7 +455,8 @@ def format(s, *args, **kwargs):
|
||||
return has(args.pop())
|
||||
elif char == 'L':
|
||||
t = args.pop()
|
||||
if isinstance(t, list):
|
||||
if isinstance(t, list) or (sys.version_info[0] >= 3 and
|
||||
(isinstance(t, map) or isinstance(t, filter))):
|
||||
return commaAndify(t)
|
||||
elif isinstance(t, tuple) and len(t) == 2:
|
||||
if not isinstance(t[0], list):
|
||||
|
Loading…
Reference in New Issue
Block a user