#22307: tempfile.SpooledTemporaryFile passed to File causes exception
------------------------------+--------------------
     Reporter:  hrlawrenz@…   |      Owner:  nobody
         Type:  Bug           |     Status:  new
    Component:  Core (Other)  |    Version:  1.6
     Severity:  Normal        |   Keywords:
 Triage Stage:  Unreviewed    |  Has patch:  1
Easy pickings:  0             |      UI/UX:  0
------------------------------+--------------------
 When a File object is created from a tempfile.SpooledTemporaryFile, an
 exception occurs when the File.size method is called and the
 tempfile.SpooledTemporaryFile isn't large enough to have been written to
 disk. The exception is caused by an attempt to call os.path.exists on a
 None value. The name attribute of the tempfile.SpooledTemporaryFile in
 this case is None in this case because it doesn't exist on disk.

 Patch in pull request at https://github.com/django/django/pull/2455

 The patch just adds another condition before calling os.path.exists to
 verify that the file name isn't None.


 Traceback (most recent call last):
   File "/Users/hrwl/Documents/Projects/django/tests/files/tests.py", line
 215, in test_in_memory_spooled_temp
     self.assertTrue(django_file.size, 17)
   File "/Users/hrwl/Documents/Projects/django/django/core/files/base.py",
 line 43, in _get_size
     elif hasattr(self.file, 'name') and os.path.exists(self.file.name):
   File
 
"/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/genericpath.py",
 line 18, in exists
     os.stat(path)
 TypeError: coercing to Unicode: need string or buffer, NoneType found

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22307>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/062.e72a8a0efd484d6971f4caac09e8b134%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to