Closed cjwatson closed 4 years ago
Looks good to me. I'll need to check with a bit more time at hand, but I think this can be merged and released without any deprecation warning phase. It is unlikely that someone expects a part to be readable after an error condition.
In particular I believe that, in all the cases I touched, the part in question is literally inaccessible by callers - it hasn't yet been yielded or returned.
Hi - would it be possible to look at this fairly soon? I think my PR to convert zope.publisher to multipart (zopefoundation/zope.publisher#55) is otherwise ready to land, but it would be a bit of a shame to land it in a state that adds ResourceWarnings.
Thanks for the reminder! I just merged this and released version 0.2.2
to pypi.
Add a MultipartPart.close method, which consumers can use to close files (if any) when they're finished with them. Call it on some error paths when parts are about to go out of scope, avoiding ResourceWarnings in the test suite.
Also use a context manager in MultipartPart.save_as to avoid another more straightforward ResourceWarning.