Issue 2918: Merge StringIO/cStringIO in 3.0 (original) (raw)

Created on 2008-05-19 20:01 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
add-stringio-1.patch alexandre.vassalotti,2008-06-10 02:14
add-stringio-2.patch alexandre.vassalotti,2008-06-11 04:22
add-stringio-3.patch alexandre.vassalotti,2008-06-11 22:02
Messages (5)
msg67072 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2008-05-19 20:01
PEP 3108 calls for StringIO (which is io.StringIO in 3.0) to have an accelerated version behind it when available. Alexandre has been working on this so assigning to him.
msg67886 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-10 02:14
Here's a preliminary patch that add the C optimization for StringIO. All tests are passing except two which depends on the StringIO.buffer attribute of the TextIOWrapper class. Honestly, I am not sure what is the correct way to fix this. I cannot simply "fake" the attribute by returning a BytesIO object, since the file position of buffer is undecidable. It seems to me that the only way to fix these failing tests would be to define a FakeIO class, in their test file, that would wrap ByteIO with TextIOWrapper, just like the old and inefficient StringIO. So, any idea on what would be the best thing to do?
msg67940 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-11 04:22
Here's another patch fixes the failing tests. I have tried to support the buffer attribute using following hack: @property def buffer(self): # XXX Hack to support the buffer attribute. buf = codecs.getwriter(self.encoding)(BytesIO(), self.errors) value = self.getvalue() buf.write(value[:self.tell()]) pos = buf.stream.tell() buf.write(value[self.tell():]) buf.stream.seek(pos) return buf.stream but this doesn't work since some application might want to modify the buffer. So, I removed it. Another thing that bothered me were the bogus encoding and errors arguments. So, I also removed them.
msg68028 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-11 22:02
I updated the patch to use the new module framework.
msg68033 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2008-06-11 23:05
Committed in r64154.
History
Date User Action Args
2022-04-11 14:56:34 admin set github: 47167
2008-06-11 23:07:45 alexandre.vassalotti unlink issue2775 dependencies
2008-06-11 23:05:51 alexandre.vassalotti set status: open -> closedresolution: acceptedmessages: +
2008-06-11 22:03:43 alexandre.vassalotti set files: + add-stringio-3.patchmessages: +
2008-06-11 04:22:50 alexandre.vassalotti set files: + add-stringio-2.patchmessages: +
2008-06-10 02:14:10 alexandre.vassalotti set files: + add-stringio-1.patchkeywords: + patchmessages: +
2008-05-29 22:35:36 hdiogenes set nosy: + hdiogenes
2008-05-19 20:02:29 brett.cannon link issue2775 dependencies
2008-05-19 20:01:01 brett.cannon create