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

[py3k] tell() fails in some situation #47825

Closed
ocean-city mannequin opened this issue Aug 17, 2008 · 7 comments
Closed

[py3k] tell() fails in some situation #47825

ocean-city mannequin opened this issue Aug 17, 2008 · 7 comments
Labels
stdlib Python modules in the Lib dir

Comments

@ocean-city
Copy link
Mannequin

ocean-city mannequin commented Aug 17, 2008

BPO 3575
Nosy @birkenfeld, @pitrou
Files
  • fix_mbidecoder_decode.patch: use s* instead of t#
  • 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 = None
    closed_at = <Date 2008-08-17.13:11:32.728>
    created_at = <Date 2008-08-17.09:13:54.445>
    labels = ['library']
    title = '[py3k] tell() fails in some situation'
    updated_at = <Date 2008-08-17.15:04:43.699>
    user = 'https://bugs.python.org/ocean-city'

    bugs.python.org fields:

    activity = <Date 2008-08-17.15:04:43.699>
    actor = 'ocean-city'
    assignee = 'none'
    closed = True
    closed_date = <Date 2008-08-17.13:11:32.728>
    closer = 'ocean-city'
    components = ['Library (Lib)']
    creation = <Date 2008-08-17.09:13:54.445>
    creator = 'ocean-city'
    dependencies = []
    files = ['11135']
    hgrepos = []
    issue_num = 3575
    keywords = ['patch']
    message_count = 7.0
    messages = ['71262', '71266', '71267', '71271', '71272', '71276', '71277']
    nosy_count = 3.0
    nosy_names = ['georg.brandl', 'pitrou', 'ocean-city']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue3575'
    versions = ['Python 3.0']

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Aug 17, 2008

    Hello. I noticed test_mailbox (test_add) fails on my win2k machine.
    It's something like this.

    ======================================================================
    ERROR: test_add (main.TestMbox)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "test_mailbox.py", line 60, in tearDown
        self._box.close()
      File "e:\python-dev\py3k\lib\mailbox.py", line 642, in close
        self.flush()
      File "e:\python-dev\py3k\lib\mailbox.py", line 600, in flush
        stop - self._file.tell()))
      File "e:\python-dev\py3k\lib\io.py", line 1625, in tell
        chars_decoded += len(decoder.decode(next_byte))
      File "e:\python-dev\py3k\lib\io.py", line 1295, in decode
        output = self.decoder.decode(input, final=final)
    TypeError: decode() argument 1 must be string or pinned buffer, not
    bytearray

    And this is simple reproducable code. ("a.txt" contains some text)

    f = open("a.txt")
    f.read(1)
    f.tell() # boom

    I searched the place where raises this error in C code,
    and I found mbidecoder_decode() is.

        if (!PyArg_ParseTupleAndKeywords(args, kwargs, "t#|i:decode",
        		incrementalkwarglist, &data, &size, &final))
    	return NULL;

    This uses "t#", so cannot accept bytearray, probably.
    I hope attached file solves this issue. Thank you.

    @pitrou
    Copy link
    Member

    pitrou commented Aug 17, 2008

    Your patch looks right to me. It should also be backported to 2.6.

    @pitrou pitrou added the stdlib Python modules in the Lib dir label Aug 17, 2008
    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Aug 17, 2008

    Well, MultibyteCodec_Decode() also uses Py_buffer in py3k but not in
    trunk. Is this also backported?

    @pitrou
    Copy link
    Member

    pitrou commented Aug 17, 2008

    Le dimanche 17 août 2008 à 11:44 +0000, Hirokazu Yamamoto a écrit :

    Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> added the comment:

    Well, MultibyteCodec_Decode() also uses Py_buffer in py3k but not in
    trunk. Is this also backported?

    It should be :-)

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Aug 17, 2008

    OK, done.

    @ocean-city ocean-city mannequin closed this as completed Aug 17, 2008
    @birkenfeld
    Copy link
    Member

    Please state the revision numbers when closing an issue due to a commit;
    this makes it easier to find the change later.

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Aug 17, 2008

    Sorry, fixed in r65760 and r65762.

    @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
    stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants