mirror of
https://github.com/python/cpython.git
synced 2025-07-19 09:15:34 +00:00
Given that ord() of a bytes object of length 1 is defined, it should
never return a negative number.
This commit is contained in:
parent
2b08b38dea
commit
f9e91c9c58
3 changed files with 15 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue