[Python-Dev] What type of object mmap.read_byte should return on py3k? (original) (raw)

Hirokazu Yamamoto ocean-city at m2.ccsnet.ne.jp
Sat Feb 28 12:19:00 CET 2009


Hello. I noticed mmap.read_byte returns 1-length unicode on py3k. I felt this was strange, so I created issue on bug tracker (http://bugs.python.org/issue5391) and Martin proposed this is suitable for discussion on python-dev. I'll quote messages on bug tracker here.

I wrote:

On Python3000, mmap.readbyte returns str not bytes, and mmap.writebyte accepts str. Is this intended behavior?

import mmap m = mmap.mmap(-1, 10) type(m.readbyte()) <class 'str'> m.writebyte("a") m.writebyte(b"a") Maybe another possibility. readbyte() returns int which represents byte, writebyte accepts int which represents byte. (Like b"abc"[0] returns int not 1-length bytes)

Martin wrote:

Indeed, I think it should use the "b" code, instead of the "c" code. Please discuss this on python-dev, though.

It might not be ok to backport this to 3.0, since it may break existing code.

Furthermore, all other uses of the "c" code might need to be reconsidered.



More information about the Python-Dev mailing list