#7812: read() in an InMemoryUploadedFile returns an empty string
---------------------------------------------+------------------------------
          Reporter:  kratorius               |         Owner:  nobody
            Status:  new                     |     Milestone:        
         Component:  Core framework          |       Version:  SVN   
        Resolution:                          |      Keywords:  upload
             Stage:  Design decision needed  |     Has_patch:  1     
        Needs_docs:  0                       |   Needs_tests:  0     
Needs_better_patch:  0                       |  
---------------------------------------------+------------------------------
Changes (by kratorius):

  * needs_tests:  1 => 0
  * stage:  Ready for checkin => Design decision needed

Comment:

 After a bit of thinking (and a short discussion yesterday on IRC), I came
 to conclusion that the previous patch breaks the {{{.read()}}} behaviour
 since with that patch, {{{.read()}}} ''always'' read from the beginning of
 the file, but someone could still want to read a bunch of bytes at times.

 The right behaviour should be:
  1. {{{.read()}}} called first time, returns the whole file
  2. the second time (and third, fourth and so on) {{{.read()}}} returns
 the empty string

 (I didn't talked about the case when you call {{{.read(size)}}}, but
 should work more or less in the same way, except that you'll have to call
 {{{.read()}}} multiple times before to get the empty string).

 I'm still trying to figure out what's happening since both at
 {{{InMemoryUploadedFile}}} and {{{TemporaryUploadedFile}}} there's a
 {{{file.seek(0)}}} in the {{{__init__}}}, but looks like if the file
 pointer gets changed somewhere before I can call {{{.read()}}}.
 Anyway, I'm going to attach a fixed testcase that covers this issue.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/7812#comment:3>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to