diff options
| author | Claude Paroz <claude@2xlibre.net> | 2017-01-20 10:20:53 +0100 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2017-01-20 14:13:55 +0100 |
| commit | 042b7350a080cc964f913faf1cf7f0097f650a58 (patch) | |
| tree | 4ad77d8fc8ae016770afe01a543a6042fa02357a /django | |
| parent | 4e729feaa647547f25debb1cb63dec989dc41a20 (diff) | |
Refs #23919 -- Removed unneeded str() calls
Diffstat (limited to 'django')
32 files changed, 70 insertions, 74 deletions
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index b76e860324..4dca40150f 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -83,7 +83,7 @@ class OpenLayersWidget(Textarea): # JavaScript construction utilities for the Bounds and Projection. def ol_bounds(extent): - return 'new OpenLayers.Bounds(%s)' % str(extent) + return 'new OpenLayers.Bounds(%s)' % extent def ol_projection(srid): return 'new OpenLayers.Projection("EPSG:%s")' % srid diff --git a/django/contrib/gis/db/backends/postgis/adapter.py b/django/contrib/gis/db/backends/postgis/adapter.py index 84ec5bfae9..a3ec99de46 100644 --- a/django/contrib/gis/db/backends/postgis/adapter.py +++ b/django/contrib/gis/db/backends/postgis/adapter.py @@ -58,9 +58,9 @@ class PostGISAdapter: """ if self.is_geometry: # Psycopg will figure out whether to use E'\\000' or '\000'. - return str('%s(%s)' % ( + return '%s(%s)' % ( 'ST_GeogFromWKB' if self.geography else 'ST_GeomFromEWKB', - self._adapter.getquoted().decode()) + self._adapter.getquoted().decode() ) else: # For rasters, add explicit type cast to WKB string. diff --git a/django/contrib/gis/db/models/functions.py b/django/contrib/gis/db/models/functions.py index 0a5c14f7a7..5454b2a740 100644 --- a/django/contrib/gis/db/models/functions.py +++ b/django/contrib/gis/db/models/functions.py @@ -65,7 +65,7 @@ class GeoFunc(Func): if check_types and not isinstance(value, check_types): raise TypeError( "The %s parameter has the wrong type: should be %s." % ( - param_name, str(check_types)) + param_name, check_types) ) return value diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py index 3008da804c..7759fd79ae 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -109,7 +109,7 @@ class DataSource(GDALBase): def __str__(self): "Returns OGR GetName and Driver for the Data Source." - return '%s (%s)' % (self.name, str(self.driver)) + return '%s (%s)' % (self.name, self.driver) @property def layer_count(self): diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py index 20ebaeff20..fb348bb377 100644 --- a/django/contrib/gis/gdal/driver.py +++ b/django/contrib/gis/gdal/driver.py @@ -60,11 +60,11 @@ class Driver(GDALBase): elif isinstance(dr_input, c_void_p): driver = dr_input else: - raise GDALException('Unrecognized input type for GDAL/OGR Driver: %s' % str(type(dr_input))) + raise GDALException('Unrecognized input type for GDAL/OGR Driver: %s' % type(dr_input)) # Making sure we get a valid pointer to the OGR Driver if not driver: - raise GDALException('Could not initialize GDAL/OGR Driver on input: %s' % str(dr_input)) + raise GDALException('Could not initialize GDAL/OGR Driver on input: %s' % dr_input) self.ptr = driver def __str__(self): diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py index e7c7e3dde1..4cf30c06d9 100644 --- a/django/contrib/gis/gdal/envelope.py +++ b/django/contrib/gis/gdal/envelope.py @@ -51,7 +51,7 @@ class Envelope: else: self._from_sequence(args[0]) else: - raise TypeError('Incorrect type of argument: %s' % str(type(args[0]))) + raise TypeError('Incorrect type of argument: %s' % type(args[0])) elif len(args) == 4: # Individual parameters passed in. # Thanks to ww for the help @@ -123,7 +123,7 @@ class Envelope: else: raise GDALException('Incorrect number of tuple elements (%d).' % len(args[0])) else: - raise TypeError('Incorrect type of argument: %s' % str(type(args[0]))) + raise TypeError('Incorrect type of argument: %s' % type(args[0])) elif len(args) == 2: # An x and an y parameter were passed in return self.expand_to_include((args[0], args[1], args[0], args[1])) diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index 1dd85ac139..b1acc5bf5b 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -109,7 +109,7 @@ class OGRGeometry(GDALBase): # Now checking the Geometry pointer before finishing initialization # by setting the pointer for the object. if not g: - raise GDALException('Cannot create OGR Geometry from input: %s' % str(geom_input)) + raise GDALException('Cannot create OGR Geometry from input: %s' % geom_input) self.ptr = g # Assigning the SpatialReference object to the geometry, if valid. @@ -549,7 +549,7 @@ class LineString(OGRGeometry): elif dim == 3: return (x.value, y.value, z.value) else: - raise OGRIndexError('index out of range: %s' % str(index)) + raise OGRIndexError('index out of range: %s' % index) def __iter__(self): "Iterates over each point in the LineString." diff --git a/django/contrib/gis/geos/coordseq.py b/django/contrib/gis/geos/coordseq.py index 6908b040c0..f40d99865e 100644 --- a/django/contrib/gis/geos/coordseq.py +++ b/django/contrib/gis/geos/coordseq.py @@ -73,7 +73,7 @@ class GEOSCoordSeq(GEOSBase): "Checks the given index." sz = self.size if (sz < 1) or (index < 0) or (index >= sz): - raise IndexError('invalid GEOS Geometry index: %s' % str(index)) + raise IndexError('invalid GEOS Geometry index: %s' % index) def _checkdim(self, dim): "Checks the given dimension." diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index 2ff4037764..f473506539 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -73,7 +73,7 @@ class GEOSGeometry(GEOSBase, ListMixin): g = capi.geom_clone(geo_input.ptr) else: # Invalid geometry type. - raise TypeError('Improper geometry input type: %s' % str(type(geo_input))) + raise TypeError('Improper geometry input type: %s' % type(geo_input)) if g: # Setting the pointer object with a valid pointer. diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index d6e36db31a..c7fb703ce1 100644 --- a/django/contrib/gis/geos/mutable_list.py +++ b/django/contrib/gis/geos/mutable_list.py @@ -179,7 +179,7 @@ class ListMixin: for i in range(0, len(self)): if self[i] == val: return i - raise ValueError('%s not found in object' % str(val)) + raise ValueError('%s not found in object' % val) # ## Mutating ## def append(self, val): @@ -242,7 +242,7 @@ class ListMixin: return index if correct and -length <= index < 0: return index + length - raise IndexError('invalid index: %s' % str(index)) + raise IndexError('invalid index: %s' % index) def _check_allowed(self, items): if hasattr(self, '_allowed'): diff --git a/django/contrib/gis/geos/point.py b/django/contrib/gis/geos/point.py index 72de47f9f6..6486b2a5e1 100644 --- a/django/contrib/gis/geos/point.py +++ b/django/contrib/gis/geos/point.py @@ -56,7 +56,7 @@ class Point(GEOSGeometry): return capi.create_point(None) if ndim < 2 or ndim > 3: - raise TypeError('Invalid point dimension: %s' % str(ndim)) + raise TypeError('Invalid point dimension: %s' % ndim) cs = capi.create_cs(c_uint(1), c_uint(ndim)) i = iter(coords) diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index c61dae1dfa..7d8a12176a 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -153,9 +153,9 @@ class WSGIHandler(base.BaseHandler): response._handler_class = self.__class__ status = '%d %s' % (response.status_code, response.reason_phrase) - response_headers = [(str(k), str(v)) for k, v in response.items()] + response_headers = list(response.items()) for c in response.cookies.values(): - response_headers.append((str('Set-Cookie'), str(c.output(header='')))) + response_headers.append(('Set-Cookie', c.output(header=''))) start_response(status, response_headers) if getattr(response, 'file_to_stream', None) is not None and environ.get('wsgi.file_wrapper'): response = environ['wsgi.file_wrapper'](response.file_to_stream) @@ -208,9 +208,9 @@ def get_bytes_from_wsgi(environ, key, default): """ Get a value from the WSGI environ dictionary as bytes. - key and default should be str objects. + key and default should be strings. """ - value = environ.get(str(key), str(default)) + value = environ.get(key, default) # Non-ASCII values in the WSGI environ are arbitrarily decoded with # ISO-8859-1. This is wrong for Django websites where UTF-8 is the default. # Re-encode to recover the original bytestring. diff --git a/django/core/mail/message.py b/django/core/mail/message.py index 228084f2d1..dd5e1e6d7b 100644 --- a/django/core/mail/message.py +++ b/django/core/mail/message.py @@ -68,7 +68,7 @@ def forbid_multi_line_headers(name, val, encoding): else: if name.lower() == 'subject': val = Header(val).encode() - return str(name), val + return name, val def split_addr(addr, encoding): diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py index 5b74ddaa0d..029d5163a5 100644 --- a/django/core/management/commands/makemessages.py +++ b/django/core/management/commands/makemessages.py @@ -398,7 +398,7 @@ class Command(BaseCommand): self.process_files(file_list) potfiles = [] for path in self.locale_paths: - potfile = os.path.join(path, '%s.pot' % str(self.domain)) + potfile = os.path.join(path, '%s.pot' % self.domain) if not os.path.exists(potfile): continue args = ['msguniq'] + self.msguniq_options + [potfile] @@ -417,7 +417,7 @@ class Command(BaseCommand): def remove_potfiles(self): for path in self.locale_paths: - pot_path = os.path.join(path, '%s.pot' % str(self.domain)) + pot_path = os.path.join(path, '%s.pot' % self.domain) if os.path.exists(pot_path): os.unlink(pot_path) @@ -583,7 +583,7 @@ class Command(BaseCommand): ) for build_file in build_files: msgs = build_file.postprocess_messages(msgs) - potfile = os.path.join(locale_dir, '%s.pot' % str(self.domain)) + potfile = os.path.join(locale_dir, '%s.pot' % self.domain) write_pot_file(potfile, msgs) for build_file in build_files: @@ -599,7 +599,7 @@ class Command(BaseCommand): basedir = os.path.join(os.path.dirname(potfile), locale, 'LC_MESSAGES') if not os.path.isdir(basedir): os.makedirs(basedir) - pofile = os.path.join(basedir, '%s.po' % str(self.domain)) + pofile = os.path.join(basedir, '%s.po' % self.domain) if os.path.exists(pofile): args = ['msgmerge'] + self.msgmerge_options + [pofile, potfile] diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py index e5dcaa1771..61a275d61f 100644 --- a/django/core/management/commands/runserver.py +++ b/django/core/management/commands/runserver.py @@ -56,7 +56,7 @@ class Command(BaseCommand): # We rely on the environment because it's currently the only # way to reach WSGIRequestHandler. This seems an acceptable # compromise considering `runserver` runs indefinitely. - os.environ[str("DJANGO_COLORS")] = str("nocolor") + os.environ["DJANGO_COLORS"] = "nocolor" super(Command, self).execute(*args, **options) def get_handler(self, *args, **options): diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index b706f74ec8..a9ab0668f7 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -103,7 +103,7 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler): } if args[1][0] == '4': # 0x16 = Handshake, 0x03 = SSL 3.0 or TLS 1.x - if args[0].startswith(str('\x16\x03')): + if args[0].startswith('\x16\x03'): extra['status_code'] = 500 logger.error( "You're accessing the development server over HTTPS, but " diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py index 44f81c8ba1..07c4ceb1e7 100644 --- a/django/db/backends/sqlite3/base.py +++ b/django/db/backends/sqlite3/base.py @@ -45,13 +45,13 @@ def decoder(conv_func): return lambda s: conv_func(s.decode('utf-8')) -Database.register_converter(str("bool"), decoder(lambda s: s == '1')) -Database.register_converter(str("time"), decoder(parse_time)) -Database.register_converter(str("date"), decoder(parse_date)) -Database.register_converter(str("datetime"), decoder(parse_datetime)) -Database.register_converter(str("timestamp"), decoder(parse_datetime)) -Database.register_converter(str("TIMESTAMP"), decoder(parse_datetime)) -Database.register_converter(str("decimal"), decoder(backend_utils.typecast_decimal)) +Database.register_converter("bool", decoder(lambda s: s == '1')) +Database.register_converter("time", decoder(parse_time)) +Database.register_converter("date", decoder(parse_date)) +Database.register_converter("datetime", decoder(parse_datetime)) +Database.register_converter("timestamp", decoder(parse_datetime)) +Database.register_converter("TIMESTAMP", decoder(parse_datetime)) +Database.register_converter("decimal", decoder(backend_utils.typecast_decimal)) Database.register_adapter(decimal.Decimal, backend_utils.rev_typecast_decimal) diff --git a/django/db/models/base.py b/django/db/models/base.py index 047f90ec73..66b671698d 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -35,10 +35,10 @@ from django.utils.version import get_version class Deferred: def __repr__(self): - return str('<Deferred field>') + return '<Deferred field>' def __str__(self): - return str('<Deferred field>') + return '<Deferred field>' DEFERRED = Deferred() @@ -118,7 +118,7 @@ class ModelBase(type): new_class.add_to_class( 'DoesNotExist', subclass_exception( - str('DoesNotExist'), + 'DoesNotExist', tuple( x.DoesNotExist for x in parents if hasattr(x, '_meta') and not x._meta.abstract ) or (ObjectDoesNotExist,), @@ -127,7 +127,7 @@ class ModelBase(type): new_class.add_to_class( 'MultipleObjectsReturned', subclass_exception( - str('MultipleObjectsReturned'), + 'MultipleObjectsReturned', tuple( x.MultipleObjectsReturned for x in parents if hasattr(x, '_meta') and not x._meta.abstract ) or (MultipleObjectsReturned,), diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 26b0bb2378..fabd291159 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -32,9 +32,7 @@ from django.utils.itercompat import is_iterable from django.utils.text import capfirst from django.utils.translation import ugettext_lazy as _ -# Avoid "TypeError: Item in ``from list'' not a string" -- unicode_literals -# makes these strings unicode -__all__ = [str(x) for x in ( +__all__ = [ 'AutoField', 'BLANK_CHOICE_DASH', 'BigAutoField', 'BigIntegerField', 'BinaryField', 'BooleanField', 'CharField', 'CommaSeparatedIntegerField', 'DateField', 'DateTimeField', 'DecimalField', 'DurationField', @@ -43,7 +41,7 @@ __all__ = [str(x) for x in ( 'NOT_PROVIDED', 'NullBooleanField', 'PositiveIntegerField', 'PositiveSmallIntegerField', 'SlugField', 'SmallIntegerField', 'TextField', 'TimeField', 'URLField', 'UUIDField', -)] +] class Empty: diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py index d1937bd5db..4e678ea672 100644 --- a/django/db/models/fields/files.py +++ b/django/db/models/fields/files.py @@ -277,7 +277,7 @@ class FileField(Field): def get_prep_value(self, value): "Returns field's value prepared for saving into a database." value = super(FileField, self).get_prep_value(value) - # Need to convert File objects provided via a form to unicode for database insertion + # Need to convert File objects provided via a form to string for database insertion if value is None: return None return str(value) diff --git a/django/db/models/indexes.py b/django/db/models/indexes.py index 03aa06fa52..7721826380 100644 --- a/django/db/models/indexes.py +++ b/django/db/models/indexes.py @@ -2,7 +2,7 @@ import hashlib from django.utils.encoding import force_bytes -__all__ = [str('Index')] +__all__ = ['Index'] # The max length of the names of the indexes (restricted to 30 due to Oracle) MAX_NAME_LENGTH = 30 diff --git a/django/http/cookie.py b/django/http/cookie.py index fb0a7786ef..36945ce106 100644 --- a/django/http/cookie.py +++ b/django/http/cookie.py @@ -22,13 +22,13 @@ def parse_cookie(cookie): Return a dictionary parsed from a `Cookie:` header string. """ cookiedict = {} - for chunk in cookie.split(str(';')): - if str('=') in chunk: - key, val = chunk.split(str('='), 1) + for chunk in cookie.split(';'): + if '=' in chunk: + key, val = chunk.split('=', 1) else: # Assume an empty name per # https://bugzilla.mozilla.org/show_bug.cgi?id=169091 - key, val = str(''), chunk + key, val = '', chunk key, val = key.strip(), val.strip() if key or val: # unquote using Python's algorithm. diff --git a/django/http/request.py b/django/http/request.py index 6f3b0c9951..554e05217d 100644 --- a/django/http/request.py +++ b/django/http/request.py @@ -509,11 +509,11 @@ class QueryDict(MultiValueDict): # this slightly more restricted function, used by QueryDict. def bytes_to_text(s, encoding): """ - Converts basestring objects to unicode, using the given encoding. Illegally + Convert bytes objects to strings, using the given encoding. Illegally encoded input characters are replaced with Unicode "unknown" codepoint (\ufffd). - Returns any non-basestring objects without change. + Return any non-bytes objects without change. """ if isinstance(s, bytes): return str(s, encoding, 'replace') diff --git a/django/http/response.py b/django/http/response.py index e992adaed5..9c697f5b88 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -124,8 +124,7 @@ class HttpResponseBase: value = value.decode(charset) except UnicodeError as e: if mime_encode: - # Wrapping in str() is a workaround for #12422 under Python 2. - value = str(Header(value, 'utf-8', maxlinelen=sys.maxsize).encode()) + value = Header(value, 'utf-8', maxlinelen=sys.maxsize).encode() else: e.reason += ', HTTP response headers must be in %s format' % charset raise diff --git a/django/test/client.py b/django/test/client.py index 20c968bb3f..f09051d2d5 100644 --- a/django/test/client.py +++ b/django/test/client.py @@ -281,15 +281,15 @@ class RequestFactory: # See http://www.python.org/dev/peps/pep-3333/#environ-variables environ = { 'HTTP_COOKIE': self.cookies.output(header='', sep='; '), - 'PATH_INFO': str('/'), - 'REMOTE_ADDR': str('127.0.0.1'), - 'REQUEST_METHOD': str('GET'), - 'SCRIPT_NAME': str(''), - 'SERVER_NAME': str('testserver'), - 'SERVER_PORT': str('80'), - 'SERVER_PROTOCOL': str('HTTP/1.1'), + 'PATH_INFO': '/', + 'REMOTE_ADDR': '127.0.0.1', + 'REQUEST_METHOD': 'GET', + 'SCRIPT_NAME': '', + 'SERVER_NAME': 'testserver', + 'SERVER_PORT': '80', + 'SERVER_PROTOCOL': 'HTTP/1.1', 'wsgi.version': (1, 0), - 'wsgi.url_scheme': str('http'), + 'wsgi.url_scheme': 'http', 'wsgi.input': FakePayload(b''), 'wsgi.errors': self.errors, 'wsgi.multiprocess': True, @@ -393,14 +393,14 @@ class RequestFactory: data = force_bytes(data, settings.DEFAULT_CHARSET) r = { 'PATH_INFO': self._get_path(parsed), - 'REQUEST_METHOD': str(method), - 'SERVER_PORT': str('443') if secure else str('80'), - 'wsgi.url_scheme': str('https') if secure else str('http'), + 'REQUEST_METHOD': method, + 'SERVER_PORT': '443' if secure else '80', + 'wsgi.url_scheme': 'https' if secure else 'http', } if data: r.update({ 'CONTENT_LENGTH': len(data), - 'CONTENT_TYPE': str(content_type), + 'CONTENT_TYPE': content_type, 'wsgi.input': FakePayload(data), }) r.update(extra) diff --git a/django/test/selenium.py b/django/test/selenium.py index 236f7d8053..e1415339dd 100644 --- a/django/test/selenium.py +++ b/django/test/selenium.py @@ -35,7 +35,7 @@ class SeleniumTestCaseBase(type(LiveServerTestCase)): for browser in test_class.browsers[1:]: browser_test_class = cls.__new__( cls, - str("%s%s" % (capfirst(browser), name)), + "%s%s" % (capfirst(browser), name), (test_class,), {'browser': browser, '__module__': test_class.__module__} ) diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index 6084684d73..376aedc3c1 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -236,7 +236,7 @@ class RegexURLResolver(LocaleRegexProvider): urlconf_repr = '<%s list>' % self.urlconf_name[0].__class__.__name__ else: urlconf_repr = repr(self.urlconf_name) - return str('<%s %s (%s:%s) %s>') % ( + return '<%s %s (%s:%s) %s>' % ( self.__class__.__name__, urlconf_repr, self.app_name, self.namespace, self.regex.pattern, ) diff --git a/django/utils/html.py b/django/utils/html.py index 63335d74b4..fb9c18219c 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -193,7 +193,7 @@ def smart_urlquote(url): # Tilde is part of RFC3986 Unreserved Characters # http://tools.ietf.org/html/rfc3986#section-2.3 # See also http://bugs.python.org/issue16285 - segment = quote(segment, safe=RFC3986_SUBDELIMS + RFC3986_GENDELIMS + str('~')) + segment = quote(segment, safe=RFC3986_SUBDELIMS + RFC3986_GENDELIMS + '~') return force_text(segment) # Handle IDN before quoting. diff --git a/django/utils/http.py b/django/utils/http.py index 5791856813..7b15dc2812 100644 --- a/django/utils/http.py +++ b/django/utils/http.py @@ -40,8 +40,8 @@ RFC1123_DATE = re.compile(r'^\w{3}, %s %s %s %s GMT$' % (__D, __M, __Y, __T)) RFC850_DATE = re.compile(r'^\w{6,9}, %s-%s-%s %s GMT$' % (__D, __M, __Y2, __T)) ASCTIME_DATE = re.compile(r'^\w{3} %s %s %s %s$' % (__M, __D2, __T, __Y)) -RFC3986_GENDELIMS = str(":/?#[]@") -RFC3986_SUBDELIMS = str("!$&'()*+,;=") +RFC3986_GENDELIMS = ":/?#[]@" +RFC3986_SUBDELIMS = "!$&'()*+,;=" FIELDS_MATCH = re.compile('[&;]') @@ -365,7 +365,7 @@ def limited_parse_qsl(qs, keep_blank_values=False, encoding='utf-8', for name_value in pairs: if not name_value: continue - nv = name_value.split(str('='), 1) + nv = name_value.split('=', 1) if len(nv) != 2: # Handle case of a control-name with no equal sign if keep_blank_values: diff --git a/django/utils/safestring.py b/django/utils/safestring.py index fe5ca422c3..2dfbd01cfe 100644 --- a/django/utils/safestring.py +++ b/django/utils/safestring.py @@ -95,7 +95,7 @@ def _safety_decorator(safety_marker, func): def mark_safe(s): """ Explicitly mark a string as safe for (HTML) output purposes. The returned - object can be used everywhere a string or unicode object is appropriate. + object can be used everywhere a string is appropriate. If used on a method as a decorator, mark the returned data as safe. diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py index 14bb0ce786..62ff122621 100644 --- a/django/utils/translation/trans_real.py +++ b/django/utils/translation/trans_real.py @@ -307,8 +307,7 @@ def do_translate(message, translation_function): """ global _default - # str() is allowing a bytestring message to remain bytestring on Python 2 - eol_message = message.replace(str('\r\n'), str('\n')).replace(str('\r'), str('\n')) + eol_message = message.replace('\r\n', '\n').replace('\r', '\n') if len(eol_message) == 0: # Returns an empty value of the corresponding type if an empty message diff --git a/django/utils/version.py b/django/utils/version.py index e9666f906e..b80d445d0c 100644 --- a/django/utils/version.py +++ b/django/utils/version.py @@ -25,7 +25,7 @@ def get_version(version=None): mapping = {'alpha': 'a', 'beta': 'b', 'rc': 'rc'} sub = mapping[version[3]] + str(version[4]) - return str(main + sub) + return main + sub def get_main_version(version=None): |
