mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +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)
|
spec(irc, msg, args, state)
|
||||||
return
|
return
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
e2 = e # 'e' is local.
|
||||||
errored = state.errored
|
errored = state.errored
|
||||||
state.errored = False
|
state.errored = False
|
||||||
continue
|
continue
|
||||||
@ -877,7 +878,7 @@ class first(context):
|
|||||||
state.args.append(self.default)
|
state.args.append(self.default)
|
||||||
else:
|
else:
|
||||||
state.errored = errored
|
state.errored = errored
|
||||||
raise e
|
raise e2
|
||||||
|
|
||||||
class reverse(context):
|
class reverse(context):
|
||||||
def __call__(self, irc, msg, args, state):
|
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_type', 'text/plain; charset=utf-8')
|
||||||
self.send_header('Content-Length', len(self.defaultResponse))
|
self.send_header('Content-Length', len(self.defaultResponse))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(self.defaultResponse)
|
self.wfile.write(self.defaultResponse.encode())
|
||||||
|
|
||||||
doPost = doHead = doGet
|
doPost = doHead = doGet
|
||||||
|
|
||||||
@ -159,7 +159,7 @@ class Supy404(SupyHTTPServerCallback):
|
|||||||
self.send_header('Content_type', 'text/plain; charset=utf-8')
|
self.send_header('Content_type', 'text/plain; charset=utf-8')
|
||||||
self.send_header('Content-Length', len(self.response))
|
self.send_header('Content-Length', len(self.response))
|
||||||
self.end_headers()
|
self.end_headers()
|
||||||
self.wfile.write(self.response)
|
self.wfile.write(self.response.encode())
|
||||||
|
|
||||||
doPost = doHead = doGet
|
doPost = doHead = doGet
|
||||||
|
|
||||||
|
@ -38,7 +38,6 @@ import urllib
|
|||||||
import httplib
|
import httplib
|
||||||
import unittest
|
import unittest
|
||||||
import threading
|
import threading
|
||||||
import StringIO
|
|
||||||
|
|
||||||
import supybot.log as log
|
import supybot.log as log
|
||||||
import supybot.i18n as i18n
|
import supybot.i18n as i18n
|
||||||
@ -568,8 +567,12 @@ class HTTPPluginTestCase(PluginTestCase):
|
|||||||
|
|
||||||
def request(self, url, method='GET', read=True, data={}):
|
def request(self, url, method='GET', read=True, data={}):
|
||||||
assert url.startswith('/')
|
assert url.startswith('/')
|
||||||
wfile = StringIO.StringIO()
|
try:
|
||||||
rfile = StringIO.StringIO()
|
from io import BytesIO as StringIO
|
||||||
|
except ImportError:
|
||||||
|
from StringIO import StringIO
|
||||||
|
wfile = StringIO()
|
||||||
|
rfile = StringIO()
|
||||||
connection = FakeHTTPConnection(wfile, rfile)
|
connection = FakeHTTPConnection(wfile, rfile)
|
||||||
connection.putrequest(method, url)
|
connection.putrequest(method, url)
|
||||||
connection.endheaders()
|
connection.endheaders()
|
||||||
|
@ -455,7 +455,8 @@ def format(s, *args, **kwargs):
|
|||||||
return has(args.pop())
|
return has(args.pop())
|
||||||
elif char == 'L':
|
elif char == 'L':
|
||||||
t = args.pop()
|
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)
|
return commaAndify(t)
|
||||||
elif isinstance(t, tuple) and len(t) == 2:
|
elif isinstance(t, tuple) and len(t) == 2:
|
||||||
if not isinstance(t[0], list):
|
if not isinstance(t[0], list):
|
||||||
|
Loading…
Reference in New Issue
Block a user