Mercurial > p > roundup > code
changeset 5671:f60c44563c3a
Adjust make_file override to use binary files only when needed.
Previous version would produce errors for large text fields in form
submissions with Python 3, so inherit from the default make_file
implementation and only force binary files in the specific case
(self.length >= 0) identified in <https://bugs.python.org/issue27777>.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Sun, 24 Mar 2019 21:49:17 +0000 |
| parents | 018bbad2a63e |
| children | 6b6bc8d31caf |
| files | roundup/cgi/client.py |
| diffstat | 1 files changed, 3 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/roundup/cgi/client.py Sun Mar 24 12:52:03 2019 -0400 +++ b/roundup/cgi/client.py Sun Mar 24 21:49:17 2019 +0000 @@ -237,15 +237,13 @@ needed for handling json and xml data blobs under python 3. Under python 2, str and binary are interchangable, not so under 3. - - Note that there may be places where this should support text mode. - (e.g. a large text file upload??). None are known, but this could be - a problem. ''' def make_file(self, mode=None): ''' work around https://bugs.python.org/issue27777 ''' import tempfile - return tempfile.TemporaryFile("wb+") + if self.length >= 0: + return tempfile.TemporaryFile("wb+") + return super().make_file() class Client: """Instantiate to handle one CGI request.
