diff --git a/mitmproxy/builtins/serverplayback.py b/mitmproxy/builtins/serverplayback.py index 29fc95efc..b495bc27e 100644 --- a/mitmproxy/builtins/serverplayback.py +++ b/mitmproxy/builtins/serverplayback.py @@ -1,5 +1,5 @@ from __future__ import absolute_import, print_function, division -from six.moves import urllib +import urllib import hashlib from netlib import strutils diff --git a/mitmproxy/builtins/stickycookie.py b/mitmproxy/builtins/stickycookie.py index 027e624fa..d89bd92d1 100644 --- a/mitmproxy/builtins/stickycookie.py +++ b/mitmproxy/builtins/stickycookie.py @@ -1,5 +1,6 @@ import collections -from six.moves import http_cookiejar +from http import cookiejar + from netlib.http import cookies from mitmproxy import exceptions @@ -20,9 +21,9 @@ def ckey(attrs, f): def domain_match(a, b): - if http_cookiejar.domain_match(a, b): + if cookiejar.domain_match(a, b): return True - elif http_cookiejar.domain_match(a, b.strip(".")): + elif cookiejar.domain_match(a, b.strip(".")): return True return False diff --git a/mitmproxy/console/grideditor/base.py b/mitmproxy/console/grideditor/base.py index 8b80badbf..eed70c0b0 100644 --- a/mitmproxy/console/grideditor/base.py +++ b/mitmproxy/console/grideditor/base.py @@ -2,7 +2,6 @@ from __future__ import absolute_import, print_function, division import abc import copy -import six import urwid from mitmproxy.console import common from mitmproxy.console import signals @@ -24,8 +23,7 @@ FOOTER_EDITING = [ ] -@six.add_metaclass(abc.ABCMeta) -class Column(object): +class Column(object, metaclass=abc.ABCMeta): subeditor = None def __init__(self, heading): diff --git a/mitmproxy/console/master.py b/mitmproxy/console/master.py index 16abcb96a..d648d808c 100644 --- a/mitmproxy/console/master.py +++ b/mitmproxy/console/master.py @@ -13,7 +13,6 @@ import tempfile import traceback import weakref -import six import urwid from typing import Optional # noqa @@ -357,13 +356,8 @@ class ConsoleMaster(flow.FlowMaster): def spawn_editor(self, data): text = not isinstance(data, bytes) fd, name = tempfile.mkstemp('', "mproxy", text=text) - if six.PY2: - os.close(fd) - with open(name, "w" if text else "wb") as f: - f.write(data) - else: - with open(fd, "w" if text else "wb") as f: - f.write(data) + with open(fd, "w" if text else "wb") as f: + f.write(data) # if no EDITOR is set, assume 'vi' c = os.environ.get("EDITOR") or "vi" cmd = shlex.split(c) diff --git a/mitmproxy/contentviews.py b/mitmproxy/contentviews.py index 83e6a7ad0..03ef8f052 100644 --- a/mitmproxy/contentviews.py +++ b/mitmproxy/contentviews.py @@ -16,24 +16,26 @@ from __future__ import absolute_import, print_function, division import cssutils import datetime -import html2text -import jsbeautifier import json import logging -import lxml.etree -import lxml.html import subprocess import traceback +import io +from typing import Mapping # noqa + +import lxml.etree +import lxml.html from PIL import ExifTags from PIL import Image +import html2text +import jsbeautifier + from mitmproxy import exceptions from mitmproxy.contrib.wbxml import ASCommandResponse from netlib import http from netlib import multidict from netlib import strutils from netlib.http import url -from six import BytesIO -from typing import Mapping # noqa try: import pyamf @@ -422,7 +424,7 @@ class ViewImage(View): def __call__(self, data, **metadata): try: - img = Image.open(BytesIO(data)) + img = Image.open(io.BytesIO(data)) except IOError: return None parts = [ diff --git a/mitmproxy/contrib/tls/utils.py b/mitmproxy/contrib/tls/utils.py index 4c917303e..87afbacb7 100644 --- a/mitmproxy/contrib/tls/utils.py +++ b/mitmproxy/contrib/tls/utils.py @@ -6,15 +6,12 @@ from __future__ import absolute_import, division, print_function import construct -import six - - class _UBInt24(construct.Adapter): def _encode(self, obj, context): - return ( - six.int2byte((obj & 0xFF0000) >> 16) + - six.int2byte((obj & 0x00FF00) >> 8) + - six.int2byte(obj & 0x0000FF) + return bytes( + (obj & 0xFF0000) >> 16, + (obj & 0x00FF00) >> 8, + obj & 0x0000FF ) def _decode(self, obj, context): diff --git a/mitmproxy/contrib/tnetstring.py b/mitmproxy/contrib/tnetstring.py index f5e1d5c10..22ecab652 100644 --- a/mitmproxy/contrib/tnetstring.py +++ b/mitmproxy/contrib/tnetstring.py @@ -41,7 +41,6 @@ all other strings are returned as plain bytes. """ import collections -import six from typing import io, Union, Tuple # noqa TSerializable = Union[None, bool, int, float, bytes, list, tuple, dict] @@ -96,7 +95,7 @@ def _rdumpq(q, size, value): elif value is False: write(b'5:false!') return size + 8 - elif isinstance(value, six.integer_types): + elif isinstance(value, int): data = str(value).encode() ldata = len(data) span = str(ldata).encode() @@ -191,16 +190,12 @@ def load(file_handle): def parse(data_type, data): # type: (int, bytes) -> TSerializable - if six.PY2: - data_type = ord(data_type) if data_type == ord(b','): return data if data_type == ord(b';'): return data.decode("utf8") if data_type == ord(b'#'): try: - if six.PY2: - return long(data) return int(data) except ValueError: raise ValueError("not a tnetstring: invalid integer literal: {}".format(data)) diff --git a/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py b/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py index ecc76efb5..b616028c4 100644 --- a/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py +++ b/mitmproxy/contrib/wbxml/ASWBXMLByteQueue.py @@ -5,7 +5,7 @@ Inspired by EAS Inspector for Fiddler https://easinspectorforfiddler.codeplex.com ------ The MIT License (MIT) ----- +----- The MIT License (MIT) ----- Filename: ASWBXMLByteQueue.py Copyright (c) 2014, David P. Shaw @@ -27,25 +27,25 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' -from six.moves.queue import Queue +from queue import Queue import logging class ASWBXMLByteQueue(Queue): def __init__(self, wbxmlBytes): - + self.bytesDequeued = 0 self.bytesEnqueued = 0 - + Queue.__init__(self) for byte in wbxmlBytes: self.put(ord(byte)) self.bytesEnqueued += 1 - - + + logging.debug("Array byte count: %d, enqueued: %d" % (self.qsize(), self.bytesEnqueued)) - + """ Created to debug the dequeueing of bytes """ @@ -54,18 +54,18 @@ class ASWBXMLByteQueue(Queue): self.bytesDequeued += 1 logging.debug("Dequeued byte 0x{0:X} ({1} total)".format(singleByte, self.bytesDequeued)) return singleByte - + """ Return true if the continuation bit is set in the byte """ def checkContinuationBit(self, byteval): continuationBitmask = 0x80 return (continuationBitmask & byteval) != 0 - + def dequeueMultibyteInt(self): iReturn = 0 singleByte = 0xFF - + while True: iReturn <<= 7 if (self.qsize() == 0): @@ -100,4 +100,3 @@ class ASWBXMLByteQueue(Queue): break return strReturn - diff --git a/mitmproxy/controller.py b/mitmproxy/controller.py index 4fd66bfab..579cf92dc 100644 --- a/mitmproxy/controller.py +++ b/mitmproxy/controller.py @@ -3,8 +3,7 @@ from __future__ import absolute_import, print_function, division import functools import threading import contextlib - -from six.moves import queue +import queue from mitmproxy import addons from mitmproxy import options diff --git a/mitmproxy/flow/export.py b/mitmproxy/flow/export.py index eb2d38d28..44ba1905d 100644 --- a/mitmproxy/flow/export.py +++ b/mitmproxy/flow/export.py @@ -2,21 +2,15 @@ from __future__ import absolute_import, print_function, division import json import re -from textwrap import dedent - -import six -from six.moves import urllib +import textwrap +import urllib import netlib.http def _native(s): - if six.PY2: - if isinstance(s, str): - return s.encode() - else: - if isinstance(s, bytes): - return s.decode() + if isinstance(s, bytes): + return s.decode() return s @@ -49,7 +43,7 @@ def curl_command(flow): def python_code(flow): - code = dedent(""" + code = textwrap.dedent(""" import requests url = '{url}' @@ -110,7 +104,7 @@ def is_json(headers, content): def locust_code(flow): - code = dedent(""" + code = textwrap.dedent(""" from locust import HttpLocust, TaskSet, task class UserBehavior(TaskSet): diff --git a/mitmproxy/flow/io_compat.py b/mitmproxy/flow/io_compat.py index b01f96b66..e7753adb0 100644 --- a/mitmproxy/flow/io_compat.py +++ b/mitmproxy/flow/io_compat.py @@ -3,7 +3,6 @@ This module handles the import of mitmproxy flows generated by old versions. """ from __future__ import absolute_import, print_function, division -import six from typing import Any # noqa from netlib import version, strutils @@ -93,23 +92,21 @@ def _convert_dict_vals(o, values_to_convert): def convert_unicode(data): # type: (dict) -> dict """ - The Python 2 version of mitmproxy serializes everything as bytes. This method converts between Python 3 and Python 2 dumpfiles. """ - if not six.PY2: - data = _convert_dict_keys(data) - data = _convert_dict_vals( - data, { - "type": True, - "id": True, - "request": { - "first_line_format": True - }, - "error": { - "msg": True - } + data = _convert_dict_keys(data) + data = _convert_dict_vals( + data, { + "type": True, + "id": True, + "request": { + "first_line_format": True + }, + "error": { + "msg": True } - ) + } + ) return data diff --git a/mitmproxy/flow/state.py b/mitmproxy/flow/state.py index 26b18c84d..f6395c79d 100644 --- a/mitmproxy/flow/state.py +++ b/mitmproxy/flow/state.py @@ -2,15 +2,13 @@ from __future__ import absolute_import, print_function, division from abc import abstractmethod, ABCMeta -import six from typing import List # noqa from mitmproxy import flowfilter from mitmproxy import models # noqa -@six.add_metaclass(ABCMeta) -class FlowList(object): +class FlowList(metaclass=ABCMeta): def __init__(self): self._list = [] # type: List[models.Flow] @@ -26,9 +24,6 @@ class FlowList(object): def __bool__(self): return bool(self._list) - if six.PY2: - __nonzero__ = __bool__ - def __len__(self): return len(self._list) diff --git a/mitmproxy/main.py b/mitmproxy/main.py index 6ae99bddd..e39742f34 100644 --- a/mitmproxy/main.py +++ b/mitmproxy/main.py @@ -4,8 +4,6 @@ import os import signal import sys -from six.moves import _thread # PY3: We only need _thread.error, which is an alias of RuntimeError in 3.3+ - from mitmproxy import cmdline from mitmproxy import exceptions from mitmproxy.proxy import config @@ -78,7 +76,7 @@ def mitmproxy(args=None): # pragma: no cover sys.exit(1) try: m.run() - except (KeyboardInterrupt, _thread.error): + except (KeyboardInterrupt, RuntimeError): pass @@ -109,7 +107,7 @@ def mitmdump(args=None): # pragma: no cover except (dump.DumpError, exceptions.OptionsError) as e: print("mitmdump: %s" % e, file=sys.stderr) sys.exit(1) - except (KeyboardInterrupt, _thread.error): + except (KeyboardInterrupt, RuntimeError): pass if master is None or master.has_errored: print("mitmdump: errors occurred during run", file=sys.stderr) @@ -142,5 +140,5 @@ def mitmweb(args=None): # pragma: no cover sys.exit(1) try: m.run() - except (KeyboardInterrupt, _thread.error): + except (KeyboardInterrupt, RuntimeError): pass diff --git a/mitmproxy/models/connections.py b/mitmproxy/models/connections.py index 9778b7f12..a99327d87 100644 --- a/mitmproxy/models/connections.py +++ b/mitmproxy/models/connections.py @@ -4,8 +4,6 @@ import time import copy import os -import six - from mitmproxy import stateobject from netlib import certutils from netlib import tcp @@ -47,9 +45,6 @@ class ClientConnection(tcp.BaseHandler, stateobject.StateObject): def __bool__(self): return bool(self.connection) and not self.finished - if six.PY2: - __nonzero__ = __bool__ - def __repr__(self): return "".format( ssl="[ssl] " if self.ssl_established else "", @@ -136,9 +131,6 @@ class ServerConnection(tcp.TCPClient, stateobject.StateObject): def __bool__(self): return bool(self.connection) and not self.finished - if six.PY2: - __nonzero__ = __bool__ - def __repr__(self): if self.ssl_established and self.sni: ssl = "[ssl: {0}] ".format(self.sni) diff --git a/mitmproxy/platform/windows.py b/mitmproxy/platform/windows.py index 576516e22..54d29c72d 100644 --- a/mitmproxy/platform/windows.py +++ b/mitmproxy/platform/windows.py @@ -10,8 +10,8 @@ import time import configargparse from pydivert import enum from pydivert import windivert -from six.moves import cPickle as pickle -from six.moves import socketserver +import pickle +import socketserver PROXY_API_PORT = 8085 diff --git a/mitmproxy/protocol/base.py b/mitmproxy/protocol/base.py index da6e83563..b280ec35a 100644 --- a/mitmproxy/protocol/base.py +++ b/mitmproxy/protocol/base.py @@ -1,9 +1,5 @@ from __future__ import absolute_import, print_function, division -import sys - -import six - import netlib.exceptions from mitmproxy import exceptions from mitmproxy import models @@ -184,12 +180,8 @@ class ServerConnectionMixin(object): try: self.server_conn.connect() except netlib.exceptions.TcpException as e: - six.reraise( - exceptions.ProtocolException, - exceptions.ProtocolException( - "Server connection to {} failed: {}".format( - repr(self.server_conn.address), str(e) - ) - ), - sys.exc_info()[2] + raise exceptions.ProtocolException( + "Server connection to {} failed: {}".format( + repr(self.server_conn.address), str(e) + ) ) diff --git a/mitmproxy/protocol/http.py b/mitmproxy/protocol/http.py index 35b375de6..54b611993 100644 --- a/mitmproxy/protocol/http.py +++ b/mitmproxy/protocol/http.py @@ -2,8 +2,6 @@ from __future__ import absolute_import, print_function, division import h2.exceptions import netlib.exceptions -import six -import sys import time import traceback from mitmproxy import exceptions @@ -83,9 +81,6 @@ class ConnectServerConnection(object): def __bool__(self): return bool(self.via) - if six.PY2: - __nonzero__ = __bool__ - class UpstreamConnectLayer(base.Layer): @@ -159,12 +154,8 @@ class HttpLayer(base.Layer): # We optimistically guess there might be an HTTP client on the # other end self.send_error_response(400, repr(e)) - six.reraise( - exceptions.ProtocolException, - exceptions.ProtocolException( - "HTTP protocol error in client request: {}".format(e) - ), - sys.exc_info()[2] + raise exceptions.ProtocolException( + "HTTP protocol error in client request: {}".format(e) ) self.log("request", "debug", [repr(request)]) @@ -193,10 +184,7 @@ class HttpLayer(base.Layer): # update host header in reverse proxy mode if self.config.options.mode == "reverse": - if six.PY2: - flow.request.headers["Host"] = self.config.upstream_server.address.host.encode() - else: - flow.request.headers["Host"] = self.config.upstream_server.address.host + flow.request.headers["Host"] = self.config.upstream_server.address.host # set upstream auth if self.mode == "upstream" and self.config.upstream_auth is not None: @@ -244,8 +232,9 @@ class HttpLayer(base.Layer): self.channel.ask("error", flow) return else: - six.reraise(exceptions.ProtocolException, exceptions.ProtocolException( - "Error in HTTP connection: %s" % repr(e)), sys.exc_info()[2]) + raise exceptions.ProtocolException( + "Error in HTTP connection: %s" % repr(e) + ) finally: if flow: flow.live = False diff --git a/mitmproxy/protocol/http2.py b/mitmproxy/protocol/http2.py index ae12406fc..ffc556843 100644 --- a/mitmproxy/protocol/http2.py +++ b/mitmproxy/protocol/http2.py @@ -6,10 +6,9 @@ import traceback import functools import h2.exceptions -import six from h2 import connection from h2 import events -from six.moves import queue +import queue import netlib.exceptions from mitmproxy import exceptions @@ -208,7 +207,7 @@ class Http2Layer(base.Layer): return True def _handle_remote_settings_changed(self, event, other_conn): - new_settings = dict([(key, cs.new_value) for (key, cs) in six.iteritems(event.changed_settings)]) + new_settings = dict([(key, cs.new_value) for (key, cs) in event.changed_settings.items()]) other_conn.h2.safe_update_settings(new_settings) return True diff --git a/mitmproxy/protocol/tls.py b/mitmproxy/protocol/tls.py index 4792edb86..537737172 100644 --- a/mitmproxy/protocol/tls.py +++ b/mitmproxy/protocol/tls.py @@ -1,10 +1,8 @@ from __future__ import absolute_import, print_function, division import struct -import sys import construct -import six import netlib.exceptions from mitmproxy import exceptions @@ -214,20 +212,12 @@ def is_tls_record_magic(d): # TLS ClientHello magic, works for SSLv3, TLSv1.0, TLSv1.1, TLSv1.2 # http://www.moserware.com/2009/06/first-few-milliseconds-of-https.html#client-hello - if six.PY2: - return ( - len(d) == 3 and - d[0] == '\x16' and - d[1] == '\x03' and - d[2] in ('\x00', '\x01', '\x02', '\x03') - ) - else: - return ( - len(d) == 3 and - d[0] == 0x16 and - d[1] == 0x03 and - 0x0 <= d[2] <= 0x03 - ) + return ( + len(d) == 3 and + d[0] == 0x16 and + d[1] == 0x03 and + 0x0 <= d[2] <= 0x03 + ) def get_client_hello(client_conn): @@ -467,7 +457,7 @@ class TlsLayer(base.Layer): self._establish_tls_with_client() except: pass - six.reraise(*sys.exc_info()) + raise self._establish_tls_with_client() @@ -497,15 +487,11 @@ class TlsLayer(base.Layer): # raises ann error. self.client_conn.rfile.peek(1) except netlib.exceptions.TlsException as e: - six.reraise( - exceptions.ClientHandshakeException, - exceptions.ClientHandshakeException( - "Cannot establish TLS with client (sni: {sni}): {e}".format( - sni=self._client_hello.sni, e=repr(e) - ), - self._client_hello.sni or repr(self.server_conn.address) + raise exceptions.ClientHandshakeException( + "Cannot establish TLS with client (sni: {sni}): {e}".format( + sni=self._client_hello.sni, e=repr(e) ), - sys.exc_info()[2] + self._client_hello.sni or repr(self.server_conn.address) ) def _establish_tls_with_server(self): @@ -545,21 +531,14 @@ class TlsLayer(base.Layer): self.log(str(tls_cert_err), "warn") self.log("Ignoring server verification error, continuing with connection", "warn") except netlib.exceptions.InvalidCertificateException as e: - six.reraise( - exceptions.InvalidServerCertificate, - exceptions.InvalidServerCertificate(str(e)), - sys.exc_info()[2] - ) + raise exceptions.InvalidServerCertificate(str(e)) except netlib.exceptions.TlsException as e: - six.reraise( - exceptions.TlsProtocolException, - exceptions.TlsProtocolException("Cannot establish TLS with {address} (sni: {sni}): {e}".format( - address=repr(self.server_conn.address), - sni=self.server_sni, - e=repr(e), - )), - sys.exc_info()[2] - ) + raise exceptions.TlsProtocolException( + "Cannot establish TLS with {address} (sni: {sni}): {e}".format( + address=repr(self.server_conn.address), + sni=self.server_sni, + e=repr(e), + )) proto = self.alpn_for_client_connection.decode() if self.alpn_for_client_connection else '-' self.log("ALPN selected by server: {}".format(proto), "debug") diff --git a/mitmproxy/proxy/config.py b/mitmproxy/proxy/config.py index df4dd4c8f..e5b3bd048 100644 --- a/mitmproxy/proxy/config.py +++ b/mitmproxy/proxy/config.py @@ -6,7 +6,6 @@ import os import re from netlib import strutils -import six from OpenSSL import SSL, crypto from mitmproxy import exceptions @@ -38,9 +37,6 @@ class HostMatcher(object): def __bool__(self): return bool(self.patterns) - if six.PY2: - __nonzero__ = __bool__ - ServerSpec = collections.namedtuple("ServerSpec", "scheme address") diff --git a/mitmproxy/proxy/root_context.py b/mitmproxy/proxy/root_context.py index cfa04bdf7..d3f3c6df8 100644 --- a/mitmproxy/proxy/root_context.py +++ b/mitmproxy/proxy/root_context.py @@ -1,9 +1,5 @@ from __future__ import absolute_import, print_function, division -import sys - -import six - import netlib.exceptions from mitmproxy import controller from mitmproxy import exceptions @@ -50,7 +46,7 @@ class RootContext(object): try: d = top_layer.client_conn.rfile.peek(3) except netlib.exceptions.TcpException as e: - six.reraise(exceptions.ProtocolException, exceptions.ProtocolException(str(e)), sys.exc_info()[2]) + raise exceptions.ProtocolException(str(e)) client_tls = protocol.is_tls_record_magic(d) # 1. check for --ignore @@ -101,7 +97,7 @@ class RootContext(object): is_ascii = ( len(d) == 3 and # expect A-Za-z - all(65 <= x <= 90 or 97 <= x <= 122 for x in six.iterbytes(d)) + all(65 <= x <= 90 or 97 <= x <= 122 for x in d) ) if self.config.options.rawtcp and not is_ascii: return protocol.RawTCPLayer(top_layer) diff --git a/mitmproxy/proxy/server.py b/mitmproxy/proxy/server.py index 182f46024..0fedaa747 100644 --- a/mitmproxy/proxy/server.py +++ b/mitmproxy/proxy/server.py @@ -4,8 +4,6 @@ import socket import sys import traceback -import six - import netlib.exceptions from mitmproxy import exceptions from mitmproxy import models @@ -46,10 +44,8 @@ class ProxyServer(tcp.TCPServer): (config.options.listen_host, config.options.listen_port) ) except socket.error as e: - six.reraise( - exceptions.ServerException, - exceptions.ServerException('Error starting proxy server: ' + repr(e)), - sys.exc_info()[2] + raise exceptions.ServerException( + 'Error starting proxy server: ' + repr(e) ) self.channel = None diff --git a/mitmproxy/stateobject.py b/mitmproxy/stateobject.py index 5e4ae6e3d..a38315c14 100644 --- a/mitmproxy/stateobject.py +++ b/mitmproxy/stateobject.py @@ -1,6 +1,5 @@ from __future__ import absolute_import, print_function, division -import six from typing import Any from typing import List @@ -34,7 +33,7 @@ class StateObject(netlib.basetypes.Serializable): Retrieve object state. """ state = {} - for attr, cls in six.iteritems(self._stateobject_attributes): + for attr, cls in self._stateobject_attributes.items(): val = getattr(self, attr) if val is None: state[attr] = None @@ -51,7 +50,7 @@ class StateObject(netlib.basetypes.Serializable): Load object state from data returned by a get_state call. """ state = state.copy() - for attr, cls in six.iteritems(self._stateobject_attributes): + for attr, cls in self._stateobject_attributes.items(): val = state.pop(attr) if val is None: setattr(self, attr, val) diff --git a/mitmproxy/web/app.py b/mitmproxy/web/app.py index 34969870b..e5a050989 100644 --- a/mitmproxy/web/app.py +++ b/mitmproxy/web/app.py @@ -8,7 +8,6 @@ import re import hashlib -import six import tornado.websocket import tornado.web from io import BytesIO @@ -242,10 +241,10 @@ class FlowHandler(RequestHandler): def put(self, flow_id): flow = self.flow flow.backup() - for a, b in six.iteritems(self.json): + for a, b in self.json.items(): if a == "request": request = flow.request - for k, v in six.iteritems(b): + for k, v in b.items(): if k in ["method", "scheme", "host", "path", "http_version"]: setattr(request, k, str(v)) elif k == "port": @@ -259,7 +258,7 @@ class FlowHandler(RequestHandler): elif a == "response": response = flow.response - for k, v in six.iteritems(b): + for k, v in b.items(): if k == "msg": response.msg = str(v) elif k == "code": @@ -387,7 +386,7 @@ class Settings(RequestHandler): def put(self): update = {} - for k, v in six.iteritems(self.json): + for k, v in self.json.items(): if k == "intercept": self.master.options.intercept = v update[k] = v