Skip to content

Commit 952b9fd

Browse files
committed
issue2551046: Attempts to attach file or create large message fail
under python2 This patch fixes a bug introduced for working around an issue in python3. There were a few ways to fix this, but I think this fix: 1) follows the spirit of the original patch 2) follows python programming expectations I am still having an issue trying to get both code paths executed from the test suite. The super code path is not tested, but I did validate that path from the browser and it works producing valid uploaded files in both python 2 and 3. Thanks to Ezio Melotti and Joseph Myers for their help in guiding me to come up with this solution.
1 parent 1a982cb commit 952b9fd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

roundup/cgi/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def update(self, set_cookie=False, expire=None):
230230
if set_cookie:
231231
self.client.add_cookie(self.cookie_name, self._sid, expire=expire)
232232

233-
class BinaryFieldStorage(cgi.FieldStorage):
233+
# import from object as well so it's a new style object and I can use super()
234+
class BinaryFieldStorage(cgi.FieldStorage, object):
234235
'''This class works around the bug https://bugs.python.org/issue27777.
235236
236237
cgi.FieldStorage must save all data as binary/bytes. This is
@@ -243,7 +244,7 @@ def make_file(self, mode=None):
243244
import tempfile
244245
if self.length >= 0:
245246
return tempfile.TemporaryFile("wb+")
246-
return super().make_file()
247+
return super(BinaryFieldStorage, self).make_file()
247248

248249
class Client:
249250
"""Instantiate to handle one CGI request.

0 commit comments

Comments
 (0)