diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
a
|
b
|
class ChangeList:
|
194 | 194 | self.show_full_result_count = self.model_admin.show_full_result_count |
195 | 195 | # Admin actions are shown if there is at least one entry |
196 | 196 | # or if entries are not counted because show_full_result_count is disabled |
197 | | self.show_admin_actions = not self.show_full_result_count or bool(full_result_count) |
| 197 | self.show_admin_actions = not self.show_full_result_count or full_result_count |
198 | 198 | self.full_result_count = full_result_count |
199 | 199 | self.result_list = result_list |
200 | 200 | self.can_show_all = can_show_all |
diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py
a
|
b
|
class SessionBase:
|
141 | 141 | def is_empty(self): |
142 | 142 | "Return True when there is no session_key and the session is empty." |
143 | 143 | try: |
144 | | return not bool(self._session_key) and not self._session_cache |
| 144 | return not self._session_key and not self._session_cache |
145 | 145 | except AttributeError: |
146 | 146 | return True |
147 | 147 | |
diff --git a/django/core/validators.py b/django/core/validators.py
a
|
b
|
class RegexValidator:
|
54 | 54 | Validate that the input contains (or does *not* contain, if |
55 | 55 | inverse_match is True) a match for the regular expression. |
56 | 56 | """ |
57 | | regex_matches = bool(self.regex.search(str(value))) |
| 57 | regex_matches = self.regex.search(str(value)) |
58 | 58 | invalid_input = regex_matches if self.inverse_match else not regex_matches |
59 | 59 | if invalid_input: |
60 | 60 | raise ValidationError(self.message, code=self.code) |
diff --git a/django/db/models/options.py b/django/db/models/options.py
a
|
b
|
class Options:
|
188 | 188 | self.verbose_name_plural = format_lazy('{}s', self.verbose_name) |
189 | 189 | |
190 | 190 | # order_with_respect_and ordering are mutually exclusive. |
191 | | self._ordering_clash = bool(self.ordering and self.order_with_respect_to) |
| 191 | self._ordering_clash = self.ordering and self.order_with_respect_to |
192 | 192 | |
193 | 193 | # Any leftover attributes must be invalid. |
194 | 194 | if meta_attrs != {}: |
diff --git a/django/forms/forms.py b/django/forms/forms.py
a
|
b
|
class BaseForm:
|
139 | 139 | if self._errors is None: |
140 | 140 | is_valid = "Unknown" |
141 | 141 | else: |
142 | | is_valid = self.is_bound and not bool(self._errors) |
| 142 | is_valid = self.is_bound and not self._errors |
143 | 143 | return '<%(cls)s bound=%(bound)s, valid=%(valid)s, fields=(%(fields)s)>' % { |
144 | 144 | 'cls': self.__class__.__name__, |
145 | 145 | 'bound': self.is_bound, |
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
a
|
b
|
class Select(ChoiceWidget):
|
681 | 681 | def _choice_has_empty_value(choice): |
682 | 682 | """Return True if the choice's value is empty string or None.""" |
683 | 683 | value, _ = choice |
684 | | return (isinstance(value, str) and not bool(value)) or value is None |
| 684 | return (isinstance(value, str) and not value) or value is None |
685 | 685 | |
686 | 686 | def use_required_attribute(self, initial): |
687 | 687 | """ |
diff --git a/django/middleware/common.py b/django/middleware/common.py
a
|
b
|
class BrokenLinkEmailsMiddleware(MiddlewareMixin):
|
135 | 135 | |
136 | 136 | def is_internal_request(self, domain, referer): |
137 | 137 | """ |
138 | | Return True if the referring URL is the same domain as the current |
139 | | request. |
| 138 | Only if the referring URL is the same domain as the current request, then |
| 139 | passing the result to bool() will evaluate to True. |
140 | 140 | """ |
141 | 141 | # Different subdomains are treated as different domains. |
142 | | return bool(re.match("^https?://%s/" % re.escape(domain), referer)) |
| 142 | return re.match("^https?://%s/" % re.escape(domain), referer) |
143 | 143 | |
144 | 144 | def is_ignorable_request(self, request, uri, domain, referer): |
145 | 145 | """ |
diff --git a/django/template/backends/base.py b/django/template/backends/base.py
a
|
b
|
class BaseEngine:
|
20 | 20 | params = params.copy() |
21 | 21 | self.name = params.pop('NAME') |
22 | 22 | self.dirs = list(params.pop('DIRS')) |
23 | | self.app_dirs = bool(params.pop('APP_DIRS')) |
| 23 | self.app_dirs = params.pop('APP_DIRS') |
24 | 24 | if params: |
25 | 25 | raise ImproperlyConfigured( |
26 | 26 | "Unknown parameters: {}".format(", ".join(params))) |
diff --git a/django/utils/http.py b/django/utils/http.py
a
|
b
|
def _urlsplit(url, scheme='', allow_fragments=True):
|
324 | 324 | Note that we don't break the components up in smaller bits |
325 | 325 | (e.g. netloc is a single string) and we don't expand % escapes.""" |
326 | 326 | url, scheme, _coerce_result = _coerce_args(url, scheme) |
327 | | allow_fragments = bool(allow_fragments) |
328 | 327 | netloc = query = fragment = '' |
329 | 328 | i = url.find(':') |
330 | 329 | if i > 0: |