Index: Python/bltinmodule.c =================================================================== --- Python/bltinmodule.c (revision 58410) +++ Python/bltinmodule.c (working copy) @@ -1592,12 +1592,19 @@ } } else { /* reject string values for 'start' parameter */ - if (PyObject_TypeCheck(result, &PyBaseString_Type)) { + if (PyUnicode_Check(result)) { PyErr_SetString(PyExc_TypeError, "sum() can't sum strings [use ''.join(seq) instead]"); Py_DECREF(iter); return NULL; } + if (PyBytes_Check(result)) { + PyErr_SetString(PyExc_TypeError, + "sum() can't sum bytes [use b''.join(seq) instead]"); + Py_DECREF(iter); + return NULL; + } + Py_INCREF(result); } @@ -1785,7 +1792,6 @@ SETBUILTIN("NotImplemented", Py_NotImplemented); SETBUILTIN("False", Py_False); SETBUILTIN("True", Py_True); - SETBUILTIN("basestring", &PyBaseString_Type); SETBUILTIN("bool", &PyBool_Type); SETBUILTIN("memoryview", &PyMemoryView_Type); SETBUILTIN("bytes", &PyBytes_Type); Index: Include/stringobject.h =================================================================== --- Include/stringobject.h (revision 58410) +++ Include/stringobject.h (working copy) @@ -48,7 +48,6 @@ */ } PyStringObject; -PyAPI_DATA(PyTypeObject) PyBaseString_Type; PyAPI_DATA(PyTypeObject) PyString_Type; #define PyString_Check(op) \ Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 58410) +++ Objects/unicodeobject.c (working copy) @@ -8421,7 +8421,7 @@ argidx = -2; } if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) && - !PyObject_TypeCheck(args, &PyBaseString_Type)) + !PyString_Check(args) && !PyUnicode_Check(args)) dict = args; while (--fmtcnt >= 0) { @@ -8920,7 +8920,7 @@ unicode_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - &PyBaseString_Type, /* tp_base */ + &PyBaseObject_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ Index: Objects/stringobject.c =================================================================== --- Objects/stringobject.c (revision 58410) +++ Objects/stringobject.c (working copy) @@ -4022,14 +4022,6 @@ } static PyObject * -basestring_new(PyTypeObject *type, PyObject *args, PyObject *kwds) -{ - PyErr_SetString(PyExc_TypeError, - "The basestring type cannot be instantiated"); - return NULL; -} - -static PyObject * string_mod(PyObject *v, PyObject *w) { if (!PyString_Check(v)) { @@ -4039,9 +4031,6 @@ return PyString_Format(v, w); } -PyDoc_STRVAR(basestring_doc, -"Type basestring cannot be instantiated; it is the base for str8 and str."); - static PyNumberMethods string_as_number = { 0, /*nb_add*/ 0, /*nb_subtract*/ @@ -4049,49 +4038,6 @@ string_mod, /*nb_remainder*/ }; - -PyTypeObject PyBaseString_Type = { - PyVarObject_HEAD_INIT(&PyType_Type, 0) - "basestring", - 0, - 0, - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - basestring_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - &PyBaseObject_Type, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - basestring_new, /* tp_new */ - 0, /* tp_free */ -}; - PyDoc_STRVAR(string_doc, "str(object) -> string\n\ \n\ @@ -4132,7 +4078,7 @@ string_methods, /* tp_methods */ 0, /* tp_members */ 0, /* tp_getset */ - &PyBaseString_Type, /* tp_base */ + &PyBaseObject_Type, /* tp_base */ 0, /* tp_dict */ 0, /* tp_descr_get */ 0, /* tp_descr_set */ @@ -4564,7 +4510,7 @@ argidx = -2; } if (Py_Type(args)->tp_as_mapping && !PyTuple_Check(args) && - !PyObject_TypeCheck(args, &PyBaseString_Type)) + !PyString_Check(args) && !PyUnicode_Check(args)) dict = args; while (--fmtcnt >= 0) { if (*fmt != '%') { Index: Lib/wave.py =================================================================== --- Lib/wave.py (revision 58410) +++ Lib/wave.py (working copy) @@ -155,7 +155,7 @@ def __init__(self, f): self._i_opened_the_file = None - if isinstance(f, basestring): + if isinstance(f, str): f = __builtin__.open(f, 'rb') self._i_opened_the_file = f # else, assume it is an open file object already @@ -299,7 +299,7 @@ def __init__(self, f): self._i_opened_the_file = None - if isinstance(f, basestring): + if isinstance(f, str): f = __builtin__.open(f, 'wb') self._i_opened_the_file = f try: Index: Lib/UserString.py =================================================================== --- Lib/UserString.py (revision 58410) +++ Lib/UserString.py (working copy) @@ -11,7 +11,7 @@ class UserString: def __init__(self, seq): - if isinstance(seq, basestring): + if isinstance(seq, str): self.data = seq elif isinstance(seq, UserString): self.data = seq.data[:] @@ -66,12 +66,12 @@ def __add__(self, other): if isinstance(other, UserString): return self.__class__(self.data + other.data) - elif isinstance(other, basestring): + elif isinstance(other, str): return self.__class__(self.data + other) else: return self.__class__(self.data + str(other)) def __radd__(self, other): - if isinstance(other, basestring): + if isinstance(other, str): return self.__class__(other + self.data) else: return self.__class__(str(other) + self.data) @@ -184,7 +184,7 @@ if isinstance(index, slice): if isinstance(sub, UserString): sub = sub.data - elif not isinstance(sub, basestring): + elif not isinstance(sub, str): sub = str(sub) start, stop, step = index.indices(len(self.data)) if step == -1: @@ -221,7 +221,7 @@ def __iadd__(self, other): if isinstance(other, UserString): self.data += other.data - elif isinstance(other, basestring): + elif isinstance(other, str): self.data += other else: self.data += str(other) Index: Lib/copy_reg.py =================================================================== --- Lib/copy_reg.py (revision 58410) +++ Lib/copy_reg.py (working copy) @@ -114,7 +114,7 @@ if "__slots__" in c.__dict__: slots = c.__dict__['__slots__'] # if class has a single slot, it can be given as a string - if isinstance(slots, basestring): + if isinstance(slots, str): slots = (slots,) for name in slots: # special descriptors Index: Lib/os.py =================================================================== --- Lib/os.py (revision 58410) +++ Lib/os.py (working copy) @@ -636,7 +636,7 @@ # Supply os.popen() def popen(cmd, mode="r", buffering=None): - if not isinstance(cmd, basestring): + if not isinstance(cmd, str): raise TypeError("invalid cmd type (%s, expected string)" % type(cmd)) if mode not in ("r", "w"): raise ValueError("invalid mode %r" % mode) Index: Lib/_abcoll.py =================================================================== --- Lib/_abcoll.py (revision 58410) +++ Lib/_abcoll.py (working copy) @@ -490,7 +490,7 @@ return sum(1 for v in self if v == value) Sequence.register(tuple) -Sequence.register(basestring) +Sequence.register(str) Sequence.register(memoryview) Index: Lib/xmlrpclib.py =================================================================== --- Lib/xmlrpclib.py (revision 58410) +++ Lib/xmlrpclib.py (working copy) @@ -294,7 +294,7 @@ """ def __init__(self, value=0): - if not isinstance(value, basestring): + if not isinstance(value, str): if datetime and isinstance(value, datetime.datetime): self.value = value.strftime("%Y%m%dT%H:%M:%S") return @@ -653,7 +653,7 @@ write("\n") for k, v in value.items(): write("\n") - if not isinstance(k, basestring): + if not isinstance(k, str): raise TypeError("dictionary key must be string") write("%s\n" % escape(k)) dump(v, write) @@ -1031,7 +1031,7 @@ # standard XML-RPC wrappings if methodname: # a method call - if not isinstance(methodname, basestring): + if not isinstance(methodname, str): methodname = methodname.encode(encoding) data = ( xmlheader, Index: Lib/optparse.py =================================================================== --- Lib/optparse.py (revision 58410) +++ Lib/optparse.py (working copy) @@ -815,9 +815,6 @@ SUPPRESS_HELP = "SUPPRESS"+"HELP" SUPPRESS_USAGE = "SUPPRESS"+"USAGE" -def isbasestring(x): - return isinstance(x, basestring) - class Values: def __init__(self, defaults=None): @@ -994,7 +991,7 @@ """add_option(Option) add_option(opt_str, ..., kwarg=val, ...) """ - if isbasestring(args[0]): + if isinstance(args[0], str): option = self.option_class(*args, **kwargs) elif len(args) == 1 and not kwargs: option = args[0] @@ -1294,7 +1291,7 @@ defaults = self.defaults.copy() for option in self._get_all_options(): default = defaults.get(option.dest) - if isbasestring(default): + if isinstance(default, str): opt_str = option.get_opt_string() defaults[option.dest] = option.check_value(opt_str, default) @@ -1305,7 +1302,7 @@ def add_option_group(self, *args, **kwargs): # XXX lots of overlap with OptionContainer.add_option() - if isbasestring(args[0]): + if isinstance(args[0], str): group = OptionGroup(self, *args, **kwargs) elif len(args) == 1 and not kwargs: group = args[0] Index: Lib/smtplib.py =================================================================== --- Lib/smtplib.py (revision 58410) +++ Lib/smtplib.py (working copy) @@ -668,7 +668,7 @@ self.rset() raise SMTPSenderRefused(code, resp, from_addr) senderrs={} - if isinstance(to_addrs, basestring): + if isinstance(to_addrs, str): to_addrs = [to_addrs] for each in to_addrs: (code,resp)=self.rcpt(each, rcpt_options) Index: Lib/warnings.py =================================================================== --- Lib/warnings.py (revision 58410) +++ Lib/warnings.py (working copy) @@ -150,10 +150,10 @@ import re assert action in ("error", "ignore", "always", "default", "module", "once"), "invalid action: %r" % (action,) - assert isinstance(message, basestring), "message must be a string" + assert isinstance(message, str), "message must be a string" assert isinstance(category, type), "category must be a class" assert issubclass(category, Warning), "category must be a Warning subclass" - assert isinstance(module, basestring), "module must be a string" + assert isinstance(module, str), "module must be a string" assert isinstance(lineno, int) and lineno >= 0, \ "lineno must be an int >= 0" item = (action, re.compile(message, re.I), category, Index: Lib/distutils/cmd.py =================================================================== --- Lib/distutils/cmd.py (revision 58410) +++ Lib/distutils/cmd.py (working copy) @@ -213,7 +213,7 @@ if val is None: setattr(self, option, default) return default - elif not isinstance(val, basestring): + elif not isinstance(val, str): raise DistutilsOptionError("'%s' must be a %s (got `%s`)" % (option, what, val)) return val @@ -233,11 +233,11 @@ val = getattr(self, option) if val is None: return - elif isinstance(val, basestring): + elif isinstance(val, str): setattr(self, option, re.split(r',\s*|\s+', val)) else: if isinstance(val, list): - ok = all(isinstance(v, basestring) for v in val) + ok = all(isinstance(v, str) for v in val) else: ok = False if not ok: @@ -390,7 +390,7 @@ # Allow 'infiles' to be a single string - if isinstance(infiles, basestring): + if isinstance(infiles, str): infiles = (infiles,) elif not isinstance(infiles, (list, tuple)): raise TypeError( Index: Lib/distutils/dist.py =================================================================== --- Lib/distutils/dist.py (revision 58410) +++ Lib/distutils/dist.py (working copy) @@ -581,13 +581,13 @@ keywords = self.metadata.keywords if keywords is not None: - if isinstance(keywords, basestring): + if isinstance(keywords, str): keywordlist = keywords.split(',') self.metadata.keywords = [x.strip() for x in keywordlist] platforms = self.metadata.platforms if platforms is not None: - if isinstance(platforms, basestring): + if isinstance(platforms, str): platformlist = platforms.split(',') self.metadata.platforms = [x.strip() for x in platformlist] @@ -875,7 +875,7 @@ neg_opt = {} try: - is_string = isinstance(value, basestring) + is_string = isinstance(value, str) if option in neg_opt and is_string: setattr(command_obj, neg_opt[option], not strtobool(value)) elif option in bool_opts and is_string: Index: Lib/distutils/dir_util.py =================================================================== --- Lib/distutils/dir_util.py (revision 58410) +++ Lib/distutils/dir_util.py (working copy) @@ -28,7 +28,7 @@ global _path_created # Detect a common bug -- name is None - if not isinstance(name, basestring): + if not isinstance(name, str): raise DistutilsInternalError( "mkpath: 'name' must be a string (got %r)" % (name,)) Index: Lib/distutils/filelist.py =================================================================== --- Lib/distutils/filelist.py (revision 58410) +++ Lib/distutils/filelist.py (working copy) @@ -301,7 +301,7 @@ or just returned as-is (assumes it's a regex object). """ if is_regex: - if isinstance(pattern, basestring): + if isinstance(pattern, str): return re.compile(pattern) else: return pattern Index: Lib/distutils/extension.py =================================================================== --- Lib/distutils/extension.py (revision 58410) +++ Lib/distutils/extension.py (working copy) @@ -102,9 +102,9 @@ language=None, **kw # To catch unknown keywords ): - assert isinstance(name, basestring), "'name' must be a string" + assert isinstance(name, str), "'name' must be a string" assert (isinstance(sources, list) and - all(isinstance(v, basestring) for v in sources)), \ + all(isinstance(v, str) for v in sources)), \ "'sources' must be a list of strings" self.name = name Index: Lib/distutils/ccompiler.py =================================================================== --- Lib/distutils/ccompiler.py (revision 58410) +++ Lib/distutils/ccompiler.py (working copy) @@ -154,7 +154,7 @@ self.set_executable(key, value) def set_executable(self, key, value): - if isinstance(value, basestring): + if isinstance(value, str): setattr(self, key, split_quoted(value)) else: setattr(self, key, value) @@ -175,8 +175,8 @@ for defn in definitions: if not (isinstance(defn, tuple) and (len(defn) in (1, 2) and - (isinstance (defn[1], basestring) or defn[1] is None)) and - isinstance (defn[0], basestring)): + (isinstance (defn[1], str) or defn[1] is None)) and + isinstance (defn[0], str)): raise TypeError(("invalid macro definition '%s': " % defn) + \ "must be tuple (string,), (string, string), or " + \ "(string, None)") @@ -318,7 +318,7 @@ """ if outdir is None: outdir = self.output_dir - elif not isinstance(outdir, basestring): + elif not isinstance(outdir, str): raise TypeError("'output_dir' must be a string or None") if macros is None: @@ -415,7 +415,7 @@ """ if output_dir is None: output_dir = self.output_dir - elif not isinstance(output_dir, basestring): + elif not isinstance(output_dir, str): raise TypeError("'output_dir' must be a string or None") if macros is None: @@ -494,7 +494,7 @@ if output_dir is None: output_dir = self.output_dir - elif not isinstance(output_dir, basestring): + elif not isinstance(output_dir, str): raise TypeError("'output_dir' must be a string or None") return (objects, output_dir) Index: Lib/distutils/unixccompiler.py =================================================================== --- Lib/distutils/unixccompiler.py (revision 58410) +++ Lib/distutils/unixccompiler.py (working copy) @@ -211,7 +211,7 @@ lib_opts = gen_lib_options(self, library_dirs, runtime_library_dirs, libraries) - if not isinstance(output_dir, (basestring, type(None))): + if not isinstance(output_dir, (str, type(None))): raise TypeError("'output_dir' must be a string or None") if output_dir is not None: output_filename = os.path.join(output_dir, output_filename) Index: Lib/distutils/fancy_getopt.py =================================================================== --- Lib/distutils/fancy_getopt.py (revision 58410) +++ Lib/distutils/fancy_getopt.py (working copy) @@ -154,12 +154,12 @@ raise ValueError("invalid option tuple: %r" % (option,)) # Type- and value-check the option names - if not isinstance(long, basestring) or len(long) < 2: + if not isinstance(long, str) or len(long) < 2: raise DistutilsGetoptError(("invalid long option '%s': " "must be a string of length >= 2") % long) if (not ((short is None) or - (isinstance(short, basestring) and len(short) == 1))): + (isinstance(short, str) and len(short) == 1))): raise DistutilsGetoptError("invalid short option '%s': " "must a single character or None" % short) Index: Lib/distutils/command/build_clib.py =================================================================== --- Lib/distutils/command/build_clib.py (revision 58410) +++ Lib/distutils/command/build_clib.py (working copy) @@ -86,7 +86,7 @@ if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - if isinstance(self.include_dirs, basestring): + if isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) # XXX same as for build_ext -- what about 'self.define' and @@ -134,7 +134,7 @@ raise DistutilsSetupError( "each element of 'libraries' must a 2-tuple") - if isinstance(lib[0], basestring): + if isinstance(lib[0], str): raise DistutilsSetupError( "first element of each tuple in 'libraries' " "must be a string (the library name)") Index: Lib/distutils/command/install_data.py =================================================================== --- Lib/distutils/command/install_data.py (revision 58410) +++ Lib/distutils/command/install_data.py (working copy) @@ -45,7 +45,7 @@ def run(self): self.mkpath(self.install_dir) for f in self.data_files: - if isinstance(f, basestring): + if isinstance(f, str): # it's a simple file, so copy it f = convert_path(f) if self.warn_dir: Index: Lib/distutils/command/config.py =================================================================== --- Lib/distutils/command/config.py (revision 58410) +++ Lib/distutils/command/config.py (working copy) @@ -69,17 +69,17 @@ def finalize_options(self): if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - elif isinstance(self.include_dirs, basestring): + elif isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) if self.libraries is None: self.libraries = [] - elif isinstance(self.libraries, basestring): + elif isinstance(self.libraries, str): self.libraries = [self.libraries] if self.library_dirs is None: self.library_dirs = [] - elif isinstance(self.library_dirs, basestring): + elif isinstance(self.library_dirs, str): self.library_dirs = self.library_dirs.split(os.pathsep) def run(self): @@ -204,7 +204,7 @@ self._check_compiler() (src, out) = self._preprocess(body, headers, include_dirs, lang) - if isinstance(pattern, basestring): + if isinstance(pattern, str): pattern = re.compile(pattern) file = open(out) Index: Lib/distutils/command/install.py =================================================================== --- Lib/distutils/command/install.py (revision 58410) +++ Lib/distutils/command/install.py (working copy) @@ -449,7 +449,7 @@ self.extra_path = self.distribution.extra_path if self.extra_path is not None: - if isinstance(self.extra_path, basestring): + if isinstance(self.extra_path, str): self.extra_path = self.extra_path.split(',') if len(self.extra_path) == 1: Index: Lib/distutils/command/build_py.py =================================================================== --- Lib/distutils/command/build_py.py (revision 58410) +++ Lib/distutils/command/build_py.py (working copy) @@ -325,7 +325,7 @@ return outputs def build_module(self, module, module_file, package): - if isinstance(package, basestring): + if isinstance(package, str): package = package.split('.') elif not isinstance(package, (list, tuple)): raise TypeError( Index: Lib/distutils/command/build_ext.py =================================================================== --- Lib/distutils/command/build_ext.py (revision 58410) +++ Lib/distutils/command/build_ext.py (working copy) @@ -133,7 +133,7 @@ plat_py_include = sysconfig.get_python_inc(plat_specific=1) if self.include_dirs is None: self.include_dirs = self.distribution.include_dirs or [] - if isinstance(self.include_dirs, basestring): + if isinstance(self.include_dirs, str): self.include_dirs = self.include_dirs.split(os.pathsep) # Put the Python "system" include dir at the end, so that @@ -142,7 +142,7 @@ if plat_py_include != py_include: self.include_dirs.append(plat_py_include) - if isinstance(self.libraries, basestring): + if isinstance(self.libraries, str): self.libraries = [self.libraries] # Life is easier if we're not forever checking for None, so @@ -151,12 +151,12 @@ self.libraries = [] if self.library_dirs is None: self.library_dirs = [] - elif isinstance(self.library_dirs, basestring): + elif isinstance(self.library_dirs, str): self.library_dirs = self.library_dirs.split(os.pathsep) if self.rpath is None: self.rpath = [] - elif isinstance(self.rpath, basestring): + elif isinstance(self.rpath, str): self.rpath = self.rpath.split(os.pathsep) # for extensions under windows use different directories @@ -309,7 +309,7 @@ "each element of 'ext_modules' option must be an " "Extension instance or 2-tuple") - if not (isinstance(ext_name, basestring) and + if not (isinstance(ext_name, str) and extension_name_re.match(ext_name)): raise DistutilsSetupError( "first element of each tuple in 'ext_modules' " Index: Lib/shlex.py =================================================================== --- Lib/shlex.py (revision 58410) +++ Lib/shlex.py (working copy) @@ -18,7 +18,7 @@ class shlex: "A lexical analyzer class for simple shell-like syntaxes." def __init__(self, instream=None, infile=None, posix=False): - if isinstance(instream, basestring): + if isinstance(instream, str): instream = StringIO(instream) if instream is not None: self.instream = instream @@ -61,7 +61,7 @@ def push_source(self, newstream, newfile=None): "Push an input source onto the lexer's input source stack." - if isinstance(newstream, basestring): + if isinstance(newstream, str): newstream = StringIO(newstream) self.filestack.appendleft((self.infile, self.instream, self.lineno)) self.infile = newfile @@ -247,7 +247,7 @@ if newfile[0] == '"': newfile = newfile[1:-1] # This implements cpp-like semantics for relative-path inclusion. - if isinstance(self.infile, basestring) and not os.path.isabs(newfile): + if isinstance(self.infile, str) and not os.path.isabs(newfile): newfile = os.path.join(os.path.dirname(self.infile), newfile) return (newfile, open(newfile, "r")) Index: Lib/pickletools.py =================================================================== --- Lib/pickletools.py (revision 58410) +++ Lib/pickletools.py (working copy) @@ -701,7 +701,7 @@ ) def __init__(self, name, obtype, doc): - assert isinstance(name, basestring) + assert isinstance(name, str) self.name = name assert isinstance(obtype, type) or isinstance(obtype, tuple) @@ -710,7 +710,7 @@ assert isinstance(contained, type) self.obtype = obtype - assert isinstance(doc, basestring) + assert isinstance(doc, str) self.doc = doc def __repr__(self): @@ -846,10 +846,10 @@ def __init__(self, name, code, arg, stack_before, stack_after, proto, doc): - assert isinstance(name, basestring) + assert isinstance(name, str) self.name = name - assert isinstance(code, basestring) + assert isinstance(code, str) assert len(code) == 1 self.code = code @@ -869,7 +869,7 @@ assert isinstance(proto, int) and 0 <= proto <= 2 self.proto = proto - assert isinstance(doc, basestring) + assert isinstance(doc, str) self.doc = doc I = OpcodeInfo Index: Lib/decimal.py =================================================================== --- Lib/decimal.py (revision 58410) +++ Lib/decimal.py (working copy) @@ -588,7 +588,7 @@ # From a string # REs insist on real strings, so we can too. - if isinstance(value, basestring): + if isinstance(value, str): if _isinfinity(value): self._exp = 'F' self._int = (0,) Index: Lib/logging/__init__.py =================================================================== --- Lib/logging/__init__.py (revision 58410) +++ Lib/logging/__init__.py (working copy) @@ -281,7 +281,7 @@ msg = str(self.msg) else: msg = self.msg - if not isinstance(msg, basestring): + if not isinstance(msg, str): try: msg = str(self.msg) except UnicodeError: Index: Lib/cookielib.py =================================================================== --- Lib/cookielib.py (revision 58410) +++ Lib/cookielib.py (working copy) @@ -367,7 +367,7 @@ [[('Basic', None), ('realm', '"foobar"')]] """ - assert not isinstance(header_values, basestring) + assert not isinstance(header_values, str) result = [] for text in header_values: orig_text = text Index: Lib/inspect.py =================================================================== --- Lib/inspect.py (revision 58410) +++ Lib/inspect.py (working copy) @@ -313,7 +313,7 @@ doc = object.__doc__ except AttributeError: return None - if not isinstance(doc, basestring): + if not isinstance(doc, str): return None try: lines = doc.expandtabs().split('\n') Index: Lib/webbrowser.py =================================================================== --- Lib/webbrowser.py (revision 58410) +++ Lib/webbrowser.py (working copy) @@ -159,7 +159,7 @@ and without remote functionality.""" def __init__(self, name): - if isinstance(name, basestring): + if isinstance(name, str): self.name = name self.args = ["%s"] else: Index: Lib/io.py =================================================================== --- Lib/io.py (revision 58410) +++ Lib/io.py (working copy) @@ -104,13 +104,13 @@ binary stream, a buffered binary stream, or a buffered text stream, open for reading and/or writing. """ - if not isinstance(file, (basestring, int)): + if not isinstance(file, (str, int)): raise TypeError("invalid file: %r" % file) - if not isinstance(mode, basestring): + if not isinstance(mode, str): raise TypeError("invalid mode: %r" % mode) if buffering is not None and not isinstance(buffering, int): raise TypeError("invalid buffering: %r" % buffering) - if encoding is not None and not isinstance(encoding, basestring): + if encoding is not None and not isinstance(encoding, str): raise TypeError("invalid encoding: %r" % encoding) modes = set(mode) if modes - set("arwb+tU") or len(mode) > len(modes): @@ -1093,7 +1093,7 @@ def write(self, s: str): if self.closed: raise ValueError("write to closed file") - if not isinstance(s, basestring): + if not isinstance(s, str): raise TypeError("can't write %s to text stream" % s.__class__.__name__) haslf = "\n" in s @@ -1395,7 +1395,7 @@ encoding=encoding, newline=newline) if initial_value: - if not isinstance(initial_value, basestring): + if not isinstance(initial_value, str): initial_value = str(initial_value) self.write(initial_value) self.seek(0) Index: Lib/pstats.py =================================================================== --- Lib/pstats.py (revision 58410) +++ Lib/pstats.py (working copy) @@ -116,7 +116,7 @@ def load_stats(self, arg): if not arg: self.stats = {} - elif isinstance(arg, basestring): + elif isinstance(arg, str): f = open(arg, 'rb') self.stats = marshal.load(f) f.close() Index: Lib/msilib/__init__.py =================================================================== --- Lib/msilib/__init__.py (revision 58410) +++ Lib/msilib/__init__.py (working copy) @@ -101,7 +101,7 @@ field = value[i] if isinstance(field, int): r.SetInteger(i+1,field) - elif isinstance(field, basestring): + elif isinstance(field, str): r.SetString(i+1,field) elif field is None: pass Index: Lib/cProfile.py =================================================================== --- Lib/cProfile.py (revision 58410) +++ Lib/cProfile.py (working copy) @@ -153,7 +153,7 @@ # ____________________________________________________________ def label(code): - if isinstance(code, basestring): + if isinstance(code, str): return ('~', 0, code) # built-in functions ('~' sorts at the end) else: return (code.co_filename, code.co_firstlineno, code.co_name) Index: Lib/cmd.py =================================================================== --- Lib/cmd.py (revision 58410) +++ Lib/cmd.py (working copy) @@ -356,7 +356,7 @@ return nonstrings = [i for i in range(len(list)) - if not isinstance(list[i], basestring)] + if not isinstance(list[i], str)] if nonstrings: raise TypeError("list[i] not a string for i in %s" % ", ".join(map(str, nonstrings))) Index: Lib/unittest.py =================================================================== --- Lib/unittest.py (revision 58410) +++ Lib/unittest.py (working copy) @@ -418,7 +418,7 @@ self._tests.append(test) def addTests(self, tests): - if isinstance(tests, basestring): + if isinstance(tests, str): raise TypeError("tests must be an iterable of tests, not a string") for test in tests: self.addTest(test) Index: Lib/tarfile.py =================================================================== --- Lib/tarfile.py (revision 58410) +++ Lib/tarfile.py (working copy) @@ -2041,7 +2041,7 @@ """ self._check("r") - if isinstance(member, basestring): + if isinstance(member, str): tarinfo = self.getmember(member) else: tarinfo = member @@ -2077,7 +2077,7 @@ """ self._check("r") - if isinstance(member, basestring): + if isinstance(member, str): tarinfo = self.getmember(member) else: tarinfo = member Index: Lib/lib-tk/Tkinter.py =================================================================== --- Lib/lib-tk/Tkinter.py (revision 58410) +++ Lib/lib-tk/Tkinter.py (working copy) @@ -255,7 +255,7 @@ def get(self): """Return value of variable as string.""" value = self._tk.globalgetvar(self._name) - if isinstance(value, basestring): + if isinstance(value, str): return value return str(value) Index: Lib/fileinput.py =================================================================== --- Lib/fileinput.py (revision 58410) +++ Lib/fileinput.py (working copy) @@ -196,7 +196,7 @@ def __init__(self, files=None, inplace=0, backup="", bufsize=0, mode="r", openhook=None): - if isinstance(files, basestring): + if isinstance(files, str): files = (files,) else: if files is None: Index: Lib/email/iterators.py =================================================================== --- Lib/email/iterators.py (revision 58410) +++ Lib/email/iterators.py (working copy) @@ -39,7 +39,7 @@ """ for subpart in msg.walk(): payload = subpart.get_payload(decode=decode) - if isinstance(payload, basestring): + if isinstance(payload, str): for line in StringIO(payload): yield line Index: Lib/email/feedparser.py =================================================================== --- Lib/email/feedparser.py (revision 58410) +++ Lib/email/feedparser.py (working copy) @@ -365,7 +365,7 @@ self._last.epilogue = epilogue[:-end] else: payload = self._last.get_payload() - if isinstance(payload, basestring): + if isinstance(payload, str): mo = NLCRE_eol.search(payload) if mo: payload = payload[:-len(mo.group(0))] Index: Lib/email/generator.py =================================================================== --- Lib/email/generator.py (revision 58410) +++ Lib/email/generator.py (working copy) @@ -151,7 +151,7 @@ payload = msg.get_payload() if payload is None: return - if not isinstance(payload, basestring): + if not isinstance(payload, str): raise TypeError('string payload expected: %s' % type(payload)) if self._mangle_from_: payload = fcre.sub('>From ', payload) @@ -168,7 +168,7 @@ subparts = msg.get_payload() if subparts is None: subparts = [] - elif isinstance(subparts, basestring): + elif isinstance(subparts, str): # e.g. a non-strict parse of a message with no starting boundary. self._fp.write(subparts) return Index: Lib/zipfile.py =================================================================== --- Lib/zipfile.py (revision 58410) +++ Lib/zipfile.py (working copy) @@ -596,7 +596,7 @@ self.pwd = None # Check if we were passed a file-like object - if isinstance(file, basestring): + if isinstance(file, str): # No, it's a filename self._filePassed = 0 self.filename = file Index: Lib/doctest.py =================================================================== --- Lib/doctest.py (revision 58410) +++ Lib/doctest.py (working copy) @@ -442,7 +442,7 @@ Create a new DocTest containing the given examples. The DocTest's globals are initialized with a copy of `globs`. """ - assert not isinstance(examples, basestring), \ + assert not isinstance(examples, str), \ "DocTest no longer accepts str; use DocTestParser instead" self.examples = examples self.docstring = docstring @@ -874,13 +874,13 @@ # Look for tests in a module's __test__ dictionary. if inspect.ismodule(obj) and self._recurse: for valname, val in getattr(obj, '__test__', {}).items(): - if not isinstance(valname, basestring): + if not isinstance(valname, str): raise ValueError("DocTestFinder.find: __test__ keys " "must be strings: %r" % (type(valname),)) if not (inspect.isfunction(val) or inspect.isclass(val) or inspect.ismethod(val) or inspect.ismodule(val) or - isinstance(val, basestring)): + isinstance(val, str)): raise ValueError("DocTestFinder.find: __test__ values " "must be strings, functions, methods, " "classes, or modules: %r" % @@ -913,7 +913,7 @@ """ # Extract the object's docstring. If it doesn't have one, # then return None (no test for this object). - if isinstance(obj, basestring): + if isinstance(obj, str): docstring = obj else: try: @@ -921,7 +921,7 @@ docstring = '' else: docstring = obj.__doc__ - if not isinstance(docstring, basestring): + if not isinstance(docstring, str): docstring = str(docstring) except (TypeError, AttributeError): docstring = '' Index: Lib/urllib2.py =================================================================== --- Lib/urllib2.py (revision 58410) +++ Lib/urllib2.py (working copy) @@ -359,7 +359,7 @@ def open(self, fullurl, data=None, timeout=None): # accept a URL or a Request object - if isinstance(fullurl, basestring): + if isinstance(fullurl, str): req = Request(fullurl, data) else: req = fullurl @@ -702,7 +702,7 @@ def add_password(self, realm, uri, user, passwd): # uri could be a single URI or a sequence - if isinstance(uri, basestring): + if isinstance(uri, str): uri = [uri] if not realm in self.passwd: self.passwd[realm] = {} Index: Lib/ConfigParser.py =================================================================== --- Lib/ConfigParser.py (revision 58410) +++ Lib/ConfigParser.py (working copy) @@ -271,7 +271,7 @@ Return list of successfully read files. """ - if isinstance(filenames, basestring): + if isinstance(filenames, str): filenames = [filenames] read_ok = [] for filename in filenames: @@ -652,7 +652,7 @@ def set(self, section, option, value): """Set an option. Extend ConfigParser.set: check for string values.""" - if not isinstance(value, basestring): + if not isinstance(value, str): raise TypeError("option values must be strings") # check for bad percent signs: # first, replace all "good" interpolations Index: Lib/test/test_isinstance.py =================================================================== --- Lib/test/test_isinstance.py (revision 58410) +++ Lib/test/test_isinstance.py (working copy) @@ -242,7 +242,7 @@ self.assertEqual(True, issubclass(NewSuper, (NewChild, (NewSuper,)))) self.assertEqual(True, issubclass(int, (int, (float, int)))) - self.assertEqual(True, issubclass(str, (str, (Child, NewChild, basestring)))) + self.assertEqual(True, issubclass(str, (str, (Child, NewChild, str)))) def test_subclass_recursion_limit(self): # make sure that issubclass raises RuntimeError before the C stack is Index: Lib/test/test___future__.py =================================================================== --- Lib/test/test___future__.py (revision 58410) +++ Lib/test/test___future__.py (working copy) @@ -39,7 +39,7 @@ a(isinstance(major, int), "%s major isn't int" % name) a(isinstance(minor, int), "%s minor isn't int" % name) a(isinstance(micro, int), "%s micro isn't int" % name) - a(isinstance(level, basestring), + a(isinstance(level, str), "%s level isn't string" % name) a(level in GOOD_SERIALS, "%s level string has unknown value" % name) Index: Lib/test/test_abc.py =================================================================== --- Lib/test/test_abc.py (revision 58410) +++ Lib/test/test_abc.py (working copy) @@ -81,7 +81,7 @@ self.assertEqual(issubclass(int, A), True) class B(A): pass - B.register(basestring) + B.register(str) self.assertEqual(isinstance("", A), True) self.assertEqual(issubclass(str, A), True) Index: Lib/test/test_textwrap.py =================================================================== --- Lib/test/test_textwrap.py (revision 58410) +++ Lib/test/test_textwrap.py (working copy) @@ -23,7 +23,7 @@ for i in range(len(textin)): result.append(" %d: %r" % (i, textin[i])) result = '\n'.join(result) - elif isinstance(textin, basestring): + elif isinstance(textin, str): result = " %s\n" % repr(textin) return result Index: Lib/test/test_pwd.py =================================================================== --- Lib/test/test_pwd.py (revision 58410) +++ Lib/test/test_pwd.py (working copy) @@ -13,19 +13,19 @@ for e in entries: self.assertEqual(len(e), 7) self.assertEqual(e[0], e.pw_name) - self.assert_(isinstance(e.pw_name, basestring)) + self.assert_(isinstance(e.pw_name, str)) self.assertEqual(e[1], e.pw_passwd) - self.assert_(isinstance(e.pw_passwd, basestring)) + self.assert_(isinstance(e.pw_passwd, str)) self.assertEqual(e[2], e.pw_uid) self.assert_(isinstance(e.pw_uid, int)) self.assertEqual(e[3], e.pw_gid) self.assert_(isinstance(e.pw_gid, int)) self.assertEqual(e[4], e.pw_gecos) - self.assert_(isinstance(e.pw_gecos, basestring)) + self.assert_(isinstance(e.pw_gecos, str)) self.assertEqual(e[5], e.pw_dir) - self.assert_(isinstance(e.pw_dir, basestring)) + self.assert_(isinstance(e.pw_dir, str)) self.assertEqual(e[6], e.pw_shell) - self.assert_(isinstance(e.pw_shell, basestring)) + self.assert_(isinstance(e.pw_shell, str)) # The following won't work, because of duplicate entries # for one uid Index: Lib/test/test_tempfile.py =================================================================== --- Lib/test/test_tempfile.py (revision 58410) +++ Lib/test/test_tempfile.py (working copy) @@ -143,7 +143,7 @@ self.failIf(len(cand) == 0) for c in cand: - self.assert_(isinstance(c, basestring), + self.assert_(isinstance(c, str), "%s is not a string" % c) def test_wanted_dirs(self): @@ -328,7 +328,7 @@ # gettempprefix returns a nonempty prefix string p = tempfile.gettempprefix() - self.assert_(isinstance(p, basestring)) + self.assert_(isinstance(p, str)) self.assert_(len(p) > 0) def test_usable_template(self): @@ -463,7 +463,7 @@ extant[i] = self.do_create(pre="aa") finally: for i in extant: - if(isinstance(i, basestring)): + if(isinstance(i, str)): os.rmdir(i) def test_choose_directory(self): Index: Lib/test/test_unittest.py =================================================================== --- Lib/test/test_unittest.py (revision 58410) +++ Lib/test/test_unittest.py (working copy) @@ -1718,7 +1718,7 @@ def test_id(self): test = unittest.FunctionTestCase(lambda: None) - self.failUnless(isinstance(test.id(), basestring)) + self.failUnless(isinstance(test.id(), str)) # "Returns a one-line description of the test, or None if no description # has been provided. The default implementation of this method returns @@ -2239,7 +2239,7 @@ def runTest(self): pass - self.failUnless(isinstance(Foo().id(), basestring)) + self.failUnless(isinstance(Foo().id(), str)) # "Returns a one-line description of the test, or None if no description # has been provided. The default implementation of this method returns Index: Lib/test/test_grp.py =================================================================== --- Lib/test/test_grp.py (revision 58410) +++ Lib/test/test_grp.py (working copy) @@ -11,9 +11,9 @@ # attributes promised by the docs self.assertEqual(len(value), 4) self.assertEqual(value[0], value.gr_name) - self.assert_(isinstance(value.gr_name, basestring)) + self.assert_(isinstance(value.gr_name, str)) self.assertEqual(value[1], value.gr_passwd) - self.assert_(isinstance(value.gr_passwd, basestring)) + self.assert_(isinstance(value.gr_passwd, str)) self.assertEqual(value[2], value.gr_gid) self.assert_(isinstance(value.gr_gid, int)) self.assertEqual(value[3], value.gr_mem) Index: Lib/test/test_support.py =================================================================== --- Lib/test/test_support.py (revision 58410) +++ Lib/test/test_support.py (working copy) @@ -529,7 +529,7 @@ valid_types = (unittest.TestSuite, unittest.TestCase) suite = unittest.TestSuite() for cls in classes: - if isinstance(cls, basestring): + if isinstance(cls, str): if cls in sys.modules: suite.addTest(unittest.findTestCases(sys.modules[cls])) else: Index: Lib/test/test_collections.py =================================================================== --- Lib/test/test_collections.py (revision 58410) +++ Lib/test/test_collections.py (working copy) @@ -235,7 +235,7 @@ for sample in [tuple, list, bytes, str]: self.failUnless(isinstance(sample(), Sequence)) self.failUnless(issubclass(sample, Sequence)) - self.failUnless(issubclass(basestring, Sequence)) + self.failUnless(issubclass(str, Sequence)) def test_MutableSequence(self): for sample in [tuple, str]: @@ -244,7 +244,7 @@ for sample in [list, bytes]: self.failUnless(isinstance(sample(), MutableSequence)) self.failUnless(issubclass(sample, MutableSequence)) - self.failIf(issubclass(basestring, MutableSequence)) + self.failIf(issubclass(str, MutableSequence)) def test_main(verbose=None): Index: Lib/test/test_sys.py =================================================================== --- Lib/test/test_sys.py (revision 58410) +++ Lib/test/test_sys.py (working copy) @@ -126,7 +126,7 @@ def test_getdefaultencoding(self): self.assertRaises(TypeError, sys.getdefaultencoding, 42) # can't check more than the type, as the user might have changed it - self.assert_(isinstance(sys.getdefaultencoding(), basestring)) + self.assert_(isinstance(sys.getdefaultencoding(), str)) # testing sys.settrace() is done in test_trace.py # testing sys.setprofile() is done in test_profile.py @@ -275,15 +275,15 @@ self.assert_(isinstance(sys.argv, list)) self.assert_(sys.byteorder in ("little", "big")) self.assert_(isinstance(sys.builtin_module_names, tuple)) - self.assert_(isinstance(sys.copyright, basestring)) - self.assert_(isinstance(sys.exec_prefix, basestring)) - self.assert_(isinstance(sys.executable, basestring)) + self.assert_(isinstance(sys.copyright, str)) + self.assert_(isinstance(sys.exec_prefix, str)) + self.assert_(isinstance(sys.executable, str)) self.assert_(isinstance(sys.hexversion, int)) self.assert_(isinstance(sys.maxint, int)) self.assert_(isinstance(sys.maxunicode, int)) - self.assert_(isinstance(sys.platform, basestring)) - self.assert_(isinstance(sys.prefix, basestring)) - self.assert_(isinstance(sys.version, basestring)) + self.assert_(isinstance(sys.platform, str)) + self.assert_(isinstance(sys.prefix, str)) + self.assert_(isinstance(sys.version, str)) vi = sys.version_info self.assert_(isinstance(vi, tuple)) self.assertEqual(len(vi), 5) Index: Lib/test/test_posixpath.py =================================================================== --- Lib/test/test_posixpath.py (revision 58410) +++ Lib/test/test_posixpath.py (working copy) @@ -335,15 +335,15 @@ except ImportError: pass else: - self.assert_(isinstance(posixpath.expanduser("~/"), basestring)) + self.assert_(isinstance(posixpath.expanduser("~/"), str)) # if home directory == root directory, this test makes no sense if posixpath.expanduser("~") != '/': self.assertEqual( posixpath.expanduser("~") + "/", posixpath.expanduser("~/") ) - self.assert_(isinstance(posixpath.expanduser("~root/"), basestring)) - self.assert_(isinstance(posixpath.expanduser("~foo/"), basestring)) + self.assert_(isinstance(posixpath.expanduser("~root/"), str)) + self.assert_(isinstance(posixpath.expanduser("~foo/"), str)) self.assertRaises(TypeError, posixpath.expanduser) Index: Lib/test/test_ast.py =================================================================== --- Lib/test/test_ast.py (revision 58410) +++ Lib/test/test_ast.py (working copy) @@ -2,7 +2,7 @@ import _ast def to_tuple(t): - if t is None or isinstance(t, (basestring, int, int, complex)): + if t is None or isinstance(t, (str, int, int, complex)): return t elif isinstance(t, list): return [to_tuple(e) for e in t] Index: Lib/subprocess.py =================================================================== --- Lib/subprocess.py (revision 58410) +++ Lib/subprocess.py (working copy) @@ -698,7 +698,7 @@ errread, errwrite): """Execute program (MS Windows version)""" - if not isinstance(args, basestring): + if not isinstance(args, str): args = list2cmdline(args) # Process startup details @@ -913,7 +913,7 @@ errread, errwrite): """Execute program (POSIX version)""" - if isinstance(args, basestring): + if isinstance(args, str): args = [args] else: args = list(args) Index: Lib/uu.py =================================================================== --- Lib/uu.py (revision 58410) +++ Lib/uu.py (working copy) @@ -46,7 +46,7 @@ # if in_file == '-': in_file = sys.stdin.buffer - elif isinstance(in_file, basestring): + elif isinstance(in_file, str): if name is None: name = os.path.basename(in_file) if mode is None: @@ -60,7 +60,7 @@ # if out_file == '-': out_file = sys.stdout.buffer - elif isinstance(out_file, basestring): + elif isinstance(out_file, str): out_file = open(out_file, 'wb') # # Set defaults for name and mode @@ -87,7 +87,7 @@ # if in_file == '-': in_file = sys.stdin.buffer - elif isinstance(in_file, basestring): + elif isinstance(in_file, str): in_file = open(in_file, 'rb') # # Read until a begin is encountered or we've exhausted the file @@ -118,7 +118,7 @@ opened = False if out_file == '-': out_file = sys.stdout.buffer - elif isinstance(out_file, basestring): + elif isinstance(out_file, str): fp = open(out_file, 'wb') try: os.path.chmod(out_file, mode) @@ -169,7 +169,7 @@ if options.decode: if options.text: - if isinstance(output, basestring): + if isinstance(output, str): output = open(output, 'wb') else: print(sys.argv[0], ': cannot do -t to stdout') @@ -177,7 +177,7 @@ decode(input, output) else: if options.text: - if isinstance(input, basestring): + if isinstance(input, str): input = open(input, 'rb') else: print(sys.argv[0], ': cannot do -t from stdin') Index: Lib/timeit.py =================================================================== --- Lib/timeit.py (revision 58410) +++ Lib/timeit.py (working copy) @@ -121,9 +121,9 @@ """Constructor. See class doc string.""" self.timer = timer ns = {} - if isinstance(stmt, basestring): + if isinstance(stmt, str): stmt = reindent(stmt, 8) - if isinstance(setup, basestring): + if isinstance(setup, str): setup = reindent(setup, 4) src = template % {'stmt': stmt, 'setup': setup} elif hasattr(setup, '__call__'): @@ -137,7 +137,7 @@ self.inner = ns["inner"] elif hasattr(stmt, '__call__'): self.src = None - if isinstance(setup, basestring): + if isinstance(setup, str): _setup = setup def setup(): exec(_setup, globals(), ns) Index: Lib/locale.py =================================================================== --- Lib/locale.py (revision 58410) +++ Lib/locale.py (working copy) @@ -12,6 +12,7 @@ """ import sys, encodings, encodings.aliases +from __builtin__ import str as _builtin_str # Try importing the _locale module. # @@ -472,7 +473,7 @@ category may be given as one of the LC_* values. """ - if locale and not isinstance(locale, basestring): + if locale and not isinstance(locale, _builtin_str): # convert to string locale = normalize(_build_localename(locale)) return _setlocale(category, locale) Index: Lib/sre_compile.py =================================================================== --- Lib/sre_compile.py (revision 58410) +++ Lib/sre_compile.py (working copy) @@ -472,7 +472,7 @@ code[skip] = len(code) - skip def isstring(obj): - return isinstance(obj, basestring) + return isinstance(obj, str) def _code(p, flags): Index: Lib/pickle.py =================================================================== --- Lib/pickle.py (revision 58410) +++ Lib/pickle.py (working copy) @@ -307,7 +307,7 @@ (t.__name__, obj)) # Check for string returned by reduce(), meaning "save as global" - if isinstance(rv, basestring): + if isinstance(rv, str): self.save_global(obj, rv) return Index: Lib/xml/dom/pulldom.py =================================================================== --- Lib/xml/dom/pulldom.py (revision 58410) +++ Lib/xml/dom/pulldom.py (working copy) @@ -325,7 +325,7 @@ def parse(stream_or_string, parser=None, bufsize=None): if bufsize is None: bufsize = default_bufsize - if isinstance(stream_or_string, basestring): + if isinstance(stream_or_string, str): stream = open(stream_or_string) else: stream = stream_or_string Index: Lib/xml/sax/saxutils.py =================================================================== --- Lib/xml/sax/saxutils.py (revision 58410) +++ Lib/xml/sax/saxutils.py (working copy) @@ -272,7 +272,7 @@ """This function takes an InputSource and an optional base URL and returns a fully resolved InputSource object ready for reading.""" - if isinstance(source, basestring): + if isinstance(source, str): source = xmlreader.InputSource(source) elif hasattr(source, "read"): f = source Index: Lib/binhex.py =================================================================== --- Lib/binhex.py (revision 58410) +++ Lib/binhex.py (working copy) @@ -169,7 +169,7 @@ class BinHex: def __init__(self, name_finfo_dlen_rlen, ofp): name, finfo, dlen, rlen = name_finfo_dlen_rlen - if isinstance(ofp, basestring): + if isinstance(ofp, str): ofname = ofp ofp = io.open(ofname, 'wb') if os.name == 'mac': @@ -371,7 +371,7 @@ class HexBin: def __init__(self, ifp): - if isinstance(ifp, basestring): + if isinstance(ifp, str): ifp = io.open(ifp, 'rb') # # Find initial colon. Index: Lib/pkgutil.py =================================================================== --- Lib/pkgutil.py (revision 58410) +++ Lib/pkgutil.py (working copy) @@ -516,7 +516,7 @@ path = path[:] # Start with a copy of the existing path for dir in sys.path: - if not isinstance(dir, basestring) or not os.path.isdir(dir): + if not isinstance(dir, str) or not os.path.isdir(dir): continue subdir = os.path.join(dir, pname) # XXX This may still add duplicate entries to path on Index: Modules/_csv.c =================================================================== --- Modules/_csv.c (revision 58410) +++ Modules/_csv.c (working copy) @@ -62,7 +62,7 @@ /* end 2.2 compatibility macros */ #define IS_BASESTRING(o) \ - PyObject_TypeCheck(o, &PyBaseString_Type) + PyUnicode_Check(o) static PyObject *error_obj; /* CSV exception */ static PyObject *dialects; /* Dialect registry */