Index: Bundles/Python.tmbundle/Support/sitecustomize.py
===================================================================
--- Bundles/Python.tmbundle/Support/sitecustomize.py	(revision 10710)
+++ Bundles/Python.tmbundle/Support/sitecustomize.py	(working copy)
@@ -17,21 +17,14 @@
 
 # now import local sitecustomize
 try:
-  import sitecustomize
-  reload(sitecustomize)
+    import sitecustomize
 except ImportError: pass
 
-import codecs
-
 from os import environ, path, fdopen, popen
 from traceback import extract_tb
 from cgi import escape
-from urllib import quote
+from urllib.parse import quote
 
-# add utf-8 support to stdout/stderr
-sys.stdout = codecs.getwriter('utf-8')(sys.stdout);
-sys.stderr = codecs.getwriter('utf-8')(sys.stderr);
-
 def tm_excepthook(e_type, e, tb):
     """
     Catch unhandled exceptions, and write the traceback in pretty HTML
@@ -42,63 +35,47 @@
     io = fdopen(error_fd, 'wb', 0)
     io.write("<div id='exception_report' class='framed'>\n")
     if isinstance(e_type, str):
-        io.write("<p id='exception'><strong>String Exception:</strong> %s</p>\n" % escape(e_type))
+        io.write("<p id='exception'><strong>String Exception:</strong> {0}</p>\n".format(escape(e_type)))
     elif e_type is SyntaxError:
         # if this is a SyntaxError, then tb == None
         filename, line_number, offset, text = e.filename, e.lineno, e.offset, e.text
         url, display_name = '', 'untitled'
-        io.write("<pre>%s\n%s</pre>\n" % (escape(e.text).rstrip(), "&nbsp;" * (offset-1) + "↑"))
+        io.write("<pre>{0}\n{1}</pre>\n".format(escape(e.text).rstrip(), "&nbsp;" * (offset-1) + "↑"))
         io.write("<blockquote><table border='0' cellspacing='0' cellpadding='0'>\n")
         if filename and path.exists(filename) and "TM_SCRIPT_IS_UNTITLED" not in environ:
-            url = "&url=file://%s" % quote(filename)
+            url = "&url=file://{0}".format(quote(filename))
             display_name = path.basename(filename)
         if filename == '<string>': # exception in exec'd string.
             display_name = 'exec'
-        io.write("<tr><td><a class='near' href='txmt://open?line=%i&column=%i%s'>" %
-                                                    (line_number, offset, url))
-        io.write("line %i, column %i" % (line_number, offset))
-        io.write("</a></td>\n<td>&nbsp;in <strong>%s</strong></td></tr>\n" %
-                                            (escape(display_name)))
+        io.write("<tr><td><a class='near' href='txmt://open?line={0}&column={1}{2}'>".format(line_number, offset, url))
+        io.write("line {0}, column {1}".format(line_number, offset))
+        io.write("</a></td>\n<td>&nbsp;in <strong>{0}</strong></td></tr>\n".format(escape(display_name)))
         io.write("</table></blockquote></div>")
     else:
         message = ""
         if e.args:
-            # For some reason the loop below works, but using either of the lines below
-            # doesn't
-            # message = ", ".join([str(arg) for arg in e.args])
-            # message = ", ".join([unicode(arg) for arg in e.args])
-            message = "%s" % e.args[0]
-            if len(e.args) > 1:
-                for arg in e.args[1:]:
-                    message += ", %s" % arg
-        if isinstance(message, unicode):
-            io.write("<p id='exception'><strong>%s:</strong> %s</p>\n" %
-                                    (e_type.__name__, escape(message).encode("utf-8")))
-        else:
-            io.write("<p id='exception'><strong>%s:</strong> %s</p>\n" %
-                                    (e_type.__name__, escape(message)))
+            message = ", ".join([str(arg) for arg in e.args])
+        io.write("<p id='exception'><strong>{0}:</strong> {1}</p>\n".format(e_type.__name__, escape(message)))
     if tb: # now we write out the stack trace if we have a traceback
         io.write("<blockquote><table border='0' cellspacing='0' cellpadding='0'>\n")
         for trace in extract_tb(tb)[1:]: # skip the first one, to avoid showing pymate's execfile call.
             filename, line_number, function_name, text = trace
             url, display_name = '', 'untitled'
             if filename and path.exists(filename) and "TM_SCRIPT_IS_UNTITLED" not in environ:
-                url = "&url=file://%s" % quote(path.abspath(filename))
+                url = "&url=file://{0}".format(quote(path.abspath(filename)))
                 display_name = path.basename(filename)
-            io.write("<tr><td><a class='near' href='txmt://open?line=%i%s'>" %
-                                                            (line_number, url))
+            io.write("<tr><td><a class='near' href='txmt://open?line={0}{1}'>".format(line_number, url))
             if filename == '<string>': # exception in exec'd string.
                 display_name = 'exec'
             if function_name and function_name != "?":
                 if function_name == '<module>':
                     io.write("<em>module body</em>")
                 else:
-                    io.write("function %s" % escape(function_name))
+                    io.write("function {0}".format(escape(function_name)))
             else:
                 io.write('<em>at file root</em>')
-            io.write("</a> in <strong>%s</strong> at line %i</td></tr>\n" %
-                                                (escape(display_name).encode("utf-8"), line_number))
-            io.write("<tr><td><pre class=\"snippet\">%s</pre></tr></td>" % text)
+            io.write("</a> in <strong>{0}</strong> at line {1}</td></tr>\n".format(escape(display_name), line_number))
+            io.write("<tr><td><pre class=\"snippet\">{0}</pre></tr></td>".format(text))
         io.write("</table></blockquote></div>")
     if e_type is UnicodeDecodeError:
         io.write("<p id='warning'><strong>Warning:</strong> It seems that you are trying to print a plain string containing unicode characters.\
