[issue7649] "u'%c' % char" broken for chars in range '\x80'-'\xFF'

Eric Smith report at bugs.python.org
Wed Feb 24 19:03:07 CET 2010


Eric Smith <eric at trueblade.com> added the comment:

I'm working on a similar issue for int.__format__('c'). What's not clear to me is why this doesn't work the same as chr(i).  That is, shouldn't chr(i) == ('%c' % i) hold for i in range(256)? And if that's so, why not just copy chr's implementation:
	if (x < 0 || x >= 256) {
		PyErr_SetString(PyExc_ValueError,
				"chr() arg not in range(256)");
		return NULL;
	}
	s[0] = (char)x;
	return PyString_FromStringAndSize(s, 1);

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7649>
_______________________________________


More information about the Python-bugs-list mailing list