mirror of
https://github.com/django/django.git
synced 2025-09-24 19:23:03 +00:00
[py3] Replaced __nonzero__ by __bool__
Of course, __nonzero__ alias has been kept for Python 2 compatibility.
This commit is contained in:
parent
12cda89ffe
commit
576ec12f8e
7 changed files with 15 additions and 8 deletions
|
@ -120,7 +120,7 @@ class QuerySet(object):
|
|||
if len(self._result_cache) <= pos:
|
||||
self._fill_cache()
|
||||
|
||||
def __nonzero__(self):
|
||||
def __bool__(self):
|
||||
if self._prefetch_related_lookups and not self._prefetch_done:
|
||||
# We need all the results in order to be able to do the prefetch
|
||||
# in one go. To minimize code duplication, we use the __len__
|
||||
|
@ -134,6 +134,7 @@ class QuerySet(object):
|
|||
except StopIteration:
|
||||
return False
|
||||
return True
|
||||
__nonzero__ = __bool__ # Python 2
|
||||
|
||||
def __contains__(self, val):
|
||||
# The 'in' operator works without this method, due to __iter__. This
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue