diff options
Diffstat (limited to 'cherrypy')
-rw-r--r-- | cherrypy/_cpcompat.py | 1 | ||||
-rw-r--r-- | cherrypy/_cpconfig.py | 6 | ||||
-rw-r--r-- | cherrypy/_cperror.py | 4 | ||||
-rw-r--r-- | cherrypy/_cpmodpy.py | 2 | ||||
-rw-r--r-- | cherrypy/_cpreqbody.py | 4 | ||||
-rw-r--r-- | cherrypy/_cprequest.py | 8 | ||||
-rw-r--r-- | cherrypy/_cpserver.py | 6 | ||||
-rw-r--r-- | cherrypy/_helper.py | 4 | ||||
-rw-r--r-- | cherrypy/lib/cptools.py | 4 | ||||
-rw-r--r-- | cherrypy/lib/encoding.py | 4 | ||||
-rw-r--r-- | cherrypy/lib/httputil.py | 4 | ||||
-rw-r--r-- | cherrypy/lib/jsontools.py | 4 | ||||
-rw-r--r-- | cherrypy/lib/reprconf.py | 10 | ||||
-rw-r--r-- | cherrypy/process/plugins.py | 8 | ||||
-rw-r--r-- | cherrypy/test/helper.py | 6 | ||||
-rw-r--r-- | cherrypy/test/logtest.py | 4 | ||||
-rw-r--r-- | cherrypy/test/webtest.py | 6 |
17 files changed, 42 insertions, 43 deletions
diff --git a/cherrypy/_cpcompat.py b/cherrypy/_cpcompat.py index 6c97bc4b..32aaf09b 100644 --- a/cherrypy/_cpcompat.py +++ b/cherrypy/_cpcompat.py @@ -280,7 +280,6 @@ finally: json_encode = _json_encode text_or_bytes = six.text_type, six.binary_type -basestring = text_or_bytes try: import cPickle as pickle diff --git a/cherrypy/_cpconfig.py b/cherrypy/_cpconfig.py index 0b7ad948..7afb9131 100644 --- a/cherrypy/_cpconfig.py +++ b/cherrypy/_cpconfig.py @@ -119,7 +119,7 @@ style) context manager. """ import cherrypy -from cherrypy._cpcompat import basestring +from cherrypy._cpcompat import text_or_bytes from cherrypy.lib import reprconf # Deprecated in CherryPy 3.2--remove in 3.3 @@ -132,7 +132,7 @@ def merge(base, other): If the given config is a filename, it will be appended to the list of files to monitor for "autoreload" changes. """ - if isinstance(other, basestring): + if isinstance(other, text_or_bytes): cherrypy.engine.autoreload.files.add(other) # Load other into base @@ -152,7 +152,7 @@ class Config(reprconf.Config): def update(self, config): """Update self from a dict, file or filename.""" - if isinstance(config, basestring): + if isinstance(config, text_or_bytes): # Filename cherrypy.engine.autoreload.files.add(config) reprconf.Config.update(self, config) diff --git a/cherrypy/_cperror.py b/cherrypy/_cperror.py index 64cf3aa5..9029690c 100644 --- a/cherrypy/_cperror.py +++ b/cherrypy/_cperror.py @@ -121,7 +121,7 @@ from traceback import format_exception as _format_exception import six -from cherrypy._cpcompat import basestring, iteritems, ntob +from cherrypy._cpcompat import text_or_bytes, iteritems, ntob from cherrypy._cpcompat import tonative, urljoin as _urljoin from cherrypy.lib import httputil as _httputil @@ -209,7 +209,7 @@ class HTTPRedirect(CherryPyException): import cherrypy request = cherrypy.serving.request - if isinstance(urls, basestring): + if isinstance(urls, text_or_bytes): urls = [urls] abs_urls = [] diff --git a/cherrypy/_cpmodpy.py b/cherrypy/_cpmodpy.py index 82f6ab3b..1f80093f 100644 --- a/cherrypy/_cpmodpy.py +++ b/cherrypy/_cpmodpy.py @@ -262,7 +262,7 @@ def send_response(req, status, headers, body, stream=False): req.flush() # Set response body - if isinstance(body, basestring): + if isinstance(body, text_or_bytes): req.write(body) else: for seg in body: diff --git a/cherrypy/_cpreqbody.py b/cherrypy/_cpreqbody.py index e2d342b2..bb8ae6c7 100644 --- a/cherrypy/_cpreqbody.py +++ b/cherrypy/_cpreqbody.py @@ -132,7 +132,7 @@ except ImportError: return ntob('').join(atoms) import cherrypy -from cherrypy._cpcompat import basestring, ntob, ntou +from cherrypy._cpcompat import text_or_bytes, ntob, ntou from cherrypy.lib import httputil @@ -715,7 +715,7 @@ class Part(Entity): self.file = self.read_into_file() else: result = self.read_lines_to_boundary() - if isinstance(result, basestring): + if isinstance(result, text_or_bytes): self.value = result else: self.file = result diff --git a/cherrypy/_cprequest.py b/cherrypy/_cprequest.py index a40e51b4..81771497 100644 --- a/cherrypy/_cprequest.py +++ b/cherrypy/_cprequest.py @@ -5,7 +5,7 @@ import warnings import six import cherrypy -from cherrypy._cpcompat import basestring, copykeys, ntob +from cherrypy._cpcompat import text_or_bytes, copykeys, ntob from cherrypy._cpcompat import SimpleCookie, CookieError from cherrypy import _cpreqbody, _cpconfig from cherrypy._cperror import format_exc, bare_error @@ -139,7 +139,7 @@ def hooks_namespace(k, v): # hookpoint per path (e.g. "hooks.before_handler.1"). # Little-known fact you only get from reading source ;) hookpoint = k.split(".", 1)[0] - if isinstance(v, basestring): + if isinstance(v, text_or_bytes): v = cherrypy.lib.attributes(v) if not isinstance(v, Hook): v = Hook(v) @@ -815,7 +815,7 @@ class ResponseBody(object): if six.PY3 and isinstance(value, str): raise ValueError(self.unicode_err) - if isinstance(value, basestring): + if isinstance(value, text_or_bytes): # strings get wrapped in a list because iterating over a single # item list is much faster than iterating over every character # in a long string. @@ -901,7 +901,7 @@ class Response(object): def collapse_body(self): """Collapse self.body to a single string; replace it and return it.""" - if isinstance(self.body, basestring): + if isinstance(self.body, text_or_bytes): return self.body newbody = [] diff --git a/cherrypy/_cpserver.py b/cherrypy/_cpserver.py index e47085cd..a11404d7 100644 --- a/cherrypy/_cpserver.py +++ b/cherrypy/_cpserver.py @@ -4,7 +4,7 @@ import six import cherrypy from cherrypy.lib import attributes -from cherrypy._cpcompat import basestring +from cherrypy._cpcompat import text_or_bytes # We import * because we want to export check_port # et al as attributes of this module. @@ -156,7 +156,7 @@ class Server(ServerAdapter): if httpserver is None: from cherrypy import _cpwsgi_server httpserver = _cpwsgi_server.CPWSGIServer(self) - if isinstance(httpserver, basestring): + if isinstance(httpserver, text_or_bytes): # Is anyone using this? Can I add an arg? httpserver = attributes(httpserver)(self) return httpserver, self.bind_addr @@ -180,7 +180,7 @@ class Server(ServerAdapter): self.socket_file = None self.socket_host = None self.socket_port = None - elif isinstance(value, basestring): + elif isinstance(value, text_or_bytes): self.socket_file = value self.socket_host = None self.socket_port = None diff --git a/cherrypy/_helper.py b/cherrypy/_helper.py index 970e2a4a..23357bc8 100644 --- a/cherrypy/_helper.py +++ b/cherrypy/_helper.py @@ -5,7 +5,7 @@ Helper functions for CP apps import six from cherrypy._cpcompat import urljoin as _urljoin, urlencode as _urlencode -from cherrypy._cpcompat import basestring +from cherrypy._cpcompat import text_or_bytes import cherrypy @@ -17,7 +17,7 @@ def expose(func=None, alias=None): def expose_(func): func.exposed = True if alias is not None: - if isinstance(alias, basestring): + if isinstance(alias, text_or_bytes): parents[alias.replace(".", "_")] = func else: for a in alias: diff --git a/cherrypy/lib/cptools.py b/cherrypy/lib/cptools.py index 073216e0..3221066b 100644 --- a/cherrypy/lib/cptools.py +++ b/cherrypy/lib/cptools.py @@ -7,7 +7,7 @@ from hashlib import md5 import six import cherrypy -from cherrypy._cpcompat import basestring +from cherrypy._cpcompat import text_or_bytes from cherrypy.lib import httputil as _httputil from cherrypy.lib import is_iterator @@ -533,7 +533,7 @@ def accept(media=None, debug=False): """ if not media: return - if isinstance(media, basestring): + if isinstance(media, text_or_bytes): media = [media] request = cherrypy.serving.request diff --git a/cherrypy/lib/encoding.py b/cherrypy/lib/encoding.py index 88f25634..e1179415 100644 --- a/cherrypy/lib/encoding.py +++ b/cherrypy/lib/encoding.py @@ -5,7 +5,7 @@ import io import six import cherrypy -from cherrypy._cpcompat import basestring, ntob +from cherrypy._cpcompat import text_or_bytes, ntob from cherrypy.lib import file_generator from cherrypy.lib import is_closable_iterator from cherrypy.lib import set_vary_header @@ -219,7 +219,7 @@ class ResponseEncoder: response = cherrypy.serving.response self.body = self.oldhandler(*args, **kwargs) - if isinstance(self.body, basestring): + if isinstance(self.body, text_or_bytes): # strings get wrapped in a list because iterating over a single # item list is much faster than iterating over every character # in a long string. diff --git a/cherrypy/lib/httputil.py b/cherrypy/lib/httputil.py index e8b9a2ac..78cc4039 100644 --- a/cherrypy/lib/httputil.py +++ b/cherrypy/lib/httputil.py @@ -14,7 +14,7 @@ from binascii import b2a_base64 import six from cherrypy._cpcompat import BaseHTTPRequestHandler, ntob, ntou -from cherrypy._cpcompat import basestring, iteritems +from cherrypy._cpcompat import text_or_bytes, iteritems from cherrypy._cpcompat import reversed, sorted, unquote_qs response_codes = BaseHTTPRequestHandler.responses.copy() @@ -465,7 +465,7 @@ class HeaderMap(CaseInsensitiveDict): if isinstance(k, six.text_type): k = cls.encode(k) - if not isinstance(v, basestring): + if not isinstance(v, text_or_bytes): v = str(v) if isinstance(v, six.text_type): diff --git a/cherrypy/lib/jsontools.py b/cherrypy/lib/jsontools.py index 90b3ff8a..79ceaa48 100644 --- a/cherrypy/lib/jsontools.py +++ b/cherrypy/lib/jsontools.py @@ -1,5 +1,5 @@ import cherrypy -from cherrypy._cpcompat import basestring, ntou, json_encode, json_decode +from cherrypy._cpcompat import text_or_bytes, ntou, json_encode, json_decode def json_processor(entity): @@ -41,7 +41,7 @@ def json_in(content_type=[ntou('application/json'), ntou('text/javascript')], package importable; otherwise, ValueError is raised during processing. """ request = cherrypy.serving.request - if isinstance(content_type, basestring): + if isinstance(content_type, text_or_bytes): content_type = [content_type] if force: diff --git a/cherrypy/lib/reprconf.py b/cherrypy/lib/reprconf.py index 8af1f777..ae7b1d3f 100644 --- a/cherrypy/lib/reprconf.py +++ b/cherrypy/lib/reprconf.py @@ -30,9 +30,9 @@ except NameError: from sets import Set as set try: - basestring + text_or_bytes except NameError: - basestring = str + text_or_bytes = str try: # Python 3 @@ -47,7 +47,7 @@ import sys def as_dict(config): """Return a dict from 'config' whether it is a dict, file, or filename.""" - if isinstance(config, basestring): + if isinstance(config, text_or_bytes): config = Parser().dict_from_file(config) elif hasattr(config, 'read'): config = Parser().dict_from_file(config) @@ -155,7 +155,7 @@ class Config(dict): def update(self, config): """Update self from a dict, file or filename.""" - if isinstance(config, basestring): + if isinstance(config, text_or_bytes): # Filename config = Parser().dict_from_file(config) elif hasattr(config, 'read'): @@ -192,7 +192,7 @@ class Parser(ConfigParser): return optionstr def read(self, filenames): - if isinstance(filenames, basestring): + if isinstance(filenames, text_or_bytes): filenames = [filenames] for filename in filenames: # try: diff --git a/cherrypy/process/plugins.py b/cherrypy/process/plugins.py index 0ec585c0..23c83e91 100644 --- a/cherrypy/process/plugins.py +++ b/cherrypy/process/plugins.py @@ -7,7 +7,7 @@ import sys import time import threading -from cherrypy._cpcompat import basestring, get_daemon, get_thread_ident +from cherrypy._cpcompat import text_or_bytes, get_daemon, get_thread_ident from cherrypy._cpcompat import ntob, Timer, SetDaemonProperty # _module__file__base is used by Autoreload to make @@ -176,7 +176,7 @@ class SignalHandler(object): If the given signal name or number is not available on the current platform, ValueError is raised. """ - if isinstance(signal, basestring): + if isinstance(signal, text_or_bytes): signum = getattr(_signal, signal, None) if signum is None: raise ValueError("No such signal: %r" % signal) @@ -242,7 +242,7 @@ class DropPrivileges(SimplePlugin): self.bus.log("pwd module not available; ignoring uid.", level=30) val = None - elif isinstance(val, basestring): + elif isinstance(val, text_or_bytes): val = pwd.getpwnam(val)[2] self._uid = val uid = property(_get_uid, _set_uid, @@ -257,7 +257,7 @@ class DropPrivileges(SimplePlugin): self.bus.log("grp module not available; ignoring gid.", level=30) val = None - elif isinstance(val, basestring): + elif isinstance(val, text_or_bytes): val = grp.getgrnam(val)[2] self._gid = val gid = property(_get_gid, _set_gid, diff --git a/cherrypy/test/helper.py b/cherrypy/test/helper.py index d2d0e2b2..dc5cbf86 100644 --- a/cherrypy/test/helper.py +++ b/cherrypy/test/helper.py @@ -14,7 +14,7 @@ import time import warnings import cherrypy -from cherrypy._cpcompat import basestring, copyitems, HTTPSConnection, ntob +from cherrypy._cpcompat import text_or_bytes, copyitems, HTTPSConnection, ntob from cherrypy.lib import httputil from cherrypy.lib import gctools from cherrypy.lib.reprconf import unrepr @@ -48,7 +48,7 @@ def get_tst_config(overconf={}): _conf = testconfig.config.get('supervisor', None) if _conf is not None: for k, v in _conf.items(): - if isinstance(v, basestring): + if isinstance(v, text_or_bytes): _conf[k] = unrepr(v) conf.update(_conf) except ImportError: @@ -253,7 +253,7 @@ class CPWebCase(webtest.WebCase): if sys.platform[:4] == 'java': cherrypy.config.update({'server.nodelay': False}) - if isinstance(conf, basestring): + if isinstance(conf, text_or_bytes): parser = cherrypy.lib.reprconf.Parser() conf = parser.dict_from_file(conf).get('global', {}) else: diff --git a/cherrypy/test/logtest.py b/cherrypy/test/logtest.py index 53f29f11..27feac86 100644 --- a/cherrypy/test/logtest.py +++ b/cherrypy/test/logtest.py @@ -5,7 +5,7 @@ import time import six -from cherrypy._cpcompat import basestring, ntob +from cherrypy._cpcompat import text_or_bytes, ntob try: @@ -187,7 +187,7 @@ class LogCase(object): # Multiple args. Use __getslice__ and require lines to be list. if isinstance(lines, tuple): lines = list(lines) - elif isinstance(lines, basestring): + elif isinstance(lines, text_or_bytes): raise TypeError("The 'lines' arg must be a list when " "'sliceargs' is a tuple.") diff --git a/cherrypy/test/webtest.py b/cherrypy/test/webtest.py index 5ea2b975..8e8352be 100644 --- a/cherrypy/test/webtest.py +++ b/cherrypy/test/webtest.py @@ -30,7 +30,7 @@ import unittest import six -from cherrypy._cpcompat import basestring, HTTPConnection +from cherrypy._cpcompat import text_or_bytes, HTTPConnection from cherrypy._cpcompat import HTTPSConnection @@ -349,7 +349,7 @@ class WebCase(unittest.TestCase): def assertStatus(self, status, msg=None): """Fail if self.status != status.""" - if isinstance(status, basestring): + if isinstance(status, text_or_bytes): if not self.status == status: if msg is None: msg = 'Status (%r) != %r' % (self.status, status) @@ -364,7 +364,7 @@ class WebCase(unittest.TestCase): # status is a tuple or list. match = False for s in status: - if isinstance(s, basestring): + if isinstance(s, text_or_bytes): if self.status == s: match = True break |