Skip to content

Merge StringIO/cStringIO in 3.0 #47167

Closed
Closed

Description

@brettcannon
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']

    Activity

    1. brettcannon commented on May 19, 2008

      @brettcannon
      MemberAuthor

      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.

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-bugAn unexpected behavior, bug, or error
      on May 19, 2008
    3. avassalotti commented on Jun 10, 2008

      @avassalotti
      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?

    4. avassalotti commented on Jun 11, 2008

      @avassalotti
      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.

    5. avassalotti commented on Jun 11, 2008

      @avassalotti
      Member

      I updated the patch to use the new module framework.

    6. avassalotti commented on Jun 11, 2008

      @avassalotti
      Member

      Committed in r64154.

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    release-blockerstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions