Code

Opened 6 years ago

Closed 6 years ago

#9075 closed (fixed)

Missing destination.close()

Reported by: bmsleight Owned by: nobody
Component: Documentation Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation:
Needs tests: Patch needs improvement:
Easy pickings: UI/UX:

Description

In page http://docs.djangoproject.com/en/dev/topics/http/file-uploads/

def handle_uploaded_file(f):
    destination = open('some/file/name.txt', 'wb+')
    for chunk in f.chunks():
        destination.write(chunk)

IMHO should read:-

def handle_uploaded_file(f):
    destination = open('some/file/name.txt', 'wb+')
    for chunk in f.chunks():
        destination.write(chunk)
        destination.close()

Regards,
Brendan

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(In [9027]) Fixed #9075: Added a call to close() in the example file upload handler. Thanks to Brendan (bmsleight) for the suggestion.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.