diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-11-03 21:43:11 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-11-03 22:07:35 +0100 |
| commit | fc10418fba4fb906e4265650b62c510d526d63f7 (patch) | |
| tree | e00dc8dfa531f03a9ba973e4da80d0f796e83733 /django/core/files/base.py | |
| parent | 973f539ab83bb46645f2f711190735c66a246797 (diff) | |
| download | django-fc10418fba4fb906e4265650b62c510d526d63f7.tar.gz | |
Fixed #18963 -- Used a subclass-friendly pattern
for Python 2 object model compatibility methods.
Diffstat (limited to 'django/core/files/base.py')
| -rw-r--r-- | django/core/files/base.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/django/core/files/base.py b/django/core/files/base.py index b81e180292..71de5ab741 100644 --- a/django/core/files/base.py +++ b/django/core/files/base.py @@ -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) |
