Given that ord() of a bytes object of length 1 is defined, it should

never return a negative number.
This commit is contained in:
Guido van Rossum 2007-05-08 21:05:48 +00:00
parent 2b08b38dea
commit f9e91c9c58
3 changed files with 15 additions and 1 deletions

View file

@ -1482,7 +1482,7 @@ builtin_ord(PyObject *self, PyObject* obj)
/* XXX Hopefully this is temporary */
size = PyBytes_GET_SIZE(obj);
if (size == 1) {
ord = (long)*PyBytes_AS_STRING(obj);
ord = (long)((unsigned char)*PyBytes_AS_STRING(obj));
return PyInt_FromLong(ord);
}
}