Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge StringIO/cStringIO in 3.0 #47167

Closed
brettcannon opened this issue May 19, 2008 · 5 comments
Closed

Merge StringIO/cStringIO in 3.0 #47167

brettcannon opened this issue May 19, 2008 · 5 comments
Assignees
Labels
release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@brettcannon
Copy link
Member

BPO 2918
Nosy @brettcannon, @avassalotti, @hdiogenes
Files
  • add-stringio-1.patch
  • add-stringio-2.patch
  • add-stringio-3.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/avassalotti'
    closed_at = <Date 2008-06-11.23:05:51.628>
    created_at = <Date 2008-05-19.20:01:01.620>
    labels = ['type-bug', 'library', 'release-blocker']
    title = 'Merge StringIO/cStringIO in 3.0'
    updated_at = <Date 2008-06-11.23:05:51.586>
    user = 'https://github.com/brettcannon'

    bugs.python.org fields:

    activity = <Date 2008-06-11.23:05:51.586>
    actor = 'alexandre.vassalotti'
    assignee = 'alexandre.vassalotti'
    closed = True
    closed_date = <Date 2008-06-11.23:05:51.628>
    closer = 'alexandre.vassalotti'
    components = ['Library (Lib)']
    creation = <Date 2008-05-19.20:01:01.620>
    creator = 'brett.cannon'
    dependencies = []
    files = ['10568', '10577', '10593']
    hgrepos = []
    issue_num = 2918
    keywords = ['patch']
    message_count = 5.0
    messages = ['67072', '67886', '67940', '68028', '68033']
    nosy_count = 3.0
    nosy_names = ['brett.cannon', 'alexandre.vassalotti', 'hdiogenes']
    pr_nums = []
    priority = 'release blocker'
    resolution = 'accepted'
    stage = None
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue2918'
    versions = ['Python 3.0']

    @brettcannon
    Copy link
    Member Author

    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.

    @brettcannon brettcannon added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels May 19, 2008
    @avassalotti
    Copy link
    Member

    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?

    @avassalotti
    Copy link
    Member

    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.

    @avassalotti
    Copy link
    Member

    I updated the patch to use the new module framework.

    @avassalotti
    Copy link
    Member

    Committed in r64154.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    release-blocker stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants