From 7afb47646920ab3835dfa1750257dace01883a4b Mon Sep 17 00:00:00 2001 From: Tom Date: Sat, 20 May 2017 22:16:36 +0100 Subject: [PATCH] Fixed #28226 -- Replaced use of str.join() with concatenation. --- django/contrib/admin/checks.py | 2 +- django/contrib/auth/base_user.py | 2 +- django/contrib/contenttypes/forms.py | 13 ++++++++----- django/db/models/query.py | 4 ++-- django/forms/formsets.py | 6 +++--- django/http/multipartparser.py | 2 +- django/http/response.py | 2 +- django/urls/resolvers.py | 4 ++-- django/views/generic/dates.py | 4 ++-- tests/runtests.py | 2 +- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py index 0d5db6c786..0102ce9a57 100644 --- a/django/contrib/admin/checks.py +++ b/django/contrib/admin/checks.py @@ -560,7 +560,7 @@ class ModelAdminChecks(BaseModelAdminChecks): def _check_inlines_item(self, obj, model, inline, label): """ Check one inline model admin. """ - inline_label = '.'.join([inline.__module__, inline.__name__]) + inline_label = inline.__module__ + '.' + inline.__name__ from django.contrib.admin.options import InlineModelAdmin diff --git a/django/contrib/auth/base_user.py b/django/contrib/auth/base_user.py index cf3c71d751..8865b671c9 100644 --- a/django/contrib/auth/base_user.py +++ b/django/contrib/auth/base_user.py @@ -26,7 +26,7 @@ class BaseUserManager(models.Manager): except ValueError: pass else: - email = '@'.join([email_name, domain_part.lower()]) + email = email_name + '@' + domain_part.lower() return email def make_random_password(self, length=10, diff --git a/django/contrib/contenttypes/forms.py b/django/contrib/contenttypes/forms.py index 60e6d794b5..4970ab452b 100644 --- a/django/contrib/contenttypes/forms.py +++ b/django/contrib/contenttypes/forms.py @@ -13,10 +13,10 @@ class BaseGenericInlineFormSet(BaseModelFormSet): prefix=None, queryset=None, **kwargs): opts = self.model._meta self.instance = instance - self.rel_name = '-'.join(( - opts.app_label, opts.model_name, - self.ct_field.name, self.ct_fk_field.name, - )) + self.rel_name = ( + opts.app_label + '-' + opts.model_name + '-' + + self.ct_field.name + '-' + self.ct_fk_field.name + ) if self.instance is None or self.instance.pk is None: qs = self.model._default_manager.none() else: @@ -32,7 +32,10 @@ class BaseGenericInlineFormSet(BaseModelFormSet): @classmethod def get_default_prefix(cls): opts = cls.model._meta - return '-'.join((opts.app_label, opts.model_name, cls.ct_field.name, cls.ct_fk_field.name)) + return ( + opts.app_label + '-' + opts.model_name + '-' + + cls.ct_field.name + '-' + cls.ct_fk_field.name + ) def save_new(self, form, commit=True): setattr(form.instance, self.ct_field.get_attname(), ContentType.objects.get_for_model(self.instance).pk) diff --git a/django/db/models/query.py b/django/db/models/query.py index 10952195db..cd9709c1fa 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -1282,8 +1282,8 @@ class Prefetch: return obj_dict def add_prefix(self, prefix): - self.prefetch_through = LOOKUP_SEP.join([prefix, self.prefetch_through]) - self.prefetch_to = LOOKUP_SEP.join([prefix, self.prefetch_to]) + self.prefetch_through = prefix + LOOKUP_SEP + self.prefetch_through + self.prefetch_to = prefix + LOOKUP_SEP + self.prefetch_to def get_current_prefetch_to(self, level): return LOOKUP_SEP.join(self.prefetch_to.split(LOOKUP_SEP)[:level + 1]) diff --git a/django/forms/formsets.py b/django/forms/formsets.py index 0df122c5bc..49febc2b2e 100644 --- a/django/forms/formsets.py +++ b/django/forms/formsets.py @@ -399,17 +399,17 @@ class BaseFormSet: # probably should be. It might make sense to render each form as a # table row with each field as a td. forms = ' '.join(form.as_table() for form in self) - return mark_safe('\n'.join([str(self.management_form), forms])) + return mark_safe(str(self.management_form) + '\n' + forms) def as_p(self): "Return this formset rendered as HTML

s." forms = ' '.join(form.as_p() for form in self) - return mark_safe('\n'.join([str(self.management_form), forms])) + return mark_safe(str(self.management_form) + '\n' + forms) def as_ul(self): "Return this formset rendered as HTML

  • s." forms = ' '.join(form.as_ul() for form in self) - return mark_safe('\n'.join([str(self.management_form), forms])) + return mark_safe(str(self.management_form) + '\n' + forms) def formset_factory(form, formset=BaseFormSet, extra=1, can_order=False, diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py index 080f45f8ef..f66cf2772f 100644 --- a/django/http/multipartparser.py +++ b/django/http/multipartparser.py @@ -401,7 +401,7 @@ class LazyStream: return self._update_unget_history(len(bytes)) self.position -= len(bytes) - self._leftover = b''.join([bytes, self._leftover]) + self._leftover = bytes + self._leftover def _update_unget_history(self, num_bytes): """ diff --git a/django/http/response.py b/django/http/response.py index 2495ebcc09..1083fd7dca 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -92,7 +92,7 @@ class HttpResponseBase: return val if isinstance(val, bytes) else val.encode(encoding) headers = [ - (b': '.join([to_bytes(key, 'ascii'), to_bytes(value, 'latin-1')])) + (to_bytes(key, 'ascii') + b': ' + to_bytes(value, 'latin-1')) for key, value in self._headers.values() ] return b'\r\n'.join(headers) diff --git a/django/urls/resolvers.py b/django/urls/resolvers.py index 8bb80c86cb..7f39e77c35 100644 --- a/django/urls/resolvers.py +++ b/django/urls/resolvers.py @@ -41,10 +41,10 @@ class ResolverMatch: if not hasattr(func, '__name__'): # A class-based view - self._func_path = '.'.join([func.__class__.__module__, func.__class__.__name__]) + self._func_path = func.__class__.__module__ + '.' + func.__class__.__name__ else: # A function-based view - self._func_path = '.'.join([func.__module__, func.__name__]) + self._func_path = func.__module__ + '.' + func.__name__ view_path = url_name or self._func_path self.view_name = ':'.join(self.namespaces + [view_path]) diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py index 3081c76d45..2ec8aabf6a 100644 --- a/django/views/generic/dates.py +++ b/django/views/generic/dates.py @@ -600,8 +600,8 @@ def _date_from_string(year, year_format, month='', month_format='', day='', day_ Get a datetime.date object given a format string and a year, month, and day (only year is mandatory). Raise a 404 for an invalid date. """ - format = delim.join((year_format, month_format, day_format)) - datestr = delim.join((year, month, day)) + format = year_format + delim + month_format + delim + day_format + datestr = year + delim + month + delim + day try: return datetime.datetime.strptime(datestr, format).date() except ValueError: diff --git a/tests/runtests.py b/tests/runtests.py index b05483526e..9202534c51 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -183,7 +183,7 @@ def setup(verbosity, test_labels, parallel): installed_app_names = set(get_installed()) for modpath, module_name in test_modules: if modpath: - module_label = '.'.join([modpath, module_name]) + module_label = modpath + '.' + module_name else: module_label = module_name # if the module (or an ancestor) was named on the command line, or