use .seek(0) instead of reset() for compatibility

Since I don't find docs for the .reset() method, I lookup up the source
code, and it should work just the same as .seek(0).

For reference:
8eeb7e9122/Modules/cStringIO.c (L281)
This commit is contained in:
Felix Yan 2014-07-15 16:24:57 +08:00
parent 2999fc75b1
commit ef8872a518
2 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,7 @@ class ReceivedDataProtocol(Protocol):
return self.__filename
def close(self):
self.body.close() if self.filename else self.body.reset()
self.body.close() if self.filename else self.body.seek(0)
_CODE_RE = re.compile("\d+")
class FTPDownloadHandler(object):

View File

@ -132,7 +132,7 @@ class PickleItemExporterTest(BaseItemExporterTest):
ie.export_item(i1)
ie.export_item(i2)
ie.finish_exporting()
f.reset()
f.seek(0)
self.assertEqual(pickle.load(f), i1)
self.assertEqual(pickle.load(f), i2)