Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 15635:838551869790 legacy-trunk
Patch #102955, fixing one of the warnings in bug #121479:
Simplifies ord()'s logic at the cost of some code duplication, removing a
" `ord' might be used uninitialized in this function" warning
| author | Andrew M. Kuchling <amk@amk.ca> |
|---|---|
| date | Wed, 20 Dec 2000 14:36:56 +0000 |
| parents | 856b2bc216f9 |
| children | 7fb7c51a2e61 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Wed Dec 20 00:55:46 2000 +0000 +++ b/Python/bltinmodule.c Wed Dec 20 14:36:56 2000 +0000 @@ -1,4 +1,4 @@ - +fo /* Built-in functions */ #include "Python.h" @@ -1512,20 +1512,22 @@ if (PyString_Check(obj)) { size = PyString_GET_SIZE(obj); - if (size == 1) + if (size == 1) { ord = (long)((unsigned char)*PyString_AS_STRING(obj)); + return PyInt_FromLong(ord); + } } else if (PyUnicode_Check(obj)) { size = PyUnicode_GET_SIZE(obj); - if (size == 1) + if (size == 1) { ord = (long)*PyUnicode_AS_UNICODE(obj); + return PyInt_FromLong(ord); + } } else { PyErr_Format(PyExc_TypeError, "ord() expected string or Unicode character, " \ "%.200s found", obj->ob_type->tp_name); return NULL; } - if (size == 1) - return PyInt_FromLong(ord); PyErr_Format(PyExc_TypeError, "ord() expected a character, length-%d string found",
