mirror of
https://github.com/django/django.git
synced 2025-11-07 07:15:35 +00:00
[py3] Replaced __nonzero__ by __bool__
Of course, __nonzero__ alias has been kept for Python 2 compatibility.
This commit is contained in:
@@ -26,8 +26,9 @@ class File(FileProxyMixin):
|
||||
def __repr__(self):
|
||||
return "<%s: %s>" % (self.__class__.__name__, self or "None")
|
||||
|
||||
def __nonzero__(self):
|
||||
def __bool__(self):
|
||||
return bool(self.name)
|
||||
__nonzero__ = __bool__ # Python 2
|
||||
|
||||
def __len__(self):
|
||||
return self.size
|
||||
@@ -135,8 +136,9 @@ class ContentFile(File):
|
||||
def __str__(self):
|
||||
return 'Raw content'
|
||||
|
||||
def __nonzero__(self):
|
||||
def __bool__(self):
|
||||
return True
|
||||
__nonzero__ = __bool__ # Python 2
|
||||
|
||||
def open(self, mode=None):
|
||||
self.seek(0)
|
||||
|
||||
Reference in New Issue
Block a user