diff --git a/build/windows_toolchain.py b/build/windows_toolchain.py index 2896bbf7ad..dcb43616a0 100644 --- a/build/windows_toolchain.py +++ b/build/windows_toolchain.py @@ -200,7 +200,7 @@ def format_manifest(manifest): def write_zip(zip_path, prefix=None): """Write toolchain data to a zip file.""" - if isinstance(prefix, unicode): + if isinstance(prefix, str): prefix = prefix.encode('utf-8') with JarWriter(file=zip_path, optimize=False, compress=5) as zip: diff --git a/config/nsinstall.py b/config/nsinstall.py index 4814133703..be5559d6e1 100755 --- a/config/nsinstall.py +++ b/config/nsinstall.py @@ -149,7 +149,7 @@ def _nsinstall_internal(argv): # nsinstall as a native command is always UTF-8 def nsinstall(argv): - return _nsinstall_internal([unicode(arg, "utf-8") for arg in argv]) + return _nsinstall_internal([str(arg, "utf-8") for arg in argv]) if __name__ == '__main__': # sys.argv corrupts characters outside the system code page on Windows @@ -175,8 +175,8 @@ if __name__ == '__main__': else: # For consistency, do it on Unix as well if sys.stdin.encoding is not None: - argv = [unicode(arg, sys.stdin.encoding) for arg in sys.argv] + argv = [str(arg, sys.stdin.encoding) for arg in sys.argv] else: - argv = [unicode(arg) for arg in sys.argv] + argv = [str(arg) for arg in sys.argv] sys.exit(_nsinstall_internal(argv[1:])) diff --git a/config/tests/unit-nsinstall.py b/config/tests/unit-nsinstall.py index 9c05076f5d..a94eb3661a 100644 --- a/config/tests/unit-nsinstall.py +++ b/config/tests/unit-nsinstall.py @@ -28,9 +28,9 @@ class TestNsinstall(unittest.TestCase): # Unicode strings means non-ASCII children can be deleted properly on # Windows if sys.stdin.encoding is None: - tmpdir = unicode(self.tmpdir) + tmpdir = str(self.tmpdir) else: - tmpdir = unicode(self.tmpdir, sys.stdin.encoding) + tmpdir = str(self.tmpdir, sys.stdin.encoding) rmtree(tmpdir) # utility methods for tests @@ -141,9 +141,9 @@ class TestNsinstall(unittest.TestCase): if RUN_NON_ASCII_TESTS: def test_nsinstall_non_ascii(self): "Test that nsinstall handles non-ASCII files" - filename = u"\u2325\u3452\u2415\u5081" + filename = "\u2325\u3452\u2415\u5081" testfile = self.touch(filename) - testdir = self.mkdirs(u"\u4241\u1D04\u1414") + testdir = self.mkdirs("\u4241\u1D04\u1414") self.assertEqual(nsinstall([testfile.encode("utf-8"), testdir.encode("utf-8")]), 0) @@ -152,9 +152,9 @@ class TestNsinstall(unittest.TestCase): def test_nsinstall_non_ascii_subprocess(self): "Test that nsinstall as a subprocess handles non-ASCII files" - filename = u"\u2325\u3452\u2415\u5081" + filename = "\u2325\u3452\u2415\u5081" testfile = self.touch(filename) - testdir = self.mkdirs(u"\u4241\u1D04\u1414") + testdir = self.mkdirs("\u4241\u1D04\u1414") # We don't use subprocess because it can't handle Unicode on # Windows . mozprocess calls # CreateProcessW directly so it's perfect. diff --git a/dom/base/test/file_websocket_wsh.py b/dom/base/test/file_websocket_wsh.py index ef440580ef..34a267a01d 100644 --- a/dom/base/test/file_websocket_wsh.py +++ b/dom/base/test/file_websocket_wsh.py @@ -72,7 +72,7 @@ def web_socket_transfer_data(request): msgutil.send_message(request, resp.decode('utf-8')) elif request.ws_protocol == "test-12": msg = msgutil.receive_message(request) - if msg == u'a\ufffdb': + if msg == 'a\ufffdb': # converted unpaired surrogate in UTF-16 to UTF-8 OK msgutil.send_message(request, "SUCCESS") else: diff --git a/dom/media/test/external/docs/conf.py b/dom/media/test/external/docs/conf.py index 09b15a3fd2..2492bc1995 100644 --- a/dom/media/test/external/docs/conf.py +++ b/dom/media/test/external/docs/conf.py @@ -48,18 +48,18 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'External Media Tests' -copyright = u'2015-2016, Mozilla, Inc.' -author = u'Syd Polk and Maja Frydrychowicz' +project = 'External Media Tests' +copyright = '2015-2016, Mozilla, Inc.' +author = 'Syd Polk and Maja Frydrychowicz' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'0.1' +version = '0.1' # The full version, including alpha/beta/rc tags. -release = u'0.1' +release = '0.1' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -235,8 +235,8 @@ latex_elements = { # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'ExternalMediaTests.tex', u'External Media Tests Documentation', - u'Syd Polk and Maja Frydrychowicz', 'manual'), + (master_doc, 'ExternalMediaTests.tex', 'External Media Tests Documentation', + 'Syd Polk and Maja Frydrychowicz', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -265,7 +265,7 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'externalmediatests', u'External Media Tests Documentation', + (master_doc, 'externalmediatests', 'External Media Tests Documentation', [author], 1) ] @@ -279,7 +279,7 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'ExternalMediaTests', u'External Media Tests Documentation', + (master_doc, 'ExternalMediaTests', 'External Media Tests Documentation', author, 'ExternalMediaTests', 'One line description of project.', 'Miscellaneous'), ] diff --git a/dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py b/dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py index 4adb19c455..64ef786d8b 100644 --- a/dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py +++ b/dom/media/test/external/external_media_tests/media_utils/video_puppeteer.py @@ -408,7 +408,7 @@ class VideoPuppeteer(object): for field in self._last_seen_video_state._fields: # For compatibility with different test environments we force ascii field_ascii = ( - unicode(getattr(self._last_seen_video_state, field)) + str(getattr(self._last_seen_video_state, field)) .encode('ascii','replace')) messages += [('\t{}: {}'.format(field, field_ascii))] messages += '}' diff --git a/dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py b/dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py index de657b2709..b92e49078a 100644 --- a/dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py +++ b/dom/media/test/external/external_media_tests/media_utils/youtube_puppeteer.py @@ -489,7 +489,7 @@ class YouTubePuppeteer(VideoPuppeteer): for field in self._last_seen_player_state._fields: # For compatibility with different test environments we force ascii field_ascii = ( - unicode(getattr(self._last_seen_player_state, field)) + str(getattr(self._last_seen_player_state, field)) .encode('ascii', 'replace')) messages += [('\t{}: {}'.format(field, field_ascii))] messages += '}' diff --git a/gfx/harfbuzz/src/gen-tag-table.py b/gfx/harfbuzz/src/gen-tag-table.py index 24f7fc6c2a..f57f79772a 100644 --- a/gfx/harfbuzz/src/gen-tag-table.py +++ b/gfx/harfbuzz/src/gen-tag-table.py @@ -918,7 +918,7 @@ def get_variant_set (name): Returns: A set of normalized language names. """ - return set (unicodedata.normalize ('NFD', n.replace ('\u2019', "'")) + return set (unicodedata.normalize ('NFD', n.replace ('\\u2019', "'")) .encode ('ASCII', 'ignore') .strip () for n in re.split ('[\n(),]', name) if n) diff --git a/js/src/builtin/intl/make_intl_data.py b/js/src/builtin/intl/make_intl_data.py index 51fd3aaee5..2081eda1f9 100644 --- a/js/src/builtin/intl/make_intl_data.py +++ b/js/src/builtin/intl/make_intl_data.py @@ -50,9 +50,9 @@ def writeMappingHeader(println, description, source, url): if type(description) is not list: description = [description] for desc in description: - println(u"// {0}".format(desc)) - println(u"// Derived from {0}.".format(source)) - println(u"// {0}".format(url)) + println("// {0}".format(desc)) + println("// Derived from {0}.".format(source)) + println("// {0}".format(url)) def writeMappingsVar(println, mapping, name, description, source, url): """ Writes a variable definition with a mapping table. @@ -61,12 +61,12 @@ def writeMappingsVar(println, mapping, name, description, source, url): function with the given variable name and a comment with description, source, and URL. """ - println(u"") + println("") writeMappingHeader(println, description, source, url) - println(u"var {0} = {{".format(name)) + println("var {0} = {{".format(name)) for (key, value) in sorted(list(mapping.items()), key=itemgetter(0)): - println(u' "{0}": "{1}",'.format(key, value)) - println(u"};") + println(' "{0}": "{1}",'.format(key, value)) + println("};") def writeMappingsBinarySearch(println, fn_name, type_name, name, validate_fn, validate_case_fn, mappings, tag_maxlength, description, source, url): @@ -75,9 +75,9 @@ def writeMappingsBinarySearch(println, fn_name, type_name, name, validate_fn, va Uses the contents of |mapping|, which can either be a dictionary or set, to emit a mapping function to find subtag replacements. """ - println(u"") + println("") writeMappingHeader(println, description, source, url) - println(u""" + println(""" bool js::intl::LanguageTag::{0}({1} {2}) {{ MOZ_ASSERT({3}({2}.span())); MOZ_ASSERT({4}({2}.span())); @@ -85,18 +85,18 @@ bool js::intl::LanguageTag::{0}({1} {2}) {{ def write_array(subtags, name, length, fixed): if fixed: - println(u" static const char {}[{}][{}] = {{".format(name, len(subtags), + println(" static const char {}[{}][{}] = {{".format(name, len(subtags), length + 1)) else: - println(u" static const char* {}[{}] = {{".format(name, len(subtags))) + println(" static const char* {}[{}] = {{".format(name, len(subtags))) # Group in pairs of ten to not exceed the 80 line column limit. for entries in grouper(subtags, 10): - entries = (u"\"{}\"".format(tag).rjust(length + 2) + entries = ("\"{}\"".format(tag).rjust(length + 2) for tag in entries if tag is not None) - println(u" {},".format(u", ".join(entries))) + println(" {},".format(", ".join(entries))) - println(u" };") + println(" };") trailing_return = True @@ -107,12 +107,12 @@ bool js::intl::LanguageTag::{0}({1} {2}) {{ for (length, subtags) in groupby(sorted(mappings_keys, key=len), len): # Omit the length check if the current length is the maximum length. if length != tag_maxlength: - println(u""" + println(""" if ({}.length() == {}) {{ """.format(name, length).rstrip("\n")) else: trailing_return = False - println(u""" + println(""" { """.rstrip("\n")) @@ -120,12 +120,12 @@ bool js::intl::LanguageTag::{0}({1} {2}) {{ subtags = sorted(subtags) def equals(subtag): - return u"""{}.equalTo("{}")""".format(name, subtag) + return """{}.equalTo("{}")""".format(name, subtag) # Don't emit a binary search for short lists. if len(subtags) == 1: if type(mappings) == dict: - println(u""" + println(""" if ({}) {{ {}.set("{}"); return true; @@ -133,35 +133,35 @@ bool js::intl::LanguageTag::{0}({1} {2}) {{ return false; """.format(equals(subtags[0]), name, mappings[subtags[0]]).strip("\n")) else: - println(u""" + println(""" return {}; """.format(equals(subtags[0])).strip("\n")) elif len(subtags) <= 4: if type(mappings) == dict: for subtag in subtags: - println(u""" + println(""" if ({}) {{ {}.set("{}"); return true; }} """.format(equals(subtag), name, mappings[subtag]).strip("\n")) - println(u""" + println(""" return false; """.strip("\n")) else: cond = (equals(subtag) for subtag in subtags) - cond = (u" ||\n" + u" " * (4 + len("return "))).join(cond) - println(u""" + cond = (" ||\n" + " " * (4 + len("return "))).join(cond) + println(""" return {}; """.format(cond).strip("\n")) else: write_array(subtags, name + "s", length, True) if type(mappings) == dict: - write_array([mappings[k] for k in subtags], u"aliases", length, False) + write_array([mappings[k] for k in subtags], "aliases", length, False) - println(u""" + println(""" if (const char* replacement = SearchReplacement({0}s, aliases, {0})) {{ {0}.set(mozilla::MakeCStringSpan(replacement)); return true; @@ -169,27 +169,27 @@ bool js::intl::LanguageTag::{0}({1} {2}) {{ return false; """.format(name).rstrip()) else: - println(u""" + println(""" return HasReplacement({0}s, {0}); """.format(name).rstrip()) - println(u""" + println(""" } """.strip("\n")) if trailing_return: - println(u""" + println(""" return false;""") - println(u""" + println(""" }""".lstrip("\n")) def writeComplexLanguageTagMappings(println, complex_language_mappings, description, source, url): - println(u"") + println("") writeMappingHeader(println, description, source, url) - println(u""" + println(""" void js::intl::LanguageTag::performComplexLanguageMappings() { MOZ_ASSERT(IsStructurallyValidLanguageTag(language().span())); MOZ_ASSERT(IsCanonicallyCasedLanguageTag(language().span())); @@ -214,42 +214,42 @@ void js::intl::LanguageTag::performComplexLanguageMappings() { if deprecated_language in language_aliases[key]: continue - if_kind = u"if" if first_language else u"else if" + if_kind = "if" if first_language else "else if" first_language = False - cond = (u"language().equalTo(\"{}\")".format(lang) + cond = ("language().equalTo(\"{}\")".format(lang) for lang in [deprecated_language] + language_aliases[key]) - cond = (u" ||\n" + u" " * (2 + len(if_kind) + 2)).join(cond) + cond = (" ||\n" + " " * (2 + len(if_kind) + 2)).join(cond) - println(u""" + println(""" {} ({}) {{""".format(if_kind, cond).strip("\n")) - println(u""" + println(""" setLanguage("{}");""".format(language).strip("\n")) if script is not None: - println(u""" + println(""" if (script().missing()) {{ setScript("{}"); }}""".format(script).strip("\n")) if region is not None: - println(u""" + println(""" if (region().missing()) {{ setRegion("{}"); }}""".format(region).strip("\n")) - println(u""" + println(""" }""".strip("\n")) - println(u""" + println(""" } """.strip("\n")) def writeComplexRegionTagMappings(println, complex_region_mappings, description, source, url): - println(u"") + println("") writeMappingHeader(println, description, source, url) - println(u""" + println(""" void js::intl::LanguageTag::performComplexRegionMappings() { MOZ_ASSERT(IsStructurallyValidLanguageTag(language().span())); MOZ_ASSERT(IsCanonicallyCasedLanguageTag(language().span())); @@ -281,14 +281,14 @@ void js::intl::LanguageTag::performComplexRegionMappings() { if deprecated_region in region_aliases[key]: continue - if_kind = u"if" if first_region else u"else if" + if_kind = "if" if first_region else "else if" first_region = False - cond = (u"region().equalTo(\"{}\")".format(region) + cond = ("region().equalTo(\"{}\")".format(region) for region in [deprecated_region] + region_aliases[key]) - cond = (u" ||\n" + u" " * (2 + len(if_kind) + 2)).join(cond) + cond = (" ||\n" + " " * (2 + len(if_kind) + 2)).join(cond) - println(u""" + println(""" {} ({}) {{""".format(if_kind, cond).strip("\n")) replacement_regions = sorted({region for (_, _, region) in non_default_replacements}) @@ -301,31 +301,31 @@ void js::intl::LanguageTag::performComplexRegionMappings() { ) if region == replacement_region) - if_kind = u"if" if first_case else u"else if" + if_kind = "if" if first_case else "else if" first_case = False def compare_tags(language, script): if script is None: - return u"language().equalTo(\"{}\")".format(language) - return u"(language().equalTo(\"{}\") && script().equalTo(\"{}\"))".format( + return "language().equalTo(\"{}\")".format(language) + return "(language().equalTo(\"{}\") && script().equalTo(\"{}\"))".format( language, script) cond = (compare_tags(language, script) for (language, script) in replacement_language_script) - cond = (u" ||\n" + u" " * (4 + len(if_kind) + 2)).join(cond) + cond = (" ||\n" + " " * (4 + len(if_kind) + 2)).join(cond) - println(u""" + println(""" {} ({}) {{ setRegion("{}"); }}""".format(if_kind, cond, replacement_region).rstrip().strip("\n")) - println(u""" + println(""" else {{ setRegion("{}"); }} }}""".format(default).rstrip().strip("\n")) - println(u""" + println(""" } """.strip("\n")) @@ -333,7 +333,7 @@ void js::intl::LanguageTag::performComplexRegionMappings() { def writeVariantTagMappings(println, variant_mappings, description, source, url): """ Writes a function definition that maps variant subtags. """ - println(u""" + println(""" static const char* ToCharPointer(const char* str) { return str; } @@ -348,7 +348,7 @@ static bool IsLessThan(const T& a, const U& b) { } """) writeMappingHeader(println, description, source, url) - println(u""" + println(""" bool js::intl::LanguageTag::performVariantMappings(JSContext* cx) { // The variant subtags need to be sorted for binary search. MOZ_ASSERT(std::is_sorted(variants_.begin(), variants_.end(), @@ -382,35 +382,35 @@ bool js::intl::LanguageTag::performVariantMappings(JSContext* cx) { for (deprecated_variant, (type, replacement)) in ( sorted(list(variant_mappings.items()), key=itemgetter(0)) ): - if_kind = u"if" if first_variant else u"else if" + if_kind = "if" if first_variant else "else if" first_variant = False - println(u""" + println(""" {} (strcmp(variant.get(), "{}") == 0) {{ variants_.erase(variants_.begin() + i); """.format(if_kind, deprecated_variant).strip("\n")) if type == "language": - println(u""" + println(""" setLanguage("{}"); """.format(replacement).strip("\n")) elif type == "region": - println(u""" + println(""" setRegion("{}"); """.format(replacement).strip("\n")) else: assert type == "variant" - println(u""" + println(""" if (!insertVariantSortedIfNotPresent("{}")) {{ return false; }} """.format(replacement).strip("\n")) - println(u""" + println(""" } """.strip("\n")) - println(u""" + println(""" else { i++; } @@ -423,9 +423,9 @@ bool js::intl::LanguageTag::performVariantMappings(JSContext* cx) { def writeGrandfatheredMappingsFunction(println, grandfathered_mappings, description, source, url): """ Writes a function definition that maps grandfathered language tags. """ - println(u"") + println("") writeMappingHeader(println, description, source, url) - println(u"""\ + println("""\ bool js::intl::LanguageTag::updateGrandfatheredMappings(JSContext* cx) { // We're mapping regular grandfathered tags to non-grandfathered form here. // Other tags remain unchanged. @@ -526,11 +526,11 @@ bool js::intl::LanguageTag::updateGrandfatheredMappings(JSContext* cx) { modern_variants = modern_match.group("variants") modern_privateuse = modern_match.group("privateuse") - println(u""" + println(""" // {} -> {} """.format(tag, modern).rstrip()) - println(u""" + println(""" {}if (language().equalTo("{}") && variantEqualTo("{}")) {{ """.format("" if is_first else "else ", tag_language, @@ -538,29 +538,29 @@ bool js::intl::LanguageTag::updateGrandfatheredMappings(JSContext* cx) { is_first = False - println(u""" + println(""" setLanguage("{}"); """.format(modern_language).rstrip().strip("\n")) if modern_script is not None: - println(u""" + println(""" setScript("{}"); """.format(modern_script).rstrip().strip("\n")) if modern_region is not None: - println(u""" + println(""" setRegion("{}"); """.format(modern_region).rstrip().strip("\n")) assert modern_variants is None, ( "all regular grandfathered tags' modern forms do not contain variant subtags") - println(u""" + println(""" clearVariants(); """.rstrip().strip("\n")) if modern_privateuse is not None: - println(u""" + println(""" auto privateuse = DuplicateString(cx, "{}"); if (!privateuse) {{ return false; @@ -568,11 +568,11 @@ bool js::intl::LanguageTag::updateGrandfatheredMappings(JSContext* cx) { setPrivateuse(std::move(privateuse)); """.format(modern_privateuse).rstrip().rstrip("\n")) - println(u""" + println(""" return true; }""".rstrip().strip("\n")) - println(u""" + println(""" return true; }""") @@ -1022,10 +1022,10 @@ def writeCLDRLanguageTagData(println, data, url): """ Writes the language tag data to the Intl data file. """ println(generatedFileWarning) - println(u"// Version: CLDR-{}".format(data["version"])) - println(u"// URL: {}".format(url)) + println("// Version: CLDR-{}".format(data["version"])) + println("// URL: {}".format(url)) - println(u""" + println(""" #include "mozilla/Assertions.h" #include "mozilla/Span.h" #include "mozilla/TextUtils.h" @@ -1126,7 +1126,7 @@ static bool IsCanonicallyCasedTransformType(mozilla::Span type) { #endif """.rstrip()) - source = u"CLDR Supplemental Data, version {}".format(data["version"]) + source = "CLDR Supplemental Data, version {}".format(data["version"]) grandfathered_mappings = data["grandfatheredMappings"] language_mappings = data["languageMappings"] complex_language_mappings = data["complexLanguageMappings"] @@ -1188,7 +1188,7 @@ def writeCLDRLanguageTagLikelySubtagsTest(println, data, url): println(generatedFileWarning) - source = u"CLDR Supplemental Data, version {}".format(data["version"]) + source = "CLDR Supplemental Data, version {}".format(data["version"]) language_mappings = data["languageMappings"] complex_language_mappings = data["complexLanguageMappings"] region_mappings = data["regionMappings"] @@ -1295,17 +1295,17 @@ def writeCLDRLanguageTagLikelySubtagsTest(println, data, url): writeMappingsVar(println, {bcp47(k): bcp47(v) for (k, v) in list(minimized.items())}, "minLikelySubtags", "Extracted from likelySubtags.xml.", source, url) - println(u""" + println(""" for (let [tag, maximal] of Object.entries(maxLikelySubtags)) { assertEq(new Intl.Locale(tag).maximize().toString(), maximal); }""") - println(u""" + println(""" for (let [tag, minimal] of Object.entries(minLikelySubtags)) { assertEq(new Intl.Locale(tag).minimize().toString(), minimal); }""") - println(u""" + println(""" if (typeof reportCompare === "function") reportCompare(0, 0);""") @@ -1375,7 +1375,7 @@ def updateCLDRLangTags(args): with io.open(test_file, mode="w", encoding="utf-8", newline="") as f: println = partial(print, file=f) - println(u"// |reftest| skip-if(!this.hasOwnProperty('Intl'))") + println("// |reftest| skip-if(!this.hasOwnProperty('Intl'))") writeCLDRLanguageTagLikelySubtagsTest(println, data, url) @@ -1838,8 +1838,8 @@ def findIncorrectICULinks(ianaZones, ianaLinks, icuZones, icuLinks): return sorted(result, key=itemgetter(0)) -generatedFileWarning = u"// Generated by make_intl_data.py. DO NOT EDIT." -tzdataVersionComment = u"// tzdata version = {0}" +generatedFileWarning = "// Generated by make_intl_data.py. DO NOT EDIT." +tzdataVersionComment = "// tzdata version = {0}" def processTimeZones(tzdataDir, icuDir, icuTzDir, version, ignoreBackzone, ignoreFactory, out): """ Read the time zone info and create a new time zone cpp file. """ @@ -1870,51 +1870,51 @@ def processTimeZones(tzdataDir, icuDir, icuTzDir, version, ignoreBackzone, ignor println(generatedFileWarning) println(tzdataVersionComment.format(version)) - println(u"") + println("") - println(u"#ifndef builtin_intl_TimeZoneDataGenerated_h") - println(u"#define builtin_intl_TimeZoneDataGenerated_h") - println(u"") + println("#ifndef builtin_intl_TimeZoneDataGenerated_h") + println("#define builtin_intl_TimeZoneDataGenerated_h") + println("") - println(u"namespace js {") - println(u"namespace timezone {") - println(u"") + println("namespace js {") + println("namespace timezone {") + println("") - println(u"// Format:") - println(u'// "ZoneName" // ICU-Name [time zone file]') - println(u"const char* const ianaZonesTreatedAsLinksByICU[] = {") + println("// Format:") + println('// "ZoneName" // ICU-Name [time zone file]') + println("const char* const ianaZonesTreatedAsLinksByICU[] = {") for (zone, icuZone) in incorrectZones: - println(u' "%s", // %s [%s]' % (zone, icuZone, zone.filename)) - println(u"};") - println(u"") + println(' "%s", // %s [%s]' % (zone, icuZone, zone.filename)) + println("};") + println("") - println(u"// Format:") - println(u'// "LinkName", "Target" // ICU-Target [time zone file]') - println(u"struct LinkAndTarget") - println(u"{") - println(u" const char* const link;") - println(u" const char* const target;") - println(u"};") - println(u"") - println(u"const LinkAndTarget ianaLinksCanonicalizedDifferentlyByICU[] = {") + println("// Format:") + println('// "LinkName", "Target" // ICU-Target [time zone file]') + println("struct LinkAndTarget") + println("{") + println(" const char* const link;") + println(" const char* const target;") + println("};") + println("") + println("const LinkAndTarget ianaLinksCanonicalizedDifferentlyByICU[] = {") for (zone, target, icuTarget) in incorrectLinks: - println(u' { "%s", "%s" }, // %s [%s]' % (zone, target, icuTarget, zone.filename)) - println(u"};") - println(u"") + println(' { "%s", "%s" }, // %s [%s]' % (zone, target, icuTarget, zone.filename)) + println("};") + println("") - println(u"// Legacy ICU time zones, these are not valid IANA time zone names. We also") - println(u"// disallow the old and deprecated System V time zones.") - println(u"// https://ssl.icu-project.org/repos/icu/trunk/icu4c/source/tools/tzcode/icuzones") - println(u"const char* const legacyICUTimeZones[] = {") + println("// Legacy ICU time zones, these are not valid IANA time zone names. We also") + println("// disallow the old and deprecated System V time zones.") + println("// https://ssl.icu-project.org/repos/icu/trunk/icu4c/source/tools/tzcode/icuzones") + println("const char* const legacyICUTimeZones[] = {") for zone in chain(sorted(legacyLinks.keys()), sorted(legacyZones)): - println(u' "%s",' % zone) - println(u"};") - println(u"") + println(' "%s",' % zone) + println("};") + println("") - println(u"} // namespace timezone") - println(u"} // namespace js") - println(u"") - println(u"#endif /* builtin_intl_TimeZoneDataGenerated_h */") + println("} // namespace timezone") + println("} // namespace js") + println("") + println("#endif /* builtin_intl_TimeZoneDataGenerated_h */") def updateBackzoneLinks(tzdataDir, links): (backzoneZones, backzoneLinks) = readIANAFiles(tzdataDir, ["backzone"]) @@ -1935,11 +1935,11 @@ def generateTzDataLinkTestContent(testDir, version, fileName, description, links with io.open(os.path.join(testDir, fileName), mode="w", encoding="utf-8", newline="") as f: println = partial(print, file=f) - println(u'// |reftest| skip-if(!this.hasOwnProperty("Intl"))') - println(u"") + println('// |reftest| skip-if(!this.hasOwnProperty("Intl"))') + println("") println(generatedFileWarning) println(tzdataVersionComment.format(version)) - println(u""" + println(""" const tzMapper = [ x => x, x => x.toUpperCase(), @@ -1948,12 +1948,12 @@ const tzMapper = [ """) println(description) - println(u"const links = {") + println("const links = {") for (zone, target) in sorted(links, key=itemgetter(0)): - println(u' "%s": "%s",' % (zone, target)) - println(u"};") + println(' "%s": "%s",' % (zone, target)) + println("};") - println(u""" + println(""" for (let [linkName, target] of Object.entries(links)) { if (target === "Etc/UTC" || target === "Etc/GMT") target = "UTC"; @@ -1965,7 +1965,7 @@ for (let [linkName, target] of Object.entries(links)) { } } """) - println(u""" + println(""" if (typeof reportCompare === "function") reportCompare(0, 0, "ok"); """) @@ -1980,7 +1980,7 @@ def generateTzDataTestBackwardLinks(tzdataDir, version, ignoreBackzone, testDir) generateTzDataLinkTestContent( testDir, version, "timeZone_backward_links.js", - u"// Link names derived from IANA Time Zone Database, backward file.", + "// Link names derived from IANA Time Zone Database, backward file.", iter(links.items()) ) @@ -1994,7 +1994,7 @@ def generateTzDataTestNotBackwardLinks(tzdataDir, version, ignoreBackzone, testD generateTzDataLinkTestContent( testDir, version, "timeZone_notbackward_links.js", - u"// Link names derived from IANA Time Zone Database, excluding backward file.", + "// Link names derived from IANA Time Zone Database, excluding backward file.", iter(links.items()) ) @@ -2007,14 +2007,14 @@ def generateTzDataTestBackzone(tzdataDir, version, ignoreBackzone, testDir): (backzones, backlinks) = readIANAFiles(tzdataDir, bkfiles) if not ignoreBackzone: - comment=u"""\ + comment="""\ // This file was generated with historical, pre-1970 backzone information // respected. Therefore, every zone key listed below is its own Zone, not // a Link to a modern-day target as IANA ignoring backzones would say. """ else: - comment=u"""\ + comment="""\ // This file was generated while ignoring historical, pre-1970 backzone // information. Therefore, every zone key listed below is part of a Link // whose target is the corresponding value. @@ -2024,7 +2024,7 @@ def generateTzDataTestBackzone(tzdataDir, version, ignoreBackzone, testDir): generateTzDataLinkTestContent( testDir, version, "timeZone_backzone.js", - comment + u"// Backzone zones derived from IANA Time Zone Database.", + comment + "// Backzone zones derived from IANA Time Zone Database.", ((zone, zone if not ignoreBackzone else links[zone]) for zone in backzones if zone in links) ) @@ -2037,7 +2037,7 @@ def generateTzDataTestBackzoneLinks(tzdataDir, version, ignoreBackzone, testDir) (backzones, backlinks) = readIANAFiles(tzdataDir, bkfiles) if not ignoreBackzone: - comment=u"""\ + comment="""\ // This file was generated with historical, pre-1970 backzone information // respected. Therefore, every zone key listed below points to a target // in the backzone file and not to its modern-day target as IANA ignoring @@ -2045,7 +2045,7 @@ def generateTzDataTestBackzoneLinks(tzdataDir, version, ignoreBackzone, testDir) """ else: - comment=u"""\ + comment="""\ // This file was generated while ignoring historical, pre-1970 backzone // information. Therefore, every zone key listed below is part of a Link // whose target is the corresponding value ignoring any backzone entries. @@ -2055,7 +2055,7 @@ def generateTzDataTestBackzoneLinks(tzdataDir, version, ignoreBackzone, testDir) generateTzDataLinkTestContent( testDir, version, "timeZone_backzone_links.js", - comment + u"// Backzone links derived from IANA Time Zone Database.", + comment + "// Backzone links derived from IANA Time Zone Database.", ((zone, target if not ignoreBackzone else links[zone]) for (zone, target) in backlinks.items()) ) @@ -2125,7 +2125,7 @@ def updateTzdata(topsrcdir, args): updateFrom(tzDir) def writeUnicodeExtensionsMappings(println, mapping, extension): - println(u""" + println(""" template static inline bool Is{0}Key( mozilla::Span key, const char (&str)[Length]) {{ @@ -2150,7 +2150,7 @@ static inline bool Is{0}Type( for replacements in list(mapping.values())) if needs_binary_search: - println(u""" + println(""" static int32_t Compare{0}Type(const char* a, mozilla::Span b) {{ MOZ_ASSERT(!std::char_traits::find(b.data(), b.size(), '\\0'), "unexpected null-character in string"); @@ -2186,7 +2186,7 @@ static inline const char* Search{0}Replacement( }} """.format(extension).rstrip("\n")) - println(u""" + println(""" /** * Mapping from deprecated BCP 47 {0} extension types to their preferred * values. @@ -2209,14 +2209,14 @@ const char* js::intl::LanguageTag::replace{0}ExtensionType( def write_array(subtags, name, length): max_entries = (80 - len(" ")) // (length + len('"", ')) - println(u" static const char* {}[{}] = {{".format(name, len(subtags))) + println(" static const char* {}[{}] = {{".format(name, len(subtags))) for entries in grouper(subtags, max_entries): - entries = (u"\"{}\"".format(tag).rjust(length + 2) + entries = ("\"{}\"".format(tag).rjust(length + 2) for tag in entries if tag is not None) - println(u" {},".format(u", ".join(entries))) + println(" {},".format(", ".join(entries))) - println(u" };") + println(" };") # Merge duplicate keys. key_aliases = {} @@ -2233,12 +2233,12 @@ const char* js::intl::LanguageTag::replace{0}ExtensionType( if key in key_aliases[hash_key]: continue - cond = (u"Is{}Key(key, \"{}\")".format(extension, k) + cond = ("Is{}Key(key, \"{}\")".format(extension, k) for k in [key] + key_aliases[hash_key]) - if_kind = u"if" if first_key else u"else if" - cond = (u" ||\n" + u" " * (2 + len(if_kind) + 2)).join(cond) - println(u""" + if_kind = "if" if first_key else "else if" + cond = (" ||\n" + " " * (2 + len(if_kind) + 2)).join(cond) + println(""" {} ({}) {{""".format(if_kind, cond).strip("\n")) first_key = False @@ -2251,20 +2251,20 @@ const char* js::intl::LanguageTag::replace{0}ExtensionType( write_array(types, "types", max_len) write_array(preferred, "aliases", max_len) - println(u""" + println(""" return Search{}Replacement(types, aliases, type); """.format(extension).strip("\n")) else: for (type, replacement) in replacements: - println(u""" + println(""" if (Is{}Type(type, "{}")) {{ return "{}"; }}""".format(extension, type, replacement).strip("\n")) - println(u""" + println(""" }""".lstrip("\n")) - println(u""" + println(""" return nullptr; } """.strip("\n")) diff --git a/js/src/gdb/mozilla/JSString.py b/js/src/gdb/mozilla/JSString.py index 99d5ce987d..98547f4abe 100644 --- a/js/src/gdb/mozilla/JSString.py +++ b/js/src/gdb/mozilla/JSString.py @@ -7,7 +7,7 @@ from mozilla.prettyprinters import pretty_printer, ptr_pretty_printer try: chr(10000) # UPPER RIGHT PENCIL except ValueError as exc: # yuck, we are in Python 2.x, so chr() is 8-bit - chr = unichr # replace with teh unicodes + chr = chr # replace with teh unicodes # Forget any printers from previous loads of this module. mozilla.prettyprinters.clear_module_printers(__name__) @@ -61,7 +61,7 @@ class JSStringPtr(Common): yield chars[i] def to_string(self): - s = u'' + s = '' for c in self.chars(): s += chr(c) return s diff --git a/js/src/vm/make_unicode.py b/js/src/vm/make_unicode.py index 738fbc3180..70a661a885 100755 --- a/js/src/vm/make_unicode.py +++ b/js/src/vm/make_unicode.py @@ -46,23 +46,23 @@ whitespace = [ 0x9, # CHARACTER TABULATION 0xb, # LINE TABULATION 0xc, # FORM FEED - ord(u'\N{SPACE}'), - ord(u'\N{NO-BREAK SPACE}'), - ord(u'\N{ZERO WIDTH NO-BREAK SPACE}'), # also BOM + ord('\N{SPACE}'), + ord('\N{NO-BREAK SPACE}'), + ord('\N{ZERO WIDTH NO-BREAK SPACE}'), # also BOM ] # §11.3 Line Terminators line_terminator = [ 0xa, # LINE FEED 0xd, # CARRIAGE RETURN - ord(u'\N{LINE SEPARATOR}'), - ord(u'\N{PARAGRAPH SEPARATOR}'), + ord('\N{LINE SEPARATOR}'), + ord('\N{PARAGRAPH SEPARATOR}'), ] # These are also part of IdentifierPart §11.6 Names and Keywords compatibility_identifier_part = [ - ord(u'\N{ZERO WIDTH NON-JOINER}'), - ord(u'\N{ZERO WIDTH JOINER}'), + ord('\N{ZERO WIDTH NON-JOINER}'), + ord('\N{ZERO WIDTH JOINER}'), ] FLAG_SPACE = 1 << 0 @@ -825,7 +825,7 @@ def write_special_casing_methods(unconditional_toupper, codepoint_table, println def make_bmp_mapping_test(version, codepoint_table, unconditional_tolower, unconditional_toupper): def unicodeEsc(n): - return '\u{:04X}'.format(n) + return '\\u{:04X}'.format(n) file_name = '../tests/ecma_5/String/string-upper-lower-mapping.js' with io.open(file_name, mode='wb') as output: diff --git a/media/libaom/src/test/gviz_api.py b/media/libaom/src/test/gviz_api.py index b89b526fd9..995487ea43 100755 --- a/media/libaom/src/test/gviz_api.py +++ b/media/libaom/src/test/gviz_api.py @@ -231,7 +231,7 @@ class DataTable(object): raise DataTableException("Wrong type %s when expected number" % t_value) elif value_type == "string": - if isinstance(value, unicode): + if isinstance(value, str): return value else: return str(value).decode("utf-8") @@ -296,7 +296,7 @@ class DataTable(object): datetime.date, datetime.time)): return str(value) - elif isinstance(value, unicode): + elif isinstance(value, str): return value elif isinstance(value, bool): return str(value).lower() diff --git a/media/libaom/src/tools/cpplint.py b/media/libaom/src/tools/cpplint.py index aba40709e3..95e0d57f33 100755 --- a/media/libaom/src/tools/cpplint.py +++ b/media/libaom/src/tools/cpplint.py @@ -2023,7 +2023,7 @@ def CheckForBadCharacters(filename, lines, error): error: The function to call with any errors found. """ for linenum, line in enumerate(lines): - if u'\ufffd' in line: + if '\ufffd' in line: error(filename, linenum, 'readability/utf8', 5, 'Line contains invalid UTF-8 (or Unicode replacement character).') if '\0' in line: @@ -4286,7 +4286,7 @@ def GetLineWidth(line): The width of the line in column positions, accounting for Unicode combining characters and wide characters. """ - if isinstance(line, unicode): + if isinstance(line, str): width = 0 for uc in unicodedata.normalize('NFC', line): if unicodedata.east_asian_width(uc) in ('W', 'F'): diff --git a/media/libvpx/libvpx/tools/cpplint.py b/media/libvpx/libvpx/tools/cpplint.py index aba40709e3..95e0d57f33 100755 --- a/media/libvpx/libvpx/tools/cpplint.py +++ b/media/libvpx/libvpx/tools/cpplint.py @@ -2023,7 +2023,7 @@ def CheckForBadCharacters(filename, lines, error): error: The function to call with any errors found. """ for linenum, line in enumerate(lines): - if u'\ufffd' in line: + if '\ufffd' in line: error(filename, linenum, 'readability/utf8', 5, 'Line contains invalid UTF-8 (or Unicode replacement character).') if '\0' in line: @@ -4286,7 +4286,7 @@ def GetLineWidth(line): The width of the line in column positions, accounting for Unicode combining characters and wide characters. """ - if isinstance(line, unicode): + if isinstance(line, str): width = 0 for uc in unicodedata.normalize('NFC', line): if unicodedata.east_asian_width(uc) in ('W', 'F'): diff --git a/media/webrtc/trunk/tools/gyp/pylib/gyp/simple_copy.py b/media/webrtc/trunk/tools/gyp/pylib/gyp/simple_copy.py index 916520efa5..571baa4193 100644 --- a/media/webrtc/trunk/tools/gyp/pylib/gyp/simple_copy.py +++ b/media/webrtc/trunk/tools/gyp/pylib/gyp/simple_copy.py @@ -29,7 +29,7 @@ def _deepcopy_atomic(x): return x for x in (type(None), int, int, float, - bool, str, unicode, type): + bool, str, str, type): d[x] = _deepcopy_atomic def _deepcopy_list(x): diff --git a/media/webrtc/trunk/tools/gyp/pylib/gyp/xcodeproj_file.py b/media/webrtc/trunk/tools/gyp/pylib/gyp/xcodeproj_file.py index a99f95e1d2..6de8d60137 100644 --- a/media/webrtc/trunk/tools/gyp/pylib/gyp/xcodeproj_file.py +++ b/media/webrtc/trunk/tools/gyp/pylib/gyp/xcodeproj_file.py @@ -324,7 +324,7 @@ class XCObject(object): that._properties[key] = new_value else: that._properties[key] = value - elif isinstance(value, str) or isinstance(value, unicode) or \ + elif isinstance(value, str) or isinstance(value, str) or \ isinstance(value, int): that._properties[key] = value elif isinstance(value, list): @@ -603,7 +603,7 @@ class XCObject(object): comment = value.Comment() elif isinstance(value, str): printable += self._EncodeString(value) - elif isinstance(value, unicode): + elif isinstance(value, str): printable += self._EncodeString(value.encode('utf-8')) elif isinstance(value, int): printable += str(value) @@ -766,7 +766,7 @@ class XCObject(object): ' must be list, not ' + value.__class__.__name__) for item in value: if not isinstance(item, property_type) and \ - not (item.__class__ == unicode and property_type == str): + not (item.__class__ == str and property_type == str): # Accept unicode where str is specified. str is treated as # UTF-8-encoded. raise TypeError( @@ -774,7 +774,7 @@ class XCObject(object): ' must be ' + property_type.__name__ + ', not ' + \ item.__class__.__name__) elif not isinstance(value, property_type) and \ - not (value.__class__ == unicode and property_type == str): + not (value.__class__ == str and property_type == str): # Accept unicode where str is specified. str is treated as # UTF-8-encoded. raise TypeError( @@ -788,7 +788,7 @@ class XCObject(object): self._properties[property] = value.Copy() else: self._properties[property] = value - elif isinstance(value, str) or isinstance(value, unicode) or \ + elif isinstance(value, str) or isinstance(value, str) or \ isinstance(value, int): self._properties[property] = value elif isinstance(value, list): diff --git a/media/webrtc/trunk/tools/gyp/test/lib/TestCmd.py b/media/webrtc/trunk/tools/gyp/test/lib/TestCmd.py index 87ce536f83..d60783f539 100644 --- a/media/webrtc/trunk/tools/gyp/test/lib/TestCmd.py +++ b/media/webrtc/trunk/tools/gyp/test/lib/TestCmd.py @@ -821,13 +821,12 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0): time.sleep(max((x-time.time())/tr, 0)) return ''.join(y) -# TODO(3.0: rewrite to use memoryview() def send_all(p, data): while len(data): sent = p.send(data) if sent is None: raise Exception(disconnect_message) - data = buffer(data, sent) + data = memoryview(data)[sent:] diff --git a/media/webrtc/trunk/tools/gyp/test/lib/TestGyp.py b/media/webrtc/trunk/tools/gyp/test/lib/TestGyp.py index 3e7bb32754..a0b20d8058 100644 --- a/media/webrtc/trunk/tools/gyp/test/lib/TestGyp.py +++ b/media/webrtc/trunk/tools/gyp/test/lib/TestGyp.py @@ -887,9 +887,9 @@ class TestGypMSVS(TestGypOnMSToolchain): Verifies that a build of the specified Visual Studio target is up to date. Beware that VS2010 will behave strangely if you build under - C:\USERS\yourname\AppData\Local. It will cause needless work. The ouptut + C:\\USERS\yourname\AppData\Local. It will cause needless work. The ouptut will be "1 succeeded and 0 up to date". MSBuild tracing reveals that: - "Project 'C:\Users\...\AppData\Local\...vcxproj' not up to date because + "Project 'C:\\Users\...\AppData\Local\...vcxproj' not up to date because 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 10.0\VC\BIN\1033\CLUI.DLL' was modified at 02/21/2011 17:03:30, which is newer than '' which was modified at 01/01/0001 00:00:00. diff --git a/parser/html/java/htmlparser/generate-encoding-data.py b/parser/html/java/htmlparser/generate-encoding-data.py index 8466dd2e05..26e871e595 100644 --- a/parser/html/java/htmlparser/generate-encoding-data.py +++ b/parser/html/java/htmlparser/generate-encoding-data.py @@ -33,13 +33,13 @@ class Label: # non-generated decoder implementation class. Otherwise, the JDK default # decoder is used as a placeholder. MULTI_BYTE_DECODER_IMPLEMENTED = [ - u"x-user-defined", - u"replacement", - u"big5", + "x-user-defined", + "replacement", + "big5", ] MULTI_BYTE_ENCODER_IMPLEMENTED = [ - u"big5", + "big5", ] preferred = [] @@ -55,14 +55,14 @@ single_byte = [] multi_byte = [] def to_camel_name(name): - if name == u"iso-8859-8-i": - return u"Iso8I" - if name.startswith(u"iso-8859-"): - return name.replace(u"iso-8859-", u"Iso") - return name.title().replace(u"X-", u"").replace(u"-", u"").replace(u"_", u"") + if name == "iso-8859-8-i": + return "Iso8I" + if name.startswith("iso-8859-"): + return name.replace("iso-8859-", "Iso") + return name.title().replace("X-", "").replace("-", "").replace("_", "") def to_constant_name(name): - return name.replace(u"-", u"_").upper() + return name.replace("-", "_").upper() # Encoding.java @@ -328,8 +328,8 @@ for encoding in single_byte: labels.sort() class_name = to_camel_name(name) mapping_name = name - if mapping_name == u"iso-8859-8-i": - mapping_name = u"iso-8859-8" + if mapping_name == "iso-8859-8-i": + mapping_name = "iso-8859-8" mapping = indexes[mapping_name] class_file = open("src/nu/validator/encoding/%s.java" % class_name, "w") class_file.write('''/* @@ -377,7 +377,7 @@ class ''') fallible = True if comma: class_file.write(",") - class_file.write("\n '\u%04x'" % code_point); + class_file.write("\n '\\u%04x'" % code_point); comma = True class_file.write(''' }; diff --git a/python/altgraph/doc/conf.py b/python/altgraph/doc/conf.py index cd3fd9912e..78fefb03f4 100644 --- a/python/altgraph/doc/conf.py +++ b/python/altgraph/doc/conf.py @@ -48,8 +48,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'altgraph' -copyright = u'2010-2011, Ronald Oussoren, Bob Ippolito, 2004 Istvan Albert' +project = 'altgraph' +copyright = '2010-2011, Ronald Oussoren, Bob Ippolito, 2004 Istvan Albert' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -183,8 +183,8 @@ htmlhelp_basename = 'altgraphdoc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'altgraph.tex', u'altgraph Documentation', - u'Ronald Oussoren', 'manual'), + ('index', 'altgraph.tex', 'altgraph Documentation', + 'Ronald Oussoren', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/python/bitstring/bitstring.py b/python/bitstring/bitstring.py index 49156f0abe..51e02ddbd9 100644 --- a/python/bitstring/bitstring.py +++ b/python/bitstring/bitstring.py @@ -1905,7 +1905,7 @@ class Bits(object): data = bytearray.fromhex(hexstring) except TypeError: # Python 2.6 needs a unicode string (a bug). 2.7 and 3.x work fine. - data = bytearray.fromhex(unicode(hexstring)) + data = bytearray.fromhex(str(hexstring)) except ValueError: raise CreationError("Invalid symbol in hex initialiser.") self._setbytes_unsafe(data, length * 4, 0) diff --git a/python/blessings/blessings/__init__.py b/python/blessings/blessings/__init__.py index 081288ba68..9c42e1ab49 100644 --- a/python/blessings/blessings/__init__.py +++ b/python/blessings/blessings/__init__.py @@ -272,7 +272,7 @@ class Terminal(object): # optimization: combine all formatting into a single escape # sequence. return self._formatting_string( - u''.join(self._resolve_formatter(s) for s in formatters)) + ''.join(self._resolve_formatter(s) for s in formatters)) else: return ParametrizingString(self._resolve_capability(attr)) @@ -289,7 +289,7 @@ class Terminal(object): # contain chars > 127, and UTF-8 never changes anything within that # range.. return code.decode('utf-8') - return u'' + return '' def _resolve_color(self, color): """Resolve a color like red or on_bright_green into a callable capability.""" @@ -333,7 +333,7 @@ COMPOUNDABLES = (COLORS | 'shadow', 'standout', 'subscript', 'superscript'])) -class ParametrizingString(unicode): +class ParametrizingString(str): """A Unicode string which can be called to parametrize it as a terminal capability""" def __new__(cls, formatting, normal=None): """Instantiate. @@ -343,7 +343,7 @@ class ParametrizingString(unicode): "normal" capability. """ - new = unicode.__new__(cls, formatting) + new = str.__new__(cls, formatting) new._normal = normal return new @@ -360,7 +360,7 @@ class ParametrizingString(unicode): # running simply `nosetests` (without progressive) on nose- # progressive. Perhaps the terminal has gone away between calling # tigetstr and calling tparm. - return u'' + return '' except TypeError: # If the first non-int (i.e. incorrect) arg was a string, suggest # something intelligent: @@ -375,10 +375,10 @@ class ParametrizingString(unicode): raise -class FormattingString(unicode): +class FormattingString(str): """A Unicode string which can be called upon a piece of text to wrap it in formatting""" def __new__(cls, formatting, normal): - new = unicode.__new__(cls, formatting) + new = str.__new__(cls, formatting) new._normal = normal return new @@ -393,7 +393,7 @@ class FormattingString(unicode): return self + text + self._normal -class NullCallableString(unicode): +class NullCallableString(str): """A dummy class to stand in for ``FormattingString`` and ``ParametrizingString`` A callable bytestring that returns an empty Unicode when called with an int @@ -402,12 +402,12 @@ class NullCallableString(unicode): """ def __new__(cls): - new = unicode.__new__(cls, u'') + new = str.__new__(cls, '') return new def __call__(self, arg): if isinstance(arg, int): - return u'' + return '' return arg # TODO: Force even strs in Python 2.x to be unicodes? Nah. How would I know what encoding to use to convert it? diff --git a/python/blessings/blessings/tests.py b/python/blessings/blessings/tests.py index d07ecfe516..3f7edf0353 100644 --- a/python/blessings/blessings/tests.py +++ b/python/blessings/blessings/tests.py @@ -52,8 +52,8 @@ def test_capability(): def test_capability_without_tty(): """Assert capability templates are '' when stream is not a tty.""" t = TestTerminal(stream=StringIO()) - eq_(t.save, u'') - eq_(t.red, u'') + eq_(t.save, '') + eq_(t.red, '') def test_capability_with_forced_tty(): @@ -84,11 +84,11 @@ def test_location(): t = TestTerminal(stream=StringIO(), force_styling=True) with t.location(3, 4): - t.stream.write(u'hi') + t.stream.write('hi') eq_(t.stream.getvalue(), unicode_cap('sc') + unicode_parm('cup', 4, 3) + - u'hi' + + 'hi' + unicode_cap('rc')) @@ -111,7 +111,7 @@ def test_null_fileno(): out = StringIO() out.fileno = None t = TestTerminal(stream=out) - eq_(t.save, u'') + eq_(t.save, '') def test_mnemonic_colors(): @@ -179,26 +179,26 @@ def test_formatting_functions(): """Test crazy-ass formatting wrappers, both simple and compound.""" t = TestTerminal() # By now, it should be safe to use sugared attributes. Other tests test those. - eq_(t.bold(u'hi'), t.bold + u'hi' + t.normal) - eq_(t.green('hi'), t.green + u'hi' + t.normal) # Plain strs for Python 2.x + eq_(t.bold('hi'), t.bold + 'hi' + t.normal) + eq_(t.green('hi'), t.green + 'hi' + t.normal) # Plain strs for Python 2.x # Test some non-ASCII chars, probably not necessary: - eq_(t.bold_green(u'boö'), t.bold + t.green + u'boö' + t.normal) + eq_(t.bold_green('boö'), t.bold + t.green + 'boö' + t.normal) eq_(t.bold_underline_green_on_red('boo'), - t.bold + t.underline + t.green + t.on_red + u'boo' + t.normal) + t.bold + t.underline + t.green + t.on_red + 'boo' + t.normal) # Don't spell things like this: eq_(t.on_bright_red_bold_bright_green_underline('meh'), - t.on_bright_red + t.bold + t.bright_green + t.underline + u'meh' + t.normal) + t.on_bright_red + t.bold + t.bright_green + t.underline + 'meh' + t.normal) def test_formatting_functions_without_tty(): """Test crazy-ass formatting wrappers when there's no tty.""" t = TestTerminal(stream=StringIO()) - eq_(t.bold(u'hi'), u'hi') - eq_(t.green('hi'), u'hi') + eq_(t.bold('hi'), 'hi') + eq_(t.green('hi'), 'hi') # Test non-ASCII chars, no longer really necessary: - eq_(t.bold_green(u'boö'), u'boö') - eq_(t.bold_underline_green_on_red('loo'), u'loo') - eq_(t.on_bright_red_bold_bright_green_underline('meh'), u'meh') + eq_(t.bold_green('boö'), 'boö') + eq_(t.bold_underline_green_on_red('loo'), 'loo') + eq_(t.on_bright_red_bold_bright_green_underline('meh'), 'meh') def test_nice_formatting_errors(): @@ -210,7 +210,7 @@ def test_nice_formatting_errors(): assert 'probably misspelled' in e.args[0] try: - t.bold_misspelled(u'hey') # unicode + t.bold_misspelled('hey') # unicode except TypeError as e: assert 'probably misspelled' in e.args[0] diff --git a/python/compare-locales/compare_locales/checks.py b/python/compare-locales/compare_locales/checks.py index d502181557..c5cf7ccfcd 100644 --- a/python/compare-locales/compare_locales/checks.py +++ b/python/compare-locales/compare_locales/checks.py @@ -293,7 +293,7 @@ class DTDChecker(Checker): col -= len("' % CharMinusDash - NameStartChar = u':A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF' + \ - u'\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F' + \ - u'\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD' + NameStartChar = ':A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF' + \ + '\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F' + \ + '\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD' # + \U00010000-\U000EFFFF seems to be unsupported in python # NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | # [#x0300-#x036F] | [#x203F-#x2040] - NameChar = NameStartChar + ur'\-\.0-9' + u'\xB7\u0300-\u036F\u203F-\u2040' + NameChar = NameStartChar + r'\-\.0-9' + '\xB7\u0300-\u036F\u203F-\u2040' Name = '[' + NameStartChar + '][' + NameChar + ']*' reKey = re.compile('(?:(?P
\s*)(?P(?:' + XmlComment +
                        '\s*)*)(?P' + Name +
@@ -236,9 +236,9 @@ class DTDParser(Parser):
                        '(?P[ \t]*(?:' + XmlComment + '\s*)*\n?)?)',
                        re.DOTALL)
     # add BOM to DTDs, details in bug 435002
-    reHeader = re.compile(u'^\ufeff?'
-                          u'(\s*)?', re.S)
+    reHeader = re.compile('^\ufeff?'
+                          '(\s*)?', re.S)
     reFooter = re.compile('\s*(\s*)*$')
     rePE = re.compile('(?:(\s*)((?:' + XmlComment + '\s*)*)'
                       '(
+        self._test('''
 '''.encode('utf-8'),
-            (('warning', (0, 0), u'Referencing unknown entity `ƞǿŧ`',
+            (('warning', (0, 0), 'Referencing unknown entity `ƞǿŧ`',
               'xmlparse'),))
 
     def testErrorFirstLine(self):
@@ -233,10 +233,10 @@ class TestAndroid(unittest.TestCase):
     Make sure we're hitting our extra rules only if
     we're passing in a DTD file in the embedding/android module.
     """
-    apos_msg = u"Apostrophes in Android DTDs need escaping with \\' or " + \
-               u"\\u0027, or use \u2019, or put string in quotes."
-    quot_msg = u"Quotes in Android DTDs need escaping with \\\" or " + \
-               u"\\u0022, or put string in apostrophes."
+    apos_msg = "Apostrophes in Android DTDs need escaping with \\' or " + \
+               "\\u0027, or use \u2019, or put string in quotes."
+    quot_msg = "Quotes in Android DTDs need escaping with \\\" or " + \
+               "\\u0022, or put string in apostrophes."
 
     def getEntity(self, v):
         return Entity(v, lambda s: s, (0, len(v)), (), (0, 0), (), (),
@@ -318,12 +318,12 @@ class TestAndroid(unittest.TestCase):
                          (('error', 2, self.quot_msg, 'android'),))
 
         # broken unicode escape
-        l10n = self.getDTDEntity("Some broken \u098 unicode")
+        l10n = self.getDTDEntity("Some broken \\u098 unicode")
         self.assertEqual(tuple(checker.check(ref, l10n)),
                          (('error', 12, 'truncated \\uXXXX escape',
                            'android'),))
         # broken unicode escape, try to set the error off
-        l10n = self.getDTDEntity(u"\u9690"*14+"\u006"+"  "+"\u0064")
+        l10n = self.getDTDEntity("\u9690"*14+"\\u006"+"  "+"\\u0064")
         self.assertEqual(tuple(checker.check(ref, l10n)),
                          (('error', 14, 'truncated \\uXXXX escape',
                            'android'),))
diff --git a/python/compare-locales/compare_locales/tests/test_merge.py b/python/compare-locales/compare_locales/tests/test_merge.py
index afc8e9acb1..270de9d2a7 100644
--- a/python/compare-locales/compare_locales/tests/test_merge.py
+++ b/python/compare-locales/compare_locales/tests/test_merge.py
@@ -81,7 +81,7 @@ eff = effVal""")
              'details': {
                  'children': [
                      ('l10n.properties',
-                         {'value': {'missingEntity': [u'eff', u'foo']}}
+                         {'value': {'missingEntity': ['eff', 'foo']}}
                       )
                  ]}
              }
@@ -115,9 +115,9 @@ eff = leffVal
                  'children': [
                      ('l10n.properties',
                          {'value': {
-                          'error': [u'argument 1 `S` should be `d` '
-                                    u'at line 1, column 6 for bar'],
-                          'missingEntity': [u'foo']}}
+                          'error': ['argument 1 `S` should be `d` '
+                                    'at line 1, column 6 for bar'],
+                          'missingEntity': ['foo']}}
                       )
                  ]}
              }
@@ -151,7 +151,7 @@ eff = leffVal
              'details': {
                  'children': [
                      ('l10n.properties',
-                         {'value': {'obsoleteEntity': [u'other']}})]},
+                         {'value': {'obsoleteEntity': ['other']}})]},
              }
         )
 
@@ -212,7 +212,7 @@ class TestDTD(unittest.TestCase, ContentMixin):
              'details': {
                  'children': [
                      ('l10n.dtd',
-                         {'value': {'missingEntity': [u'eff', u'foo']}}
+                         {'value': {'missingEntity': ['eff', 'foo']}}
                       )
                  ]}
              }
@@ -247,9 +247,9 @@ class TestDTD(unittest.TestCase, ContentMixin):
                  'children': [
                      ('l10n.dtd',
                          {'value': {
-                             'error': [u'Unparsed content "" at 23-44'],
-                             'missingEntity': [u'bar']}}
+                             'error': ['Unparsed content "" at 23-44'],
+                             'missingEntity': ['bar']}}
                       )
                  ]}
              }
diff --git a/python/compare-locales/compare_locales/tests/test_properties.py b/python/compare-locales/compare_locales/tests/test_properties.py
index 7dae0bd68c..a1f925b558 100644
--- a/python/compare-locales/compare_locales/tests/test_properties.py
+++ b/python/compare-locales/compare_locales/tests/test_properties.py
@@ -22,8 +22,8 @@ two_lines_triple = This line is one of two and ends in \\\
 and still has another line coming
 ''', (
             ('one_line', 'This is one line'),
-            ('two_line', u'This is the first of two lines'),
-            ('one_line_trailing', u'This line ends in \\'),
+            ('two_line', 'This is the first of two lines'),
+            ('one_line_trailing', 'This line ends in \\'),
             ('_junk_\\d+_113-126$', 'and has junk\n'),
             ('two_lines_triple', 'This line is one of two and ends in \\'
              'and still has another line coming')))
@@ -41,11 +41,11 @@ and still has another line coming
     def test_bug121341(self):
         # port of xpcom/tests/unit/test_bug121341.js
         self.parser.readContents(self.resource('bug121341.properties'))
-        ref = ['abc', 'xy', u"\u1234\t\r\n\u00AB\u0001\n",
+        ref = ['abc', 'xy', "\u1234\t\r\n\u00AB\u0001\n",
                "this is multiline property",
-               "this is another multiline property", u"test\u0036",
-               "yet another multiline propery", u"\ttest5\u0020", " test6\t",
-               u"c\uCDEFd", u"\uABCD"]
+               "this is another multiline property", "test\u0036",
+               "yet another multiline propery", "\ttest5\u0020", " test6\t",
+               "c\uCDEFd", "\uABCD"]
         i = iter(self.parser)
         for r, e in zip(ref, i):
             self.assertEqual(e.val, r)
diff --git a/python/configobj/configobj.py b/python/configobj/configobj.py
index 57635c5678..1abfa23ae2 100644
--- a/python/configobj/configobj.py
+++ b/python/configobj/configobj.py
@@ -1502,7 +1502,7 @@ class ConfigObj(Section):
             # NOTE: Could raise a ``UnicodeDecodeError``
             return infile.decode(encoding).splitlines(True)
         for i, line in enumerate(infile):
-            if not isinstance(line, unicode):
+            if not isinstance(line, str):
                 # NOTE: The isinstance test here handles mixed lists of unicode/string
                 # NOTE: But the decode will break on any non-string values
                 # NOTE: Or could raise a ``UnicodeDecodeError``
diff --git a/python/futures/docs/conf.py b/python/futures/docs/conf.py
index 5cea44c881..c3f8abca62 100644
--- a/python/futures/docs/conf.py
+++ b/python/futures/docs/conf.py
@@ -37,8 +37,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'futures'
-copyright = u'2009-2011, Brian Quinlan'
+project = 'futures'
+copyright = '2009-2011, Brian Quinlan'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -172,8 +172,8 @@ htmlhelp_basename = 'futuresdoc'
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'futures.tex', u'futures Documentation',
-   u'Brian Quinlan', 'manual'),
+  ('index', 'futures.tex', 'futures Documentation',
+   'Brian Quinlan', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
diff --git a/python/jsmin/jsmin/__init__.py b/python/jsmin/jsmin/__init__.py
index 9a04172e91..ab516c58f1 100644
--- a/python/jsmin/jsmin/__init__.py
+++ b/python/jsmin/jsmin/__init__.py
@@ -45,7 +45,7 @@ def jsmin(js, **kwargs):
     returns a minified version of the javascript string
     """
     if not is_3:        
-        if cStringIO and not isinstance(js, unicode):
+        if cStringIO and not isinstance(js, str):
             # strings can use cStringIO for a 3x performance
             # improvement, but unicode (in python2) cannot
             klass = io.StringIO
diff --git a/python/jsmin/jsmin/test.py b/python/jsmin/jsmin/test.py
index 8111eb4e17..6362cc409c 100644
--- a/python/jsmin/jsmin/test.py
+++ b/python/jsmin/jsmin/test.py
@@ -260,8 +260,8 @@ var  foo    =  "hey";
         assert output == "function foo(''){}"
     
     def testUnicode(self):
-        instr = u'\u4000 //foo'
-        expected = u'\u4000'
+        instr = '\u4000 //foo'
+        expected = '\u4000'
         output = jsmin.jsmin(instr)
         self.assertEqual(output, expected)
 
diff --git a/python/mach/mach/mixin/process.py b/python/mach/mach/mixin/process.py
index 548b59dd32..9be19aaced 100644
--- a/python/mach/mach/mixin/process.py
+++ b/python/mach/mach/mixin/process.py
@@ -109,10 +109,10 @@ class ProcessExecutionMixin(LoggingMixin):
         # want UTF-8, they shouldn't pass in a unicode instance.
         normalized_env = {}
         for k, v in list(use_env.items()):
-            if isinstance(k, unicode):
+            if isinstance(k, str):
                 k = k.encode('utf-8', 'strict')
 
-            if isinstance(v, unicode):
+            if isinstance(v, str):
                 v = v.encode('utf-8', 'strict')
 
             normalized_env[k] = v
diff --git a/python/macholib/doc/conf.py b/python/macholib/doc/conf.py
index 08a48f3ede..9d53cc23b6 100644
--- a/python/macholib/doc/conf.py
+++ b/python/macholib/doc/conf.py
@@ -52,8 +52,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'macholib'
-copyright = u'2010-2011, Ronald Oussoren'
+project = 'macholib'
+copyright = '2010-2011, Ronald Oussoren'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -190,8 +190,8 @@ htmlhelp_basename = 'macholibdoc'
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-  ('index', 'macholib.tex', u'macholib Documentation',
-   u'Ronald Oussoren', 'manual'),
+  ('index', 'macholib.tex', 'macholib Documentation',
+   'Ronald Oussoren', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -223,18 +223,18 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'macholib', u'macholib Documentation',
-     [u'Ronald Oussoren'], 1)
+    ('index', 'macholib', 'macholib Documentation',
+     ['Ronald Oussoren'], 1)
 ]
 
 
 # -- Options for Epub output ---------------------------------------------------
 
 # Bibliographic Dublin Core info.
-epub_title = u'macholib'
-epub_author = u'Ronald Oussoren'
-epub_publisher = u'Ronald Oussoren'
-epub_copyright = u'2010, Ronald Oussoren'
+epub_title = 'macholib'
+epub_author = 'Ronald Oussoren'
+epub_publisher = 'Ronald Oussoren'
+epub_copyright = '2010, Ronald Oussoren'
 
 # The language of the text. It defaults to the language option
 # or en if the language is not set.
diff --git a/python/macholib/macholib/MachO.py b/python/macholib/macholib/MachO.py
index f83ddb7115..d3353f0460 100644
--- a/python/macholib/macholib/MachO.py
+++ b/python/macholib/macholib/MachO.py
@@ -15,9 +15,9 @@ except ImportError:
     pass
 
 try:
-    unicode
+    str
 except NameError:
-    unicode = str
+    str = str
 
 __all__ = ['MachO']
 
@@ -338,7 +338,7 @@ class MachOHeader(object):
             cmd.to_fileobj(fileobj)
 
             if sys.version_info[0] == 2:
-                if isinstance(data, unicode):
+                if isinstance(data, str):
                     fileobj.write(data.encode(sys.getfilesystemencoding()))
 
                 elif isinstance(data, (bytes, str)):
diff --git a/python/macholib/macholib/MachOGraph.py b/python/macholib/macholib/MachOGraph.py
index e841a24173..7316e8a580 100644
--- a/python/macholib/macholib/MachOGraph.py
+++ b/python/macholib/macholib/MachOGraph.py
@@ -16,9 +16,9 @@ from macholib.itergraphreport import itergraphreport
 __all__ = ['MachOGraph']
 
 try:
-    unicode
+    str
 except NameError:
-    unicode = str
+    str = str
 
 class MissingMachO(object):
     def __init__(self, filename):
@@ -39,7 +39,7 @@ class MachOGraph(ObjectGraph):
         self.executable_path = executable_path
 
     def locate(self, filename, loader=None):
-        assert isinstance(filename, (str, unicode))
+        assert isinstance(filename, (str, str))
         if filename.startswith('@loader_path/') and loader is not None:
             fn = self.trans_table.get((loader.filename, filename))
             if fn is None:
@@ -63,7 +63,7 @@ class MachOGraph(ObjectGraph):
         return fn
 
     def findNode(self, name, loader=None):
-        assert isinstance(name, (str, unicode))
+        assert isinstance(name, (str, str))
         data = super(MachOGraph, self).findNode(name)
         if data is not None:
             return data
@@ -73,7 +73,7 @@ class MachOGraph(ObjectGraph):
         return None
 
     def run_file(self, pathname, caller=None):
-        assert isinstance(pathname, (str, unicode))
+        assert isinstance(pathname, (str, str))
         self.msgin(2, "run_file", pathname)
         m = self.findNode(pathname, loader=caller)
         if m is None:
@@ -86,7 +86,7 @@ class MachOGraph(ObjectGraph):
         return m
 
     def load_file(self, name, caller=None):
-        assert isinstance(name, (str, unicode))
+        assert isinstance(name, (str, str))
         self.msgin(2, "load_file", name)
         m = self.findNode(name)
         if m is None:
@@ -105,8 +105,8 @@ class MachOGraph(ObjectGraph):
         self.msgin(2, 'scan_node', node)
         for header in node.headers:
             for idx, name, filename in header.walkRelocatables():
-                assert isinstance(name, (str, unicode))
-                assert isinstance(filename, (str, unicode))
+                assert isinstance(name, (str, str))
+                assert isinstance(filename, (str, str))
                 m = self.load_file(filename, caller=node)
                 self.createReference(node, m, edge_data=name)
         self.msgout(2, '', node)
diff --git a/python/macholib/macholib/dyld.py b/python/macholib/macholib/dyld.py
index 2e81db7f88..01faed3d76 100644
--- a/python/macholib/macholib/dyld.py
+++ b/python/macholib/macholib/dyld.py
@@ -34,7 +34,7 @@ _DEFAULT_LIBRARY_FALLBACK = [
 if sys.version_info[0] == 2:
     def _ensure_utf8(s):
         """Not all of PyObjC and Python understand unicode paths very well yet"""
-        if isinstance(s, unicode):
+        if isinstance(s, str):
             return s.encode('utf8')
         return s
 else:
diff --git a/python/macholib/macholib/util.py b/python/macholib/macholib/util.py
index e20516ecc7..ad14b6742a 100644
--- a/python/macholib/macholib/util.py
+++ b/python/macholib/macholib/util.py
@@ -18,16 +18,16 @@ MAGIC_LEN = 4
 STRIPCMD = ['/usr/bin/strip', '-x', '-S', '-']
 
 try:
-    unicode
+    str
 except NameError:
-    unicode = str
+    str = str
 
 
 def fsencoding(s, encoding=sys.getfilesystemencoding()):
     """
     Ensure the given argument is in filesystem encoding (not unicode)
     """
-    if isinstance(s, unicode):
+    if isinstance(s, str):
         s = s.encode(encoding)
     return s
 
diff --git a/python/mock-1.0.0/docs/conf.py b/python/mock-1.0.0/docs/conf.py
index 62f0491cca..51ca069900 100644
--- a/python/mock-1.0.0/docs/conf.py
+++ b/python/mock-1.0.0/docs/conf.py
@@ -65,8 +65,8 @@ source_suffix = '.txt'
 master_doc = 'index'
 
 # General substitutions.
-project = u'Mock'
-copyright = u'2007-2012, Michael Foord & the mock team'
+project = 'Mock'
+copyright = '2007-2012, Michael Foord & the mock team'
 
 # The default replacements for |version| and |release|, also used in various
 # other places throughout the built documents.
@@ -187,8 +187,8 @@ latex_font_size = '12pt'
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, document class [howto/manual]).
 latex_documents = [
-  ('index', 'Mock.tex', u'Mock Documentation',
-   u'Michael Foord', 'manual'),
+  ('index', 'Mock.tex', 'Mock Documentation',
+   'Michael Foord', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
diff --git a/python/mock-1.0.0/mock.py b/python/mock-1.0.0/mock.py
index 3f68c4c2d1..e173d3a001 100644
--- a/python/mock-1.0.0/mock.py
+++ b/python/mock-1.0.0/mock.py
@@ -56,10 +56,10 @@ except ImportError:
         return inner
 
 try:
-    unicode
+    str
 except NameError:
     # Python 3
-    basestring = unicode = str
+    basestring = str = str
 
 try:
     int
@@ -1454,7 +1454,7 @@ def _patch_multiple(target, spec=None, create=False, spec_set=None,
     When used as a class decorator `patch.multiple` honours `patch.TEST_PREFIX`
     for choosing which methods to wrap.
     """
-    if type(target) in (unicode, str):
+    if type(target) in (str, str):
         getter = lambda: _importer(target)
     else:
         getter = lambda: target
@@ -1755,7 +1755,7 @@ _calculate_return_value = {
     '__hash__': lambda self: object.__hash__(self),
     '__str__': lambda self: object.__str__(self),
     '__sizeof__': lambda self: object.__sizeof__(self),
-    '__unicode__': lambda self: unicode(object.__str__(self)),
+    '__unicode__': lambda self: str(object.__str__(self)),
 }
 
 _return_values = {
diff --git a/python/mock-1.0.0/tests/testmagicmethods.py b/python/mock-1.0.0/tests/testmagicmethods.py
index ad03efb305..b8b143af61 100644
--- a/python/mock-1.0.0/tests/testmagicmethods.py
+++ b/python/mock-1.0.0/tests/testmagicmethods.py
@@ -5,10 +5,10 @@
 from tests.support import unittest2, inPy3k
 
 try:
-    unicode
+    str
 except NameError:
     # Python 3
-    unicode = str
+    str = str
     long = int
 
 import inspect
@@ -83,10 +83,10 @@ class TestMockingMagicMethods(unittest2.TestCase):
     @unittest2.skipIf(inPy3k, "no unicode in Python 3")
     def test_unicode(self):
         mock = Mock()
-        self.assertEqual(unicode(mock), unicode(str(mock)))
+        self.assertEqual(str(mock), str(str(mock)))
 
-        mock.__unicode__ = lambda s: unicode('foo')
-        self.assertEqual(unicode(mock), unicode('foo'))
+        mock.__unicode__ = lambda s: str('foo')
+        self.assertEqual(str(mock), str('foo'))
 
 
     def test_dict_methods(self):
@@ -321,8 +321,8 @@ class TestMockingMagicMethods(unittest2.TestCase):
         self.assertEqual(list(mock), [])
         self.assertEqual(hash(mock), object.__hash__(mock))
         self.assertEqual(str(mock), object.__str__(mock))
-        self.assertEqual(unicode(mock), object.__str__(mock))
-        self.assertIsInstance(unicode(mock), unicode)
+        self.assertEqual(str(mock), object.__str__(mock))
+        self.assertIsInstance(str(mock), str)
         self.assertTrue(bool(mock))
         if not inPy3k:
             self.assertEqual(oct(mock), '1')
diff --git a/python/mock-1.0.0/tests/testmock.py b/python/mock-1.0.0/tests/testmock.py
index 273290fb42..cb7f10c865 100644
--- a/python/mock-1.0.0/tests/testmock.py
+++ b/python/mock-1.0.0/tests/testmock.py
@@ -20,9 +20,9 @@ from mock import (
 
 
 try:
-    unicode
+    str
 except NameError:
-    unicode = str
+    str = str
 
 
 class Iter(object):
@@ -87,7 +87,7 @@ class MockTest(unittest2.TestCase):
 
     def test_unicode_not_broken(self):
         # This used to raise an exception with Python 2.5 and Mock 0.4
-        unicode(Mock())
+        str(Mock())
 
 
     def test_return_value_in_constructor(self):
diff --git a/python/mock-1.0.0/tests/testpatch.py b/python/mock-1.0.0/tests/testpatch.py
index 1ebe671065..fd31592b19 100644
--- a/python/mock-1.0.0/tests/testpatch.py
+++ b/python/mock-1.0.0/tests/testpatch.py
@@ -17,7 +17,7 @@ from mock import (
 builtin_string = '__builtin__'
 if inPy3k:
     builtin_string = 'builtins'
-    unicode = str
+    str = str
 
 PTModule = sys.modules[__name__]
 MODNAME = '%s.PTModule' % __name__
@@ -1528,7 +1528,7 @@ class PatchTest(unittest2.TestCase):
 
 
     def test_patch_multiple_string_subclasses(self):
-        for base in (str, unicode):
+        for base in (str, str):
             Foo = type('Foo', (base,), {'fish': 'tasty'})
             foo = Foo()
             @patch.multiple(foo, fish='nearly gone')
diff --git a/python/mozbuild/mozbuild/backend/configenvironment.py b/python/mozbuild/mozbuild/backend/configenvironment.py
index f1a637d1c3..834ebb0ca4 100644
--- a/python/mozbuild/mozbuild/backend/configenvironment.py
+++ b/python/mozbuild/mozbuild/backend/configenvironment.py
@@ -17,7 +17,7 @@ from mozbuild.shellutil import quote as shell_quote
 
 
 if sys.version_info.major == 2:
-    text_type = unicode
+    text_type = str
 else:
     text_type = str
 
diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py
index eccb870acf..ffd135dea4 100644
--- a/python/mozbuild/mozbuild/backend/recursivemake.py
+++ b/python/mozbuild/mozbuild/backend/recursivemake.py
@@ -201,7 +201,7 @@ class BackendMakeFile(object):
         self.fh.write(buf)
 
     def write_once(self, buf):
-        if isinstance(buf, unicode):
+        if isinstance(buf, str):
             buf = buf.encode('utf-8')
         if b'\n' + buf not in self.fh.getvalue():
             self.write(buf)
diff --git a/python/mozbuild/mozbuild/configure/__init__.py b/python/mozbuild/mozbuild/configure/__init__.py
index 49da5cd7e5..b11c0b7cac 100644
--- a/python/mozbuild/mozbuild/configure/__init__.py
+++ b/python/mozbuild/mozbuild/configure/__init__.py
@@ -194,7 +194,7 @@ class ConfigureSandbox(dict):
                   'list', 'tuple', 'set', 'dict', 'isinstance', 'getattr',
                   'hasattr', 'enumerate', 'range', 'zip', '__build_class__')
         if b in __builtins__},
-    __import__=forbidden_import, str=unicode)
+    __import__=forbidden_import, str=str)
 
     # Expose a limited set of functions from os.path
     OS = ReadOnlyNamespace(path=ReadOnlyNamespace(**{
diff --git a/python/mozbuild/mozbuild/configure/util.py b/python/mozbuild/mozbuild/configure/util.py
index c7a305282b..9814a94614 100644
--- a/python/mozbuild/mozbuild/configure/util.py
+++ b/python/mozbuild/mozbuild/configure/util.py
@@ -52,7 +52,7 @@ class Version(LooseVersion):
 
     def __cmp__(self, other):
         # LooseVersion checks isinstance(StringType), so work around it.
-        if isinstance(other, unicode):
+        if isinstance(other, str):
             other = other.encode('ascii')
         return LooseVersion.__cmp__(self, other)
 
diff --git a/python/mozbuild/mozbuild/frontend/context.py b/python/mozbuild/mozbuild/frontend/context.py
index 598a0d22b1..2537940979 100644
--- a/python/mozbuild/mozbuild/frontend/context.py
+++ b/python/mozbuild/mozbuild/frontend/context.py
@@ -297,7 +297,7 @@ class InitializedDefines(ContextDerivedValue, OrderedDict):
             self.update(value)
 
 
-class FinalTargetValue(ContextDerivedValue, unicode):
+class FinalTargetValue(ContextDerivedValue, str):
     def __new__(cls, context, value=""):
         if not value:
             value = 'dist/'
@@ -307,7 +307,7 @@ class FinalTargetValue(ContextDerivedValue, unicode):
                 value += 'bin'
             if context['DIST_SUBDIR']:
                 value += '/' + context['DIST_SUBDIR']
-        return unicode.__new__(cls, value)
+        return str.__new__(cls, value)
 
 
 def Enum(*values):
@@ -355,7 +355,7 @@ class PathMeta(type):
                 cls = SourcePath
         return super(PathMeta, cls).__call__(context, value)
 
-class Path(ContextDerivedValue, unicode, metaclass=PathMeta):
+class Path(ContextDerivedValue, str, metaclass=PathMeta):
     """Stores and resolves a source path relative to a given context
 
     This class is used as a backing type for some of the sandbox variables.
@@ -385,7 +385,7 @@ class Path(ContextDerivedValue, unicode, metaclass=PathMeta):
     def __cmp__(self, other):
         if isinstance(other, Path) and self.srcdir != other.srcdir:
             return cmp(self.full_path, other.full_path)
-        return cmp(unicode(self), other)
+        return cmp(str(self), other)
 
     # __cmp__ is not enough because unicode has __eq__, __ne__, etc. defined
     # and __cmp__ is only used for those when they don't exist.
@@ -613,8 +613,8 @@ def TypedListWithAction(typ, action):
     return _TypedListWithAction
 
 WebPlatformTestManifest = TypedNamedTuple("WebPlatformTestManifest",
-                                          [("manifest_path", unicode),
-                                           ("test_root", unicode)])
+                                          [("manifest_path", str),
+                                           ("test_root", str)])
 ManifestparserManifestList = OrderedListWithAction(read_manifestparser_manifest)
 ReftestManifestList = OrderedListWithAction(read_reftest_manifest)
 WptManifestList = TypedListWithAction(WebPlatformTestManifest, read_wpt_manifest)
@@ -622,12 +622,12 @@ WptManifestList = TypedListWithAction(WebPlatformTestManifest, read_wpt_manifest
 OrderedSourceList = ContextDerivedTypedList(SourcePath, StrictOrderingOnAppendList)
 OrderedTestFlavorList = TypedList(Enum(*all_test_flavors()),
                                   StrictOrderingOnAppendList)
-OrderedStringList = TypedList(unicode, StrictOrderingOnAppendList)
+OrderedStringList = TypedList(str, StrictOrderingOnAppendList)
 DependentTestsEntry = ContextDerivedTypedRecord(('files', OrderedSourceList),
                                                 ('tags', OrderedStringList),
                                                 ('flavors', OrderedTestFlavorList))
 BugzillaComponent = TypedNamedTuple('BugzillaComponent',
-                        [('product', unicode), ('component', unicode)])
+                        [('product', str), ('component', str)])
 
 
 class Files(SubContext):
@@ -908,7 +908,7 @@ VARIABLES = {
         """),
 
     'GENERATED_FILES': (StrictOrderingOnAppendListWithFlagsFactory({
-                'script': unicode,
+                'script': str,
                 'inputs': list }), list,
         """Generic generated files.
 
@@ -1053,7 +1053,7 @@ VARIABLES = {
         """Like ``OBJDIR_FILES``, with preprocessing. Use sparingly.
         """),
 
-    'FINAL_LIBRARY': (unicode, unicode,
+    'FINAL_LIBRARY': (str, str,
         """Library in which the objects of the current directory will be linked.
 
         This variable contains the name of a library, defined elsewhere with
@@ -1104,7 +1104,7 @@ VARIABLES = {
         """A list of python unit tests.
         """),
 
-    'HOST_LIBRARY_NAME': (unicode, unicode,
+    'HOST_LIBRARY_NAME': (str, str,
         """Name of target library generated when cross compiling.
         """),
 
@@ -1122,7 +1122,7 @@ VARIABLES = {
         libraries that link into this library via FINAL_LIBRARY.
         """),
 
-    'LIBRARY_NAME': (unicode, unicode,
+    'LIBRARY_NAME': (str, str,
         """The code name of the library generated for a directory.
 
         By default STATIC_LIBRARY_NAME and SHARED_LIBRARY_NAME take this name.
@@ -1134,7 +1134,7 @@ VARIABLES = {
         ``example/components/xpcomsample.lib`` on Windows.
         """),
 
-    'SHARED_LIBRARY_NAME': (unicode, unicode,
+    'SHARED_LIBRARY_NAME': (str, str,
         """The name of the static library generated for a directory, if it needs to
         differ from the library code name.
 
@@ -1148,7 +1148,7 @@ VARIABLES = {
         Implies FORCE_SHARED_LIB.
         """),
 
-    'STATIC_LIBRARY_NAME': (unicode, unicode,
+    'STATIC_LIBRARY_NAME': (str, str,
         """The name of the static library generated for a directory, if it needs to
         differ from the library code name.
 
@@ -1184,37 +1184,37 @@ VARIABLES = {
 
         This variable contains a list of system libaries to link against.
         """),
-    'RCFILE': (unicode, unicode,
+    'RCFILE': (str, str,
         """The program .rc file.
 
         This variable can only be used on Windows.
         """),
 
-    'RESFILE': (unicode, unicode,
+    'RESFILE': (str, str,
         """The program .res file.
 
         This variable can only be used on Windows.
         """),
 
-    'RCINCLUDE': (unicode, unicode,
+    'RCINCLUDE': (str, str,
         """The resource script file to be included in the default .res file.
 
         This variable can only be used on Windows.
         """),
 
-    'DEFFILE': (unicode, unicode,
+    'DEFFILE': (str, str,
         """The program .def (module definition) file.
 
         This variable can only be used on Windows.
         """),
 
-    'LD_VERSION_SCRIPT': (unicode, unicode,
+    'LD_VERSION_SCRIPT': (str, str,
         """The linker version script for shared libraries.
 
         This variable can only be used on Linux.
         """),
 
-    'SYMBOLS_FILE': (Path, unicode,
+    'SYMBOLS_FILE': (Path, str,
         """A file containing a list of symbols to export from a shared library.
 
         The given file contains a list of symbols to be exported, and is
@@ -1269,7 +1269,7 @@ VARIABLES = {
         ``BIN_SUFFIX``, the name will remain unchanged.
         """),
 
-    'SONAME': (unicode, unicode,
+    'SONAME': (str, str,
         """The soname of the shared object currently being linked
 
         soname is the "logical name" of a shared object, often used to provide
@@ -1325,7 +1325,7 @@ VARIABLES = {
         ``GENERATED_FILES``.
         """),
 
-    'PROGRAM' : (unicode, unicode,
+    'PROGRAM' : (str, str,
         """Compiled executable name.
 
         If the configuration token ``BIN_SUFFIX`` is set, its value will be
@@ -1333,7 +1333,7 @@ VARIABLES = {
         ``BIN_SUFFIX``, ``PROGRAM`` will remain unchanged.
         """),
 
-    'HOST_PROGRAM' : (unicode, unicode,
+    'HOST_PROGRAM' : (str, str,
         """Compiled host executable name.
 
         If the configuration token ``HOST_BIN_SUFFIX`` is set, its value will be
@@ -1371,7 +1371,7 @@ VARIABLES = {
         files.
         """),
 
-    'XPIDL_MODULE': (unicode, unicode,
+    'XPIDL_MODULE': (str, str,
         """XPCOM Interface Definition Module Name.
 
         This is the name of the ``.xpt`` file that is created by linking
@@ -1525,14 +1525,14 @@ VARIABLES = {
         """),
 
     # The following variables are used to control the target of installed files.
-    'XPI_NAME': (unicode, unicode,
+    'XPI_NAME': (str, str,
         """The name of an extension XPI to generate.
 
         When this variable is present, the results of this directory will end up
         being packaged into an extension instead of the main dist/bin results.
         """),
 
-    'DIST_SUBDIR': (unicode, unicode,
+    'DIST_SUBDIR': (str, str,
         """The name of an alternate directory to install files to.
 
         When this variable is present, the results of this directory will end up
@@ -1540,7 +1540,7 @@ VARIABLES = {
         otherwise be placed.
         """),
 
-    'FINAL_TARGET': (FinalTargetValue, unicode,
+    'FINAL_TARGET': (FinalTargetValue, str,
         """The name of the directory to install targets to.
 
         The directory is relative to the top of the object directory. The
@@ -1571,7 +1571,7 @@ VARIABLES = {
 
     'GYP_DIRS': (StrictOrderingOnAppendListWithFlagsFactory({
             'variables': dict,
-            'input': unicode,
+            'input': str,
             'sandbox_vars': dict,
             'no_chromium': bool,
             'no_unified': bool,
diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py
index 7c75468bbb..040458d3ad 100644
--- a/python/mozbuild/mozbuild/frontend/emitter.py
+++ b/python/mozbuild/mozbuild/frontend/emitter.py
@@ -117,7 +117,7 @@ class TreeMetadataEmitter(LoggingMixin):
         # rid ourselves of 2.6.
         self.info = {}
         for k, v in list(mozinfo.info.items()):
-            if isinstance(k, unicode):
+            if isinstance(k, str):
                 k = k.encode('ascii')
             self.info[k] = v
 
@@ -378,7 +378,7 @@ class TreeMetadataEmitter(LoggingMixin):
         """Verify that a crate's dependencies all specify local paths."""
         for dep_crate_name, values in dependencies.items():
             # A simple version number.
-            if isinstance(values, (str, unicode)):
+            if isinstance(values, (str, str)):
                 raise SandboxValidationError(
                     '%s %s of crate %s does not list a path' % (description, dep_crate_name, crate_name),
                     context)
@@ -1033,7 +1033,7 @@ class TreeMetadataEmitter(LoggingMixin):
             script = mozpath.join(mozpath.dirname(mozpath.dirname(__file__)),
                                   'action', 'process_define_files.py')
             yield GeneratedFile(context, script, 'process_define_file',
-                                unicode(path),
+                                str(path),
                                 [Path(context, path + '.in')])
 
         generated_files = context.get('GENERATED_FILES')
diff --git a/python/mozbuild/mozbuild/frontend/gyp_reader.py b/python/mozbuild/mozbuild/frontend/gyp_reader.py
index f0ae008ad3..f709e84718 100644
--- a/python/mozbuild/mozbuild/frontend/gyp_reader.py
+++ b/python/mozbuild/mozbuild/frontend/gyp_reader.py
@@ -42,7 +42,7 @@ script_dir = mozpath.join(chrome_src, 'build')
 
 
 def encode(value):
-    if isinstance(value, unicode):
+    if isinstance(value, str):
         return value.encode('utf-8')
     return value
 
diff --git a/python/mozbuild/mozbuild/frontend/reader.py b/python/mozbuild/mozbuild/frontend/reader.py
index d4252d8883..a798a971c7 100644
--- a/python/mozbuild/mozbuild/frontend/reader.py
+++ b/python/mozbuild/mozbuild/frontend/reader.py
@@ -83,7 +83,7 @@ from functools import reduce
 
 
 if sys.version_info.major == 2:
-    text_type = unicode
+    text_type = str
     type_type = types.TypeType
 else:
     text_type = str
@@ -483,7 +483,7 @@ class TemplateFunction(object):
         def visit_Str(self, node):
             # String nodes we got from the AST parser are str, but we want
             # unicode literals everywhere, so transform them.
-            node.s = unicode(node.s)
+            node.s = str(node.s)
             return node
 
         def visit_Name(self, node):
@@ -616,7 +616,7 @@ class BuildReaderError(Exception):
 
             for l in traceback.format_exception(type(self.other), self.other,
                 self.trace):
-                s.write(unicode(l))
+                s.write(str(l))
 
         return s.getvalue()
 
diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py
index d8e2bb25d9..21524b0200 100644
--- a/python/mozbuild/mozbuild/preprocessor.py
+++ b/python/mozbuild/mozbuild/preprocessor.py
@@ -733,7 +733,7 @@ class Preprocessor:
         args can either be a file name, or a file-like object.
         Files should be opened, and will be closed after processing.
         """
-        isName = type(args) == str or type(args) == unicode
+        isName = type(args) == str or type(args) == str
         oldCheckLineNumbers = self.checkLineNumbers
         self.checkLineNumbers = False
         if isName:
diff --git a/python/mozbuild/mozbuild/test/backend/test_configenvironment.py b/python/mozbuild/mozbuild/test/backend/test_configenvironment.py
index 54d0186fa4..f1128ea051 100644
--- a/python/mozbuild/mozbuild/test/backend/test_configenvironment.py
+++ b/python/mozbuild/mozbuild/test/backend/test_configenvironment.py
@@ -29,7 +29,7 @@ class ConfigEnvironment(ConfigStatus.ConfigEnvironment):
             self.substs = ReadOnlyDict(d)
 
             d = dict(self.substs_unicode)
-            d[u'top_srcdir'] = top_srcdir.decode('utf-8')
+            d['top_srcdir'] = top_srcdir.decode('utf-8')
             self.substs_unicode = ReadOnlyDict(d)
 
 
diff --git a/python/mozbuild/mozbuild/test/frontend/test_context.py b/python/mozbuild/mozbuild/test/frontend/test_context.py
index 1a627c8c8b..7228d0eee1 100644
--- a/python/mozbuild/mozbuild/test/frontend/test_context.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_context.py
@@ -631,7 +631,7 @@ class TestPaths(unittest.TestCase):
 class TestTypedRecord(unittest.TestCase):
 
     def test_fields(self):
-        T = ContextDerivedTypedRecord(('field1', unicode),
+        T = ContextDerivedTypedRecord(('field1', str),
                                       ('field2', list))
         inst = T(None)
         self.assertEqual(inst.field1, '')
@@ -647,7 +647,7 @@ class TestTypedRecord(unittest.TestCase):
             inst.field3 = []
 
     def test_coercion(self):
-        T = ContextDerivedTypedRecord(('field1', unicode),
+        T = ContextDerivedTypedRecord(('field1', str),
                                       ('field2', list))
         inst = T(None)
         inst.field1 = 3
@@ -673,45 +673,45 @@ class TestFiles(unittest.TestCase):
     def test_single_bug_component(self):
         c = Context({})
         f = Files(c, pattern='**')
-        f['BUG_COMPONENT'] = (u'Product1', u'Component1')
+        f['BUG_COMPONENT'] = ('Product1', 'Component1')
 
         files = {'moz.build': f}
         self.assertEqual(Files.aggregate(files), {
-            'bug_component_counts': [((u'Product1', u'Component1'), 1)],
-            'recommended_bug_component': (u'Product1', u'Component1'),
+            'bug_component_counts': [(('Product1', 'Component1'), 1)],
+            'recommended_bug_component': ('Product1', 'Component1'),
         })
 
     def test_multiple_bug_components(self):
         c = Context({})
         f1 = Files(c, pattern='**')
-        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')
+        f1['BUG_COMPONENT'] = ('Product1', 'Component1')
 
         f2 = Files(c, pattern='**')
-        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')
+        f2['BUG_COMPONENT'] = ('Product2', 'Component2')
 
         files = {'a': f1, 'b': f2, 'c': f1}
         self.assertEqual(Files.aggregate(files), {
             'bug_component_counts': [
-                ((u'Product1', u'Component1'), 2),
-                ((u'Product2', u'Component2'), 1),
+                (('Product1', 'Component1'), 2),
+                (('Product2', 'Component2'), 1),
             ],
-            'recommended_bug_component': (u'Product1', u'Component1'),
+            'recommended_bug_component': ('Product1', 'Component1'),
         })
 
     def test_no_recommended_bug_component(self):
         """If there is no clear count winner, we don't recommend a bug component."""
         c = Context({})
         f1 = Files(c, pattern='**')
-        f1['BUG_COMPONENT'] = (u'Product1', u'Component1')
+        f1['BUG_COMPONENT'] = ('Product1', 'Component1')
 
         f2 = Files(c, pattern='**')
-        f2['BUG_COMPONENT'] = (u'Product2', u'Component2')
+        f2['BUG_COMPONENT'] = ('Product2', 'Component2')
 
         files = {'a': f1, 'b': f2}
         self.assertEqual(Files.aggregate(files), {
             'bug_component_counts': [
-                ((u'Product1', u'Component1'), 1),
-                ((u'Product2', u'Component2'), 1),
+                (('Product1', 'Component1'), 1),
+                (('Product2', 'Component2'), 1),
             ],
             'recommended_bug_component': None,
         })
diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
index fac3a3ebb7..24802ef536 100644
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -1013,7 +1013,7 @@ class TestEmitterBasic(unittest.TestCase):
 
             expected = {'install.rdf', 'main.js'}
             for f in files:
-                self.assertTrue(unicode(f) in expected)
+                self.assertTrue(str(f) in expected)
 
     def test_missing_final_target_pp_files(self):
         """Test that FINAL_TARGET_PP_FILES with missing files throws errors."""
diff --git a/python/mozbuild/mozbuild/test/frontend/test_namespaces.py b/python/mozbuild/mozbuild/test/frontend/test_namespaces.py
index 71cc634e1b..0e952eb171 100644
--- a/python/mozbuild/mozbuild/test/frontend/test_namespaces.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_namespaces.py
@@ -29,7 +29,7 @@ class Fuga(object):
 
 class Piyo(ContextDerivedValue):
     def __init__(self, context, value):
-        if not isinstance(value, unicode):
+        if not isinstance(value, str):
             raise ValueError
         self.context = context
         self.value = value
@@ -48,9 +48,9 @@ class Piyo(ContextDerivedValue):
 
 
 VARIABLES = {
-    'HOGE': (unicode, unicode, None),
-    'FUGA': (Fuga, unicode, None),
-    'PIYO': (Piyo, unicode, None),
+    'HOGE': (str, str, None),
+    'FUGA': (Fuga, str, None),
+    'PIYO': (Piyo, str, None),
     'HOGERA': (ContextDerivedTypedList(Piyo, StrictOrderingOnAppendList),
         list, None),
     'HOGEHOGE': (ContextDerivedTypedListWithItems(
@@ -104,7 +104,7 @@ class TestContext(unittest.TestCase):
         self.assertEqual(e[1], 'set_type')
         self.assertEqual(e[2], 'HOGE')
         self.assertEqual(e[3], True)
-        self.assertEqual(e[4], unicode)
+        self.assertEqual(e[4], str)
 
     def test_key_checking(self):
         # Checking for existence of a key should not populate the key if it
@@ -127,7 +127,7 @@ class TestContext(unittest.TestCase):
         self.assertEqual(e[1], 'set_type')
         self.assertEqual(e[2], 'FUGA')
         self.assertEqual(e[3], False)
-        self.assertEqual(e[4], unicode)
+        self.assertEqual(e[4], str)
 
         ns['FUGA'] = 'fuga'
         self.assertIsInstance(ns['FUGA'], Fuga)
@@ -150,7 +150,7 @@ class TestContext(unittest.TestCase):
         self.assertEqual(e[1], 'set_type')
         self.assertEqual(e[2], 'PIYO')
         self.assertEqual(e[3], False)
-        self.assertEqual(e[4], unicode)
+        self.assertEqual(e[4], str)
 
         ns['PIYO'] = 'piyo'
         self.assertIsInstance(ns['PIYO'], Piyo)
diff --git a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py
index d07dd32184..ac07195d54 100644
--- a/python/mozbuild/mozbuild/test/frontend/test_sandbox.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_sandbox.py
@@ -345,7 +345,7 @@ class TestMozbuildSandbox(unittest.TestCase):
         sandbox = MozbuildSandbox(Context(VARIABLES, config))
 
         self.assertEqual(sandbox['CONFIG']['BAD_UTF8'],
-            u'\ufffd\ufffd\ufffd\ufffd:')
+            '\ufffd\ufffd\ufffd\ufffd:')
 
     def test_invalid_exports_set_base(self):
         sandbox = self.sandbox()
diff --git a/python/mozbuild/mozbuild/test/test_util.py b/python/mozbuild/mozbuild/test/test_util.py
index 27646bc290..3cbe74078e 100644
--- a/python/mozbuild/mozbuild/test/test_util.py
+++ b/python/mozbuild/mozbuild/test/test_util.py
@@ -524,7 +524,7 @@ class TestStrictOrderingOnAppendListWithFlagsFactory(unittest.TestCase):
 
     def test_strict_ordering_on_append_list_with_flags_factory_extend(self):
         FooList = StrictOrderingOnAppendListWithFlagsFactory({
-            'foo': bool, 'bar': unicode
+            'foo': bool, 'bar': str
         })
         foo = FooList(['a', 'b', 'c'])
         foo['a'].foo = True
@@ -532,7 +532,7 @@ class TestStrictOrderingOnAppendListWithFlagsFactory(unittest.TestCase):
 
         # Don't allow extending lists with different flag definitions.
         BarList = StrictOrderingOnAppendListWithFlagsFactory({
-            'foo': unicode, 'baz': bool
+            'foo': str, 'baz': bool
         })
         bar = BarList(['d', 'e', 'f'])
         bar['d'].foo = 'foo'
@@ -752,9 +752,9 @@ class TestTypedList(unittest.TestCase):
 
 class TypedTestStrictOrderingOnAppendList(unittest.TestCase):
     def test_init(self):
-        class Unicode(unicode):
+        class Unicode(str):
             def __init__(self, other):
-                if not isinstance(other, unicode):
+                if not isinstance(other, str):
                     raise ValueError()
                 super(Unicode, self).__init__(other)
 
@@ -776,7 +776,7 @@ class TypedTestStrictOrderingOnAppendList(unittest.TestCase):
 
 class TestTypedNamedTuple(unittest.TestCase):
     def test_simple(self):
-        FooBar = TypedNamedTuple('FooBar', [('foo', unicode), ('bar', int)])
+        FooBar = TypedNamedTuple('FooBar', [('foo', str), ('bar', int)])
 
         t = FooBar(foo='foo', bar=2)
         self.assertEqual(type(t), FooBar)
diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py
index 7959300bca..ba8d742aa9 100644
--- a/python/mozbuild/mozbuild/util.py
+++ b/python/mozbuild/mozbuild/util.py
@@ -78,7 +78,7 @@ def hash_file(path, hasher=None):
     return h.hexdigest()
 
 
-class EmptyValue(unicode):
+class EmptyValue(str):
     """A dummy type that behaves like an empty string and sequence.
 
     This type exists in order to support
@@ -224,7 +224,7 @@ class FileAvoidWrite(BytesIO):
         self.mode = mode
 
     def write(self, buf):
-        if isinstance(buf, unicode):
+        if isinstance(buf, str):
             buf = buf.encode('utf-8')
         BytesIO.write(self, buf)
 
@@ -1149,7 +1149,7 @@ class EnumStringComparisonError(Exception):
     pass
 
 
-class EnumString(unicode):
+class EnumString(str):
     '''A string type that only can have a limited set of values, similarly to
     an Enum, and can only be compared against that set of values.
 
@@ -1185,13 +1185,13 @@ def _escape_char(c):
     # quoting could be done with either ' or ".
     if c == "'":
         return "\\'"
-    return unicode(c.encode('unicode_escape'))
+    return str(c.encode('unicode_escape'))
 
 # Mapping table between raw characters below \x80 and their escaped
 # counterpart, when they differ
 _INDENTED_REPR_TABLE = {
     c: e
-    for c, e in [(x, _escape_char(x)) for x in list(map(unichr, list(range(128))))]
+    for c, e in [(x, _escape_char(x)) for x in list(map(chr, list(range(128))))]
     if c != e
 }
 # Regexp matching all characters to escape.
@@ -1222,7 +1222,7 @@ def indented_repr(o, indent=4):
         elif isinstance(o, bytes):
             yield 'b'
             yield repr(o)
-        elif isinstance(o, unicode):
+        elif isinstance(o, str):
             yield "'"
             # We want a readable string (non escaped unicode), but some
             # special characters need escaping (e.g. \n, \t, etc.)
@@ -1256,7 +1256,7 @@ def encode(obj, encoding='utf-8'):
         }
     if isinstance(obj, bytes):
         return obj
-    if isinstance(obj, unicode):
+    if isinstance(obj, str):
         return obj.encode(encoding)
     if isinstance(obj, Iterable):
         return [encode(i, encoding) for i in obj]
diff --git a/python/mozbuild/mozbuild/virtualenv.py b/python/mozbuild/mozbuild/virtualenv.py
index 05d30424b8..b09b66ace2 100644
--- a/python/mozbuild/mozbuild/virtualenv.py
+++ b/python/mozbuild/mozbuild/virtualenv.py
@@ -462,7 +462,7 @@ class VirtualenvManager(object):
         """
 
         execfile(self.activate_path, dict(__file__=self.activate_path))
-        if isinstance(os.environ['PATH'], unicode):
+        if isinstance(os.environ['PATH'], str):
             os.environ['PATH'] = os.environ['PATH'].encode('utf-8')
 
     def install_pip_package(self, package):
diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py
index 64766e9285..9300c4c4d5 100644
--- a/python/mozbuild/mozpack/files.py
+++ b/python/mozbuild/mozpack/files.py
@@ -57,7 +57,7 @@ else:
 
     def _copyfile(src, dest):
         # False indicates `dest` should be overwritten if it exists already.
-        if isinstance(src, unicode) and isinstance(dest, unicode):
+        if isinstance(src, str) and isinstance(dest, str):
             _CopyFileW(src, dest, False)
         elif isinstance(src, str) and isinstance(dest, str):
             _CopyFileA(src, dest, False)
diff --git a/python/mozbuild/mozpack/hg.py b/python/mozbuild/mozpack/hg.py
index 79876061f4..4c9c95d264 100644
--- a/python/mozbuild/mozpack/hg.py
+++ b/python/mozbuild/mozpack/hg.py
@@ -56,7 +56,7 @@ class MercurialNativeRevisionFinder(BaseFinder):
 
         Accepts a Mercurial localrepo and changectx instance.
         """
-        if isinstance(repo, (str, unicode)):
+        if isinstance(repo, (str, str)):
             path = repo
             repo = hg.repository(hgui.ui(), repo)
         else:
@@ -85,7 +85,7 @@ class MercurialNativeRevisionFinder(BaseFinder):
         return self._get(path)
 
     def _get(self, path):
-        if isinstance(path, unicode):
+        if isinstance(path, str):
             path = path.encode('utf-8', 'replace')
 
         try:
diff --git a/python/mozlint/mozlint/formatters/stylish.py b/python/mozlint/mozlint/formatters/stylish.py
index 6ca99c0f71..857591c02d 100644
--- a/python/mozlint/mozlint/formatters/stylish.py
+++ b/python/mozlint/mozlint/formatters/stylish.py
@@ -14,15 +14,15 @@ except ImportError:
 
 class NullTerminal(object):
     """Replacement for `blessings.Terminal()` that does no formatting."""
-    class NullCallableString(unicode):
+    class NullCallableString(str):
         """A dummy callable Unicode stolen from blessings"""
         def __new__(cls):
-            new = unicode.__new__(cls, u'')
+            new = str.__new__(cls, '')
             return new
 
         def __call__(self, *args):
             if len(args) != 1 or isinstance(args[0], int):
-                return u''
+                return ''
             return args[0]
 
     def __getattr__(self, attr):
diff --git a/python/psutil/psutil/_compat.py b/python/psutil/psutil/_compat.py
index 5b14f6a9e9..a0edb92d8d 100644
--- a/python/psutil/psutil/_compat.py
+++ b/python/psutil/psutil/_compat.py
@@ -17,17 +17,17 @@ PY3 = sys.version_info[0] == 3
 if PY3:
     long = int
     xrange = range
-    unicode = str
+    str = str
 
     def u(s):
         return s
 else:
     long = int
     xrange = xrange
-    unicode = unicode
+    str = str
 
     def u(s):
-        return unicode(s, "unicode_escape")
+        return str(s, "unicode_escape")
 
 
 # removed in 3.0, reintroduced in 3.2
diff --git a/python/psutil/psutil/_psposix.py b/python/psutil/psutil/_psposix.py
index 5bb16a386d..69bcf63595 100644
--- a/python/psutil/psutil/_psposix.py
+++ b/python/psutil/psutil/_psposix.py
@@ -13,7 +13,7 @@ import sys
 import time
 
 from ._common import sdiskusage, usage_percent, memoize
-from ._compat import PY3, unicode
+from ._compat import PY3, str
 
 
 class TimeoutExpired(Exception):
@@ -120,7 +120,7 @@ def disk_usage(path):
     try:
         st = os.statvfs(path)
     except UnicodeEncodeError:
-        if not PY3 and isinstance(path, unicode):
+        if not PY3 and isinstance(path, str):
             # this is a bug with os.statvfs() and unicode on
             # Python 2, see:
             # - https://github.com/giampaolo/psutil/issues/416
diff --git a/python/psutil/test/test_psutil.py b/python/psutil/test/test_psutil.py
index 52d782dc8a..288faa8c4b 100644
--- a/python/psutil/test/test_psutil.py
+++ b/python/psutil/test/test_psutil.py
@@ -53,7 +53,7 @@ except ImportError:
     import mock  # requires "pip install mock"
 
 import psutil
-from psutil._compat import PY3, callable, int, unicode
+from psutil._compat import PY3, callable, int, str
 
 if sys.version_info < (2, 7):
     import unittest2 as unittest  # https://pypi.python.org/pypi/unittest2
@@ -85,7 +85,7 @@ TESTFN_UNICODE = TESTFN + "ƒőő"
 TESTFILE_PREFIX = 'psutil-test-suite-'
 if not PY3:
     try:
-        TESTFN_UNICODE = unicode(TESTFN_UNICODE, sys.getfilesystemencoding())
+        TESTFN_UNICODE = str(TESTFN_UNICODE, sys.getfilesystemencoding())
     except UnicodeDecodeError:
         TESTFN_UNICODE = TESTFN + "???"
 
@@ -325,13 +325,13 @@ def check_ip_address(addr, family):
             assert 0 <= num <= 255, addr
         if ipaddress:
             if not PY3:
-                addr = unicode(addr)
+                addr = str(addr)
             ipaddress.IPv4Address(addr)
     elif family == AF_INET6:
         assert isinstance(addr, str), addr
         if ipaddress:
             if not PY3:
-                addr = unicode(addr)
+                addr = str(addr)
             ipaddress.IPv6Address(addr)
     elif family == psutil.AF_LINK:
         assert re.match('([a-fA-F0-9]{2}[:|\-]?){6}', addr) is not None, addr
@@ -2434,7 +2434,7 @@ class TestFetchAllProcesses(unittest.TestCase):
         self.assertTrue(ret >= 0)
 
     def name(self, ret):
-        self.assertIsInstance(ret, (str, unicode))
+        self.assertIsInstance(ret, (str, str))
         self.assertTrue(ret)
 
     def create_time(self, ret):
diff --git a/python/py/py/_builtin.py b/python/py/py/_builtin.py
index 1adc53cc67..5185b41273 100644
--- a/python/py/py/_builtin.py
+++ b/python/py/py/_builtin.py
@@ -165,16 +165,16 @@ if sys.version_info >= (3, 0):
 
 else:
     import builtins as builtins
-    _totext = unicode
+    _totext = str
     _basestring = basestring
-    text = unicode
+    text = str
     bytes = str
     execfile = execfile
     callable = callable
     def _isbytes(x):
         return isinstance(x, str)
     def _istext(x):
-        return isinstance(x, unicode)
+        return isinstance(x, str)
 
     def _getimself(function):
         return getattr(function, 'im_self', None)
diff --git a/python/py/py/_code/_py2traceback.py b/python/py/py/_code/_py2traceback.py
index d65e27cb73..5ac0a27f7b 100644
--- a/python/py/py/_code/_py2traceback.py
+++ b/python/py/py/_code/_py2traceback.py
@@ -70,7 +70,7 @@ def _format_final_exc_line(etype, value):
 
 def _some_str(value):
     try:
-        return unicode(value)
+        return str(value)
     except Exception:
         try:
             return str(value)
diff --git a/python/py/py/_code/code.py b/python/py/py/_code/code.py
index 7d60410184..889363647e 100644
--- a/python/py/py/_code/code.py
+++ b/python/py/py/_code/code.py
@@ -419,7 +419,7 @@ class ExceptionInfo(object):
     def __unicode__(self):
         entry = self.traceback[-1]
         loc = ReprFileLocation(entry.path, entry.lineno + 1, self.exconly())
-        return unicode(loc)
+        return str(loc)
 
 
 class FormattedExcinfo(object):
diff --git a/python/py/py/_io/capture.py b/python/py/py/_io/capture.py
index 1563eeb3c2..38f685bdc9 100644
--- a/python/py/py/_io/capture.py
+++ b/python/py/py/_io/capture.py
@@ -11,8 +11,8 @@ except ImportError:
 if sys.version_info < (3,0):
     class TextIO(StringIO):
         def write(self, data):
-            if not isinstance(data, unicode):
-                data = unicode(data, getattr(self, '_encoding', 'UTF-8'), 'replace')
+            if not isinstance(data, str):
+                data = str(data, getattr(self, '_encoding', 'UTF-8'), 'replace')
             StringIO.write(self, data)
 else:
     TextIO = StringIO
@@ -22,7 +22,7 @@ try:
 except ImportError:
     class BytesIO(StringIO):
         def write(self, data):
-            if isinstance(data, unicode):
+            if isinstance(data, str):
                 raise TypeError("not a byte value: %r" %(data,))
             StringIO.write(self, data)
 
@@ -122,7 +122,7 @@ class EncodedFile(object):
         self.encoding = encoding
 
     def write(self, obj):
-        if isinstance(obj, unicode):
+        if isinstance(obj, str):
             obj = obj.encode(self.encoding)
         elif isinstance(obj, str):
             pass
diff --git a/python/py/py/_process/cmdexec.py b/python/py/py/_process/cmdexec.py
index f83a249402..31296d94ca 100644
--- a/python/py/py/_process/cmdexec.py
+++ b/python/py/py/_process/cmdexec.py
@@ -21,8 +21,8 @@ def cmdexec(cmd):
             default_encoding = sys.getdefaultencoding() # jython may not have it
         except AttributeError:
             default_encoding = sys.stdout.encoding or 'UTF-8'
-        out = unicode(out, process.stdout.encoding or default_encoding)
-        err = unicode(err, process.stderr.encoding or default_encoding)
+        out = str(out, process.stdout.encoding or default_encoding)
+        err = str(err, process.stderr.encoding or default_encoding)
     status = process.poll()
     if status:
         raise ExecutionFailed(status, status, cmd, out, err)
diff --git a/python/py/py/_xmlgen.py b/python/py/py/_xmlgen.py
index 553747bb5d..8f4c12dc3d 100644
--- a/python/py/py/_xmlgen.py
+++ b/python/py/py/_xmlgen.py
@@ -9,14 +9,14 @@ import sys, re
 if sys.version_info >= (3,0):
     def u(s):
         return s
-    def unicode(x, errors=None):
+    def str(x, errors=None):
         if hasattr(x, '__unicode__'):
             return x.__unicode__()
         return str(x)
 else:
     def u(s):
-        return unicode(s)
-    unicode = unicode
+        return str(s)
+    str = str
 
 
 class NamespaceMetaclass(type):
@@ -45,10 +45,10 @@ class Tag(list):
         self.attr = self.Attr(**kwargs)
 
     def __unicode__(self):
-        return self.unicode(indent=0)
+        return self.str(indent=0)
     __str__ = __unicode__
 
-    def unicode(self, indent=2):
+    def str(self, indent=2):
         l = []
         SimpleUnicodeVisitor(l.append, indent).visit(self)
         return u("").join(l)
@@ -64,7 +64,7 @@ Namespace = NamespaceMetaclass('Namespace', (object, ), {
 })
 
 class HtmlTag(Tag):
-    def unicode(self, indent=2):
+    def str(self, indent=2):
         l = []
         HtmlVisitor(l.append, indent, shortempty=False).visit(self)
         return u("").join(l)
@@ -129,7 +129,7 @@ class SimpleUnicodeVisitor(object):
     # to avoid clashes with the tag name object
     def __object(self, obj):
         #self.write(obj)
-        self.write(escape(unicode(obj)))
+        self.write(escape(str(obj)))
 
     def raw(self, obj):
         self.write(obj.uniobj)
@@ -186,7 +186,7 @@ class SimpleUnicodeVisitor(object):
             if isinstance(value, raw):
                 insert = value.uniobj
             else:
-                insert = escape(unicode(value))
+                insert = escape(str(value))
             return ' %s="%s"' % (name, insert)
 
     def getstyle(self, tag):
@@ -245,9 +245,9 @@ class _escape:
     def __call__(self, ustring):
         """ xml-escape the given unicode string. """
         try:
-            ustring = unicode(ustring)
+            ustring = str(ustring)
         except UnicodeDecodeError:
-            ustring = unicode(ustring, 'utf-8', errors='replace')
+            ustring = str(ustring, 'utf-8', errors='replace')
         return self.charef_rex.sub(self._replacer, ustring)
 
 escape = _escape()
diff --git a/python/pystache/pystache/common.py b/python/pystache/pystache/common.py
index fb266dd8b5..0ee26ac4b3 100644
--- a/python/pystache/pystache/common.py
+++ b/python/pystache/pystache/common.py
@@ -15,7 +15,7 @@ def _get_string_types():
     if version_info < (3, ):
          return basestring
     # The latter evaluates to "bytes" in Python 3 -- even after conversion by 2to3.
-    return (unicode, type(u"a".encode('utf-8')))
+    return (str, type("a".encode('utf-8')))
 
 
 _STRING_TYPES = _get_string_types()
diff --git a/python/pystache/pystache/defaults.py b/python/pystache/pystache/defaults.py
index bcfdf4cd3a..2fab0e0ece 100644
--- a/python/pystache/pystache/defaults.py
+++ b/python/pystache/pystache/defaults.py
@@ -39,7 +39,7 @@ STRING_ENCODING = sys.getdefaultencoding()
 FILE_ENCODING = sys.getdefaultencoding()
 
 # The delimiters to start with when parsing.
-DELIMITERS = (u'{{', u'}}')
+DELIMITERS = ('{{', '}}')
 
 # How to handle missing tags when rendering a template.
 MISSING_TAGS = MissingTags.ignore
diff --git a/python/pystache/pystache/loader.py b/python/pystache/pystache/loader.py
index d4a7e5310f..54b5ff1596 100644
--- a/python/pystache/pystache/loader.py
+++ b/python/pystache/pystache/loader.py
@@ -24,7 +24,7 @@ def _make_to_unicode():
         """
         if encoding is None:
             encoding = defaults.STRING_ENCODING
-        return unicode(s, encoding, defaults.DECODE_ERRORS)
+        return str(s, encoding, defaults.DECODE_ERRORS)
     return to_unicode
 
 
@@ -86,7 +86,7 @@ class Loader(object):
     def _make_locator(self):
         return Locator(extension=self.extension)
 
-    def unicode(self, s, encoding=None):
+    def str(self, s, encoding=None):
         """
         Convert a string to unicode using the given encoding, and return it.
 
@@ -104,8 +104,8 @@ class Loader(object):
             Defaults to None.
 
         """
-        if isinstance(s, unicode):
-            return unicode(s)
+        if isinstance(s, str):
+            return str(s)
 
         return self.to_unicode(s, encoding)
 
@@ -119,7 +119,7 @@ class Loader(object):
         if encoding is None:
             encoding = self.file_encoding
 
-        return self.unicode(b, encoding)
+        return self.str(b, encoding)
 
     def load_file(self, file_name):
         """
diff --git a/python/pystache/pystache/parsed.py b/python/pystache/pystache/parsed.py
index f017dd44aa..75d417de96 100644
--- a/python/pystache/pystache/parsed.py
+++ b/python/pystache/pystache/parsed.py
@@ -41,10 +41,10 @@ class ParsedTemplate(object):
         """
         # We avoid use of the ternary operator for Python 2.4 support.
         def get_unicode(node):
-            if type(node) is unicode:
+            if type(node) is str:
                 return node
             return node.render(engine, context)
         parts = list(map(get_unicode, self._parse_tree))
         s = ''.join(parts)
 
-        return unicode(s)
+        return str(s)
diff --git a/python/pystache/pystache/parser.py b/python/pystache/pystache/parser.py
index 9a4fba235b..50fd39f91f 100644
--- a/python/pystache/pystache/parser.py
+++ b/python/pystache/pystache/parser.py
@@ -11,8 +11,8 @@ from pystache import defaults
 from pystache.parsed import ParsedTemplate
 
 
-END_OF_LINE_CHARACTERS = [u'\r', u'\n']
-NON_BLANK_RE = re.compile(ur'^(.)', re.M)
+END_OF_LINE_CHARACTERS = ['\r', '\n']
+NON_BLANK_RE = re.compile(r'^(.)', re.M)
 
 
 # TODO: add some unit tests for this.
@@ -35,7 +35,7 @@ def parse(template, delimiters=None):
     ['Hey ', _SectionNode(key='who', index_begin=12, index_end=21, parsed=[_EscapeNode(key='name'), '!'])]
 
     """
-    if type(template) is not unicode:
+    if type(template) is not str:
         raise Exception("Template is not unicode: %s" % type(template))
     parser = _Parser(delimiters)
     return parser.parse(template)
@@ -94,7 +94,7 @@ class _CommentNode(object):
         return _format(self)
 
     def render(self, engine, context):
-        return u''
+        return ''
 
 
 class _ChangeNode(object):
@@ -106,7 +106,7 @@ class _ChangeNode(object):
         return _format(self)
 
     def render(self, engine, context):
-        return u''
+        return ''
 
 
 class _EscapeNode(object):
@@ -147,7 +147,7 @@ class _PartialNode(object):
     def render(self, engine, context):
         template = engine.resolve_partial(self.key)
         # Indent before rendering.
-        template = re.sub(NON_BLANK_RE, self.indent + ur'\1', template)
+        template = re.sub(NON_BLANK_RE, self.indent + r'\1', template)
 
         return engine.render(template, context)
 
@@ -168,7 +168,7 @@ class _InvertedNode(object):
         # Note that lambdas are considered truthy for inverted sections
         # per the spec.
         if data:
-            return u''
+            return ''
         return self.parsed_section.render(engine, context)
 
 
@@ -218,7 +218,7 @@ class _SectionNode(object):
             parts.append(self.parsed.render(engine, context))
             context.pop()
 
-        return unicode(''.join(parts))
+        return str(''.join(parts))
 
 
 class _Parser(object):
diff --git a/python/pystache/pystache/renderengine.py b/python/pystache/pystache/renderengine.py
index c797b1765a..2f1e341960 100644
--- a/python/pystache/pystache/renderengine.py
+++ b/python/pystache/pystache/renderengine.py
@@ -160,7 +160,7 @@ class RenderEngine(object):
         if not is_string(val):
             # In case the template is an integer, for example.
             val = self.to_str(val)
-        if type(val) is not unicode:
+        if type(val) is not str:
             val = self.literal(val)
         return self.render(val, context, delimiters)
 
diff --git a/python/pystache/pystache/renderer.py b/python/pystache/pystache/renderer.py
index ff6a90c64b..508572f62a 100644
--- a/python/pystache/pystache/renderer.py
+++ b/python/pystache/pystache/renderer.py
@@ -177,16 +177,16 @@ class Renderer(object):
         """
         # We type-check to avoid "TypeError: decoding Unicode is not supported".
         # We avoid the Python ternary operator for Python 2.4 support.
-        if isinstance(s, unicode):
+        if isinstance(s, str):
             return s
-        return self.unicode(s)
+        return self.str(s)
 
     def _to_unicode_hard(self, s):
         """
         Convert a basestring to a string with type unicode (not subclass).
 
         """
-        return unicode(self._to_unicode_soft(s))
+        return str(self._to_unicode_soft(s))
 
     def _escape_to_unicode(self, s):
         """
@@ -195,9 +195,9 @@ class Renderer(object):
         Returns a unicode string (not subclass).
 
         """
-        return unicode(self.escape(self._to_unicode_soft(s)))
+        return str(self.escape(self._to_unicode_soft(s)))
 
-    def unicode(self, b, encoding=None):
+    def str(self, b, encoding=None):
         """
         Convert a byte string to unicode, using string_encoding and decode_errors.
 
@@ -222,7 +222,7 @@ class Renderer(object):
 
         # TODO: Wrap UnicodeDecodeErrors with a message about setting
         # the string_encoding and decode_errors attributes.
-        return unicode(b, encoding, self.decode_errors)
+        return str(b, encoding, self.decode_errors)
 
     def _make_loader(self):
         """
@@ -230,7 +230,7 @@ class Renderer(object):
 
         """
         return Loader(file_encoding=self.file_encoding, extension=self.file_extension,
-                      to_unicode=self.unicode, search_dirs=self.search_dirs)
+                      to_unicode=self.str, search_dirs=self.search_dirs)
 
     def _make_load_template(self):
         """
@@ -299,7 +299,7 @@ class Renderer(object):
             try:
                 return load_partial(name)
             except TemplateNotFoundError:
-                return u''
+                return ''
 
         return resolve_partial
 
@@ -316,7 +316,7 @@ class Renderer(object):
             try:
                 return context_get(stack, name)
             except KeyNotFoundError:
-                return u''
+                return ''
 
         return resolve_context
 
diff --git a/python/pystache/pystache/specloader.py b/python/pystache/pystache/specloader.py
index 3a77d4c528..a82d52a1ea 100644
--- a/python/pystache/pystache/specloader.py
+++ b/python/pystache/pystache/specloader.py
@@ -83,7 +83,7 @@ class SpecLoader(object):
 
         """
         if spec.template is not None:
-            return self.loader.unicode(spec.template, spec.template_encoding)
+            return self.loader.str(spec.template, spec.template_encoding)
 
         path = self._find(spec)
 
diff --git a/python/pytest/_pytest/_code/_py2traceback.py b/python/pytest/_pytest/_code/_py2traceback.py
index a830d9899a..b48e47f842 100644
--- a/python/pytest/_pytest/_code/_py2traceback.py
+++ b/python/pytest/_pytest/_code/_py2traceback.py
@@ -49,7 +49,7 @@ def format_exception_only(etype, value):
         if badline is not None:
             if isinstance(badline, bytes):  # python 2 only
                 badline = badline.decode('utf-8', 'replace')
-            lines.append(u'    %s\n' % badline.strip())
+            lines.append('    %s\n' % badline.strip())
             if offset is not None:
                 caretspace = badline.rstrip('\n')[:offset].lstrip()
                 # non-space whitespace (likes tabs) must be kept for alignment
@@ -72,7 +72,7 @@ def _format_final_exc_line(etype, value):
 
 def _some_str(value):
     try:
-        return unicode(value)
+        return str(value)
     except Exception:
         try:
             return str(value)
diff --git a/python/pytest/_pytest/_code/code.py b/python/pytest/_pytest/_code/code.py
index b90c618f8b..b3c4317c9c 100644
--- a/python/pytest/_pytest/_code/code.py
+++ b/python/pytest/_pytest/_code/code.py
@@ -425,7 +425,7 @@ class ExceptionInfo(object):
     def __unicode__(self):
         entry = self.traceback[-1]
         loc = ReprFileLocation(entry.path, entry.lineno + 1, self.exconly())
-        return unicode(loc)
+        return str(loc)
 
 
 class FormattedExcinfo(object):
diff --git a/python/pytest/_pytest/capture.py b/python/pytest/_pytest/capture.py
index 3895a714aa..f360d99b48 100644
--- a/python/pytest/_pytest/capture.py
+++ b/python/pytest/_pytest/capture.py
@@ -12,7 +12,7 @@ import py
 import pytest
 
 from py.io import TextIO
-unicode = py.builtin.text
+str = py.builtin.text
 
 patchsysdict = {0: 'stdin', 1: 'stdout', 2: 'stderr'}
 
@@ -227,7 +227,7 @@ class EncodedFile(object):
         self.encoding = encoding
 
     def write(self, obj):
-        if isinstance(obj, unicode):
+        if isinstance(obj, str):
             obj = obj.encode(self.encoding, "replace")
         self.buffer.write(obj)
 
diff --git a/python/pytest/_pytest/junitxml.py b/python/pytest/_pytest/junitxml.py
index f4de1343ed..5cd4f3516b 100644
--- a/python/pytest/_pytest/junitxml.py
+++ b/python/pytest/_pytest/junitxml.py
@@ -19,8 +19,8 @@ import pytest
 if sys.version_info[0] < 3:
     from codecs import open
 else:
-    unichr = chr
-    unicode = str
+    chr = chr
+    str = str
     long = int
 
 
@@ -37,11 +37,11 @@ _legal_ranges = (
     (0x20, 0x7E), (0x80, 0xD7FF), (0xE000, 0xFFFD), (0x10000, 0x10FFFF),
 )
 _legal_xml_re = [
-    unicode("%s-%s") % (unichr(low), unichr(high))
+    str("%s-%s") % (chr(low), chr(high))
     for (low, high) in _legal_ranges if low < sys.maxunicode
 ]
-_legal_xml_re = [unichr(x) for x in _legal_chars] + _legal_xml_re
-illegal_xml_re = re.compile(unicode('[^%s]') % unicode('').join(_legal_xml_re))
+_legal_xml_re = [chr(x) for x in _legal_chars] + _legal_xml_re
+illegal_xml_re = re.compile(str('[^%s]') % str('').join(_legal_xml_re))
 del _legal_chars
 del _legal_ranges
 del _legal_xml_re
@@ -53,9 +53,9 @@ def bin_xml_escape(arg):
     def repl(matchobj):
         i = ord(matchobj.group())
         if i <= 0xFF:
-            return unicode('#x%02X') % i
+            return str('#x%02X') % i
         else:
-            return unicode('#x%04X') % i
+            return str('#x%04X') % i
 
     return py.xml.raw(illegal_xml_re.sub(repl, py.xml.escape(arg)))
 
@@ -139,7 +139,7 @@ class _NodeReporter(object):
         else:
             if hasattr(report.longrepr, "reprcrash"):
                 message = report.longrepr.reprcrash.message
-            elif isinstance(report.longrepr, (unicode, str)):
+            elif isinstance(report.longrepr, (str, str)):
                 message = report.longrepr
             else:
                 message = str(report.longrepr)
@@ -179,7 +179,7 @@ class _NodeReporter(object):
         self._write_captured_output(report)
 
     def finalize(self):
-        data = self.to_xml().unicode(indent=0)
+        data = self.to_xml().str(indent=0)
         self.__dict__.clear()
         self.to_xml = lambda: py.xml.raw(data)
 
@@ -379,7 +379,7 @@ class LogXML(object):
             failures=self.stats['failure'],
             skips=self.stats['skipped'],
             tests=numtests,
-            time="%.3f" % suite_time_delta, ).unicode(indent=0))
+            time="%.3f" % suite_time_delta, ).str(indent=0))
         logfile.close()
 
     def pytest_terminal_summary(self, terminalreporter):
diff --git a/python/pytest/_pytest/python.py b/python/pytest/_pytest/python.py
index 503cb7e325..4444526296 100644
--- a/python/pytest/_pytest/python.py
+++ b/python/pytest/_pytest/python.py
@@ -1127,7 +1127,7 @@ def _idval(val, argname, idx, idfn):
         return str(val)
     elif isclass(val) and hasattr(val, '__name__'):
         return val.__name__
-    elif _PY2 and isinstance(val, unicode):
+    elif _PY2 and isinstance(val, str):
         # special case for python 2: if a unicode string is
         # convertible to ascii, return it as an str() object instead
         try:
diff --git a/python/pytoml/pytoml/parser.py b/python/pytoml/pytoml/parser.py
index 4ff7b03f5b..fc8d13aca5 100644
--- a/python/pytoml/pytoml/parser.py
+++ b/python/pytoml/pytoml/parser.py
@@ -2,7 +2,7 @@ import string, re, sys, datetime
 from .core import TomlError
 
 if sys.version_info[0] == 2:
-    _chr = unichr
+    _chr = chr
 else:
     _chr = chr
 
diff --git a/python/pytoml/pytoml/writer.py b/python/pytoml/pytoml/writer.py
index 45e99cc53c..11e1ba2d4b 100644
--- a/python/pytoml/pytoml/writer.py
+++ b/python/pytoml/pytoml/writer.py
@@ -3,7 +3,7 @@ import io, datetime, sys
 
 if sys.version_info[0] == 3:
     long = int
-    unicode = str
+    str = str
 
 
 def dumps(obj, sort_keys=False):
@@ -59,10 +59,10 @@ def _format_value(v):
     if isinstance(v, bool):
         return 'true' if v else 'false'
     if isinstance(v, int) or isinstance(v, int):
-        return unicode(v)
+        return str(v)
     if isinstance(v, float):
         return '{0:.17f}'.format(v)
-    elif isinstance(v, unicode) or isinstance(v, bytes):
+    elif isinstance(v, str) or isinstance(v, bytes):
         return _escape_string(v)
     elif isinstance(v, datetime.datetime):
         offs = v.utcoffset()
diff --git a/python/pyyaml/examples/yaml-highlight/yaml_hl.py b/python/pyyaml/examples/yaml-highlight/yaml_hl.py
index d6f7bf4eb2..8558a68f3d 100755
--- a/python/pyyaml/examples/yaml-highlight/yaml_hl.py
+++ b/python/pyyaml/examples/yaml-highlight/yaml_hl.py
@@ -29,10 +29,10 @@ class Style:
     def __setstate__(self, state):
         self.__init__(**state)
 
-yaml.add_path_resolver(u'tag:yaml.org,2002:python/object:__main__.Style',
+yaml.add_path_resolver('tag:yaml.org,2002:python/object:__main__.Style',
         [None], dict)
-yaml.add_path_resolver(u'tag:yaml.org,2002:pairs',
-        [None, u'replaces'], list)
+yaml.add_path_resolver('tag:yaml.org,2002:pairs',
+        [None, 'replaces'], list)
 
 class YAMLHighlight:
 
@@ -51,11 +51,11 @@ class YAMLHighlight:
     def highlight(self):
         input = self.input.read()
         if input.startswith(codecs.BOM_UTF16_LE):
-            input = unicode(input, 'utf-16-le')
+            input = str(input, 'utf-16-le')
         elif input.startswith(codecs.BOM_UTF16_BE):
-            input = unicode(input, 'utf-16-be')
+            input = str(input, 'utf-16-be')
         else:
-            input = unicode(input, 'utf-8')
+            input = str(input, 'utf-8')
         substitutions = self.style.substitutions
         tokens = yaml.scan(input)
         events = yaml.parse(input)
@@ -90,7 +90,7 @@ class YAMLHighlight:
                 position = index
             chunks.append(substitution)
         chunks.reverse()
-        result = u''.join(chunks)
+        result = ''.join(chunks)
         if self.style.header:
             self.output.write(self.style.header)
         self.output.write(result.encode('utf-8'))
diff --git a/python/pyyaml/lib/yaml/composer.py b/python/pyyaml/lib/yaml/composer.py
index ea7d7c66d9..e0b71c4d13 100644
--- a/python/pyyaml/lib/yaml/composer.py
+++ b/python/pyyaml/lib/yaml/composer.py
@@ -88,7 +88,7 @@ class Composer(object):
     def compose_scalar_node(self, anchor):
         event = self.get_event()
         tag = event.tag
-        if tag is None or tag == u'!':
+        if tag is None or tag == '!':
             tag = self.resolve(ScalarNode, event.value, event.implicit)
         node = ScalarNode(tag, event.value,
                 event.start_mark, event.end_mark, style=event.style)
@@ -99,7 +99,7 @@ class Composer(object):
     def compose_sequence_node(self, anchor):
         start_event = self.get_event()
         tag = start_event.tag
-        if tag is None or tag == u'!':
+        if tag is None or tag == '!':
             tag = self.resolve(SequenceNode, None, start_event.implicit)
         node = SequenceNode(tag, [],
                 start_event.start_mark, None,
@@ -117,7 +117,7 @@ class Composer(object):
     def compose_mapping_node(self, anchor):
         start_event = self.get_event()
         tag = start_event.tag
-        if tag is None or tag == u'!':
+        if tag is None or tag == '!':
             tag = self.resolve(MappingNode, None, start_event.implicit)
         node = MappingNode(tag, [],
                 start_event.start_mark, None,
diff --git a/python/pyyaml/lib/yaml/constructor.py b/python/pyyaml/lib/yaml/constructor.py
index d68cfa8fb4..1eb27cd3ea 100644
--- a/python/pyyaml/lib/yaml/constructor.py
+++ b/python/pyyaml/lib/yaml/constructor.py
@@ -163,7 +163,7 @@ class SafeConstructor(BaseConstructor):
     def construct_scalar(self, node):
         if isinstance(node, MappingNode):
             for key_node, value_node in node.value:
-                if key_node.tag == u'tag:yaml.org,2002:value':
+                if key_node.tag == 'tag:yaml.org,2002:value':
                     return self.construct_scalar(value_node)
         return BaseConstructor.construct_scalar(self, node)
 
@@ -172,7 +172,7 @@ class SafeConstructor(BaseConstructor):
         index = 0
         while index < len(node.value):
             key_node, value_node = node.value[index]
-            if key_node.tag == u'tag:yaml.org,2002:merge':
+            if key_node.tag == 'tag:yaml.org,2002:merge':
                 del node.value[index]
                 if isinstance(value_node, MappingNode):
                     self.flatten_mapping(value_node)
@@ -194,8 +194,8 @@ class SafeConstructor(BaseConstructor):
                     raise ConstructorError("while constructing a mapping", node.start_mark,
                             "expected a mapping or list of mappings for merging, but found %s"
                             % value_node.id, value_node.start_mark)
-            elif key_node.tag == u'tag:yaml.org,2002:value':
-                key_node.tag = u'tag:yaml.org,2002:str'
+            elif key_node.tag == 'tag:yaml.org,2002:value':
+                key_node.tag = 'tag:yaml.org,2002:str'
                 index += 1
             else:
                 index += 1
@@ -212,12 +212,12 @@ class SafeConstructor(BaseConstructor):
         return None
 
     bool_values = {
-        u'yes':     True,
-        u'no':      False,
-        u'true':    True,
-        u'false':   False,
-        u'on':      True,
-        u'off':     False,
+        'yes':     True,
+        'no':      False,
+        'true':    True,
+        'false':   False,
+        'on':      True,
+        'off':     False,
     }
 
     def construct_yaml_bool(self, node):
@@ -290,7 +290,7 @@ class SafeConstructor(BaseConstructor):
                     "failed to decode base64 data: %s" % exc, node.start_mark) 
 
     timestamp_regexp = re.compile(
-            ur'''^(?P[0-9][0-9][0-9][0-9])
+            r'''^(?P[0-9][0-9][0-9][0-9])
                 -(?P[0-9][0-9]?)
                 -(?P[0-9][0-9]?)
                 (?:(?:[Tt]|[ \t]+)
@@ -414,51 +414,51 @@ class SafeConstructor(BaseConstructor):
                 node.start_mark)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:null',
+        'tag:yaml.org,2002:null',
         SafeConstructor.construct_yaml_null)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:bool',
+        'tag:yaml.org,2002:bool',
         SafeConstructor.construct_yaml_bool)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:int',
+        'tag:yaml.org,2002:int',
         SafeConstructor.construct_yaml_int)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:float',
+        'tag:yaml.org,2002:float',
         SafeConstructor.construct_yaml_float)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:binary',
+        'tag:yaml.org,2002:binary',
         SafeConstructor.construct_yaml_binary)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:timestamp',
+        'tag:yaml.org,2002:timestamp',
         SafeConstructor.construct_yaml_timestamp)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:omap',
+        'tag:yaml.org,2002:omap',
         SafeConstructor.construct_yaml_omap)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:pairs',
+        'tag:yaml.org,2002:pairs',
         SafeConstructor.construct_yaml_pairs)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:set',
+        'tag:yaml.org,2002:set',
         SafeConstructor.construct_yaml_set)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:str',
+        'tag:yaml.org,2002:str',
         SafeConstructor.construct_yaml_str)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:seq',
+        'tag:yaml.org,2002:seq',
         SafeConstructor.construct_yaml_seq)
 
 SafeConstructor.add_constructor(
-        u'tag:yaml.org,2002:map',
+        'tag:yaml.org,2002:map',
         SafeConstructor.construct_yaml_map)
 
 SafeConstructor.add_constructor(None,
@@ -496,7 +496,7 @@ class Constructor(SafeConstructor):
         if not name:
             raise ConstructorError("while constructing a Python object", mark,
                     "expected non-empty name appended to the tag", mark)
-        if u'.' in name:
+        if '.' in name:
             module_name, object_name = name.rsplit('.', 1)
         else:
             module_name = '__builtin__'
@@ -610,66 +610,66 @@ class Constructor(SafeConstructor):
         return self.construct_python_object_apply(suffix, node, newobj=True)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/none',
+    'tag:yaml.org,2002:python/none',
     Constructor.construct_yaml_null)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/bool',
+    'tag:yaml.org,2002:python/bool',
     Constructor.construct_yaml_bool)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/str',
+    'tag:yaml.org,2002:python/str',
     Constructor.construct_python_str)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/unicode',
+    'tag:yaml.org,2002:python/unicode',
     Constructor.construct_python_unicode)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/int',
+    'tag:yaml.org,2002:python/int',
     Constructor.construct_yaml_int)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/long',
+    'tag:yaml.org,2002:python/long',
     Constructor.construct_python_long)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/float',
+    'tag:yaml.org,2002:python/float',
     Constructor.construct_yaml_float)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/complex',
+    'tag:yaml.org,2002:python/complex',
     Constructor.construct_python_complex)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/list',
+    'tag:yaml.org,2002:python/list',
     Constructor.construct_yaml_seq)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/tuple',
+    'tag:yaml.org,2002:python/tuple',
     Constructor.construct_python_tuple)
 
 Constructor.add_constructor(
-    u'tag:yaml.org,2002:python/dict',
+    'tag:yaml.org,2002:python/dict',
     Constructor.construct_yaml_map)
 
 Constructor.add_multi_constructor(
-    u'tag:yaml.org,2002:python/name:',
+    'tag:yaml.org,2002:python/name:',
     Constructor.construct_python_name)
 
 Constructor.add_multi_constructor(
-    u'tag:yaml.org,2002:python/module:',
+    'tag:yaml.org,2002:python/module:',
     Constructor.construct_python_module)
 
 Constructor.add_multi_constructor(
-    u'tag:yaml.org,2002:python/object:',
+    'tag:yaml.org,2002:python/object:',
     Constructor.construct_python_object)
 
 Constructor.add_multi_constructor(
-    u'tag:yaml.org,2002:python/object/apply:',
+    'tag:yaml.org,2002:python/object/apply:',
     Constructor.construct_python_object_apply)
 
 Constructor.add_multi_constructor(
-    u'tag:yaml.org,2002:python/object/new:',
+    'tag:yaml.org,2002:python/object/new:',
     Constructor.construct_python_object_new)
 
diff --git a/python/pyyaml/lib/yaml/emitter.py b/python/pyyaml/lib/yaml/emitter.py
index 16bc2f7165..3b6e3e211d 100644
--- a/python/pyyaml/lib/yaml/emitter.py
+++ b/python/pyyaml/lib/yaml/emitter.py
@@ -31,8 +31,8 @@ class ScalarAnalysis(object):
 class Emitter(object):
 
     DEFAULT_TAG_PREFIXES = {
-        u'!' : u'!',
-        u'tag:yaml.org,2002:' : u'!!',
+        '!' : '!',
+        'tag:yaml.org,2002:' : '!!',
     }
 
     def __init__(self, stream, canonical=None, indent=None, width=None,
@@ -88,8 +88,8 @@ class Emitter(object):
         self.best_width = 80
         if width and width > self.best_indent*2:
             self.best_width = width
-        self.best_line_break = u'\n'
-        if line_break in [u'\r', u'\n', u'\r\n']:
+        self.best_line_break = '\n'
+        if line_break in ['\r', '\n', '\r\n']:
             self.best_line_break = line_break
 
         # Tag prefixes.
@@ -178,7 +178,7 @@ class Emitter(object):
     def expect_document_start(self, first=False):
         if isinstance(self.event, DocumentStartEvent):
             if (self.event.version or self.event.tags) and self.open_ended:
-                self.write_indicator(u'...', True)
+                self.write_indicator('...', True)
                 self.write_indent()
             if self.event.version:
                 version_text = self.prepare_version(self.event.version)
@@ -198,13 +198,13 @@ class Emitter(object):
                     and not self.check_empty_document())
             if not implicit:
                 self.write_indent()
-                self.write_indicator(u'---', True)
+                self.write_indicator('---', True)
                 if self.canonical:
                     self.write_indent()
             self.state = self.expect_document_root
         elif isinstance(self.event, StreamEndEvent):
             if self.open_ended:
-                self.write_indicator(u'...', True)
+                self.write_indicator('...', True)
                 self.write_indent()
             self.write_stream_end()
             self.state = self.expect_nothing
@@ -216,7 +216,7 @@ class Emitter(object):
         if isinstance(self.event, DocumentEndEvent):
             self.write_indent()
             if self.event.explicit:
-                self.write_indicator(u'...', True)
+                self.write_indicator('...', True)
                 self.write_indent()
             self.flush_stream()
             self.state = self.expect_document_start
@@ -239,7 +239,7 @@ class Emitter(object):
         if isinstance(self.event, AliasEvent):
             self.expect_alias()
         elif isinstance(self.event, (ScalarEvent, CollectionStartEvent)):
-            self.process_anchor(u'&')
+            self.process_anchor('&')
             self.process_tag()
             if isinstance(self.event, ScalarEvent):
                 self.expect_scalar()
@@ -261,7 +261,7 @@ class Emitter(object):
     def expect_alias(self):
         if self.event.anchor is None:
             raise EmitterError("anchor is not specified for alias")
-        self.process_anchor(u'*')
+        self.process_anchor('*')
         self.state = self.states.pop()
 
     def expect_scalar(self):
@@ -273,7 +273,7 @@ class Emitter(object):
     # Flow sequence handlers.
 
     def expect_flow_sequence(self):
-        self.write_indicator(u'[', True, whitespace=True)
+        self.write_indicator('[', True, whitespace=True)
         self.flow_level += 1
         self.increase_indent(flow=True)
         self.state = self.expect_first_flow_sequence_item
@@ -282,7 +282,7 @@ class Emitter(object):
         if isinstance(self.event, SequenceEndEvent):
             self.indent = self.indents.pop()
             self.flow_level -= 1
-            self.write_indicator(u']', False)
+            self.write_indicator(']', False)
             self.state = self.states.pop()
         else:
             if self.canonical or self.column > self.best_width:
@@ -295,12 +295,12 @@ class Emitter(object):
             self.indent = self.indents.pop()
             self.flow_level -= 1
             if self.canonical:
-                self.write_indicator(u',', False)
+                self.write_indicator(',', False)
                 self.write_indent()
-            self.write_indicator(u']', False)
+            self.write_indicator(']', False)
             self.state = self.states.pop()
         else:
-            self.write_indicator(u',', False)
+            self.write_indicator(',', False)
             if self.canonical or self.column > self.best_width:
                 self.write_indent()
             self.states.append(self.expect_flow_sequence_item)
@@ -309,7 +309,7 @@ class Emitter(object):
     # Flow mapping handlers.
 
     def expect_flow_mapping(self):
-        self.write_indicator(u'{', True, whitespace=True)
+        self.write_indicator('{', True, whitespace=True)
         self.flow_level += 1
         self.increase_indent(flow=True)
         self.state = self.expect_first_flow_mapping_key
@@ -318,7 +318,7 @@ class Emitter(object):
         if isinstance(self.event, MappingEndEvent):
             self.indent = self.indents.pop()
             self.flow_level -= 1
-            self.write_indicator(u'}', False)
+            self.write_indicator('}', False)
             self.state = self.states.pop()
         else:
             if self.canonical or self.column > self.best_width:
@@ -327,7 +327,7 @@ class Emitter(object):
                 self.states.append(self.expect_flow_mapping_simple_value)
                 self.expect_node(mapping=True, simple_key=True)
             else:
-                self.write_indicator(u'?', True)
+                self.write_indicator('?', True)
                 self.states.append(self.expect_flow_mapping_value)
                 self.expect_node(mapping=True)
 
@@ -336,31 +336,31 @@ class Emitter(object):
             self.indent = self.indents.pop()
             self.flow_level -= 1
             if self.canonical:
-                self.write_indicator(u',', False)
+                self.write_indicator(',', False)
                 self.write_indent()
-            self.write_indicator(u'}', False)
+            self.write_indicator('}', False)
             self.state = self.states.pop()
         else:
-            self.write_indicator(u',', False)
+            self.write_indicator(',', False)
             if self.canonical or self.column > self.best_width:
                 self.write_indent()
             if not self.canonical and self.check_simple_key():
                 self.states.append(self.expect_flow_mapping_simple_value)
                 self.expect_node(mapping=True, simple_key=True)
             else:
-                self.write_indicator(u'?', True)
+                self.write_indicator('?', True)
                 self.states.append(self.expect_flow_mapping_value)
                 self.expect_node(mapping=True)
 
     def expect_flow_mapping_simple_value(self):
-        self.write_indicator(u':', False)
+        self.write_indicator(':', False)
         self.states.append(self.expect_flow_mapping_key)
         self.expect_node(mapping=True)
 
     def expect_flow_mapping_value(self):
         if self.canonical or self.column > self.best_width:
             self.write_indent()
-        self.write_indicator(u':', True)
+        self.write_indicator(':', True)
         self.states.append(self.expect_flow_mapping_key)
         self.expect_node(mapping=True)
 
@@ -380,7 +380,7 @@ class Emitter(object):
             self.state = self.states.pop()
         else:
             self.write_indent()
-            self.write_indicator(u'-', True, indention=True)
+            self.write_indicator('-', True, indention=True)
             self.states.append(self.expect_block_sequence_item)
             self.expect_node(sequence=True)
 
@@ -403,18 +403,18 @@ class Emitter(object):
                 self.states.append(self.expect_block_mapping_simple_value)
                 self.expect_node(mapping=True, simple_key=True)
             else:
-                self.write_indicator(u'?', True, indention=True)
+                self.write_indicator('?', True, indention=True)
                 self.states.append(self.expect_block_mapping_value)
                 self.expect_node(mapping=True)
 
     def expect_block_mapping_simple_value(self):
-        self.write_indicator(u':', False)
+        self.write_indicator(':', False)
         self.states.append(self.expect_block_mapping_key)
         self.expect_node(mapping=True)
 
     def expect_block_mapping_value(self):
         self.write_indent()
-        self.write_indicator(u':', True, indention=True)
+        self.write_indicator(':', True, indention=True)
         self.states.append(self.expect_block_mapping_key)
         self.expect_node(mapping=True)
 
@@ -433,7 +433,7 @@ class Emitter(object):
             return False
         event = self.events[0]
         return (isinstance(event, ScalarEvent) and event.anchor is None
-                and event.tag is None and event.implicit and event.value == u'')
+                and event.tag is None and event.implicit and event.value == '')
 
     def check_simple_key(self):
         length = 0
@@ -478,7 +478,7 @@ class Emitter(object):
                 self.prepared_tag = None
                 return
             if self.event.implicit[0] and tag is None:
-                tag = u'!'
+                tag = '!'
                 self.prepared_tag = None
         else:
             if (not self.canonical or tag is None) and self.event.implicit:
@@ -541,17 +541,17 @@ class Emitter(object):
         major, minor = version
         if major != 1:
             raise EmitterError("unsupported YAML version: %d.%d" % (major, minor))
-        return u'%d.%d' % (major, minor)
+        return '%d.%d' % (major, minor)
 
     def prepare_tag_handle(self, handle):
         if not handle:
             raise EmitterError("tag handle must not be empty")
-        if handle[0] != u'!' or handle[-1] != u'!':
+        if handle[0] != '!' or handle[-1] != '!':
             raise EmitterError("tag handle must start and end with '!': %r"
                     % (handle.encode('utf-8')))
         for ch in handle[1:-1]:
-            if not (u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'  \
-                    or ch in u'-_'):
+            if not ('0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'  \
+                    or ch in '-_'):
                 raise EmitterError("invalid character %r in the tag handle: %r"
                         % (ch.encode('utf-8'), handle.encode('utf-8')))
         return handle
@@ -561,12 +561,12 @@ class Emitter(object):
             raise EmitterError("tag prefix must not be empty")
         chunks = []
         start = end = 0
-        if prefix[0] == u'!':
+        if prefix[0] == '!':
             end = 1
         while end < len(prefix):
             ch = prefix[end]
-            if u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'   \
-                    or ch in u'-;/?!:@&=+$,_.~*\'()[]':
+            if '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'   \
+                    or ch in '-;/?!:@&=+$,_.~*\'()[]':
                 end += 1
             else:
                 if start < end:
@@ -574,15 +574,15 @@ class Emitter(object):
                 start = end = end+1
                 data = ch.encode('utf-8')
                 for ch in data:
-                    chunks.append(u'%%%02X' % ord(ch))
+                    chunks.append('%%%02X' % ord(ch))
         if start < end:
             chunks.append(prefix[start:end])
-        return u''.join(chunks)
+        return ''.join(chunks)
 
     def prepare_tag(self, tag):
         if not tag:
             raise EmitterError("tag must not be empty")
-        if tag == u'!':
+        if tag == '!':
             return tag
         handle = None
         suffix = tag
@@ -590,16 +590,16 @@ class Emitter(object):
         prefixes.sort()
         for prefix in prefixes:
             if tag.startswith(prefix)   \
-                    and (prefix == u'!' or len(prefix) < len(tag)):
+                    and (prefix == '!' or len(prefix) < len(tag)):
                 handle = self.tag_prefixes[prefix]
                 suffix = tag[len(prefix):]
         chunks = []
         start = end = 0
         while end < len(suffix):
             ch = suffix[end]
-            if u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'   \
-                    or ch in u'-;/?:@&=+$,_.~*\'()[]'   \
-                    or (ch == u'!' and handle != u'!'):
+            if '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'   \
+                    or ch in '-;/?:@&=+$,_.~*\'()[]'   \
+                    or (ch == '!' and handle != '!'):
                 end += 1
             else:
                 if start < end:
@@ -607,21 +607,21 @@ class Emitter(object):
                 start = end = end+1
                 data = ch.encode('utf-8')
                 for ch in data:
-                    chunks.append(u'%%%02X' % ord(ch))
+                    chunks.append('%%%02X' % ord(ch))
         if start < end:
             chunks.append(suffix[start:end])
-        suffix_text = u''.join(chunks)
+        suffix_text = ''.join(chunks)
         if handle:
-            return u'%s%s' % (handle, suffix_text)
+            return '%s%s' % (handle, suffix_text)
         else:
-            return u'!<%s>' % suffix_text
+            return '!<%s>' % suffix_text
 
     def prepare_anchor(self, anchor):
         if not anchor:
             raise EmitterError("anchor must not be empty")
         for ch in anchor:
-            if not (u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'  \
-                    or ch in u'-_'):
+            if not ('0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'  \
+                    or ch in '-_'):
                 raise EmitterError("invalid character %r in the anchor: %r"
                         % (ch.encode('utf-8'), anchor.encode('utf-8')))
         return anchor
@@ -650,7 +650,7 @@ class Emitter(object):
         space_break = False
 
         # Check document indicators.
-        if scalar.startswith(u'---') or scalar.startswith(u'...'):
+        if scalar.startswith('---') or scalar.startswith('...'):
             block_indicators = True
             flow_indicators = True
 
@@ -659,7 +659,7 @@ class Emitter(object):
 
         # Last character or followed by a whitespace.
         followed_by_whitespace = (len(scalar) == 1 or
-                scalar[1] in u'\0 \t\r\n\x85\u2028\u2029')
+                scalar[1] in '\0 \t\r\n\x85\u2028\u2029')
 
         # The previous character is a space.
         previous_space = False
@@ -674,34 +674,34 @@ class Emitter(object):
             # Check for indicators.
             if index == 0:
                 # Leading indicators are special characters.
-                if ch in u'#,[]{}&*!|>\'\"%@`': 
+                if ch in '#,[]{}&*!|>\'\"%@`': 
                     flow_indicators = True
                     block_indicators = True
-                if ch in u'?:':
+                if ch in '?:':
                     flow_indicators = True
                     if followed_by_whitespace:
                         block_indicators = True
-                if ch == u'-' and followed_by_whitespace:
+                if ch == '-' and followed_by_whitespace:
                     flow_indicators = True
                     block_indicators = True
             else:
                 # Some indicators cannot appear within a scalar as well.
-                if ch in u',?[]{}':
+                if ch in ',?[]{}':
                     flow_indicators = True
-                if ch == u':':
+                if ch == ':':
                     flow_indicators = True
                     if followed_by_whitespace:
                         block_indicators = True
-                if ch == u'#' and preceeded_by_whitespace:
+                if ch == '#' and preceeded_by_whitespace:
                     flow_indicators = True
                     block_indicators = True
 
             # Check for line breaks, special, and unicode characters.
-            if ch in u'\n\x85\u2028\u2029':
+            if ch in '\n\x85\u2028\u2029':
                 line_breaks = True
-            if not (ch == u'\n' or u'\x20' <= ch <= u'\x7E'):
-                if (ch == u'\x85' or u'\xA0' <= ch <= u'\uD7FF'
-                        or u'\uE000' <= ch <= u'\uFFFD') and ch != u'\uFEFF':
+            if not (ch == '\n' or '\x20' <= ch <= '\x7E'):
+                if (ch == '\x85' or '\xA0' <= ch <= '\uD7FF'
+                        or '\uE000' <= ch <= '\uFFFD') and ch != '\uFEFF':
                     unicode_characters = True
                     if not self.allow_unicode:
                         special_characters = True
@@ -709,7 +709,7 @@ class Emitter(object):
                     special_characters = True
 
             # Detect important whitespace combinations.
-            if ch == u' ':
+            if ch == ' ':
                 if index == 0:
                     leading_space = True
                 if index == len(scalar)-1:
@@ -718,7 +718,7 @@ class Emitter(object):
                     break_space = True
                 previous_space = True
                 previous_break = False
-            elif ch in u'\n\x85\u2028\u2029':
+            elif ch in '\n\x85\u2028\u2029':
                 if index == 0:
                     leading_break = True
                 if index == len(scalar)-1:
@@ -733,9 +733,9 @@ class Emitter(object):
 
             # Prepare for the next character.
             index += 1
-            preceeded_by_whitespace = (ch in u'\0 \t\r\n\x85\u2028\u2029')
+            preceeded_by_whitespace = (ch in '\0 \t\r\n\x85\u2028\u2029')
             followed_by_whitespace = (index+1 >= len(scalar) or
-                    scalar[index+1] in u'\0 \t\r\n\x85\u2028\u2029')
+                    scalar[index+1] in '\0 \t\r\n\x85\u2028\u2029')
 
         # Let's decide what styles are allowed.
         allow_flow_plain = True
@@ -794,7 +794,7 @@ class Emitter(object):
     def write_stream_start(self):
         # Write BOM if needed.
         if self.encoding and self.encoding.startswith('utf-16'):
-            self.stream.write(u'\uFEFF'.encode(self.encoding))
+            self.stream.write('\uFEFF'.encode(self.encoding))
 
     def write_stream_end(self):
         self.flush_stream()
@@ -804,7 +804,7 @@ class Emitter(object):
         if self.whitespace or not need_whitespace:
             data = indicator
         else:
-            data = u' '+indicator
+            data = ' '+indicator
         self.whitespace = whitespace
         self.indention = self.indention and indention
         self.column += len(data)
@@ -820,7 +820,7 @@ class Emitter(object):
             self.write_line_break()
         if self.column < indent:
             self.whitespace = True
-            data = u' '*(indent-self.column)
+            data = ' '*(indent-self.column)
             self.column = indent
             if self.encoding:
                 data = data.encode(self.encoding)
@@ -838,14 +838,14 @@ class Emitter(object):
         self.stream.write(data)
 
     def write_version_directive(self, version_text):
-        data = u'%%YAML %s' % version_text
+        data = '%%YAML %s' % version_text
         if self.encoding:
             data = data.encode(self.encoding)
         self.stream.write(data)
         self.write_line_break()
 
     def write_tag_directive(self, handle_text, prefix_text):
-        data = u'%%TAG %s %s' % (handle_text, prefix_text)
+        data = '%%TAG %s %s' % (handle_text, prefix_text)
         if self.encoding:
             data = data.encode(self.encoding)
         self.stream.write(data)
@@ -854,7 +854,7 @@ class Emitter(object):
     # Scalar streams.
 
     def write_single_quoted(self, text, split=True):
-        self.write_indicator(u'\'', True)
+        self.write_indicator('\'', True)
         spaces = False
         breaks = False
         start = end = 0
@@ -863,7 +863,7 @@ class Emitter(object):
             if end < len(text):
                 ch = text[end]
             if spaces:
-                if ch is None or ch != u' ':
+                if ch is None or ch != ' ':
                     if start+1 == end and self.column > self.best_width and split   \
                             and start != 0 and end != len(text):
                         self.write_indent()
@@ -875,18 +875,18 @@ class Emitter(object):
                         self.stream.write(data)
                     start = end
             elif breaks:
-                if ch is None or ch not in u'\n\x85\u2028\u2029':
-                    if text[start] == u'\n':
+                if ch is None or ch not in '\n\x85\u2028\u2029':
+                    if text[start] == '\n':
                         self.write_line_break()
                     for br in text[start:end]:
-                        if br == u'\n':
+                        if br == '\n':
                             self.write_line_break()
                         else:
                             self.write_line_break(br)
                     self.write_indent()
                     start = end
             else:
-                if ch is None or ch in u' \n\x85\u2028\u2029' or ch == u'\'':
+                if ch is None or ch in ' \n\x85\u2028\u2029' or ch == '\'':
                     if start < end:
                         data = text[start:end]
                         self.column += len(data)
@@ -894,49 +894,49 @@ class Emitter(object):
                             data = data.encode(self.encoding)
                         self.stream.write(data)
                         start = end
-            if ch == u'\'':
-                data = u'\'\''
+            if ch == '\'':
+                data = '\'\''
                 self.column += 2
                 if self.encoding:
                     data = data.encode(self.encoding)
                 self.stream.write(data)
                 start = end + 1
             if ch is not None:
-                spaces = (ch == u' ')
-                breaks = (ch in u'\n\x85\u2028\u2029')
+                spaces = (ch == ' ')
+                breaks = (ch in '\n\x85\u2028\u2029')
             end += 1
-        self.write_indicator(u'\'', False)
+        self.write_indicator('\'', False)
 
     ESCAPE_REPLACEMENTS = {
-        u'\0':      u'0',
-        u'\x07':    u'a',
-        u'\x08':    u'b',
-        u'\x09':    u't',
-        u'\x0A':    u'n',
-        u'\x0B':    u'v',
-        u'\x0C':    u'f',
-        u'\x0D':    u'r',
-        u'\x1B':    u'e',
-        u'\"':      u'\"',
-        u'\\':      u'\\',
-        u'\x85':    u'N',
-        u'\xA0':    u'_',
-        u'\u2028':  u'L',
-        u'\u2029':  u'P',
+        '\0':      '0',
+        '\x07':    'a',
+        '\x08':    'b',
+        '\x09':    't',
+        '\x0A':    'n',
+        '\x0B':    'v',
+        '\x0C':    'f',
+        '\x0D':    'r',
+        '\x1B':    'e',
+        '\"':      '\"',
+        '\\':      '\\',
+        '\x85':    'N',
+        '\xA0':    '_',
+        '\u2028':  'L',
+        '\u2029':  'P',
     }
 
     def write_double_quoted(self, text, split=True):
-        self.write_indicator(u'"', True)
+        self.write_indicator('"', True)
         start = end = 0
         while end <= len(text):
             ch = None
             if end < len(text):
                 ch = text[end]
-            if ch is None or ch in u'"\\\x85\u2028\u2029\uFEFF' \
-                    or not (u'\x20' <= ch <= u'\x7E'
+            if ch is None or ch in '"\\\x85\u2028\u2029\uFEFF' \
+                    or not ('\x20' <= ch <= '\x7E'
                         or (self.allow_unicode
-                            and (u'\xA0' <= ch <= u'\uD7FF'
-                                or u'\uE000' <= ch <= u'\uFFFD'))):
+                            and ('\xA0' <= ch <= '\uD7FF'
+                                or '\uE000' <= ch <= '\uFFFD'))):
                 if start < end:
                     data = text[start:end]
                     self.column += len(data)
@@ -946,21 +946,21 @@ class Emitter(object):
                     start = end
                 if ch is not None:
                     if ch in self.ESCAPE_REPLACEMENTS:
-                        data = u'\\'+self.ESCAPE_REPLACEMENTS[ch]
-                    elif ch <= u'\xFF':
-                        data = u'\\x%02X' % ord(ch)
-                    elif ch <= u'\uFFFF':
-                        data = u'\\u%04X' % ord(ch)
+                        data = '\\'+self.ESCAPE_REPLACEMENTS[ch]
+                    elif ch <= '\xFF':
+                        data = '\\x%02X' % ord(ch)
+                    elif ch <= '\uFFFF':
+                        data = '\\u%04X' % ord(ch)
                     else:
-                        data = u'\\U%08X' % ord(ch)
+                        data = '\\U%08X' % ord(ch)
                     self.column += len(data)
                     if self.encoding:
                         data = data.encode(self.encoding)
                     self.stream.write(data)
                     start = end+1
-            if 0 < end < len(text)-1 and (ch == u' ' or start >= end)   \
+            if 0 < end < len(text)-1 and (ch == ' ' or start >= end)   \
                     and self.column+(end-start) > self.best_width and split:
-                data = text[start:end]+u'\\'
+                data = text[start:end]+'\\'
                 if start < end:
                     start = end
                 self.column += len(data)
@@ -970,30 +970,30 @@ class Emitter(object):
                 self.write_indent()
                 self.whitespace = False
                 self.indention = False
-                if text[start] == u' ':
-                    data = u'\\'
+                if text[start] == ' ':
+                    data = '\\'
                     self.column += len(data)
                     if self.encoding:
                         data = data.encode(self.encoding)
                     self.stream.write(data)
             end += 1
-        self.write_indicator(u'"', False)
+        self.write_indicator('"', False)
 
     def determine_block_hints(self, text):
-        hints = u''
+        hints = ''
         if text:
-            if text[0] in u' \n\x85\u2028\u2029':
-                hints += unicode(self.best_indent)
-            if text[-1] not in u'\n\x85\u2028\u2029':
-                hints += u'-'
-            elif len(text) == 1 or text[-2] in u'\n\x85\u2028\u2029':
-                hints += u'+'
+            if text[0] in ' \n\x85\u2028\u2029':
+                hints += str(self.best_indent)
+            if text[-1] not in '\n\x85\u2028\u2029':
+                hints += '-'
+            elif len(text) == 1 or text[-2] in '\n\x85\u2028\u2029':
+                hints += '+'
         return hints
 
     def write_folded(self, text):
         hints = self.determine_block_hints(text)
-        self.write_indicator(u'>'+hints, True)
-        if hints[-1:] == u'+':
+        self.write_indicator('>'+hints, True)
+        if hints[-1:] == '+':
             self.open_ended = True
         self.write_line_break()
         leading_space = True
@@ -1005,13 +1005,13 @@ class Emitter(object):
             if end < len(text):
                 ch = text[end]
             if breaks:
-                if ch is None or ch not in u'\n\x85\u2028\u2029':
-                    if not leading_space and ch is not None and ch != u' '  \
-                            and text[start] == u'\n':
+                if ch is None or ch not in '\n\x85\u2028\u2029':
+                    if not leading_space and ch is not None and ch != ' '  \
+                            and text[start] == '\n':
                         self.write_line_break()
-                    leading_space = (ch == u' ')
+                    leading_space = (ch == ' ')
                     for br in text[start:end]:
-                        if br == u'\n':
+                        if br == '\n':
                             self.write_line_break()
                         else:
                             self.write_line_break(br)
@@ -1019,7 +1019,7 @@ class Emitter(object):
                         self.write_indent()
                     start = end
             elif spaces:
-                if ch != u' ':
+                if ch != ' ':
                     if start+1 == end and self.column > self.best_width:
                         self.write_indent()
                     else:
@@ -1030,7 +1030,7 @@ class Emitter(object):
                         self.stream.write(data)
                     start = end
             else:
-                if ch is None or ch in u' \n\x85\u2028\u2029':
+                if ch is None or ch in ' \n\x85\u2028\u2029':
                     data = text[start:end]
                     self.column += len(data)
                     if self.encoding:
@@ -1040,14 +1040,14 @@ class Emitter(object):
                         self.write_line_break()
                     start = end
             if ch is not None:
-                breaks = (ch in u'\n\x85\u2028\u2029')
-                spaces = (ch == u' ')
+                breaks = (ch in '\n\x85\u2028\u2029')
+                spaces = (ch == ' ')
             end += 1
 
     def write_literal(self, text):
         hints = self.determine_block_hints(text)
-        self.write_indicator(u'|'+hints, True)
-        if hints[-1:] == u'+':
+        self.write_indicator('|'+hints, True)
+        if hints[-1:] == '+':
             self.open_ended = True
         self.write_line_break()
         breaks = True
@@ -1057,9 +1057,9 @@ class Emitter(object):
             if end < len(text):
                 ch = text[end]
             if breaks:
-                if ch is None or ch not in u'\n\x85\u2028\u2029':
+                if ch is None or ch not in '\n\x85\u2028\u2029':
                     for br in text[start:end]:
-                        if br == u'\n':
+                        if br == '\n':
                             self.write_line_break()
                         else:
                             self.write_line_break(br)
@@ -1067,7 +1067,7 @@ class Emitter(object):
                         self.write_indent()
                     start = end
             else:
-                if ch is None or ch in u'\n\x85\u2028\u2029':
+                if ch is None or ch in '\n\x85\u2028\u2029':
                     data = text[start:end]
                     if self.encoding:
                         data = data.encode(self.encoding)
@@ -1076,7 +1076,7 @@ class Emitter(object):
                         self.write_line_break()
                     start = end
             if ch is not None:
-                breaks = (ch in u'\n\x85\u2028\u2029')
+                breaks = (ch in '\n\x85\u2028\u2029')
             end += 1
 
     def write_plain(self, text, split=True):
@@ -1085,7 +1085,7 @@ class Emitter(object):
         if not text:
             return
         if not self.whitespace:
-            data = u' '
+            data = ' '
             self.column += len(data)
             if self.encoding:
                 data = data.encode(self.encoding)
@@ -1100,7 +1100,7 @@ class Emitter(object):
             if end < len(text):
                 ch = text[end]
             if spaces:
-                if ch != u' ':
+                if ch != ' ':
                     if start+1 == end and self.column > self.best_width and split:
                         self.write_indent()
                         self.whitespace = False
@@ -1113,11 +1113,11 @@ class Emitter(object):
                         self.stream.write(data)
                     start = end
             elif breaks:
-                if ch not in u'\n\x85\u2028\u2029':
-                    if text[start] == u'\n':
+                if ch not in '\n\x85\u2028\u2029':
+                    if text[start] == '\n':
                         self.write_line_break()
                     for br in text[start:end]:
-                        if br == u'\n':
+                        if br == '\n':
                             self.write_line_break()
                         else:
                             self.write_line_break(br)
@@ -1126,7 +1126,7 @@ class Emitter(object):
                     self.indention = False
                     start = end
             else:
-                if ch is None or ch in u' \n\x85\u2028\u2029':
+                if ch is None or ch in ' \n\x85\u2028\u2029':
                     data = text[start:end]
                     self.column += len(data)
                     if self.encoding:
@@ -1134,7 +1134,7 @@ class Emitter(object):
                     self.stream.write(data)
                     start = end
             if ch is not None:
-                spaces = (ch == u' ')
-                breaks = (ch in u'\n\x85\u2028\u2029')
+                spaces = (ch == ' ')
+                breaks = (ch in '\n\x85\u2028\u2029')
             end += 1
 
diff --git a/python/pyyaml/lib/yaml/error.py b/python/pyyaml/lib/yaml/error.py
index 577686db5f..e68d5f4525 100644
--- a/python/pyyaml/lib/yaml/error.py
+++ b/python/pyyaml/lib/yaml/error.py
@@ -16,7 +16,7 @@ class Mark(object):
             return None
         head = ''
         start = self.pointer
-        while start > 0 and self.buffer[start-1] not in u'\0\r\n\x85\u2028\u2029':
+        while start > 0 and self.buffer[start-1] not in '\0\r\n\x85\u2028\u2029':
             start -= 1
             if self.pointer-start > max_length/2-1:
                 head = ' ... '
@@ -24,7 +24,7 @@ class Mark(object):
                 break
         tail = ''
         end = self.pointer
-        while end < len(self.buffer) and self.buffer[end] not in u'\0\r\n\x85\u2028\u2029':
+        while end < len(self.buffer) and self.buffer[end] not in '\0\r\n\x85\u2028\u2029':
             end += 1
             if end-self.pointer > max_length/2-1:
                 tail = ' ... '
diff --git a/python/pyyaml/lib/yaml/parser.py b/python/pyyaml/lib/yaml/parser.py
index 1bf2196e30..e8d7751e9c 100644
--- a/python/pyyaml/lib/yaml/parser.py
+++ b/python/pyyaml/lib/yaml/parser.py
@@ -74,8 +74,8 @@ class Parser(object):
     # do not give many comments here.
 
     DEFAULT_TAGS = {
-        u'!':   u'!',
-        u'!!':  u'tag:yaml.org,2002:',
+        '!':   '!',
+        '!!':  'tag:yaml.org,2002:',
     }
 
     def __init__(self):
@@ -219,7 +219,7 @@ class Parser(object):
         self.tag_handles = {}
         while self.check_token(DirectiveToken):
             token = self.get_token()
-            if token.name == u'YAML':
+            if token.name == 'YAML':
                 if self.yaml_version is not None:
                     raise ParserError(None, None,
                             "found duplicate YAML directive", token.start_mark)
@@ -229,7 +229,7 @@ class Parser(object):
                             "found incompatible YAML document (version 1.* is required)",
                             token.start_mark)
                 self.yaml_version = token.value
-            elif token.name == u'TAG':
+            elif token.name == 'TAG':
                 handle, prefix = token.value
                 if handle in self.tag_handles:
                     raise ParserError(None, None,
@@ -315,7 +315,7 @@ class Parser(object):
             if start_mark is None:
                 start_mark = end_mark = self.peek_token().start_mark
             event = None
-            implicit = (tag is None or tag == u'!')
+            implicit = (tag is None or tag == '!')
             if indentless_sequence and self.check_token(BlockEntryToken):
                 end_mark = self.peek_token().end_mark
                 event = SequenceStartEvent(anchor, tag, implicit,
@@ -325,7 +325,7 @@ class Parser(object):
                 if self.check_token(ScalarToken):
                     token = self.get_token()
                     end_mark = token.end_mark
-                    if (token.plain and tag is None) or tag == u'!':
+                    if (token.plain and tag is None) or tag == '!':
                         implicit = (True, False)
                     elif tag is None:
                         implicit = (False, True)
@@ -357,7 +357,7 @@ class Parser(object):
                 elif anchor is not None or tag is not None:
                     # Empty scalars are allowed even if a tag or an anchor is
                     # specified.
-                    event = ScalarEvent(anchor, tag, (implicit, False), u'',
+                    event = ScalarEvent(anchor, tag, (implicit, False), '',
                             start_mark, end_mark)
                     self.state = self.states.pop()
                 else:
@@ -585,5 +585,5 @@ class Parser(object):
         return self.process_empty_scalar(self.peek_token().start_mark)
 
     def process_empty_scalar(self, mark):
-        return ScalarEvent(None, None, (True, False), u'', mark, mark)
+        return ScalarEvent(None, None, (True, False), '', mark, mark)
 
diff --git a/python/pyyaml/lib/yaml/reader.py b/python/pyyaml/lib/yaml/reader.py
index 2d7106d2ec..c6d98ff1a7 100644
--- a/python/pyyaml/lib/yaml/reader.py
+++ b/python/pyyaml/lib/yaml/reader.py
@@ -61,7 +61,7 @@ class Reader(object):
         self.stream = None
         self.stream_pointer = 0
         self.eof = True
-        self.buffer = u''
+        self.buffer = ''
         self.pointer = 0
         self.raw_buffer = None
         self.raw_decode = None
@@ -69,10 +69,10 @@ class Reader(object):
         self.index = 0
         self.line = 0
         self.column = 0
-        if isinstance(stream, unicode):
+        if isinstance(stream, str):
             self.name = ""
             self.check_printable(stream)
-            self.buffer = stream+u'\0'
+            self.buffer = stream+'\0'
         elif isinstance(stream, str):
             self.name = ""
             self.raw_buffer = stream
@@ -103,11 +103,11 @@ class Reader(object):
             ch = self.buffer[self.pointer]
             self.pointer += 1
             self.index += 1
-            if ch in u'\n\x85\u2028\u2029'  \
-                    or (ch == u'\r' and self.buffer[self.pointer] != u'\n'):
+            if ch in '\n\x85\u2028\u2029'  \
+                    or (ch == '\r' and self.buffer[self.pointer] != '\n'):
                 self.line += 1
                 self.column = 0
-            elif ch != u'\uFEFF':
+            elif ch != '\uFEFF':
                 self.column += 1
             length -= 1
 
@@ -122,7 +122,7 @@ class Reader(object):
     def determine_encoding(self):
         while not self.eof and len(self.raw_buffer) < 2:
             self.update_raw()
-        if not isinstance(self.raw_buffer, unicode):
+        if not isinstance(self.raw_buffer, str):
             if self.raw_buffer.startswith(codecs.BOM_UTF16_LE):
                 self.raw_decode = codecs.utf_16_le_decode
                 self.encoding = 'utf-16-le'
@@ -134,7 +134,7 @@ class Reader(object):
                 self.encoding = 'utf-8'
         self.update(1)
 
-    NON_PRINTABLE = re.compile(u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
+    NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
     def check_printable(self, data):
         match = self.NON_PRINTABLE.search(data)
         if match:
@@ -170,7 +170,7 @@ class Reader(object):
             self.buffer += data
             self.raw_buffer = self.raw_buffer[converted:]
             if self.eof:
-                self.buffer += u'\0'
+                self.buffer += '\0'
                 self.raw_buffer = None
                 break
 
diff --git a/python/pyyaml/lib/yaml/representer.py b/python/pyyaml/lib/yaml/representer.py
index 68d1b7b866..79d666a4db 100644
--- a/python/pyyaml/lib/yaml/representer.py
+++ b/python/pyyaml/lib/yaml/representer.py
@@ -66,7 +66,7 @@ class BaseRepresenter(object):
                 elif None in self.yaml_representers:
                     node = self.yaml_representers[None](self, data)
                 else:
-                    node = ScalarNode(None, unicode(data))
+                    node = ScalarNode(None, str(data))
         #if alias_key is not None:
         #    self.represented_objects[alias_key] = node
         return node
@@ -141,44 +141,44 @@ class SafeRepresenter(BaseRepresenter):
     def ignore_aliases(self, data):
         if data in [None, ()]:
             return True
-        if isinstance(data, (str, unicode, bool, int, float)):
+        if isinstance(data, (str, str, bool, int, float)):
             return True
 
     def represent_none(self, data):
-        return self.represent_scalar(u'tag:yaml.org,2002:null',
-                u'null')
+        return self.represent_scalar('tag:yaml.org,2002:null',
+                'null')
 
     def represent_str(self, data):
         tag = None
         style = None
         try:
-            data = unicode(data, 'ascii')
-            tag = u'tag:yaml.org,2002:str'
+            data = str(data, 'ascii')
+            tag = 'tag:yaml.org,2002:str'
         except UnicodeDecodeError:
             try:
-                data = unicode(data, 'utf-8')
-                tag = u'tag:yaml.org,2002:str'
+                data = str(data, 'utf-8')
+                tag = 'tag:yaml.org,2002:str'
             except UnicodeDecodeError:
                 data = data.encode('base64')
-                tag = u'tag:yaml.org,2002:binary'
+                tag = 'tag:yaml.org,2002:binary'
                 style = '|'
         return self.represent_scalar(tag, data, style=style)
 
     def represent_unicode(self, data):
-        return self.represent_scalar(u'tag:yaml.org,2002:str', data)
+        return self.represent_scalar('tag:yaml.org,2002:str', data)
 
     def represent_bool(self, data):
         if data:
-            value = u'true'
+            value = 'true'
         else:
-            value = u'false'
-        return self.represent_scalar(u'tag:yaml.org,2002:bool', value)
+            value = 'false'
+        return self.represent_scalar('tag:yaml.org,2002:bool', value)
 
     def represent_int(self, data):
-        return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))
+        return self.represent_scalar('tag:yaml.org,2002:int', str(data))
 
     def represent_long(self, data):
-        return self.represent_scalar(u'tag:yaml.org,2002:int', unicode(data))
+        return self.represent_scalar('tag:yaml.org,2002:int', str(data))
 
     inf_value = 1e300
     while repr(inf_value) != repr(inf_value*inf_value):
@@ -186,13 +186,13 @@ class SafeRepresenter(BaseRepresenter):
 
     def represent_float(self, data):
         if data != data or (data == 0.0 and data == 1.0):
-            value = u'.nan'
+            value = '.nan'
         elif data == self.inf_value:
-            value = u'.inf'
+            value = '.inf'
         elif data == -self.inf_value:
-            value = u'-.inf'
+            value = '-.inf'
         else:
-            value = unicode(repr(data)).lower()
+            value = str(repr(data)).lower()
             # Note that in some cases `repr(data)` represents a float number
             # without the decimal parts.  For instance:
             #   >>> repr(1e17)
@@ -200,9 +200,9 @@ class SafeRepresenter(BaseRepresenter):
             # Unfortunately, this is not a valid float representation according
             # to the definition of the `!!float` tag.  We fix this by adding
             # '.0' before the 'e' symbol.
-            if u'.' not in value and u'e' in value:
-                value = value.replace(u'e', u'.0e', 1)
-        return self.represent_scalar(u'tag:yaml.org,2002:float', value)
+            if '.' not in value and 'e' in value:
+                value = value.replace('e', '.0e', 1)
+        return self.represent_scalar('tag:yaml.org,2002:float', value)
 
     def represent_list(self, data):
         #pairs = (len(data) > 0 and isinstance(data, list))
@@ -212,7 +212,7 @@ class SafeRepresenter(BaseRepresenter):
         #            pairs = False
         #            break
         #if not pairs:
-            return self.represent_sequence(u'tag:yaml.org,2002:seq', data)
+            return self.represent_sequence('tag:yaml.org,2002:seq', data)
         #value = []
         #for item_key, item_value in data:
         #    value.append(self.represent_mapping(u'tag:yaml.org,2002:map',
@@ -220,21 +220,21 @@ class SafeRepresenter(BaseRepresenter):
         #return SequenceNode(u'tag:yaml.org,2002:pairs', value)
 
     def represent_dict(self, data):
-        return self.represent_mapping(u'tag:yaml.org,2002:map', data)
+        return self.represent_mapping('tag:yaml.org,2002:map', data)
 
     def represent_set(self, data):
         value = {}
         for key in data:
             value[key] = None
-        return self.represent_mapping(u'tag:yaml.org,2002:set', value)
+        return self.represent_mapping('tag:yaml.org,2002:set', value)
 
     def represent_date(self, data):
-        value = unicode(data.isoformat())
-        return self.represent_scalar(u'tag:yaml.org,2002:timestamp', value)
+        value = str(data.isoformat())
+        return self.represent_scalar('tag:yaml.org,2002:timestamp', value)
 
     def represent_datetime(self, data):
-        value = unicode(data.isoformat(' '))
-        return self.represent_scalar(u'tag:yaml.org,2002:timestamp', value)
+        value = str(data.isoformat(' '))
+        return self.represent_scalar('tag:yaml.org,2002:timestamp', value)
 
     def represent_yaml_object(self, tag, data, cls, flow_style=None):
         if hasattr(data, '__getstate__'):
@@ -252,7 +252,7 @@ SafeRepresenter.add_representer(type(None),
 SafeRepresenter.add_representer(str,
         SafeRepresenter.represent_str)
 
-SafeRepresenter.add_representer(unicode,
+SafeRepresenter.add_representer(str,
         SafeRepresenter.represent_unicode)
 
 SafeRepresenter.add_representer(bool,
@@ -294,15 +294,15 @@ class Representer(SafeRepresenter):
         tag = None
         style = None
         try:
-            data = unicode(data, 'ascii')
-            tag = u'tag:yaml.org,2002:str'
+            data = str(data, 'ascii')
+            tag = 'tag:yaml.org,2002:str'
         except UnicodeDecodeError:
             try:
-                data = unicode(data, 'utf-8')
-                tag = u'tag:yaml.org,2002:python/str'
+                data = str(data, 'utf-8')
+                tag = 'tag:yaml.org,2002:python/str'
             except UnicodeDecodeError:
                 data = data.encode('base64')
-                tag = u'tag:yaml.org,2002:binary'
+                tag = 'tag:yaml.org,2002:binary'
                 style = '|'
         return self.represent_scalar(tag, data, style=style)
 
@@ -310,38 +310,38 @@ class Representer(SafeRepresenter):
         tag = None
         try:
             data.encode('ascii')
-            tag = u'tag:yaml.org,2002:python/unicode'
+            tag = 'tag:yaml.org,2002:python/unicode'
         except UnicodeEncodeError:
-            tag = u'tag:yaml.org,2002:str'
+            tag = 'tag:yaml.org,2002:str'
         return self.represent_scalar(tag, data)
 
     def represent_long(self, data):
-        tag = u'tag:yaml.org,2002:int'
+        tag = 'tag:yaml.org,2002:int'
         if int(data) is not data:
-            tag = u'tag:yaml.org,2002:python/long'
-        return self.represent_scalar(tag, unicode(data))
+            tag = 'tag:yaml.org,2002:python/long'
+        return self.represent_scalar(tag, str(data))
 
     def represent_complex(self, data):
         if data.imag == 0.0:
-            data = u'%r' % data.real
+            data = '%r' % data.real
         elif data.real == 0.0:
-            data = u'%rj' % data.imag
+            data = '%rj' % data.imag
         elif data.imag > 0:
-            data = u'%r+%rj' % (data.real, data.imag)
+            data = '%r+%rj' % (data.real, data.imag)
         else:
-            data = u'%r%rj' % (data.real, data.imag)
-        return self.represent_scalar(u'tag:yaml.org,2002:python/complex', data)
+            data = '%r%rj' % (data.real, data.imag)
+        return self.represent_scalar('tag:yaml.org,2002:python/complex', data)
 
     def represent_tuple(self, data):
-        return self.represent_sequence(u'tag:yaml.org,2002:python/tuple', data)
+        return self.represent_sequence('tag:yaml.org,2002:python/tuple', data)
 
     def represent_name(self, data):
-        name = u'%s.%s' % (data.__module__, data.__name__)
-        return self.represent_scalar(u'tag:yaml.org,2002:python/name:'+name, u'')
+        name = '%s.%s' % (data.__module__, data.__name__)
+        return self.represent_scalar('tag:yaml.org,2002:python/name:'+name, '')
 
     def represent_module(self, data):
         return self.represent_scalar(
-                u'tag:yaml.org,2002:python/module:'+data.__name__, u'')
+                'tag:yaml.org,2002:python/module:'+data.__name__, '')
 
     def represent_instance(self, data):
         # For instances of classic classes, we use __getinitargs__ and
@@ -362,7 +362,7 @@ class Representer(SafeRepresenter):
         # !!python/object/new node.
 
         cls = data.__class__
-        class_name = u'%s.%s' % (cls.__module__, cls.__name__)
+        class_name = '%s.%s' % (cls.__module__, cls.__name__)
         args = None
         state = None
         if hasattr(data, '__getinitargs__'):
@@ -373,16 +373,16 @@ class Representer(SafeRepresenter):
             state = data.__dict__
         if args is None and isinstance(state, dict):
             return self.represent_mapping(
-                    u'tag:yaml.org,2002:python/object:'+class_name, state)
+                    'tag:yaml.org,2002:python/object:'+class_name, state)
         if isinstance(state, dict) and not state:
             return self.represent_sequence(
-                    u'tag:yaml.org,2002:python/object/new:'+class_name, args)
+                    'tag:yaml.org,2002:python/object/new:'+class_name, args)
         value = {}
         if args:
             value['args'] = args
         value['state'] = state
         return self.represent_mapping(
-                u'tag:yaml.org,2002:python/object/new:'+class_name, value)
+                'tag:yaml.org,2002:python/object/new:'+class_name, value)
 
     def represent_object(self, data):
         # We use __reduce__ API to save the data. data.__reduce__ returns
@@ -422,16 +422,16 @@ class Representer(SafeRepresenter):
         if function.__name__ == '__newobj__':
             function = args[0]
             args = args[1:]
-            tag = u'tag:yaml.org,2002:python/object/new:'
+            tag = 'tag:yaml.org,2002:python/object/new:'
             newobj = True
         else:
-            tag = u'tag:yaml.org,2002:python/object/apply:'
+            tag = 'tag:yaml.org,2002:python/object/apply:'
             newobj = False
-        function_name = u'%s.%s' % (function.__module__, function.__name__)
+        function_name = '%s.%s' % (function.__module__, function.__name__)
         if not args and not listitems and not dictitems \
                 and isinstance(state, dict) and newobj:
             return self.represent_mapping(
-                    u'tag:yaml.org,2002:python/object:'+function_name, state)
+                    'tag:yaml.org,2002:python/object:'+function_name, state)
         if not listitems and not dictitems  \
                 and isinstance(state, dict) and not state:
             return self.represent_sequence(tag+function_name, args)
@@ -449,7 +449,7 @@ class Representer(SafeRepresenter):
 Representer.add_representer(str,
         Representer.represent_str)
 
-Representer.add_representer(unicode,
+Representer.add_representer(str,
         Representer.represent_unicode)
 
 Representer.add_representer(int,
diff --git a/python/pyyaml/lib/yaml/resolver.py b/python/pyyaml/lib/yaml/resolver.py
index 744f297db0..056fc80ae5 100644
--- a/python/pyyaml/lib/yaml/resolver.py
+++ b/python/pyyaml/lib/yaml/resolver.py
@@ -11,9 +11,9 @@ class ResolverError(YAMLError):
 
 class BaseResolver(object):
 
-    DEFAULT_SCALAR_TAG = u'tag:yaml.org,2002:str'
-    DEFAULT_SEQUENCE_TAG = u'tag:yaml.org,2002:seq'
-    DEFAULT_MAPPING_TAG = u'tag:yaml.org,2002:map'
+    DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str'
+    DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq'
+    DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map'
 
     yaml_implicit_resolvers = {}
     yaml_path_resolvers = {}
@@ -139,8 +139,8 @@ class BaseResolver(object):
 
     def resolve(self, kind, value, implicit):
         if kind is ScalarNode and implicit[0]:
-            if value == u'':
-                resolvers = self.yaml_implicit_resolvers.get(u'', [])
+            if value == '':
+                resolvers = self.yaml_implicit_resolvers.get('', [])
             else:
                 resolvers = self.yaml_implicit_resolvers.get(value[0], [])
             resolvers += self.yaml_implicit_resolvers.get(None, [])
@@ -165,60 +165,60 @@ class Resolver(BaseResolver):
     pass
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:bool',
-        re.compile(ur'''^(?:yes|Yes|YES|no|No|NO
+        'tag:yaml.org,2002:bool',
+        re.compile(r'''^(?:yes|Yes|YES|no|No|NO
                     |true|True|TRUE|false|False|FALSE
                     |on|On|ON|off|Off|OFF)$''', re.X),
-        list(u'yYnNtTfFoO'))
+        list('yYnNtTfFoO'))
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:float',
-        re.compile(ur'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)?
+        'tag:yaml.org,2002:float',
+        re.compile(r'''^(?:[-+]?(?:[0-9][0-9_]*)\.[0-9_]*(?:[eE][-+][0-9]+)?
                     |\.[0-9_]+(?:[eE][-+][0-9]+)?
                     |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*
                     |[-+]?\.(?:inf|Inf|INF)
                     |\.(?:nan|NaN|NAN))$''', re.X),
-        list(u'-+0123456789.'))
+        list('-+0123456789.'))
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:int',
-        re.compile(ur'''^(?:[-+]?0b[0-1_]+
+        'tag:yaml.org,2002:int',
+        re.compile(r'''^(?:[-+]?0b[0-1_]+
                     |[-+]?0[0-7_]+
                     |[-+]?(?:0|[1-9][0-9_]*)
                     |[-+]?0x[0-9a-fA-F_]+
                     |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9])+)$''', re.X),
-        list(u'-+0123456789'))
+        list('-+0123456789'))
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:merge',
-        re.compile(ur'^(?:<<)$'),
-        [u'<'])
+        'tag:yaml.org,2002:merge',
+        re.compile(r'^(?:<<)$'),
+        ['<'])
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:null',
-        re.compile(ur'''^(?: ~
+        'tag:yaml.org,2002:null',
+        re.compile(r'''^(?: ~
                     |null|Null|NULL
                     | )$''', re.X),
-        [u'~', u'n', u'N', u''])
+        ['~', 'n', 'N', ''])
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:timestamp',
-        re.compile(ur'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
+        'tag:yaml.org,2002:timestamp',
+        re.compile(r'''^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
                     |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?
                      (?:[Tt]|[ \t]+)[0-9][0-9]?
                      :[0-9][0-9] :[0-9][0-9] (?:\.[0-9]*)?
                      (?:[ \t]*(?:Z|[-+][0-9][0-9]?(?::[0-9][0-9])?))?)$''', re.X),
-        list(u'0123456789'))
+        list('0123456789'))
 
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:value',
-        re.compile(ur'^(?:=)$'),
-        [u'='])
+        'tag:yaml.org,2002:value',
+        re.compile(r'^(?:=)$'),
+        ['='])
 
 # The following resolver is only for documentation purposes. It cannot work
 # because plain scalars cannot start with '!', '&', or '*'.
 Resolver.add_implicit_resolver(
-        u'tag:yaml.org,2002:yaml',
-        re.compile(ur'^(?:!|&|\*)$'),
-        list(u'!&*'))
+        'tag:yaml.org,2002:yaml',
+        re.compile(r'^(?:!|&|\*)$'),
+        list('!&*'))
 
diff --git a/python/pyyaml/lib/yaml/scanner.py b/python/pyyaml/lib/yaml/scanner.py
index aaaef3b8ba..f59e3331a4 100644
--- a/python/pyyaml/lib/yaml/scanner.py
+++ b/python/pyyaml/lib/yaml/scanner.py
@@ -166,19 +166,19 @@ class Scanner(object):
         ch = self.peek()
 
         # Is it the end of stream?
-        if ch == u'\0':
+        if ch == '\0':
             return self.fetch_stream_end()
 
         # Is it a directive?
-        if ch == u'%' and self.check_directive():
+        if ch == '%' and self.check_directive():
             return self.fetch_directive()
 
         # Is it the document start?
-        if ch == u'-' and self.check_document_start():
+        if ch == '-' and self.check_document_start():
             return self.fetch_document_start()
 
         # Is it the document end?
-        if ch == u'.' and self.check_document_end():
+        if ch == '.' and self.check_document_end():
             return self.fetch_document_end()
 
         # TODO: support for BOM within a stream.
@@ -188,63 +188,63 @@ class Scanner(object):
         # Note: the order of the following checks is NOT significant.
 
         # Is it the flow sequence start indicator?
-        if ch == u'[':
+        if ch == '[':
             return self.fetch_flow_sequence_start()
 
         # Is it the flow mapping start indicator?
-        if ch == u'{':
+        if ch == '{':
             return self.fetch_flow_mapping_start()
 
         # Is it the flow sequence end indicator?
-        if ch == u']':
+        if ch == ']':
             return self.fetch_flow_sequence_end()
 
         # Is it the flow mapping end indicator?
-        if ch == u'}':
+        if ch == '}':
             return self.fetch_flow_mapping_end()
 
         # Is it the flow entry indicator?
-        if ch == u',':
+        if ch == ',':
             return self.fetch_flow_entry()
 
         # Is it the block entry indicator?
-        if ch == u'-' and self.check_block_entry():
+        if ch == '-' and self.check_block_entry():
             return self.fetch_block_entry()
 
         # Is it the key indicator?
-        if ch == u'?' and self.check_key():
+        if ch == '?' and self.check_key():
             return self.fetch_key()
 
         # Is it the value indicator?
-        if ch == u':' and self.check_value():
+        if ch == ':' and self.check_value():
             return self.fetch_value()
 
         # Is it an alias?
-        if ch == u'*':
+        if ch == '*':
             return self.fetch_alias()
 
         # Is it an anchor?
-        if ch == u'&':
+        if ch == '&':
             return self.fetch_anchor()
 
         # Is it a tag?
-        if ch == u'!':
+        if ch == '!':
             return self.fetch_tag()
 
         # Is it a literal scalar?
-        if ch == u'|' and not self.flow_level:
+        if ch == '|' and not self.flow_level:
             return self.fetch_literal()
 
         # Is it a folded scalar?
-        if ch == u'>' and not self.flow_level:
+        if ch == '>' and not self.flow_level:
             return self.fetch_folded()
 
         # Is it a single quoted scalar?
-        if ch == u'\'':
+        if ch == '\'':
             return self.fetch_single()
 
         # Is it a double quoted scalar?
-        if ch == u'\"':
+        if ch == '\"':
             return self.fetch_double()
 
         # It must be a plain scalar then.
@@ -692,22 +692,22 @@ class Scanner(object):
 
         # DOCUMENT-START:   ^ '---' (' '|'\n')
         if self.column == 0:
-            if self.prefix(3) == u'---'  \
-                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+            if self.prefix(3) == '---'  \
+                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
                 return True
 
     def check_document_end(self):
 
         # DOCUMENT-END:     ^ '...' (' '|'\n')
         if self.column == 0:
-            if self.prefix(3) == u'...'  \
-                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+            if self.prefix(3) == '...'  \
+                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
                 return True
 
     def check_block_entry(self):
 
         # BLOCK-ENTRY:      '-' (' '|'\n')
-        return self.peek(1) in u'\0 \t\r\n\x85\u2028\u2029'
+        return self.peek(1) in '\0 \t\r\n\x85\u2028\u2029'
 
     def check_key(self):
 
@@ -717,7 +717,7 @@ class Scanner(object):
 
         # KEY(block context):   '?' (' '|'\n')
         else:
-            return self.peek(1) in u'\0 \t\r\n\x85\u2028\u2029'
+            return self.peek(1) in '\0 \t\r\n\x85\u2028\u2029'
 
     def check_value(self):
 
@@ -727,7 +727,7 @@ class Scanner(object):
 
         # VALUE(block context): ':' (' '|'\n')
         else:
-            return self.peek(1) in u'\0 \t\r\n\x85\u2028\u2029'
+            return self.peek(1) in '\0 \t\r\n\x85\u2028\u2029'
 
     def check_plain(self):
 
@@ -744,9 +744,9 @@ class Scanner(object):
         # '-' character) because we want the flow context to be space
         # independent.
         ch = self.peek()
-        return ch not in u'\0 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'  \
-                or (self.peek(1) not in u'\0 \t\r\n\x85\u2028\u2029'
-                        and (ch == u'-' or (not self.flow_level and ch in u'?:')))
+        return ch not in '\0 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'  \
+                or (self.peek(1) not in '\0 \t\r\n\x85\u2028\u2029'
+                        and (ch == '-' or (not self.flow_level and ch in '?:')))
 
     # Scanners.
 
@@ -770,14 +770,14 @@ class Scanner(object):
         # `unwind_indent` before issuing BLOCK-END.
         # Scanners for block, flow, and plain scalars need to be modified.
 
-        if self.index == 0 and self.peek() == u'\uFEFF':
+        if self.index == 0 and self.peek() == '\uFEFF':
             self.forward()
         found = False
         while not found:
-            while self.peek() == u' ':
+            while self.peek() == ' ':
                 self.forward()
-            if self.peek() == u'#':
-                while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+            if self.peek() == '#':
+                while self.peek() not in '\0\r\n\x85\u2028\u2029':
                     self.forward()
             if self.scan_line_break():
                 if not self.flow_level:
@@ -791,15 +791,15 @@ class Scanner(object):
         self.forward()
         name = self.scan_directive_name(start_mark)
         value = None
-        if name == u'YAML':
+        if name == 'YAML':
             value = self.scan_yaml_directive_value(start_mark)
             end_mark = self.get_mark()
-        elif name == u'TAG':
+        elif name == 'TAG':
             value = self.scan_tag_directive_value(start_mark)
             end_mark = self.get_mark()
         else:
             end_mark = self.get_mark()
-            while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+            while self.peek() not in '\0\r\n\x85\u2028\u2029':
                 self.forward()
         self.scan_directive_ignored_line(start_mark)
         return DirectiveToken(name, value, start_mark, end_mark)
@@ -808,8 +808,8 @@ class Scanner(object):
         # See the specification for details.
         length = 0
         ch = self.peek(length)
-        while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'    \
-                or ch in u'-_':
+        while '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'    \
+                or ch in '-_':
             length += 1
             ch = self.peek(length)
         if not length:
@@ -819,7 +819,7 @@ class Scanner(object):
         value = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch not in u'\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected alphabetic or numeric character, but found %r"
                     % ch.encode('utf-8'), self.get_mark())
@@ -827,7 +827,7 @@ class Scanner(object):
 
     def scan_yaml_directive_value(self, start_mark):
         # See the specification for details.
-        while self.peek() == u' ':
+        while self.peek() == ' ':
             self.forward()
         major = self.scan_yaml_directive_number(start_mark)
         if self.peek() != '.':
@@ -837,7 +837,7 @@ class Scanner(object):
                     self.get_mark())
         self.forward()
         minor = self.scan_yaml_directive_number(start_mark)
-        if self.peek() not in u'\0 \r\n\x85\u2028\u2029':
+        if self.peek() not in '\0 \r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected a digit or ' ', but found %r"
                     % self.peek().encode('utf-8'),
@@ -847,12 +847,12 @@ class Scanner(object):
     def scan_yaml_directive_number(self, start_mark):
         # See the specification for details.
         ch = self.peek()
-        if not (u'0' <= ch <= u'9'):
+        if not ('0' <= ch <= '9'):
             raise ScannerError("while scanning a directive", start_mark,
                     "expected a digit, but found %r" % ch.encode('utf-8'),
                     self.get_mark())
         length = 0
-        while u'0' <= self.peek(length) <= u'9':
+        while '0' <= self.peek(length) <= '9':
             length += 1
         value = int(self.prefix(length))
         self.forward(length)
@@ -860,10 +860,10 @@ class Scanner(object):
 
     def scan_tag_directive_value(self, start_mark):
         # See the specification for details.
-        while self.peek() == u' ':
+        while self.peek() == ' ':
             self.forward()
         handle = self.scan_tag_directive_handle(start_mark)
-        while self.peek() == u' ':
+        while self.peek() == ' ':
             self.forward()
         prefix = self.scan_tag_directive_prefix(start_mark)
         return (handle, prefix)
@@ -872,7 +872,7 @@ class Scanner(object):
         # See the specification for details.
         value = self.scan_tag_handle('directive', start_mark)
         ch = self.peek()
-        if ch != u' ':
+        if ch != ' ':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected ' ', but found %r" % ch.encode('utf-8'),
                     self.get_mark())
@@ -882,7 +882,7 @@ class Scanner(object):
         # See the specification for details.
         value = self.scan_tag_uri('directive', start_mark)
         ch = self.peek()
-        if ch not in u'\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected ' ', but found %r" % ch.encode('utf-8'),
                     self.get_mark())
@@ -890,13 +890,13 @@ class Scanner(object):
 
     def scan_directive_ignored_line(self, start_mark):
         # See the specification for details.
-        while self.peek() == u' ':
+        while self.peek() == ' ':
             self.forward()
-        if self.peek() == u'#':
-            while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+        if self.peek() == '#':
+            while self.peek() not in '\0\r\n\x85\u2028\u2029':
                 self.forward()
         ch = self.peek()
-        if ch not in u'\0\r\n\x85\u2028\u2029':
+        if ch not in '\0\r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected a comment or a line break, but found %r"
                         % ch.encode('utf-8'), self.get_mark())
@@ -913,15 +913,15 @@ class Scanner(object):
         # Therefore we restrict aliases to numbers and ASCII letters.
         start_mark = self.get_mark()
         indicator = self.peek()
-        if indicator == u'*':
+        if indicator == '*':
             name = 'alias'
         else:
             name = 'anchor'
         self.forward()
         length = 0
         ch = self.peek(length)
-        while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'    \
-                or ch in u'-_':
+        while '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'    \
+                or ch in '-_':
             length += 1
             ch = self.peek(length)
         if not length:
@@ -931,7 +931,7 @@ class Scanner(object):
         value = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch not in u'\0 \t\r\n\x85\u2028\u2029?:,]}%@`':
+        if ch not in '\0 \t\r\n\x85\u2028\u2029?:,]}%@`':
             raise ScannerError("while scanning an %s" % name, start_mark,
                     "expected alphabetic or numeric character, but found %r"
                     % ch.encode('utf-8'), self.get_mark())
@@ -942,37 +942,37 @@ class Scanner(object):
         # See the specification for details.
         start_mark = self.get_mark()
         ch = self.peek(1)
-        if ch == u'<':
+        if ch == '<':
             handle = None
             self.forward(2)
             suffix = self.scan_tag_uri('tag', start_mark)
-            if self.peek() != u'>':
+            if self.peek() != '>':
                 raise ScannerError("while parsing a tag", start_mark,
                         "expected '>', but found %r" % self.peek().encode('utf-8'),
                         self.get_mark())
             self.forward()
-        elif ch in u'\0 \t\r\n\x85\u2028\u2029':
+        elif ch in '\0 \t\r\n\x85\u2028\u2029':
             handle = None
-            suffix = u'!'
+            suffix = '!'
             self.forward()
         else:
             length = 1
             use_handle = False
-            while ch not in u'\0 \r\n\x85\u2028\u2029':
-                if ch == u'!':
+            while ch not in '\0 \r\n\x85\u2028\u2029':
+                if ch == '!':
                     use_handle = True
                     break
                 length += 1
                 ch = self.peek(length)
-            handle = u'!'
+            handle = '!'
             if use_handle:
                 handle = self.scan_tag_handle('tag', start_mark)
             else:
-                handle = u'!'
+                handle = '!'
                 self.forward()
             suffix = self.scan_tag_uri('tag', start_mark)
         ch = self.peek()
-        if ch not in u'\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a tag", start_mark,
                     "expected ' ', but found %r" % ch.encode('utf-8'),
                     self.get_mark())
@@ -1006,29 +1006,29 @@ class Scanner(object):
         else:
             indent = min_indent+increment-1
             breaks, end_mark = self.scan_block_scalar_breaks(indent)
-        line_break = u''
+        line_break = ''
 
         # Scan the inner part of the block scalar.
-        while self.column == indent and self.peek() != u'\0':
+        while self.column == indent and self.peek() != '\0':
             chunks.extend(breaks)
-            leading_non_space = self.peek() not in u' \t'
+            leading_non_space = self.peek() not in ' \t'
             length = 0
-            while self.peek(length) not in u'\0\r\n\x85\u2028\u2029':
+            while self.peek(length) not in '\0\r\n\x85\u2028\u2029':
                 length += 1
             chunks.append(self.prefix(length))
             self.forward(length)
             line_break = self.scan_line_break()
             breaks, end_mark = self.scan_block_scalar_breaks(indent)
-            if self.column == indent and self.peek() != u'\0':
+            if self.column == indent and self.peek() != '\0':
 
                 # Unfortunately, folding rules are ambiguous.
                 #
                 # This is the folding according to the specification:
                 
-                if folded and line_break == u'\n'   \
-                        and leading_non_space and self.peek() not in u' \t':
+                if folded and line_break == '\n'   \
+                        and leading_non_space and self.peek() not in ' \t':
                     if not breaks:
-                        chunks.append(u' ')
+                        chunks.append(' ')
                 else:
                     chunks.append(line_break)
                 
@@ -1053,7 +1053,7 @@ class Scanner(object):
             chunks.extend(breaks)
 
         # We are done.
-        return ScalarToken(u''.join(chunks), False, start_mark, end_mark,
+        return ScalarToken(''.join(chunks), False, start_mark, end_mark,
                 style)
 
     def scan_block_scalar_indicators(self, start_mark):
@@ -1061,21 +1061,21 @@ class Scanner(object):
         chomping = None
         increment = None
         ch = self.peek()
-        if ch in u'+-':
+        if ch in '+-':
             if ch == '+':
                 chomping = True
             else:
                 chomping = False
             self.forward()
             ch = self.peek()
-            if ch in u'0123456789':
+            if ch in '0123456789':
                 increment = int(ch)
                 if increment == 0:
                     raise ScannerError("while scanning a block scalar", start_mark,
                             "expected indentation indicator in the range 1-9, but found 0",
                             self.get_mark())
                 self.forward()
-        elif ch in u'0123456789':
+        elif ch in '0123456789':
             increment = int(ch)
             if increment == 0:
                 raise ScannerError("while scanning a block scalar", start_mark,
@@ -1083,14 +1083,14 @@ class Scanner(object):
                         self.get_mark())
             self.forward()
             ch = self.peek()
-            if ch in u'+-':
+            if ch in '+-':
                 if ch == '+':
                     chomping = True
                 else:
                     chomping = False
                 self.forward()
         ch = self.peek()
-        if ch not in u'\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a block scalar", start_mark,
                     "expected chomping or indentation indicators, but found %r"
                         % ch.encode('utf-8'), self.get_mark())
@@ -1098,13 +1098,13 @@ class Scanner(object):
 
     def scan_block_scalar_ignored_line(self, start_mark):
         # See the specification for details.
-        while self.peek() == u' ':
+        while self.peek() == ' ':
             self.forward()
-        if self.peek() == u'#':
-            while self.peek() not in u'\0\r\n\x85\u2028\u2029':
+        if self.peek() == '#':
+            while self.peek() not in '\0\r\n\x85\u2028\u2029':
                 self.forward()
         ch = self.peek()
-        if ch not in u'\0\r\n\x85\u2028\u2029':
+        if ch not in '\0\r\n\x85\u2028\u2029':
             raise ScannerError("while scanning a block scalar", start_mark,
                     "expected a comment or a line break, but found %r"
                         % ch.encode('utf-8'), self.get_mark())
@@ -1115,8 +1115,8 @@ class Scanner(object):
         chunks = []
         max_indent = 0
         end_mark = self.get_mark()
-        while self.peek() in u' \r\n\x85\u2028\u2029':
-            if self.peek() != u' ':
+        while self.peek() in ' \r\n\x85\u2028\u2029':
+            if self.peek() != ' ':
                 chunks.append(self.scan_line_break())
                 end_mark = self.get_mark()
             else:
@@ -1129,12 +1129,12 @@ class Scanner(object):
         # See the specification for details.
         chunks = []
         end_mark = self.get_mark()
-        while self.column < indent and self.peek() == u' ':
+        while self.column < indent and self.peek() == ' ':
             self.forward()
-        while self.peek() in u'\r\n\x85\u2028\u2029':
+        while self.peek() in '\r\n\x85\u2028\u2029':
             chunks.append(self.scan_line_break())
             end_mark = self.get_mark()
-            while self.column < indent and self.peek() == u' ':
+            while self.column < indent and self.peek() == ' ':
                 self.forward()
         return chunks, end_mark
 
@@ -1159,33 +1159,33 @@ class Scanner(object):
             chunks.extend(self.scan_flow_scalar_non_spaces(double, start_mark))
         self.forward()
         end_mark = self.get_mark()
-        return ScalarToken(u''.join(chunks), False, start_mark, end_mark,
+        return ScalarToken(''.join(chunks), False, start_mark, end_mark,
                 style)
 
     ESCAPE_REPLACEMENTS = {
-        u'0':   u'\0',
-        u'a':   u'\x07',
-        u'b':   u'\x08',
-        u't':   u'\x09',
-        u'\t':  u'\x09',
-        u'n':   u'\x0A',
-        u'v':   u'\x0B',
-        u'f':   u'\x0C',
-        u'r':   u'\x0D',
-        u'e':   u'\x1B',
-        u' ':   u'\x20',
-        u'\"':  u'\"',
-        u'\\':  u'\\',
-        u'N':   u'\x85',
-        u'_':   u'\xA0',
-        u'L':   u'\u2028',
-        u'P':   u'\u2029',
+        '0':   '\0',
+        'a':   '\x07',
+        'b':   '\x08',
+        't':   '\x09',
+        '\t':  '\x09',
+        'n':   '\x0A',
+        'v':   '\x0B',
+        'f':   '\x0C',
+        'r':   '\x0D',
+        'e':   '\x1B',
+        ' ':   '\x20',
+        '\"':  '\"',
+        '\\':  '\\',
+        'N':   '\x85',
+        '_':   '\xA0',
+        'L':   '\u2028',
+        'P':   '\u2029',
     }
 
     ESCAPE_CODES = {
-        u'x':   2,
-        u'u':   4,
-        u'U':   8,
+        'x':   2,
+        'u':   4,
+        'U':   8,
     }
 
     def scan_flow_scalar_non_spaces(self, double, start_mark):
@@ -1193,19 +1193,19 @@ class Scanner(object):
         chunks = []
         while True:
             length = 0
-            while self.peek(length) not in u'\'\"\\\0 \t\r\n\x85\u2028\u2029':
+            while self.peek(length) not in '\'\"\\\0 \t\r\n\x85\u2028\u2029':
                 length += 1
             if length:
                 chunks.append(self.prefix(length))
                 self.forward(length)
             ch = self.peek()
-            if not double and ch == u'\'' and self.peek(1) == u'\'':
-                chunks.append(u'\'')
+            if not double and ch == '\'' and self.peek(1) == '\'':
+                chunks.append('\'')
                 self.forward(2)
-            elif (double and ch == u'\'') or (not double and ch in u'\"\\'):
+            elif (double and ch == '\'') or (not double and ch in '\"\\'):
                 chunks.append(ch)
                 self.forward()
-            elif double and ch == u'\\':
+            elif double and ch == '\\':
                 self.forward()
                 ch = self.peek()
                 if ch in self.ESCAPE_REPLACEMENTS:
@@ -1215,14 +1215,14 @@ class Scanner(object):
                     length = self.ESCAPE_CODES[ch]
                     self.forward()
                     for k in range(length):
-                        if self.peek(k) not in u'0123456789ABCDEFabcdef':
+                        if self.peek(k) not in '0123456789ABCDEFabcdef':
                             raise ScannerError("while scanning a double-quoted scalar", start_mark,
                                     "expected escape sequence of %d hexdecimal numbers, but found %r" %
                                         (length, self.peek(k).encode('utf-8')), self.get_mark())
                     code = int(self.prefix(length), 16)
-                    chunks.append(unichr(code))
+                    chunks.append(chr(code))
                     self.forward(length)
-                elif ch in u'\r\n\x85\u2028\u2029':
+                elif ch in '\r\n\x85\u2028\u2029':
                     self.scan_line_break()
                     chunks.extend(self.scan_flow_scalar_breaks(double, start_mark))
                 else:
@@ -1235,21 +1235,21 @@ class Scanner(object):
         # See the specification for details.
         chunks = []
         length = 0
-        while self.peek(length) in u' \t':
+        while self.peek(length) in ' \t':
             length += 1
         whitespaces = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch == u'\0':
+        if ch == '\0':
             raise ScannerError("while scanning a quoted scalar", start_mark,
                     "found unexpected end of stream", self.get_mark())
-        elif ch in u'\r\n\x85\u2028\u2029':
+        elif ch in '\r\n\x85\u2028\u2029':
             line_break = self.scan_line_break()
             breaks = self.scan_flow_scalar_breaks(double, start_mark)
-            if line_break != u'\n':
+            if line_break != '\n':
                 chunks.append(line_break)
             elif not breaks:
-                chunks.append(u' ')
+                chunks.append(' ')
             chunks.extend(breaks)
         else:
             chunks.append(whitespaces)
@@ -1262,13 +1262,13 @@ class Scanner(object):
             # Instead of checking indentation, we check for document
             # separators.
             prefix = self.prefix(3)
-            if (prefix == u'---' or prefix == u'...')   \
-                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+            if (prefix == '---' or prefix == '...')   \
+                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
                 raise ScannerError("while scanning a quoted scalar", start_mark,
                         "found unexpected document separator", self.get_mark())
-            while self.peek() in u' \t':
+            while self.peek() in ' \t':
                 self.forward()
-            if self.peek() in u'\r\n\x85\u2028\u2029':
+            if self.peek() in '\r\n\x85\u2028\u2029':
                 chunks.append(self.scan_line_break())
             else:
                 return chunks
@@ -1290,19 +1290,19 @@ class Scanner(object):
         spaces = []
         while True:
             length = 0
-            if self.peek() == u'#':
+            if self.peek() == '#':
                 break
             while True:
                 ch = self.peek(length)
-                if ch in u'\0 \t\r\n\x85\u2028\u2029'   \
-                        or (not self.flow_level and ch == u':' and
-                                self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029') \
-                        or (self.flow_level and ch in u',:?[]{}'):
+                if ch in '\0 \t\r\n\x85\u2028\u2029'   \
+                        or (not self.flow_level and ch == ':' and
+                                self.peek(length+1) in '\0 \t\r\n\x85\u2028\u2029') \
+                        or (self.flow_level and ch in ',:?[]{}'):
                     break
                 length += 1
             # It's not clear what we should do with ':' in the flow context.
-            if (self.flow_level and ch == u':'
-                    and self.peek(length+1) not in u'\0 \t\r\n\x85\u2028\u2029,[]{}'):
+            if (self.flow_level and ch == ':'
+                    and self.peek(length+1) not in '\0 \t\r\n\x85\u2028\u2029,[]{}'):
                 self.forward(length)
                 raise ScannerError("while scanning a plain scalar", start_mark,
                     "found unexpected ':'", self.get_mark(),
@@ -1315,10 +1315,10 @@ class Scanner(object):
             self.forward(length)
             end_mark = self.get_mark()
             spaces = self.scan_plain_spaces(indent, start_mark)
-            if not spaces or self.peek() == u'#' \
+            if not spaces or self.peek() == '#' \
                     or (not self.flow_level and self.column < indent):
                 break
-        return ScalarToken(u''.join(chunks), True, start_mark, end_mark)
+        return ScalarToken(''.join(chunks), True, start_mark, end_mark)
 
     def scan_plain_spaces(self, indent, start_mark):
         # See the specification for details.
@@ -1326,32 +1326,32 @@ class Scanner(object):
         # We just forbid them completely. Do not use tabs in YAML!
         chunks = []
         length = 0
-        while self.peek(length) in u' ':
+        while self.peek(length) in ' ':
             length += 1
         whitespaces = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch in u'\r\n\x85\u2028\u2029':
+        if ch in '\r\n\x85\u2028\u2029':
             line_break = self.scan_line_break()
             self.allow_simple_key = True
             prefix = self.prefix(3)
-            if (prefix == u'---' or prefix == u'...')   \
-                    and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+            if (prefix == '---' or prefix == '...')   \
+                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
                 return
             breaks = []
-            while self.peek() in u' \r\n\x85\u2028\u2029':
+            while self.peek() in ' \r\n\x85\u2028\u2029':
                 if self.peek() == ' ':
                     self.forward()
                 else:
                     breaks.append(self.scan_line_break())
                     prefix = self.prefix(3)
-                    if (prefix == u'---' or prefix == u'...')   \
-                            and self.peek(3) in u'\0 \t\r\n\x85\u2028\u2029':
+                    if (prefix == '---' or prefix == '...')   \
+                            and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
                         return
-            if line_break != u'\n':
+            if line_break != '\n':
                 chunks.append(line_break)
             elif not breaks:
-                chunks.append(u' ')
+                chunks.append(' ')
             chunks.extend(breaks)
         elif whitespaces:
             chunks.append(whitespaces)
@@ -1362,18 +1362,18 @@ class Scanner(object):
         # For some strange reasons, the specification does not allow '_' in
         # tag handles. I have allowed it anyway.
         ch = self.peek()
-        if ch != u'!':
+        if ch != '!':
             raise ScannerError("while scanning a %s" % name, start_mark,
                     "expected '!', but found %r" % ch.encode('utf-8'),
                     self.get_mark())
         length = 1
         ch = self.peek(length)
-        if ch != u' ':
-            while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'    \
-                    or ch in u'-_':
+        if ch != ' ':
+            while '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'    \
+                    or ch in '-_':
                 length += 1
                 ch = self.peek(length)
-            if ch != u'!':
+            if ch != '!':
                 self.forward(length)
                 raise ScannerError("while scanning a %s" % name, start_mark,
                         "expected '!', but found %r" % ch.encode('utf-8'),
@@ -1389,9 +1389,9 @@ class Scanner(object):
         chunks = []
         length = 0
         ch = self.peek(length)
-        while u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z'    \
-                or ch in u'-;/?:@&=+$,_.!~*\'()[]%':
-            if ch == u'%':
+        while '0' <= ch <= '9' or 'A' <= ch <= 'Z' or 'a' <= ch <= 'z'    \
+                or ch in '-;/?:@&=+$,_.!~*\'()[]%':
+            if ch == '%':
                 chunks.append(self.prefix(length))
                 self.forward(length)
                 length = 0
@@ -1407,23 +1407,23 @@ class Scanner(object):
             raise ScannerError("while parsing a %s" % name, start_mark,
                     "expected URI, but found %r" % ch.encode('utf-8'),
                     self.get_mark())
-        return u''.join(chunks)
+        return ''.join(chunks)
 
     def scan_uri_escapes(self, name, start_mark):
         # See the specification for details.
         bytes = []
         mark = self.get_mark()
-        while self.peek() == u'%':
+        while self.peek() == '%':
             self.forward()
             for k in range(2):
-                if self.peek(k) not in u'0123456789ABCDEFabcdef':
+                if self.peek(k) not in '0123456789ABCDEFabcdef':
                     raise ScannerError("while scanning a %s" % name, start_mark,
                             "expected URI escape sequence of 2 hexdecimal numbers, but found %r" %
                                 (self.peek(k).encode('utf-8')), self.get_mark())
             bytes.append(chr(int(self.prefix(2), 16)))
             self.forward(2)
         try:
-            value = unicode(''.join(bytes), 'utf-8')
+            value = str(''.join(bytes), 'utf-8')
         except UnicodeDecodeError as exc:
             raise ScannerError("while scanning a %s" % name, start_mark, str(exc), mark)
         return value
@@ -1438,16 +1438,16 @@ class Scanner(object):
         #   '\u2029     :   '\u2029'
         #   default     :   ''
         ch = self.peek()
-        if ch in u'\r\n\x85':
-            if self.prefix(2) == u'\r\n':
+        if ch in '\r\n\x85':
+            if self.prefix(2) == '\r\n':
                 self.forward(2)
             else:
                 self.forward()
-            return u'\n'
-        elif ch in u'\u2028\u2029':
+            return '\n'
+        elif ch in '\u2028\u2029':
             self.forward()
             return ch
-        return u''
+        return ''
 
 #try:
 #    import psyco
diff --git a/python/pyyaml/lib/yaml/serializer.py b/python/pyyaml/lib/yaml/serializer.py
index c6ee91b697..230bae76f9 100644
--- a/python/pyyaml/lib/yaml/serializer.py
+++ b/python/pyyaml/lib/yaml/serializer.py
@@ -10,7 +10,7 @@ class SerializerError(YAMLError):
 
 class Serializer(object):
 
-    ANCHOR_TEMPLATE = u'id%03d'
+    ANCHOR_TEMPLATE = 'id%03d'
 
     def __init__(self, encoding=None,
             explicit_start=None, explicit_end=None, version=None, tags=None):
diff --git a/python/pyyaml/lib3/yaml/emitter.py b/python/pyyaml/lib3/yaml/emitter.py
index 34cb145a5f..ea0dd05655 100644
--- a/python/pyyaml/lib3/yaml/emitter.py
+++ b/python/pyyaml/lib3/yaml/emitter.py
@@ -656,7 +656,7 @@ class Emitter:
 
         # Last character or followed by a whitespace.
         followed_by_whitespace = (len(scalar) == 1 or
-                scalar[1] in '\0 \t\r\n\x85\u2028\u2029')
+                scalar[1] in '\0 \t\r\n\x85\\u2028\\u2029')
 
         # The previous character is a space.
         previous_space = False
@@ -694,11 +694,11 @@ class Emitter:
                     block_indicators = True
 
             # Check for line breaks, special, and unicode characters.
-            if ch in '\n\x85\u2028\u2029':
+            if ch in '\n\x85\\u2028\\u2029':
                 line_breaks = True
             if not (ch == '\n' or '\x20' <= ch <= '\x7E'):
-                if (ch == '\x85' or '\xA0' <= ch <= '\uD7FF'
-                        or '\uE000' <= ch <= '\uFFFD') and ch != '\uFEFF':
+                if (ch == '\x85' or '\xA0' <= ch <= '\\uD7FF'
+                        or '\\uE000' <= ch <= '\\uFFFD') and ch != '\\uFEFF':
                     unicode_characters = True
                     if not self.allow_unicode:
                         special_characters = True
@@ -715,7 +715,7 @@ class Emitter:
                     break_space = True
                 previous_space = True
                 previous_break = False
-            elif ch in '\n\x85\u2028\u2029':
+            elif ch in '\n\x85\\u2028\\u2029':
                 if index == 0:
                     leading_break = True
                 if index == len(scalar)-1:
@@ -730,9 +730,9 @@ class Emitter:
 
             # Prepare for the next character.
             index += 1
-            preceeded_by_whitespace = (ch in '\0 \t\r\n\x85\u2028\u2029')
+            preceeded_by_whitespace = (ch in '\0 \t\r\n\x85\\u2028\\u2029')
             followed_by_whitespace = (index+1 >= len(scalar) or
-                    scalar[index+1] in '\0 \t\r\n\x85\u2028\u2029')
+                    scalar[index+1] in '\0 \t\r\n\x85\\u2028\\u2029')
 
         # Let's decide what styles are allowed.
         allow_flow_plain = True
@@ -791,7 +791,7 @@ class Emitter:
     def write_stream_start(self):
         # Write BOM if needed.
         if self.encoding and self.encoding.startswith('utf-16'):
-            self.stream.write('\uFEFF'.encode(self.encoding))
+            self.stream.write('\\uFEFF'.encode(self.encoding))
 
     def write_stream_end(self):
         self.flush_stream()
@@ -872,7 +872,7 @@ class Emitter:
                         self.stream.write(data)
                     start = end
             elif breaks:
-                if ch is None or ch not in '\n\x85\u2028\u2029':
+                if ch is None or ch not in '\n\x85\\u2028\\u2029':
                     if text[start] == '\n':
                         self.write_line_break()
                     for br in text[start:end]:
@@ -883,7 +883,7 @@ class Emitter:
                     self.write_indent()
                     start = end
             else:
-                if ch is None or ch in ' \n\x85\u2028\u2029' or ch == '\'':
+                if ch is None or ch in ' \n\x85\\u2028\\u2029' or ch == '\'':
                     if start < end:
                         data = text[start:end]
                         self.column += len(data)
@@ -900,7 +900,7 @@ class Emitter:
                 start = end + 1
             if ch is not None:
                 spaces = (ch == ' ')
-                breaks = (ch in '\n\x85\u2028\u2029')
+                breaks = (ch in '\n\x85\\u2028\\u2029')
             end += 1
         self.write_indicator('\'', False)
 
@@ -918,8 +918,8 @@ class Emitter:
         '\\':       '\\',
         '\x85':     'N',
         '\xA0':     '_',
-        '\u2028':   'L',
-        '\u2029':   'P',
+        '\\u2028':   'L',
+        '\\u2029':   'P',
     }
 
     def write_double_quoted(self, text, split=True):
@@ -929,11 +929,11 @@ class Emitter:
             ch = None
             if end < len(text):
                 ch = text[end]
-            if ch is None or ch in '"\\\x85\u2028\u2029\uFEFF' \
+            if ch is None or ch in '"\\\x85\\u2028\\u2029\\uFEFF' \
                     or not ('\x20' <= ch <= '\x7E'
                         or (self.allow_unicode
-                            and ('\xA0' <= ch <= '\uD7FF'
-                                or '\uE000' <= ch <= '\uFFFD'))):
+                            and ('\xA0' <= ch <= '\\uD7FF'
+                                or '\\uE000' <= ch <= '\\uFFFD'))):
                 if start < end:
                     data = text[start:end]
                     self.column += len(data)
@@ -946,7 +946,7 @@ class Emitter:
                         data = '\\'+self.ESCAPE_REPLACEMENTS[ch]
                     elif ch <= '\xFF':
                         data = '\\x%02X' % ord(ch)
-                    elif ch <= '\uFFFF':
+                    elif ch <= '\\uFFFF':
                         data = '\\u%04X' % ord(ch)
                     else:
                         data = '\\U%08X' % ord(ch)
@@ -979,11 +979,11 @@ class Emitter:
     def determine_block_hints(self, text):
         hints = ''
         if text:
-            if text[0] in ' \n\x85\u2028\u2029':
+            if text[0] in ' \n\x85\\u2028\\u2029':
                 hints += str(self.best_indent)
-            if text[-1] not in '\n\x85\u2028\u2029':
+            if text[-1] not in '\n\x85\\u2028\\u2029':
                 hints += '-'
-            elif len(text) == 1 or text[-2] in '\n\x85\u2028\u2029':
+            elif len(text) == 1 or text[-2] in '\n\x85\\u2028\\u2029':
                 hints += '+'
         return hints
 
@@ -1002,7 +1002,7 @@ class Emitter:
             if end < len(text):
                 ch = text[end]
             if breaks:
-                if ch is None or ch not in '\n\x85\u2028\u2029':
+                if ch is None or ch not in '\n\x85\\u2028\\u2029':
                     if not leading_space and ch is not None and ch != ' '   \
                             and text[start] == '\n':
                         self.write_line_break()
@@ -1027,7 +1027,7 @@ class Emitter:
                         self.stream.write(data)
                     start = end
             else:
-                if ch is None or ch in ' \n\x85\u2028\u2029':
+                if ch is None or ch in ' \n\x85\\u2028\\u2029':
                     data = text[start:end]
                     self.column += len(data)
                     if self.encoding:
@@ -1037,7 +1037,7 @@ class Emitter:
                         self.write_line_break()
                     start = end
             if ch is not None:
-                breaks = (ch in '\n\x85\u2028\u2029')
+                breaks = (ch in '\n\x85\\u2028\\u2029')
                 spaces = (ch == ' ')
             end += 1
 
@@ -1054,7 +1054,7 @@ class Emitter:
             if end < len(text):
                 ch = text[end]
             if breaks:
-                if ch is None or ch not in '\n\x85\u2028\u2029':
+                if ch is None or ch not in '\n\x85\\u2028\\u2029':
                     for br in text[start:end]:
                         if br == '\n':
                             self.write_line_break()
@@ -1064,7 +1064,7 @@ class Emitter:
                         self.write_indent()
                     start = end
             else:
-                if ch is None or ch in '\n\x85\u2028\u2029':
+                if ch is None or ch in '\n\x85\\u2028\\u2029':
                     data = text[start:end]
                     if self.encoding:
                         data = data.encode(self.encoding)
@@ -1073,7 +1073,7 @@ class Emitter:
                         self.write_line_break()
                     start = end
             if ch is not None:
-                breaks = (ch in '\n\x85\u2028\u2029')
+                breaks = (ch in '\n\x85\\u2028\\u2029')
             end += 1
 
     def write_plain(self, text, split=True):
@@ -1110,7 +1110,7 @@ class Emitter:
                         self.stream.write(data)
                     start = end
             elif breaks:
-                if ch not in '\n\x85\u2028\u2029':
+                if ch not in '\n\x85\\u2028\\u2029':
                     if text[start] == '\n':
                         self.write_line_break()
                     for br in text[start:end]:
@@ -1123,7 +1123,7 @@ class Emitter:
                     self.indention = False
                     start = end
             else:
-                if ch is None or ch in ' \n\x85\u2028\u2029':
+                if ch is None or ch in ' \n\x85\\u2028\\u2029':
                     data = text[start:end]
                     self.column += len(data)
                     if self.encoding:
@@ -1132,6 +1132,6 @@ class Emitter:
                     start = end
             if ch is not None:
                 spaces = (ch == ' ')
-                breaks = (ch in '\n\x85\u2028\u2029')
+                breaks = (ch in '\n\x85\\u2028\\u2029')
             end += 1
 
diff --git a/python/pyyaml/lib3/yaml/error.py b/python/pyyaml/lib3/yaml/error.py
index b796b4dc51..aae8dbdbe8 100644
--- a/python/pyyaml/lib3/yaml/error.py
+++ b/python/pyyaml/lib3/yaml/error.py
@@ -16,7 +16,7 @@ class Mark:
             return None
         head = ''
         start = self.pointer
-        while start > 0 and self.buffer[start-1] not in '\0\r\n\x85\u2028\u2029':
+        while start > 0 and self.buffer[start-1] not in '\0\r\n\x85\\u2028\\u2029':
             start -= 1
             if self.pointer-start > max_length/2-1:
                 head = ' ... '
@@ -24,7 +24,7 @@ class Mark:
                 break
         tail = ''
         end = self.pointer
-        while end < len(self.buffer) and self.buffer[end] not in '\0\r\n\x85\u2028\u2029':
+        while end < len(self.buffer) and self.buffer[end] not in '\0\r\n\x85\\u2028\\u2029':
             end += 1
             if end-self.pointer > max_length/2-1:
                 tail = ' ... '
diff --git a/python/pyyaml/lib3/yaml/reader.py b/python/pyyaml/lib3/yaml/reader.py
index f70e920f44..20ac7efb66 100644
--- a/python/pyyaml/lib3/yaml/reader.py
+++ b/python/pyyaml/lib3/yaml/reader.py
@@ -103,11 +103,11 @@ class Reader(object):
             ch = self.buffer[self.pointer]
             self.pointer += 1
             self.index += 1
-            if ch in '\n\x85\u2028\u2029'  \
+            if ch in '\n\x85\\u2028\\u2029'  \
                     or (ch == '\r' and self.buffer[self.pointer] != '\n'):
                 self.line += 1
                 self.column = 0
-            elif ch != '\uFEFF':
+            elif ch != '\\uFEFF':
                 self.column += 1
             length -= 1
 
@@ -134,7 +134,7 @@ class Reader(object):
                 self.encoding = 'utf-8'
         self.update(1)
 
-    NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]')
+    NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\\uD7FF\\uE000-\\uFFFD]')
     def check_printable(self, data):
         match = self.NON_PRINTABLE.search(data)
         if match:
diff --git a/python/pyyaml/lib3/yaml/scanner.py b/python/pyyaml/lib3/yaml/scanner.py
index 494d975ba6..55b1540f53 100644
--- a/python/pyyaml/lib3/yaml/scanner.py
+++ b/python/pyyaml/lib3/yaml/scanner.py
@@ -693,7 +693,7 @@ class Scanner:
         # DOCUMENT-START:   ^ '---' (' '|'\n')
         if self.column == 0:
             if self.prefix(3) == '---'  \
-                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
+                    and self.peek(3) in '\0 \t\r\n\x85\\u2028\\u2029':
                 return True
 
     def check_document_end(self):
@@ -701,13 +701,13 @@ class Scanner:
         # DOCUMENT-END:     ^ '...' (' '|'\n')
         if self.column == 0:
             if self.prefix(3) == '...'  \
-                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
+                    and self.peek(3) in '\0 \t\r\n\x85\\u2028\\u2029':
                 return True
 
     def check_block_entry(self):
 
         # BLOCK-ENTRY:      '-' (' '|'\n')
-        return self.peek(1) in '\0 \t\r\n\x85\u2028\u2029'
+        return self.peek(1) in '\0 \t\r\n\x85\\u2028\\u2029'
 
     def check_key(self):
 
@@ -717,7 +717,7 @@ class Scanner:
 
         # KEY(block context):   '?' (' '|'\n')
         else:
-            return self.peek(1) in '\0 \t\r\n\x85\u2028\u2029'
+            return self.peek(1) in '\0 \t\r\n\x85\\u2028\\u2029'
 
     def check_value(self):
 
@@ -727,7 +727,7 @@ class Scanner:
 
         # VALUE(block context): ':' (' '|'\n')
         else:
-            return self.peek(1) in '\0 \t\r\n\x85\u2028\u2029'
+            return self.peek(1) in '\0 \t\r\n\x85\\u2028\\u2029'
 
     def check_plain(self):
 
@@ -744,8 +744,8 @@ class Scanner:
         # '-' character) because we want the flow context to be space
         # independent.
         ch = self.peek()
-        return ch not in '\0 \t\r\n\x85\u2028\u2029-?:,[]{}#&*!|>\'\"%@`'  \
-                or (self.peek(1) not in '\0 \t\r\n\x85\u2028\u2029'
+        return ch not in '\0 \t\r\n\x85\\u2028\\u2029-?:,[]{}#&*!|>\'\"%@`'  \
+                or (self.peek(1) not in '\0 \t\r\n\x85\\u2028\\u2029'
                         and (ch == '-' or (not self.flow_level and ch in '?:')))
 
     # Scanners.
@@ -770,14 +770,14 @@ class Scanner:
         # `unwind_indent` before issuing BLOCK-END.
         # Scanners for block, flow, and plain scalars need to be modified.
 
-        if self.index == 0 and self.peek() == '\uFEFF':
+        if self.index == 0 and self.peek() == '\\uFEFF':
             self.forward()
         found = False
         while not found:
             while self.peek() == ' ':
                 self.forward()
             if self.peek() == '#':
-                while self.peek() not in '\0\r\n\x85\u2028\u2029':
+                while self.peek() not in '\0\r\n\x85\\u2028\\u2029':
                     self.forward()
             if self.scan_line_break():
                 if not self.flow_level:
@@ -799,7 +799,7 @@ class Scanner:
             end_mark = self.get_mark()
         else:
             end_mark = self.get_mark()
-            while self.peek() not in '\0\r\n\x85\u2028\u2029':
+            while self.peek() not in '\0\r\n\x85\\u2028\\u2029':
                 self.forward()
         self.scan_directive_ignored_line(start_mark)
         return DirectiveToken(name, value, start_mark, end_mark)
@@ -819,7 +819,7 @@ class Scanner:
         value = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch not in '\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected alphabetic or numeric character, but found %r"
                     % ch, self.get_mark())
@@ -836,7 +836,7 @@ class Scanner:
                     self.get_mark())
         self.forward()
         minor = self.scan_yaml_directive_number(start_mark)
-        if self.peek() not in '\0 \r\n\x85\u2028\u2029':
+        if self.peek() not in '\0 \r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected a digit or ' ', but found %r" % self.peek(),
                     self.get_mark())
@@ -878,7 +878,7 @@ class Scanner:
         # See the specification for details.
         value = self.scan_tag_uri('directive', start_mark)
         ch = self.peek()
-        if ch not in '\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected ' ', but found %r" % ch, self.get_mark())
         return value
@@ -888,10 +888,10 @@ class Scanner:
         while self.peek() == ' ':
             self.forward()
         if self.peek() == '#':
-            while self.peek() not in '\0\r\n\x85\u2028\u2029':
+            while self.peek() not in '\0\r\n\x85\\u2028\\u2029':
                 self.forward()
         ch = self.peek()
-        if ch not in '\0\r\n\x85\u2028\u2029':
+        if ch not in '\0\r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a directive", start_mark,
                     "expected a comment or a line break, but found %r"
                         % ch, self.get_mark())
@@ -926,7 +926,7 @@ class Scanner:
         value = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch not in '\0 \t\r\n\x85\u2028\u2029?:,]}%@`':
+        if ch not in '\0 \t\r\n\x85\\u2028\\u2029?:,]}%@`':
             raise ScannerError("while scanning an %s" % name, start_mark,
                     "expected alphabetic or numeric character, but found %r"
                     % ch, self.get_mark())
@@ -946,14 +946,14 @@ class Scanner:
                         "expected '>', but found %r" % self.peek(),
                         self.get_mark())
             self.forward()
-        elif ch in '\0 \t\r\n\x85\u2028\u2029':
+        elif ch in '\0 \t\r\n\x85\\u2028\\u2029':
             handle = None
             suffix = '!'
             self.forward()
         else:
             length = 1
             use_handle = False
-            while ch not in '\0 \r\n\x85\u2028\u2029':
+            while ch not in '\0 \r\n\x85\\u2028\\u2029':
                 if ch == '!':
                     use_handle = True
                     break
@@ -967,7 +967,7 @@ class Scanner:
                 self.forward()
             suffix = self.scan_tag_uri('tag', start_mark)
         ch = self.peek()
-        if ch not in '\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a tag", start_mark,
                     "expected ' ', but found %r" % ch, self.get_mark())
         value = (handle, suffix)
@@ -1007,7 +1007,7 @@ class Scanner:
             chunks.extend(breaks)
             leading_non_space = self.peek() not in ' \t'
             length = 0
-            while self.peek(length) not in '\0\r\n\x85\u2028\u2029':
+            while self.peek(length) not in '\0\r\n\x85\\u2028\\u2029':
                 length += 1
             chunks.append(self.prefix(length))
             self.forward(length)
@@ -1084,7 +1084,7 @@ class Scanner:
                     chomping = False
                 self.forward()
         ch = self.peek()
-        if ch not in '\0 \r\n\x85\u2028\u2029':
+        if ch not in '\0 \r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a block scalar", start_mark,
                     "expected chomping or indentation indicators, but found %r"
                     % ch, self.get_mark())
@@ -1095,10 +1095,10 @@ class Scanner:
         while self.peek() == ' ':
             self.forward()
         if self.peek() == '#':
-            while self.peek() not in '\0\r\n\x85\u2028\u2029':
+            while self.peek() not in '\0\r\n\x85\\u2028\\u2029':
                 self.forward()
         ch = self.peek()
-        if ch not in '\0\r\n\x85\u2028\u2029':
+        if ch not in '\0\r\n\x85\\u2028\\u2029':
             raise ScannerError("while scanning a block scalar", start_mark,
                     "expected a comment or a line break, but found %r" % ch,
                     self.get_mark())
@@ -1109,7 +1109,7 @@ class Scanner:
         chunks = []
         max_indent = 0
         end_mark = self.get_mark()
-        while self.peek() in ' \r\n\x85\u2028\u2029':
+        while self.peek() in ' \r\n\x85\\u2028\\u2029':
             if self.peek() != ' ':
                 chunks.append(self.scan_line_break())
                 end_mark = self.get_mark()
@@ -1125,7 +1125,7 @@ class Scanner:
         end_mark = self.get_mark()
         while self.column < indent and self.peek() == ' ':
             self.forward()
-        while self.peek() in '\r\n\x85\u2028\u2029':
+        while self.peek() in '\r\n\x85\\u2028\\u2029':
             chunks.append(self.scan_line_break())
             end_mark = self.get_mark()
             while self.column < indent and self.peek() == ' ':
@@ -1172,8 +1172,8 @@ class Scanner:
         '\\':   '\\',
         'N':    '\x85',
         '_':    '\xA0',
-        'L':    '\u2028',
-        'P':    '\u2029',
+        'L':    '\\u2028',
+        'P':    '\\u2029',
     }
 
     ESCAPE_CODES = {
@@ -1187,7 +1187,7 @@ class Scanner:
         chunks = []
         while True:
             length = 0
-            while self.peek(length) not in '\'\"\\\0 \t\r\n\x85\u2028\u2029':
+            while self.peek(length) not in '\'\"\\\0 \t\r\n\x85\\u2028\\u2029':
                 length += 1
             if length:
                 chunks.append(self.prefix(length))
@@ -1216,7 +1216,7 @@ class Scanner:
                     code = int(self.prefix(length), 16)
                     chunks.append(chr(code))
                     self.forward(length)
-                elif ch in '\r\n\x85\u2028\u2029':
+                elif ch in '\r\n\x85\\u2028\\u2029':
                     self.scan_line_break()
                     chunks.extend(self.scan_flow_scalar_breaks(double, start_mark))
                 else:
@@ -1237,7 +1237,7 @@ class Scanner:
         if ch == '\0':
             raise ScannerError("while scanning a quoted scalar", start_mark,
                     "found unexpected end of stream", self.get_mark())
-        elif ch in '\r\n\x85\u2028\u2029':
+        elif ch in '\r\n\x85\\u2028\\u2029':
             line_break = self.scan_line_break()
             breaks = self.scan_flow_scalar_breaks(double, start_mark)
             if line_break != '\n':
@@ -1257,12 +1257,12 @@ class Scanner:
             # separators.
             prefix = self.prefix(3)
             if (prefix == '---' or prefix == '...')   \
-                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
+                    and self.peek(3) in '\0 \t\r\n\x85\\u2028\\u2029':
                 raise ScannerError("while scanning a quoted scalar", start_mark,
                         "found unexpected document separator", self.get_mark())
             while self.peek() in ' \t':
                 self.forward()
-            if self.peek() in '\r\n\x85\u2028\u2029':
+            if self.peek() in '\r\n\x85\\u2028\\u2029':
                 chunks.append(self.scan_line_break())
             else:
                 return chunks
@@ -1288,15 +1288,15 @@ class Scanner:
                 break
             while True:
                 ch = self.peek(length)
-                if ch in '\0 \t\r\n\x85\u2028\u2029'    \
+                if ch in '\0 \t\r\n\x85\\u2028\\u2029'    \
                         or (not self.flow_level and ch == ':' and
-                                self.peek(length+1) in '\0 \t\r\n\x85\u2028\u2029') \
+                                self.peek(length+1) in '\0 \t\r\n\x85\\u2028\\u2029') \
                         or (self.flow_level and ch in ',:?[]{}'):
                     break
                 length += 1
             # It's not clear what we should do with ':' in the flow context.
             if (self.flow_level and ch == ':'
-                    and self.peek(length+1) not in '\0 \t\r\n\x85\u2028\u2029,[]{}'):
+                    and self.peek(length+1) not in '\0 \t\r\n\x85\\u2028\\u2029,[]{}'):
                 self.forward(length)
                 raise ScannerError("while scanning a plain scalar", start_mark,
                     "found unexpected ':'", self.get_mark(),
@@ -1325,22 +1325,22 @@ class Scanner:
         whitespaces = self.prefix(length)
         self.forward(length)
         ch = self.peek()
-        if ch in '\r\n\x85\u2028\u2029':
+        if ch in '\r\n\x85\\u2028\\u2029':
             line_break = self.scan_line_break()
             self.allow_simple_key = True
             prefix = self.prefix(3)
             if (prefix == '---' or prefix == '...')   \
-                    and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
+                    and self.peek(3) in '\0 \t\r\n\x85\\u2028\\u2029':
                 return
             breaks = []
-            while self.peek() in ' \r\n\x85\u2028\u2029':
+            while self.peek() in ' \r\n\x85\\u2028\\u2029':
                 if self.peek() == ' ':
                     self.forward()
                 else:
                     breaks.append(self.scan_line_break())
                     prefix = self.prefix(3)
                     if (prefix == '---' or prefix == '...')   \
-                            and self.peek(3) in '\0 \t\r\n\x85\u2028\u2029':
+                            and self.peek(3) in '\0 \t\r\n\x85\\u2028\\u2029':
                         return
             if line_break != '\n':
                 chunks.append(line_break)
@@ -1435,7 +1435,7 @@ class Scanner:
             else:
                 self.forward()
             return '\n'
-        elif ch in '\u2028\u2029':
+        elif ch in '\\u2028\\u2029':
             self.forward()
             return ch
         return ''
diff --git a/python/requests/requests/compat.py b/python/requests/requests/compat.py
index 50331a01bb..89c3d243f0 100644
--- a/python/requests/requests/compat.py
+++ b/python/requests/requests/compat.py
@@ -44,7 +44,7 @@ if is_py2:
 
     builtin_str = str
     bytes = str
-    str = unicode
+    str = str
     basestring = basestring
     numeric_types = (int, int, float)
 
diff --git a/python/requests/requests/models.py b/python/requests/requests/models.py
index 66a6d94194..fd760cf4c6 100644
--- a/python/requests/requests/models.py
+++ b/python/requests/requests/models.py
@@ -331,7 +331,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin):
         if isinstance(url, bytes):
             url = url.decode('utf8')
         else:
-            url = unicode(url) if is_py2 else str(url)
+            url = str(url) if is_py2 else str(url)
 
         # Don't do any URL preparation for non-HTTP schemes like `mailto`,
         # `data` etc to work around exceptions from `url_parse`, which
diff --git a/python/requests/requests/packages/chardet/__init__.py b/python/requests/requests/packages/chardet/__init__.py
index 82c2a48d29..09d2a3991f 100644
--- a/python/requests/requests/packages/chardet/__init__.py
+++ b/python/requests/requests/packages/chardet/__init__.py
@@ -20,7 +20,7 @@ from sys import version_info
 
 
 def detect(aBuf):
-    if ((version_info < (3, 0) and isinstance(aBuf, unicode)) or
+    if ((version_info < (3, 0) and isinstance(aBuf, str)) or
             (version_info >= (3, 0) and not isinstance(aBuf, bytes))):
         raise ValueError('Expected a bytes object, not a unicode object')
 
diff --git a/python/requests/requests/packages/chardet/compat.py b/python/requests/requests/packages/chardet/compat.py
index d9e30addf9..4ff462c74a 100644
--- a/python/requests/requests/packages/chardet/compat.py
+++ b/python/requests/requests/packages/chardet/compat.py
@@ -22,7 +22,7 @@ import sys
 
 
 if sys.version_info < (3, 0):
-    base_str = (str, unicode)
+    base_str = (str, str)
 else:
     base_str = (bytes, str)
 
diff --git a/python/requests/requests/packages/urllib3/packages/six.py b/python/requests/requests/packages/urllib3/packages/six.py
index 712b15fb19..c0cb6c8e50 100644
--- a/python/requests/requests/packages/urllib3/packages/six.py
+++ b/python/requests/requests/packages/urllib3/packages/six.py
@@ -42,7 +42,7 @@ else:
     string_types = basestring,
     integer_types = (int, int)
     class_types = (type, types.ClassType)
-    text_type = unicode
+    text_type = str
     binary_type = str
 
     if sys.platform.startswith("java"):
@@ -291,7 +291,7 @@ else:
     def b(s):
         return s
     def u(s):
-        return unicode(s, "unicode_escape")
+        return str(s, "unicode_escape")
     int2byte = chr
     import io
     StringIO = BytesIO = io.StringIO
@@ -344,13 +344,13 @@ else:
         want_unicode = False
         sep = kwargs.pop("sep", None)
         if sep is not None:
-            if isinstance(sep, unicode):
+            if isinstance(sep, str):
                 want_unicode = True
             elif not isinstance(sep, str):
                 raise TypeError("sep must be None or a string")
         end = kwargs.pop("end", None)
         if end is not None:
-            if isinstance(end, unicode):
+            if isinstance(end, str):
                 want_unicode = True
             elif not isinstance(end, str):
                 raise TypeError("end must be None or a string")
@@ -358,12 +358,12 @@ else:
             raise TypeError("invalid keyword arguments to print()")
         if not want_unicode:
             for arg in args:
-                if isinstance(arg, unicode):
+                if isinstance(arg, str):
                     want_unicode = True
                     break
         if want_unicode:
-            newline = unicode("\n")
-            space = unicode(" ")
+            newline = str("\n")
+            space = str(" ")
         else:
             newline = "\n"
             space = " "
diff --git a/python/requests/test_requests.py b/python/requests/test_requests.py
index 081dc02053..431cb39472 100755
--- a/python/requests/test_requests.py
+++ b/python/requests/test_requests.py
@@ -159,7 +159,7 @@ class TestRequests(object):
 
     def test_binary_put(self):
         request = requests.Request('PUT', 'http://example.com',
-                                   data=u"ööö".encode("utf-8")).prepare()
+                                   data="ööö".encode("utf-8")).prepare()
         assert isinstance(request.body, bytes)
 
     def test_mixed_case_scheme_acceptable(self, httpbin):
@@ -1731,7 +1731,7 @@ def test_urllib3_pool_connection_closed(httpbin):
     try:
         s.get(httpbin('status/200'))
     except ConnectionError as e:
-        assert u"Pool is closed." in str(e)
+        assert "Pool is closed." in str(e)
 
 
 def test_vendor_aliases():
diff --git a/python/rsa/rsa/_compat.py b/python/rsa/rsa/_compat.py
index d9eb76e45e..b803026921 100644
--- a/python/rsa/rsa/_compat.py
+++ b/python/rsa/rsa/_compat.py
@@ -45,7 +45,7 @@ else:
 
 try:
     # < Python3
-    unicode_type = unicode
+    unicode_type = str
     have_python3 = False
 except NameError:
     # Python3.
diff --git a/python/rsa/tests/py2kconstants.py b/python/rsa/tests/py2kconstants.py
index 5f695dd227..83b67129c9 100644
--- a/python/rsa/tests/py2kconstants.py
+++ b/python/rsa/tests/py2kconstants.py
@@ -1,3 +1,3 @@
 # -*- coding: utf-8 -*-
 
-unicode_string = u"Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+unicode_string = "Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
diff --git a/python/rsa/tests/py3kconstants.py b/python/rsa/tests/py3kconstants.py
index 83b67129c9..7973d61550 100644
--- a/python/rsa/tests/py3kconstants.py
+++ b/python/rsa/tests/py3kconstants.py
@@ -1,3 +1,3 @@
 # -*- coding: utf-8 -*-
 
-unicode_string = "Euro=\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+unicode_string = "Euro=\\u20ac ABCDEFGHIJKLMNOPQRSTUVWXYZ"
diff --git a/python/virtualenv/virtualenv.py b/python/virtualenv/virtualenv.py
index dca62da55e..991c9bd946 100755
--- a/python/virtualenv/virtualenv.py
+++ b/python/virtualenv/virtualenv.py
@@ -974,7 +974,7 @@ def path_locations(home_dir):
             size = max(len(home_dir)+1, 256)
             buf = ctypes.create_unicode_buffer(size)
             try:
-                u = unicode
+                u = str
             except NameError:
                 u = str
             ret = GetShortPathName(u(home_dir), buf, size)
diff --git a/python/voluptuous/voluptuous.py b/python/voluptuous/voluptuous.py
index b759dfbc08..b0396e3a54 100644
--- a/python/voluptuous/voluptuous.py
+++ b/python/voluptuous/voluptuous.py
@@ -96,7 +96,7 @@ from functools import wraps
 if sys.version_info >= (3,):
     import urllib.parse as urlparse
     long = int
-    unicode = str
+    str = str
     basestring = str
     ifilter = filter
     iteritems = lambda d: list(d.items())
@@ -376,7 +376,7 @@ class Schema(object):
         type_ = type(schema)
         if type_ is type:
             type_ = schema
-        if type_ in (bool, int, int, str, unicode, float, complex, object,
+        if type_ in (bool, int, int, str, str, float, complex, object,
                      list, dict, type(None)) or callable(schema):
             return _compile_scalar(schema)
         raise SchemaError('unsupported schema data type %r' %
diff --git a/security/nss/gtests/google_test/gtest/test/googletest-json-outfiles-test.py b/security/nss/gtests/google_test/gtest/test/googletest-json-outfiles-test.py
index 8e06aae1aa..73ff20c180 100644
--- a/security/nss/gtests/google_test/gtest/test/googletest-json-outfiles-test.py
+++ b/security/nss/gtests/google_test/gtest/test/googletest-json-outfiles-test.py
@@ -40,89 +40,89 @@ GTEST_OUTPUT_1_TEST = 'gtest_xml_outfile1_test_'
 GTEST_OUTPUT_2_TEST = 'gtest_xml_outfile2_test_'
 
 EXPECTED_1 = {
-    u'tests':
+    'tests':
         1,
-    u'failures':
+    'failures':
         0,
-    u'disabled':
+    'disabled':
         0,
-    u'errors':
+    'errors':
         0,
-    u'time':
-        u'*',
-    u'timestamp':
-        u'*',
-    u'name':
-        u'AllTests',
-    u'testsuites': [{
-        u'name':
-            u'PropertyOne',
-        u'tests':
+    'time':
+        '*',
+    'timestamp':
+        '*',
+    'name':
+        'AllTests',
+    'testsuites': [{
+        'name':
+            'PropertyOne',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'TestSomeProperties',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'PropertyOne',
-            u'SetUpProp': u'1',
-            u'TestSomeProperty': u'1',
-            u'TearDownProp': u'1',
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'TestSomeProperties',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'PropertyOne',
+            'SetUpProp': '1',
+            'TestSomeProperty': '1',
+            'TearDownProp': '1',
         }],
     }],
 }
 
 EXPECTED_2 = {
-    u'tests':
+    'tests':
         1,
-    u'failures':
+    'failures':
         0,
-    u'disabled':
+    'disabled':
         0,
-    u'errors':
+    'errors':
         0,
-    u'time':
-        u'*',
-    u'timestamp':
-        u'*',
-    u'name':
-        u'AllTests',
-    u'testsuites': [{
-        u'name':
-            u'PropertyTwo',
-        u'tests':
+    'time':
+        '*',
+    'timestamp':
+        '*',
+    'name':
+        'AllTests',
+    'testsuites': [{
+        'name':
+            'PropertyTwo',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'TestSomeProperties',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'timestamp': u'*',
-            u'time': u'*',
-            u'classname': u'PropertyTwo',
-            u'SetUpProp': u'2',
-            u'TestSomeProperty': u'2',
-            u'TearDownProp': u'2',
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'TestSomeProperties',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'timestamp': '*',
+            'time': '*',
+            'classname': 'PropertyTwo',
+            'SetUpProp': '2',
+            'TestSomeProperty': '2',
+            'TearDownProp': '2',
         }],
     }],
 }
diff --git a/security/nss/gtests/google_test/gtest/test/googletest-json-output-unittest.py b/security/nss/gtests/google_test/gtest/test/googletest-json-output-unittest.py
index b74ccd3b19..0a2a1ba464 100644
--- a/security/nss/gtests/google_test/gtest/test/googletest-json-output-unittest.py
+++ b/security/nss/gtests/google_test/gtest/test/googletest-json-output-unittest.py
@@ -57,611 +57,611 @@ else:
   STACK_TRACE_TEMPLATE = ''
 
 EXPECTED_NON_EMPTY = {
-    u'tests':
+    'tests':
         26,
-    u'failures':
+    'failures':
         5,
-    u'disabled':
+    'disabled':
         2,
-    u'errors':
+    'errors':
         0,
-    u'timestamp':
-        u'*',
-    u'time':
-        u'*',
-    u'ad_hoc_property':
-        u'42',
-    u'name':
-        u'AllTests',
-    u'testsuites': [{
-        u'name':
-            u'SuccessfulTest',
-        u'tests':
+    'timestamp':
+        '*',
+    'time':
+        '*',
+    'ad_hoc_property':
+        '42',
+    'name':
+        'AllTests',
+    'testsuites': [{
+        'name':
+            'SuccessfulTest',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'Succeeds',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'SuccessfulTest'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'Succeeds',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'SuccessfulTest'
         }]
     }, {
-        u'name':
-            u'FailedTest',
-        u'tests':
+        'name':
+            'FailedTest',
+        'tests':
             1,
-        u'failures':
+        'failures':
             1,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name':
-                u'Fails',
-            u'status':
-                u'RUN',
-            u'result':
-                u'COMPLETED',
-            u'time':
-                u'*',
-            u'timestamp':
-                u'*',
-            u'classname':
-                u'FailedTest',
-            u'failures': [{
-                u'failure': u'gtest_xml_output_unittest_.cc:*\n'
-                            u'Expected equality of these values:\n'
-                            u'  1\n  2' + STACK_TRACE_TEMPLATE,
-                u'type': u''
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name':
+                'Fails',
+            'status':
+                'RUN',
+            'result':
+                'COMPLETED',
+            'time':
+                '*',
+            'timestamp':
+                '*',
+            'classname':
+                'FailedTest',
+            'failures': [{
+                'failure': 'gtest_xml_output_unittest_.cc:*\n'
+                            'Expected equality of these values:\n'
+                            '  1\n  2' + STACK_TRACE_TEMPLATE,
+                'type': ''
             }]
         }]
     }, {
-        u'name':
-            u'DisabledTest',
-        u'tests':
+        'name':
+            'DisabledTest',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             1,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'DISABLED_test_not_run',
-            u'status': u'NOTRUN',
-            u'result': u'SUPPRESSED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'DisabledTest'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'DISABLED_test_not_run',
+            'status': 'NOTRUN',
+            'result': 'SUPPRESSED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'DisabledTest'
         }]
     }, {
-        u'name':
-            u'SkippedTest',
-        u'tests':
+        'name':
+            'SkippedTest',
+        'tests':
             3,
-        u'failures':
+        'failures':
             1,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'Skipped',
-            u'status': u'RUN',
-            u'result': u'SKIPPED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'SkippedTest'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'Skipped',
+            'status': 'RUN',
+            'result': 'SKIPPED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'SkippedTest'
         }, {
-            u'name': u'SkippedWithMessage',
-            u'status': u'RUN',
-            u'result': u'SKIPPED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'SkippedTest'
+            'name': 'SkippedWithMessage',
+            'status': 'RUN',
+            'result': 'SKIPPED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'SkippedTest'
         }, {
-            u'name':
-                u'SkippedAfterFailure',
-            u'status':
-                u'RUN',
-            u'result':
-                u'COMPLETED',
-            u'time':
-                u'*',
-            u'timestamp':
-                u'*',
-            u'classname':
-                u'SkippedTest',
-            u'failures': [{
-                u'failure': u'gtest_xml_output_unittest_.cc:*\n'
-                            u'Expected equality of these values:\n'
-                            u'  1\n  2' + STACK_TRACE_TEMPLATE,
-                u'type': u''
+            'name':
+                'SkippedAfterFailure',
+            'status':
+                'RUN',
+            'result':
+                'COMPLETED',
+            'time':
+                '*',
+            'timestamp':
+                '*',
+            'classname':
+                'SkippedTest',
+            'failures': [{
+                'failure': 'gtest_xml_output_unittest_.cc:*\n'
+                            'Expected equality of these values:\n'
+                            '  1\n  2' + STACK_TRACE_TEMPLATE,
+                'type': ''
             }]
         }]
     }, {
-        u'name':
-            u'MixedResultTest',
-        u'tests':
+        'name':
+            'MixedResultTest',
+        'tests':
             3,
-        u'failures':
+        'failures':
             1,
-        u'disabled':
+        'disabled':
             1,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'Succeeds',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'MixedResultTest'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'Succeeds',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'MixedResultTest'
         }, {
-            u'name':
-                u'Fails',
-            u'status':
-                u'RUN',
-            u'result':
-                u'COMPLETED',
-            u'time':
-                u'*',
-            u'timestamp':
-                u'*',
-            u'classname':
-                u'MixedResultTest',
-            u'failures': [{
-                u'failure': u'gtest_xml_output_unittest_.cc:*\n'
-                            u'Expected equality of these values:\n'
-                            u'  1\n  2' + STACK_TRACE_TEMPLATE,
-                u'type': u''
+            'name':
+                'Fails',
+            'status':
+                'RUN',
+            'result':
+                'COMPLETED',
+            'time':
+                '*',
+            'timestamp':
+                '*',
+            'classname':
+                'MixedResultTest',
+            'failures': [{
+                'failure': 'gtest_xml_output_unittest_.cc:*\n'
+                            'Expected equality of these values:\n'
+                            '  1\n  2' + STACK_TRACE_TEMPLATE,
+                'type': ''
             }, {
-                u'failure': u'gtest_xml_output_unittest_.cc:*\n'
-                            u'Expected equality of these values:\n'
-                            u'  2\n  3' + STACK_TRACE_TEMPLATE,
-                u'type': u''
+                'failure': 'gtest_xml_output_unittest_.cc:*\n'
+                            'Expected equality of these values:\n'
+                            '  2\n  3' + STACK_TRACE_TEMPLATE,
+                'type': ''
             }]
         }, {
-            u'name': u'DISABLED_test',
-            u'status': u'NOTRUN',
-            u'result': u'SUPPRESSED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'MixedResultTest'
+            'name': 'DISABLED_test',
+            'status': 'NOTRUN',
+            'result': 'SUPPRESSED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'MixedResultTest'
         }]
     }, {
-        u'name':
-            u'XmlQuotingTest',
-        u'tests':
+        'name':
+            'XmlQuotingTest',
+        'tests':
             1,
-        u'failures':
+        'failures':
             1,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name':
-                u'OutputsCData',
-            u'status':
-                u'RUN',
-            u'result':
-                u'COMPLETED',
-            u'time':
-                u'*',
-            u'timestamp':
-                u'*',
-            u'classname':
-                u'XmlQuotingTest',
-            u'failures': [{
-                u'failure': u'gtest_xml_output_unittest_.cc:*\n'
-                            u'Failed\nXML output: '
-                            u'' +
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name':
+                'OutputsCData',
+            'status':
+                'RUN',
+            'result':
+                'COMPLETED',
+            'time':
+                '*',
+            'timestamp':
+                '*',
+            'classname':
+                'XmlQuotingTest',
+            'failures': [{
+                'failure': 'gtest_xml_output_unittest_.cc:*\n'
+                            'Failed\nXML output: '
+                            '' +
                             STACK_TRACE_TEMPLATE,
-                u'type': u''
+                'type': ''
             }]
         }]
     }, {
-        u'name':
-            u'InvalidCharactersTest',
-        u'tests':
+        'name':
+            'InvalidCharactersTest',
+        'tests':
             1,
-        u'failures':
+        'failures':
             1,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name':
-                u'InvalidCharactersInMessage',
-            u'status':
-                u'RUN',
-            u'result':
-                u'COMPLETED',
-            u'time':
-                u'*',
-            u'timestamp':
-                u'*',
-            u'classname':
-                u'InvalidCharactersTest',
-            u'failures': [{
-                u'failure': u'gtest_xml_output_unittest_.cc:*\n'
-                            u'Failed\nInvalid characters in brackets'
-                            u' [\x01\x02]' + STACK_TRACE_TEMPLATE,
-                u'type': u''
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name':
+                'InvalidCharactersInMessage',
+            'status':
+                'RUN',
+            'result':
+                'COMPLETED',
+            'time':
+                '*',
+            'timestamp':
+                '*',
+            'classname':
+                'InvalidCharactersTest',
+            'failures': [{
+                'failure': 'gtest_xml_output_unittest_.cc:*\n'
+                            'Failed\nInvalid characters in brackets'
+                            ' [\x01\x02]' + STACK_TRACE_TEMPLATE,
+                'type': ''
             }]
         }]
     }, {
-        u'name':
-            u'PropertyRecordingTest',
-        u'tests':
+        'name':
+            'PropertyRecordingTest',
+        'tests':
             4,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'SetUpTestSuite':
-            u'yes',
-        u'TearDownTestSuite':
-            u'aye',
-        u'testsuite': [{
-            u'name': u'OneProperty',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'PropertyRecordingTest',
-            u'key_1': u'1'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'SetUpTestSuite':
+            'yes',
+        'TearDownTestSuite':
+            'aye',
+        'testsuite': [{
+            'name': 'OneProperty',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'PropertyRecordingTest',
+            'key_1': '1'
         }, {
-            u'name': u'IntValuedProperty',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'PropertyRecordingTest',
-            u'key_int': u'1'
+            'name': 'IntValuedProperty',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'PropertyRecordingTest',
+            'key_int': '1'
         }, {
-            u'name': u'ThreeProperties',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'PropertyRecordingTest',
-            u'key_1': u'1',
-            u'key_2': u'2',
-            u'key_3': u'3'
+            'name': 'ThreeProperties',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'PropertyRecordingTest',
+            'key_1': '1',
+            'key_2': '2',
+            'key_3': '3'
         }, {
-            u'name': u'TwoValuesForOneKeyUsesLastValue',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'PropertyRecordingTest',
-            u'key_1': u'2'
+            'name': 'TwoValuesForOneKeyUsesLastValue',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'PropertyRecordingTest',
+            'key_1': '2'
         }]
     }, {
-        u'name':
-            u'NoFixtureTest',
-        u'tests':
+        'name':
+            'NoFixtureTest',
+        'tests':
             3,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'RecordProperty',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'NoFixtureTest',
-            u'key': u'1'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'RecordProperty',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'NoFixtureTest',
+            'key': '1'
         }, {
-            u'name': u'ExternalUtilityThatCallsRecordIntValuedProperty',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'NoFixtureTest',
-            u'key_for_utility_int': u'1'
+            'name': 'ExternalUtilityThatCallsRecordIntValuedProperty',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'NoFixtureTest',
+            'key_for_utility_int': '1'
         }, {
-            u'name': u'ExternalUtilityThatCallsRecordStringValuedProperty',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'NoFixtureTest',
-            u'key_for_utility_string': u'1'
+            'name': 'ExternalUtilityThatCallsRecordStringValuedProperty',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'NoFixtureTest',
+            'key_for_utility_string': '1'
         }]
     }, {
-        u'name':
-            u'TypedTest/0',
-        u'tests':
+        'name':
+            'TypedTest/0',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'HasTypeParamAttribute',
-            u'type_param': u'int',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'TypedTest/0'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'HasTypeParamAttribute',
+            'type_param': 'int',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'TypedTest/0'
         }]
     }, {
-        u'name':
-            u'TypedTest/1',
-        u'tests':
+        'name':
+            'TypedTest/1',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'HasTypeParamAttribute',
-            u'type_param': u'long',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'TypedTest/1'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'HasTypeParamAttribute',
+            'type_param': 'long',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'TypedTest/1'
         }]
     }, {
-        u'name':
-            u'Single/TypeParameterizedTestSuite/0',
-        u'tests':
+        'name':
+            'Single/TypeParameterizedTestSuite/0',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'HasTypeParamAttribute',
-            u'type_param': u'int',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'Single/TypeParameterizedTestSuite/0'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'HasTypeParamAttribute',
+            'type_param': 'int',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'Single/TypeParameterizedTestSuite/0'
         }]
     }, {
-        u'name':
-            u'Single/TypeParameterizedTestSuite/1',
-        u'tests':
+        'name':
+            'Single/TypeParameterizedTestSuite/1',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'HasTypeParamAttribute',
-            u'type_param': u'long',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'Single/TypeParameterizedTestSuite/1'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'HasTypeParamAttribute',
+            'type_param': 'long',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'Single/TypeParameterizedTestSuite/1'
         }]
     }, {
-        u'name':
-            u'Single/ValueParamTest',
-        u'tests':
+        'name':
+            'Single/ValueParamTest',
+        'tests':
             4,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'HasValueParamAttribute/0',
-            u'value_param': u'33',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'Single/ValueParamTest'
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'HasValueParamAttribute/0',
+            'value_param': '33',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'Single/ValueParamTest'
         }, {
-            u'name': u'HasValueParamAttribute/1',
-            u'value_param': u'42',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'Single/ValueParamTest'
+            'name': 'HasValueParamAttribute/1',
+            'value_param': '42',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'Single/ValueParamTest'
         }, {
-            u'name': u'AnotherTestThatHasValueParamAttribute/0',
-            u'value_param': u'33',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'Single/ValueParamTest'
+            'name': 'AnotherTestThatHasValueParamAttribute/0',
+            'value_param': '33',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'Single/ValueParamTest'
         }, {
-            u'name': u'AnotherTestThatHasValueParamAttribute/1',
-            u'value_param': u'42',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'Single/ValueParamTest'
+            'name': 'AnotherTestThatHasValueParamAttribute/1',
+            'value_param': '42',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'Single/ValueParamTest'
         }]
     }]
 }
 
 EXPECTED_FILTERED = {
-    u'tests':
+    'tests':
         1,
-    u'failures':
+    'failures':
         0,
-    u'disabled':
+    'disabled':
         0,
-    u'errors':
+    'errors':
         0,
-    u'time':
-        u'*',
-    u'timestamp':
-        u'*',
-    u'name':
-        u'AllTests',
-    u'ad_hoc_property':
-        u'42',
-    u'testsuites': [{
-        u'name':
-            u'SuccessfulTest',
-        u'tests':
+    'time':
+        '*',
+    'timestamp':
+        '*',
+    'name':
+        'AllTests',
+    'ad_hoc_property':
+        '42',
+    'testsuites': [{
+        'name':
+            'SuccessfulTest',
+        'tests':
             1,
-        u'failures':
+        'failures':
             0,
-        u'disabled':
+        'disabled':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name': u'Succeeds',
-            u'status': u'RUN',
-            u'result': u'COMPLETED',
-            u'time': u'*',
-            u'timestamp': u'*',
-            u'classname': u'SuccessfulTest',
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name': 'Succeeds',
+            'status': 'RUN',
+            'result': 'COMPLETED',
+            'time': '*',
+            'timestamp': '*',
+            'classname': 'SuccessfulTest',
         }]
     }],
 }
 
 EXPECTED_NO_TEST = {
-    u'tests':
+    'tests':
         0,
-    u'failures':
+    'failures':
         0,
-    u'disabled':
+    'disabled':
         0,
-    u'errors':
+    'errors':
         0,
-    u'time':
-        u'*',
-    u'timestamp':
-        u'*',
-    u'name':
-        u'AllTests',
-    u'testsuites': [{
-        u'name':
-            u'NonTestSuiteFailure',
-        u'tests':
+    'time':
+        '*',
+    'timestamp':
+        '*',
+    'name':
+        'AllTests',
+    'testsuites': [{
+        'name':
+            'NonTestSuiteFailure',
+        'tests':
             1,
-        u'failures':
+        'failures':
             1,
-        u'disabled':
+        'disabled':
             0,
-        u'skipped':
+        'skipped':
             0,
-        u'errors':
+        'errors':
             0,
-        u'time':
-            u'*',
-        u'timestamp':
-            u'*',
-        u'testsuite': [{
-            u'name':
-                u'',
-            u'status':
-                u'RUN',
-            u'result':
-                u'COMPLETED',
-            u'time':
-                u'*',
-            u'timestamp':
-                u'*',
-            u'classname':
-                u'',
-            u'failures': [{
-                u'failure': u'gtest_no_test_unittest.cc:*\n'
-                            u'Expected equality of these values:\n'
-                            u'  1\n  2' + STACK_TRACE_TEMPLATE,
-                u'type': u'',
+        'time':
+            '*',
+        'timestamp':
+            '*',
+        'testsuite': [{
+            'name':
+                '',
+            'status':
+                'RUN',
+            'result':
+                'COMPLETED',
+            'time':
+                '*',
+            'timestamp':
+                '*',
+            'classname':
+                '',
+            'failures': [{
+                'failure': 'gtest_no_test_unittest.cc:*\n'
+                            'Expected equality of these values:\n'
+                            '  1\n  2' + STACK_TRACE_TEMPLATE,
+                'type': '',
             }]
         }]
     }],
diff --git a/taskcluster/taskgraph/test/test_transforms_base.py b/taskcluster/taskgraph/test/test_transforms_base.py
index bbc2d3dda2..56af30c7ad 100644
--- a/taskcluster/taskgraph/test/test_transforms_base.py
+++ b/taskcluster/taskgraph/test/test_transforms_base.py
@@ -41,8 +41,8 @@ class TestTransformSequence(unittest.TestCase):
         tests = [{}, {'two': 1, 'second': True}]
         res = list(transforms({}, tests))
         self.assertEqual(res, [
-            {u'two': 2, u'one': 1},
-            {u'second': True, u'two': 2, u'one': 1},
+            {'two': 2, 'one': 1},
+            {'second': True, 'two': 2, 'one': 1},
         ])
 
 
diff --git a/testing/mochitest/pywebsocket/mod_pywebsocket/_stream_hybi.py b/testing/mochitest/pywebsocket/mod_pywebsocket/_stream_hybi.py
index 718e8ffa39..5ae839e70a 100644
--- a/testing/mochitest/pywebsocket/mod_pywebsocket/_stream_hybi.py
+++ b/testing/mochitest/pywebsocket/mod_pywebsocket/_stream_hybi.py
@@ -501,7 +501,7 @@ class Stream(StreamBase):
             raise BadOperationException(
                 'Requested send_message after sending out a closing handshake')
 
-        if binary and isinstance(message, unicode):
+        if binary and isinstance(message, str):
             raise BadOperationException(
                 'Message for binary frame must be instance of str')
 
@@ -837,7 +837,7 @@ class Stream(StreamBase):
                     'close reason must not be specified if code is None')
             reason = ''
         else:
-            if not isinstance(reason, str) and not isinstance(reason, unicode):
+            if not isinstance(reason, str) and not isinstance(reason, str):
                 raise BadOperationException(
                     'close reason must be an instance of str or unicode')
 
diff --git a/testing/mochitest/pywebsocket/mod_pywebsocket/mux.py b/testing/mochitest/pywebsocket/mod_pywebsocket/mux.py
index 7eed4e118d..3c7238aaef 100644
--- a/testing/mochitest/pywebsocket/mod_pywebsocket/mux.py
+++ b/testing/mochitest/pywebsocket/mod_pywebsocket/mux.py
@@ -960,7 +960,7 @@ class _LogicalStream(Stream):
             raise BadOperationException(
                 'Requested send_message after sending out a closing handshake')
 
-        if binary and isinstance(message, unicode):
+        if binary and isinstance(message, str):
             raise BadOperationException(
                 'Message for binary frame must be instance of str')
 
diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py
index b7f4fc3bb4..30460db71a 100644
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -135,7 +135,7 @@ class MessageLogger(object):
     """File-like object for logging messages (structured logs)"""
     BUFFERING_THRESHOLD = 100
     # This is a delimiter used by the JS side to avoid logs interleaving
-    DELIMITER = u'\ue175\uee31\u2c32\uacbf'
+    DELIMITER = '\ue175\uee31\u2c32\uacbf'
     BUFFERED_ACTIONS = set(['test_status', 'log'])
     VALID_ACTIONS = set(['suite_start', 'suite_end', 'test_start', 'test_end',
                          'test_status', 'log',
@@ -179,8 +179,8 @@ class MessageLogger(object):
         if 'message' in message:
             if isinstance(message['message'], bytes):
                 message['message'] = message['message'].decode('utf-8', 'replace')
-            elif not isinstance(message['message'], unicode):
-                message['message'] = unicode(message['message'])
+            elif not isinstance(message['message'], str):
+                message['message'] = str(message['message'])
 
     def parse_line(self, line):
         """Takes a given line of input (structured or not) and
diff --git a/testing/mozbase/docs/conf.py b/testing/mozbase/docs/conf.py
index 95d6de64ba..845ce54318 100644
--- a/testing/mozbase/docs/conf.py
+++ b/testing/mozbase/docs/conf.py
@@ -47,8 +47,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'MozBase'
-copyright = u'2012, Mozilla Automation and Tools team'
+project = 'MozBase'
+copyright = '2012, Mozilla Automation and Tools team'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -199,8 +199,8 @@ latex_elements = {
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, documentclass [howto/manual]).
 latex_documents = [
-    ('index', 'MozBase.tex', u'MozBase Documentation',
-     u'Mozilla Automation and Tools team', 'manual'),
+    ('index', 'MozBase.tex', 'MozBase Documentation',
+     'Mozilla Automation and Tools team', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -229,8 +229,8 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'mozbase', u'MozBase Documentation',
-     [u'Mozilla Automation and Tools team'], 1)
+    ('index', 'mozbase', 'MozBase Documentation',
+     ['Mozilla Automation and Tools team'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -243,8 +243,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-    ('index', 'MozBase', u'MozBase Documentation',
-     u'Mozilla Automation and Tools team', 'MozBase', 'One line description of project.',
+    ('index', 'MozBase', 'MozBase Documentation',
+     'Mozilla Automation and Tools team', 'MozBase', 'One line description of project.',
      'Miscellaneous'),
 ]
 
diff --git a/testing/mozbase/mozcrash/mozcrash/mozcrash.py b/testing/mozbase/mozcrash/mozcrash/mozcrash.py
index 6850c82e6b..b80260cdf6 100644
--- a/testing/mozbase/mozcrash/mozcrash/mozcrash.py
+++ b/testing/mozbase/mozcrash/mozcrash/mozcrash.py
@@ -422,7 +422,7 @@ if mozinfo.isWin:
                 log.error("minidumpwriter not found in %s" % utility_path)
                 return
 
-            if isinstance(file_name, unicode):
+            if isinstance(file_name, str):
                 # Convert to a byte string before sending to the shell.
                 file_name = file_name.encode(sys.getfilesystemencoding())
 
@@ -436,10 +436,10 @@ if mozinfo.isWin:
         if not proc_handle:
             return
 
-        if not isinstance(file_name, unicode):
+        if not isinstance(file_name, str):
             # Convert to unicode explicitly so our path will be valid as input
             # to CreateFileW
-            file_name = unicode(file_name, sys.getfilesystemencoding())
+            file_name = str(file_name, sys.getfilesystemencoding())
 
         file_handle = kernel32.CreateFileW(file_name,
                                            GENERIC_READ | GENERIC_WRITE,
diff --git a/testing/mozbase/mozdevice/mozdevice/adb.py b/testing/mozbase/mozdevice/mozdevice/adb.py
index 1f298fc887..c6efa4b108 100644
--- a/testing/mozbase/mozdevice/mozdevice/adb.py
+++ b/testing/mozbase/mozdevice/mozdevice/adb.py
@@ -644,7 +644,7 @@ class ADBDevice(ADBCommand, metaclass=ABCMeta):
         def is_valid_serial(serial):
             return ":" not in serial or serial.startswith("usb:")
 
-        if isinstance(device, (str, unicode)):
+        if isinstance(device, (str, str)):
             # Treat this as a device serial
             if not is_valid_serial(device):
                 raise ValueError("Device serials containing ':' characters are "
diff --git a/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py b/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
index 6457ca0d1e..2ba5e41d2b 100644
--- a/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
+++ b/testing/mozbase/mozdevice/mozdevice/devicemanagerSUT.py
@@ -239,7 +239,7 @@ class DeviceManagerSUT(DeviceManager):
                         # Wait up to a second for socket to become ready for reading...
                         if select.select([self._sock], [], [], select_timeout)[0]:
                             temp = self._sock.recv(1024)
-                            self._logger.debug(u"response: %s" % temp.decode('utf8', 'replace'))
+                            self._logger.debug("response: %s" % temp.decode('utf8', 'replace'))
                             timer = 0
                             if not temp:
                                 socketClosed = True
diff --git a/testing/mozbase/mozinstall/mozinstall/mozinstall.py b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
index 3ef69cfe4f..ac6e2e7356 100755
--- a/testing/mozbase/mozinstall/mozinstall/mozinstall.py
+++ b/testing/mozbase/mozinstall/mozinstall/mozinstall.py
@@ -201,13 +201,13 @@ def uninstall(install_folder):
     # On Windows we have to use the uninstaller. If it's not available fallback
     # to the directory removal code
     if mozinfo.isWin:
-        uninstall_folder = '%s\uninstall' % install_folder
-        log_file = '%s\uninstall.log' % uninstall_folder
+        uninstall_folder = '%s\\uninstall' % install_folder
+        log_file = '%s\\uninstall.log' % uninstall_folder
 
         if os.path.isfile(log_file):
             trbk = None
             try:
-                cmdArgs = ['%s\uninstall\helper.exe' % install_folder, '/S']
+                cmdArgs = ['%s\\uninstall\helper.exe' % install_folder, '/S']
                 result = subprocess.call(cmdArgs)
                 if result is not 0:
                     raise Exception('Execution of uninstaller failed.')
diff --git a/testing/mozbase/mozlog/mozlog/formatters/html/html.py b/testing/mozbase/mozlog/mozlog/formatters/html/html.py
index 5d08c53535..bee32b3780 100755
--- a/testing/mozbase/mozlog/mozlog/formatters/html/html.py
+++ b/testing/mozbase/mozlog/mozlog/formatters/html/html.py
@@ -158,7 +158,7 @@ class HTMLFormatter(base.BaseFormatter):
                     # Encode base64 to avoid that some browsers (such as Firefox, Opera)
                     # treats '#' as the start of another link if it is contained in the data URL.
                     # Use 'charset=utf-8' to show special characters like Chinese.
-                    utf_encoded = unicode(content).encode('utf-8', 'xmlcharrefreplace')
+                    utf_encoded = str(content).encode('utf-8', 'xmlcharrefreplace')
                     href = 'data:text/html;charset=utf-8;base64,%s' % base64.b64encode(utf_encoded)
 
                 links_html.append(html.a(
@@ -233,4 +233,4 @@ class HTMLFormatter(base.BaseFormatter):
                         html.tbody(self.result_rows,
                                    id='results-table-body')], id='results-table')))
 
-        return u"\n" + doc.unicode(indent=2)
+        return "\n" + doc.str(indent=2)
diff --git a/testing/mozbase/mozlog/mozlog/formatters/html/xmlgen.py b/testing/mozbase/mozlog/mozlog/formatters/html/xmlgen.py
index eb3caca199..e1cc23a093 100644
--- a/testing/mozbase/mozlog/mozlog/formatters/html/xmlgen.py
+++ b/testing/mozbase/mozlog/mozlog/formatters/html/xmlgen.py
@@ -28,14 +28,14 @@ if sys.version_info >= (3, 0):
     def u(s):
         return s
 
-    def unicode(x):
+    def str(x):
         if hasattr(x, '__unicode__'):
             return x.__unicode__()
         return str(x)
 else:
     def u(s):
-        return unicode(s)
-    unicode = unicode
+        return str(s)
+    str = str
 
 
 class NamespaceMetaclass(type):
@@ -68,10 +68,10 @@ class Tag(list):
         self.attr = self.Attr(**kwargs)
 
     def __unicode__(self):
-        return self.unicode(indent=0)
+        return self.str(indent=0)
     __str__ = __unicode__
 
-    def unicode(self, indent=2):
+    def str(self, indent=2):
         l = []
         SimpleUnicodeVisitor(l.append, indent).visit(self)
         return u("").join(l)
@@ -89,7 +89,7 @@ Namespace = NamespaceMetaclass('Namespace', (object, ), {
 
 class HtmlTag(Tag):
 
-    def unicode(self, indent=2):
+    def str(self, indent=2):
         l = []
         HtmlVisitor(l.append, indent, shortempty=False).visit(self)
         return u("").join(l)
@@ -160,7 +160,7 @@ class SimpleUnicodeVisitor(object):
     # to avoid clashes with the tag name object
     def __object(self, obj):
         # self.write(obj)
-        self.write(escape(unicode(obj)))
+        self.write(escape(str(obj)))
 
     def raw(self, obj):
         self.write(obj.uniobj)
@@ -217,7 +217,7 @@ class SimpleUnicodeVisitor(object):
             if isinstance(value, raw):
                 insert = value.uniobj
             else:
-                insert = escape(unicode(value))
+                insert = escape(str(value))
             return ' %s="%s"' % (name, insert)
 
     def getstyle(self, tag):
@@ -277,7 +277,7 @@ class _escape:
 
     def __call__(self, ustring):
         """ xml-escape the given unicode string. """
-        ustring = unicode(ustring)
+        ustring = str(ustring)
         return self.charef_rex.sub(self._replacer, ustring)
 
 escape = _escape()
diff --git a/testing/mozbase/mozlog/mozlog/formatters/machformatter.py b/testing/mozbase/mozlog/mozlog/formatters/machformatter.py
index 734b7a6240..f0a1c38140 100644
--- a/testing/mozbase/mozlog/mozlog/formatters/machformatter.py
+++ b/testing/mozbase/mozlog/mozlog/formatters/machformatter.py
@@ -100,7 +100,7 @@ class MachFormatter(base.BaseFormatter):
         return test_id
 
     def _get_file_name(self, test_id):
-        if isinstance(test_id, (str, unicode)):
+        if isinstance(test_id, (str, str)):
             return test_id
 
         if isinstance(test_id, tuple):
diff --git a/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py b/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py
index 71152d4558..e2f893ad0a 100644
--- a/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py
+++ b/testing/mozbase/mozlog/mozlog/formatters/tbplformatter.py
@@ -224,7 +224,7 @@ class TbplFormatter(BaseFormatter):
         return "SUITE-END | took %is\n" % time
 
     def test_id(self, test_id):
-        if isinstance(test_id, (str, unicode)):
+        if isinstance(test_id, (str, str)):
             return test_id
         else:
             return tuple(test_id)
diff --git a/testing/mozbase/mozlog/mozlog/handlers/base.py b/testing/mozbase/mozlog/mozlog/handlers/base.py
index be4df21f9f..737c4434c5 100644
--- a/testing/mozbase/mozlog/mozlog/handlers/base.py
+++ b/testing/mozbase/mozlog/mozlog/handlers/base.py
@@ -95,7 +95,7 @@ class StreamHandler(BaseHandler):
         if not formatted:
             return
         with self._lock:
-            if isinstance(formatted, unicode):
+            if isinstance(formatted, str):
                 self.stream.write(formatted.encode("utf-8", "replace"))
             elif isinstance(formatted, str):
                 self.stream.write(formatted)
diff --git a/testing/mozbase/mozlog/mozlog/handlers/valgrindhandler.py b/testing/mozbase/mozlog/mozlog/handlers/valgrindhandler.py
index 5bedfb9abe..b3ca952a21 100644
--- a/testing/mozbase/mozlog/mozlog/handlers/valgrindhandler.py
+++ b/testing/mozbase/mozlog/mozlog/handlers/valgrindhandler.py
@@ -123,14 +123,14 @@ class ValgrindFilter(object):
                 # fields from the incoming message, since there's nowhere
                 # else to get them from.
                 output_message = {  # Mandatory fields
-                    u"action": "valgrind_error",
-                    u"time":   msg["time"],
-                    u"thread": msg["thread"],
-                    u"pid":    msg["pid"],
-                    u"source": msg["source"],
+                    "action": "valgrind_error",
+                    "time":   msg["time"],
+                    "thread": msg["thread"],
+                    "pid":    msg["pid"],
+                    "source": msg["source"],
                     # valgrind_error specific fields
-                    u"primary":   self.curr_failure_msg,
-                    u"secondary": self.buffered_lines}
+                    "primary":   self.curr_failure_msg,
+                    "secondary": self.buffered_lines}
                 self.curr_failure_msg = ""
                 self.buffered_lines = []
 
diff --git a/testing/mozbase/mozlog/mozlog/logtypes.py b/testing/mozbase/mozlog/mozlog/logtypes.py
index 6b750a5e5d..6af1f2e3f7 100644
--- a/testing/mozbase/mozlog/mozlog/logtypes.py
+++ b/testing/mozbase/mozlog/mozlog/logtypes.py
@@ -126,17 +126,17 @@ class DataType(object):
 class Unicode(DataType):
 
     def convert(self, data):
-        if isinstance(data, unicode):
+        if isinstance(data, str):
             return data
         if isinstance(data, str):
             return data.decode("utf8", "replace")
-        return unicode(data)
+        return str(data)
 
 
 class TestId(DataType):
 
     def convert(self, data):
-        if isinstance(data, unicode):
+        if isinstance(data, str):
             return data
         elif isinstance(data, bytes):
             return data.decode("utf-8", "replace")
diff --git a/testing/mozbase/mozlog/mozlog/scripts/unstable.py b/testing/mozbase/mozlog/mozlog/scripts/unstable.py
index 65259418f3..c7118897fb 100644
--- a/testing/mozbase/mozlog/mozlog/scripts/unstable.py
+++ b/testing/mozbase/mozlog/mozlog/scripts/unstable.py
@@ -13,7 +13,7 @@ class StatusHandler(reader.LogHandler):
             lambda: defaultdict(lambda: defaultdict(int))))
 
     def test_id(self, test):
-        if type(test) in (str, unicode):
+        if type(test) in (str, str):
             return test
         else:
             return tuple(test)
diff --git a/testing/mozbase/mozlog/mozlog/structuredlog.py b/testing/mozbase/mozlog/mozlog/structuredlog.py
index 3edfe8913a..ccb3d2db5c 100644
--- a/testing/mozbase/mozlog/mozlog/structuredlog.py
+++ b/testing/mozbase/mozlog/mozlog/structuredlog.py
@@ -433,7 +433,7 @@ def _log_func(level_name):
                 exc_info = sys.exc_info()
             if exc_info != (None, None, None):
                 bt = traceback.format_exception(*exc_info)
-                data["stack"] = u"\n".join(bt)
+                data["stack"] = "\n".join(bt)
 
         data["level"] = level_name
         self._log_data("log", data)
diff --git a/testing/mozbase/mozlog/tests/test_structured.py b/testing/mozbase/mozlog/tests/test_structured.py
index 07596fb8d0..ecbe2f72cd 100644
--- a/testing/mozbase/mozlog/tests/test_structured.py
+++ b/testing/mozbase/mozlog/tests/test_structured.py
@@ -407,10 +407,10 @@ class TestTypeConversions(BaseStructuredTest):
     def test_tuple(self):
         self.logger.suite_start([])
         self.logger.test_start(("\xf0\x90\x8d\x84\xf0\x90\x8c\xb4\xf0\x90\x8d\x83\xf0\x90\x8d\x84",
-                                42, u"\u16a4"))
+                                42, "\u16a4"))
         self.assert_log_equals({"action": "test_start",
-                                "test": (u'\U00010344\U00010334\U00010343\U00010344',
-                                         u"42", u"\u16a4")})
+                                "test": ('\U00010344\U00010334\U00010343\U00010344',
+                                         "42", "\u16a4")})
         self.logger.suite_end()
 
     def test_non_string_messages(self):
@@ -592,7 +592,7 @@ class TestHTMLFormatter(FormatterTest):
         self.logger.suite_start([])
         self.logger.test_start("unicode_test")
         self.logger.test_end("unicode_test", "FAIL",
-                             extra={"data": unichr(0x02A9)})
+                             extra={"data": chr(0x02A9)})
         self.logger.suite_end()
         self.assertIn("data:text/html;charset=utf-8;base64,yqk=",
                       ''.join(self.loglines))
@@ -858,7 +858,7 @@ class TestCommandline(unittest.TestCase):
     def test_setup_logging_optparse_unicode(self):
         parser = optparse.OptionParser()
         commandline.add_logging_group(parser)
-        args, _ = parser.parse_args([u"--log-raw=-"])
+        args, _ = parser.parse_args(["--log-raw=-"])
         logger = commandline.setup_logging("test_optparse_unicode", args, {})
         self.assertEqual(len(logger.handlers), 1)
         self.assertEqual(logger.handlers[0].stream, sys.stdout)
diff --git a/testing/mozbase/mozprofile/tests/test_addons.py b/testing/mozbase/mozprofile/tests/test_addons.py
index 2205469b87..8800d9faff 100644
--- a/testing/mozbase/mozprofile/tests/test_addons.py
+++ b/testing/mozbase/mozprofile/tests/test_addons.py
@@ -122,7 +122,7 @@ class TestAddonsManager(unittest.TestCase):
             self.am.install_from_path(temp_addon)
 
         # Generate a list of addons installed in the profile
-        addons_installed = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
+        addons_installed = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
                             self.profile.profile, 'extensions', 'staged'))]
         self.assertEqual(addons_to_install.sort(), addons_installed.sort())
 
@@ -287,7 +287,7 @@ class TestAddonsManager(unittest.TestCase):
 
         self.am.install_from_manifest(temp_manifest)
         # Generate a list of addons installed in the profile
-        addons_installed = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
+        addons_installed = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
                             self.profile.profile, 'extensions', 'staged'))]
         self.assertEqual(addons_installed.sort(), addons_to_install.sort())
 
@@ -327,7 +327,7 @@ class TestAddonsManager(unittest.TestCase):
         addon_two = generate_addon('test-addon-2@mozilla.org')
 
         self.am.install_addons(addon_one)
-        installed_addons = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
+        installed_addons = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
                             self.profile.profile, 'extensions', 'staged'))]
 
         # Create a new profile based on an existing profile
@@ -337,7 +337,7 @@ class TestAddonsManager(unittest.TestCase):
                                                        addons=addon_two)
         duplicate_profile.addon_manager.clean()
 
-        addons_after_cleanup = [unicode(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
+        addons_after_cleanup = [str(x[:-len('.xpi')]) for x in os.listdir(os.path.join(
                                 duplicate_profile.profile, 'extensions', 'staged'))]
         # New addons installed should be removed by clean_addons()
         self.assertEqual(installed_addons, addons_after_cleanup)
diff --git a/testing/mozharness/docs/conf.py b/testing/mozharness/docs/conf.py
index e18c868a07..62fd5aeff0 100644
--- a/testing/mozharness/docs/conf.py
+++ b/testing/mozharness/docs/conf.py
@@ -49,8 +49,8 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'Moz Harness'
-copyright = u'2014, aki and a cast of tens!'
+project = 'Moz Harness'
+copyright = '2014, aki and a cast of tens!'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
@@ -202,8 +202,8 @@ latex_elements = {
 # (source start file, target name, title,
 #  author, documentclass [howto, manual, or own class]).
 latex_documents = [
-  ('index', 'MozHarness.tex', u'Moz Harness Documentation',
-   u'aki and a cast of tens!', 'manual'),
+  ('index', 'MozHarness.tex', 'Moz Harness Documentation',
+   'aki and a cast of tens!', 'manual'),
 ]
 
 # The name of an image file (relative to this directory) to place at the top of
@@ -232,8 +232,8 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    ('index', 'mozharness', u'Moz Harness Documentation',
-     [u'aki and a cast of tens!'], 1)
+    ('index', 'mozharness', 'Moz Harness Documentation',
+     ['aki and a cast of tens!'], 1)
 ]
 
 # If true, show URL addresses after external links.
@@ -246,8 +246,8 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  ('index', 'MozHarness', u'Moz Harness Documentation',
-   u'aki and a cast of tens!', 'MozHarness', 'One line description of project.',
+  ('index', 'MozHarness', 'Moz Harness Documentation',
+   'aki and a cast of tens!', 'MozHarness', 'One line description of project.',
    'Miscellaneous'),
 ]
 
diff --git a/testing/mozharness/external_tools/virtualenv/virtualenv.py b/testing/mozharness/external_tools/virtualenv/virtualenv.py
index ec7ced2995..dd0599500e 100755
--- a/testing/mozharness/external_tools/virtualenv/virtualenv.py
+++ b/testing/mozharness/external_tools/virtualenv/virtualenv.py
@@ -968,7 +968,7 @@ def path_locations(home_dir):
             size = max(len(home_dir)+1, 256)
             buf = ctypes.create_unicode_buffer(size)
             try:
-                u = unicode
+                u = str
             except NameError:
                 u = str
             ret = GetShortPathName(u(home_dir), buf, size)
diff --git a/testing/mozharness/mozharness/base/diskutils.py b/testing/mozharness/mozharness/base/diskutils.py
index 745384ff92..726f90ecc6 100644
--- a/testing/mozharness/mozharness/base/diskutils.py
+++ b/testing/mozharness/mozharness/base/diskutils.py
@@ -116,7 +116,7 @@ class DiskSize(object):
         # depending on path format (unicode or not) and python version (2 or 3)
         # we need to call GetDiskFreeSpaceExW or GetDiskFreeSpaceExA
         called_function = ctypes.windll.kernel32.GetDiskFreeSpaceExA
-        if isinstance(path, unicode) or sys.version_info >= (3,):
+        if isinstance(path, str) or sys.version_info >= (3,):
             called_function = ctypes.windll.kernel32.GetDiskFreeSpaceExW
         # we're ready for the dll call. On error it returns 0
         if called_function(path,
diff --git a/testing/mozharness/test/test_base_script.py b/testing/mozharness/test/test_base_script.py
index dcfacb943c..3f1b8c5099 100644
--- a/testing/mozharness/test/test_base_script.py
+++ b/testing/mozharness/test/test_base_script.py
@@ -421,13 +421,13 @@ class TestHelperFunctions(unittest.TestCase):
         self.s = script.BaseScript(initial_config_file='test/test.json')
         # create a very long path that the command-prompt cannot delete
         # by using unicode format (max path length 32000)
-        path = u'\\\\?\\%s\\test_dir' % os.getcwd()
-        win32file.CreateDirectoryExW(u'.', path)
+        path = '\\\\?\\%s\\test_dir' % os.getcwd()
+        win32file.CreateDirectoryExW('.', path)
 
         for x in range(0, 20):
             print(("path=%s" % path))
-            path = path + u'\\%sxxxxxxxxxxxxxxxxxxxx' % x
-            win32file.CreateDirectoryExW(u'.', path)
+            path = path + '\\%sxxxxxxxxxxxxxxxxxxxx' % x
+            win32file.CreateDirectoryExW('.', path)
         self.s.rmtree('test_dir')
         self.assertFalse(os.path.exists('test_dir'),
                          msg="rmtree unsuccessful")
diff --git a/testing/tools/iceserver/iceserver.py b/testing/tools/iceserver/iceserver.py
index 771ccacd4b..0c2cb3b657 100644
--- a/testing/tools/iceserver/iceserver.py
+++ b/testing/tools/iceserver/iceserver.py
@@ -322,7 +322,7 @@ class StunMessage(object):
         digest_buf = self.build(MESSAGE_INTEGRITY)
         # Trim off the MESSAGE-INTEGRITY attr
         digest_buf = digest_buf[:len(digest_buf) - 24]
-        password = passlib.utils.saslprep(unicode(password))
+        password = passlib.utils.saslprep(str(password))
         key_string = "{}:{}:{}".format(username, realm, password)
         md5 = hashlib.md5()
         md5.update(key_string)
diff --git a/testing/xpcshell/mach_commands.py b/testing/xpcshell/mach_commands.py
index 2ca2a2fb94..dc6033cdd5 100644
--- a/testing/xpcshell/mach_commands.py
+++ b/testing/xpcshell/mach_commands.py
@@ -29,7 +29,7 @@ from xpcshellcommandline import parser_desktop, parser_remote
 here = os.path.abspath(os.path.dirname(__file__))
 
 if sys.version_info[0] < 3:
-    unicode_type = unicode
+    unicode_type = str
 else:
     unicode_type = str
 
diff --git a/testing/xpcshell/runxpcshelltests.py b/testing/xpcshell/runxpcshelltests.py
index 540e6364d7..9ec5223e4a 100755
--- a/testing/xpcshell/runxpcshelltests.py
+++ b/testing/xpcshell/runxpcshelltests.py
@@ -81,7 +81,7 @@ from mozrunner.utils import get_stack_fixer_function
 # (U+0000 through U+001F; U+007F; U+0080 through U+009F),
 # except TAB (U+0009), CR (U+000D), LF (U+000A) and backslash (U+005C).
 # A raw string is deliberately not used.
-_cleanup_encoding_re = re.compile(u'[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\\\\]')
+_cleanup_encoding_re = re.compile('[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\\\\]')
 def _cleanup_encoding_repl(m):
     c = m.group(0)
     return '\\\\' if c == '\\' else '\\x{0:02X}'.format(ord(c))
@@ -92,8 +92,8 @@ def cleanup_encoding(s):
        UTF-8, but it may not be *correct* UTF-8.  Return a
        sanitized unicode object."""
     if not isinstance(s, basestring):
-        return unicode(s)
-    if not isinstance(s, unicode):
+        return str(s)
+    if not isinstance(s, str):
         s = s.decode('utf-8', 'replace')
     # Replace all C0 and C1 control characters with \xNN escapes.
     return _cleanup_encoding_re.sub(_cleanup_encoding_repl, s)
@@ -1220,7 +1220,7 @@ class XPCShellTests(object):
         # All of the keys in question should be ASCII.
         fixedInfo = {}
         for k, v in list(self.mozInfo.items()):
-            if isinstance(k, unicode):
+            if isinstance(k, str):
                 k = k.encode('ascii')
             fixedInfo[k] = v
         self.mozInfo = fixedInfo
diff --git a/testing/xpcshell/selftest.py b/testing/xpcshell/selftest.py
index aea94f0a80..71936fa252 100755
--- a/testing/xpcshell/selftest.py
+++ b/testing/xpcshell/selftest.py
@@ -149,7 +149,7 @@ PASSING_TEST_UNICODE = '''
 function run_test () { run_next_test(); }
 
 add_test(function test_unicode_print () {
-  do_check_eq("\u201c\u201d", "\u201c\u201d");
+  do_check_eq("\\u201c\\u201d", "\\u201c\\u201d");
   run_next_test();
 });
 '''
diff --git a/testing/xpcshell/xpcshellcommandline.py b/testing/xpcshell/xpcshellcommandline.py
index d2a8e6bc13..b106fa058f 100644
--- a/testing/xpcshell/xpcshellcommandline.py
+++ b/testing/xpcshell/xpcshellcommandline.py
@@ -5,7 +5,7 @@ from mozlog import commandline
 
 def add_common_arguments(parser):
     parser.add_argument("--app-path",
-                        type=unicode, dest="appPath", default=None,
+                        type=str, dest="appPath", default=None,
                         help="application directory (as opposed to XRE directory)")
     parser.add_argument("--interactive",
                         action="store_true", dest="interactive", default=False,
@@ -22,7 +22,7 @@ def add_common_arguments(parser):
     parser.add_argument("--dump-tests", type=str, dest="dump_tests", default=None,
                         help="Specify path to a filename to dump all the tests that will be run")
     parser.add_argument("--manifest",
-                        type=unicode, dest="manifest", default=None,
+                        type=str, dest="manifest", default=None,
                         help="Manifest of test directories to use")
     parser.add_argument("--no-logfiles",
                         action="store_false", dest="logfiles",
diff --git a/toolkit/mozapps/installer/packager.py b/toolkit/mozapps/installer/packager.py
index f05c4c717a..f0b7667a89 100644
--- a/toolkit/mozapps/installer/packager.py
+++ b/toolkit/mozapps/installer/packager.py
@@ -81,7 +81,7 @@ class ToolLauncher(object):
         # Work around a bug in Python 2.7.2 and lower where unicode types in
         # environment variables aren't handled by subprocess.
         for k, v in list(env.items()):
-            if isinstance(v, unicode):
+            if isinstance(v, str):
                 env[k] = v.encode('utf-8')
 
         print('Executing', ' '.join(cmd), file=errors.out)
diff --git a/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py b/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py
index cb7303a129..4bdba83e84 100644
--- a/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py
+++ b/toolkit/mozapps/installer/windows/nsis/preprocess-locale.py
@@ -84,12 +84,12 @@ def preprocess_locale_files(config_dir, l10ndirs):
                                         "LangString ^",
                                         " 0 ",
                                         False)
-    fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le"))
+    fp.write(str(locale_strings, "utf-8").encode("utf-16-le"))
     fp.close()
 
     # Create the Modern User Interface language file
     fp = open_utf16le_file(join(config_dir, "baseLocale.nsh"))
-    fp.write((u""";NSIS Modern User Interface - Language File
+    fp.write((""";NSIS Modern User Interface - Language File
 ;Compatible with Modern UI 1.68
 ;Language: baseLocale (0)
 !insertmacro MOZ_MUI_LANGUAGEFILE_BEGIN \"baseLocale\"
@@ -97,8 +97,8 @@ def preprocess_locale_files(config_dir, l10ndirs):
 """).encode("utf-16-le"))
     locale_strings = get_locale_strings(lookup("mui.properties", l10ndirs),
                                         "!define ", " ", True)
-    fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le"))
-    fp.write(u"!insertmacro MOZ_MUI_LANGUAGEFILE_END\n".encode("utf-16-le"))
+    fp.write(str(locale_strings, "utf-8").encode("utf-16-le"))
+    fp.write("!insertmacro MOZ_MUI_LANGUAGEFILE_END\n".encode("utf-16-le"))
     fp.close()
 
     # Create the custom language file for our custom strings
@@ -108,7 +108,7 @@ def preprocess_locale_files(config_dir, l10ndirs):
                                         "LangString ",
                                         " 0 ",
                                         True)
-    fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le"))
+    fp.write(str(locale_strings, "utf-8").encode("utf-16-le"))
     fp.close()
 
 def create_nlf_file(moz_dir, ab_cd, config_dir):
@@ -138,7 +138,7 @@ def create_nlf_file(moz_dir, ab_cd, config_dir):
     # along with the default codepage, font name, and font size represented
     # by the '-' character.
     fp = open_utf16le_file(join(config_dir, "baseLocale.nlf"))
-    fp.write((u"""# Header, don't edit
+    fp.write(("""# Header, don't edit
 NLF v6
 # Start editing here
 # Language ID
@@ -175,7 +175,7 @@ def preprocess_locale_file(config_dir,
                                         "LangString ",
                                         " 0 ",
                                         True)
-    fp.write(unicode(locale_strings, "utf-8").encode("utf-16-le"))
+    fp.write(str(locale_strings, "utf-8").encode("utf-16-le"))
     fp.close()
 
 
@@ -189,7 +189,7 @@ def convert_utf8_utf16le(in_file_path, out_file_path):
     """
     in_fp = open(in_file_path, "r")
     out_fp = open_utf16le_file(out_file_path)
-    out_fp.write(unicode(in_fp.read(), "utf-8").encode("utf-16-le"))
+    out_fp.write(str(in_fp.read(), "utf-8").encode("utf-16-le"))
     in_fp.close()
     out_fp.close()
 
diff --git a/tools/check-moz-style/modules/cpplint.py b/tools/check-moz-style/modules/cpplint.py
index 25784ea136..8f09578d75 100644
--- a/tools/check-moz-style/modules/cpplint.py
+++ b/tools/check-moz-style/modules/cpplint.py
@@ -948,7 +948,7 @@ def check_for_unicode_replacement_characters(filename, lines, error):
       error: The function to call with any errors found.
     """
     for line_number, line in enumerate(lines):
-        if u'\ufffd' in line:
+        if '\ufffd' in line:
             error(filename, line_number, 'readability/utf8', 5,
                   'Line contains invalid UTF-8 (or Unicode replacement character).')
 
@@ -2085,7 +2085,7 @@ def get_line_width(line):
       The width of the line in column positions, accounting for Unicode
       combining characters and wide characters.
     """
-    if isinstance(line, unicode):
+    if isinstance(line, str):
         width = 0
         for c in unicodedata.normalize('NFC', line):
             if unicodedata.east_asian_width(c) in ('W', 'F'):
diff --git a/tools/docs/conf.py b/tools/docs/conf.py
index 1a919063f3..3efab2ecac 100644
--- a/tools/docs/conf.py
+++ b/tools/docs/conf.py
@@ -41,7 +41,7 @@ extensions = [
 templates_path = ['_templates']
 source_suffix = '.rst'
 master_doc = 'index'
-project = u'Mozilla Source Tree Docs'
+project = 'Mozilla Source Tree Docs'
 year = datetime.utcnow().year
 
 # Grab the version from the source tree's milestone.
diff --git a/tools/lint/docs/conf.py b/tools/lint/docs/conf.py
index 31ebb6dcc9..b040a3553e 100644
--- a/tools/lint/docs/conf.py
+++ b/tools/lint/docs/conf.py
@@ -30,9 +30,9 @@ source_suffix = '.rst'
 master_doc = 'index'
 
 # General information about the project.
-project = u'mozlint'
-copyright = u'2015, Andrew Halberstadt'
-author = u'Andrew Halberstadt'
+project = 'mozlint'
+copyright = '2015, Andrew Halberstadt'
+author = 'Andrew Halberstadt'
 
 # The short X.Y version.
 version = '0.1.0'
@@ -84,8 +84,8 @@ latex_elements = {}
 # (source start file, target name, title,
 #  author, documentclass [howto, manual, or own class]).
 latex_documents = [
-  (master_doc, 'mozlint.tex', u'mozlint Documentation',
-   u'Andrew Halberstadt', 'manual'),
+  (master_doc, 'mozlint.tex', 'mozlint Documentation',
+   'Andrew Halberstadt', 'manual'),
 ]
 
 # -- Options for manual page output ---------------------------------------
@@ -93,7 +93,7 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
-    (master_doc, 'mozlint', u'mozlint Documentation',
+    (master_doc, 'mozlint', 'mozlint Documentation',
      [author], 1)
 ]
 
@@ -103,7 +103,7 @@ man_pages = [
 # (source start file, target name, title, author,
 #  dir menu entry, description, category)
 texinfo_documents = [
-  (master_doc, 'mozlint', u'mozlint Documentation',
+  (master_doc, 'mozlint', 'mozlint Documentation',
    author, 'mozlint', 'One line description of project.',
    'Miscellaneous'),
 ]