diff options
author | Hans Lawrenz <hrlawrenz@gmail.com> | 2014-03-21 10:57:18 -0400 |
---|---|---|
committer | Baptiste Mispelon <bmispelon@gmail.com> | 2014-03-21 22:34:47 +0100 |
commit | 918a16bc4c099ab0cae72a231de3e99e2a9d02cb (patch) | |
tree | 455dc4e7fa74c3ded2987e53aa438cef544bf170 /django/core/files/base.py | |
parent | 7e0f9095f762a74116b0b4ba0c88267bdf184e0f (diff) | |
download | django-918a16bc4c099ab0cae72a231de3e99e2a9d02cb.tar.gz |
Fixed #22307 -- Fixed SpooledTemporaryFile bug in File class.
Added condition to prevent checking the existence of a file name of a
file like object when the name attribute is None. This is necessary
because a SpooledTemporaryFile won't exist on the file system or have a
name until it has reached its max_size. Also added tests.
Diffstat (limited to 'django/core/files/base.py')
-rw-r--r-- | django/core/files/base.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/django/core/files/base.py b/django/core/files/base.py index 641ff924c6..85b3c21cba 100644 --- a/django/core/files/base.py +++ b/django/core/files/base.py @@ -40,7 +40,7 @@ class File(FileProxyMixin): if not hasattr(self, '_size'): if hasattr(self.file, 'size'): self._size = self.file.size - elif hasattr(self.file, 'name') and os.path.exists(self.file.name): + elif hasattr(self.file, 'name') and self.file.name is not None and os.path.exists(self.file.name): self._size = os.path.getsize(self.file.name) elif hasattr(self.file, 'tell') and hasattr(self.file, 'seek'): pos = self.file.tell() |