This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [py3k] tell() fails in some situation
Type: Stage:
Components: Library (Lib) Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, ocean-city, pitrou
Priority: normal Keywords: patch

Created on 2008-08-17 09:13 by ocean-city, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
fix_mbidecoder_decode.patch ocean-city, 2008-08-17 09:13 use s* instead of t#
Messages (7)
msg71262 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-08-17 09:13
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.
msg71266 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-17 11:30
Your patch looks right to me. It should also be backported to 2.6.
msg71267 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-08-17 11:44
Well, MultibyteCodec_Decode() also uses Py_buffer in py3k but not in
trunk. Is this also backported?
msg71271 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-17 12:25
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 :-)
msg71272 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-08-17 13:11
OK, done.
msg71276 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-17 14:20
Please state the revision numbers when closing an issue due to a commit;
this makes it easier to find the change later.
msg71277 - (view) Author: Hirokazu Yamamoto (ocean-city) * (Python committer) Date: 2008-08-17 15:04
Sorry, fixed in r65760 and r65762.
History
Date User Action Args
2022-04-11 14:56:37adminsetgithub: 47825
2008-08-17 15:04:43ocean-citysetmessages: + msg71277
2008-08-17 14:20:42georg.brandlsetnosy: + georg.brandl
messages: + msg71276
2008-08-17 13:11:32ocean-citysetstatus: open -> closed
resolution: fixed
messages: + msg71272
2008-08-17 12:25:27pitrousetmessages: + msg71271
2008-08-17 11:44:35ocean-citysetmessages: + msg71267
2008-08-17 11:30:52pitrousetnosy: + pitrou
messages: + msg71266
components: + Library (Lib)
2008-08-17 09:13:54ocean-citycreate