1
0
mirror of https://github.com/django/django.git synced 2025-10-27 23:56:08 +00:00

Fixed #18963 -- Used a subclass-friendly pattern

for Python 2 object model compatibility methods.
This commit is contained in:
Aymeric Augustin
2012-11-03 21:43:11 +01:00
parent 973f539ab8
commit fc10418fba
14 changed files with 61 additions and 50 deletions

View File

@@ -28,7 +28,9 @@ class File(FileProxyMixin):
def __bool__(self):
return bool(self.name)
__nonzero__ = __bool__ # Python 2
def __nonzero__(self): # Python 2 compatibility
return type(self).__bool__(self)
def __len__(self):
return self.size
@@ -142,7 +144,9 @@ class ContentFile(File):
def __bool__(self):
return True
__nonzero__ = __bool__ # Python 2
def __nonzero__(self): # Python 2 compatibility
return type(self).__bool__(self)
def open(self, mode=None):
self.seek(0)