﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29278	FileResponse documentation should warn against using context managers	Mike DePalatis	Windson yang	"Idiomatic Python usually opens file objects using a context manager like this:

{{{
with open(""filename.txt"", ""rb"") as fo:
    # do stuff with fo
}}}

This is problematic when using a `FileResponse` which requires a file-like object rather than a path. Doing something like:

{{{
with open(""filename.txt"", ""rb"") as fo:
    return FileResponse(fo)
}}}

results in an error due to trying to operate on a closed file:

{{{
Exception happened during processing of request from ('127.0.0.1', 60169)
Traceback (most recent call last):
  File ""/Users/zduey/anaconda3/envs/cml/lib/python3.5/wsgiref/handlers.py"", line 138, in run
    self.finish_response()
  File ""/Users/zduey/anaconda3/envs/cml/lib/python3.5/wsgiref/handlers.py"", line 179, in finish_response
    for data in self.result:
  File ""/Users/zduey/anaconda3/envs/cml/lib/python3.5/wsgiref/util.py"", line 30, in __next__
    data = self.filelike.read(self.blksize)
ValueError: read of closed file
}}}

The documentation for `FileResponse` should be updated to explicitly warn users against passing in file objects opened with a context manager and make clear that the file will be closed automatically."	Cleanup/optimization	closed	Documentation	2.0	Normal	fixed			Accepted	1	0	0	1	1	0
