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

Hirokazu Yamamoto ocean-city at m2.ccsnet.ne.jp
Sat Feb 28 15:06:38 CET 2009


> It certainly seems like mmap should be playing in an all-bytes world
> (where only already encoded strings are allowed).

Agreed.

> On the specific
> question of whether it would be better for read_byte()/write_byte to use
> 1-length bytes objects or integers, I have no strong opinion (the former
> is closer to the 2.x class API, the later more consistent with the
> operation of the 3.x bytes class).

Personally, I was surprised when I saw b"0123"[1] != b"1". But I don't
have strong opinion neither.

> However, as Martin says, it wouldn't be reasonable to backport the fixes
> in this to 3.0 - the associated API changes would almost certainly break
> otherwise working code.

Agreed.

I greped py3k source tree with "c", I found another Py_BuildValue("c" in 
curse module. But this function returns unicode in else clause, so 
probably this is correct usage.

Modules\mmapmodule.c(207): 		return Py_BuildValue("c", value);
Modules\_cursesmodule.c(893):     return Py_BuildValue("c", rtn);
Modules\_dbmmodule.c(380): 	else if ( strcmp(flags, "c") == 0 )
Modules\_ctypes\cfield.c(112): 			if (idict->getfunc == 
getentry("c")->getfunc) {
Modules\_ctypes\stgdict.c(459): 				if (dict->getfunc != 
getentry("c")->getfunc
Modules\_ctypes\_ctypes.c(1372): 	if (itemdict->getfunc == 
getentry("c")->getfunc) {
Modules\_ctypes\_ctypes.c(1536): 		if (dict && (dict->setfunc == 
getentry("c")->setfunc)) {
Modules\_ctypes\_ctypes.c(1545): 		if (dict && (dict->setfunc == 
getentry("c")->setfunc)) {
Modules\_ctypes\_ctypes.c(4197): 		if (itemdict->getfunc == 
getentry("c")->getfunc) {
Modules\_ctypes\_ctypes.c(4890): 		if (itemdict->getfunc == 
getentry("c")->getfunc) {
PC\os2emx\getpathp.c(128): 		strcat(filename, Py_OptimizeFlag ? "o" : "c");
Python\import.c(1756): 	strcpy(buf+i, Py_OptimizeFlag ? "o" : "c");




More information about the Python-Dev mailing list