diff options
author | Andrew M. Kuchling <amk@amk.ca> | 2000-12-20 14:36:56 (GMT) |
---|---|---|
committer | Andrew M. Kuchling <amk@amk.ca> | 2000-12-20 14:36:56 (GMT) |
commit | 34c20cf705045ab6e496c1271fb522cfabd409e5 (patch) | |
tree | 33030359b2fca0bf809e437d9ab625dcff5ac015 /Python/bltinmodule.c | |
parent | c867f74a102a8df376ff55ca4dd9dc9055d16141 (diff) | |
download | cpython-34c20cf705045ab6e496c1271fb522cfabd409e5.zip cpython-34c20cf705045ab6e496c1271fb522cfabd409e5.tar.gz cpython-34c20cf705045ab6e496c1271fb522cfabd409e5.tar.bz2 |
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
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index fa560f7..af4ae20 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1,4 +1,4 @@ - +fo /* Built-in functions */ #include "Python.h" @@ -1512,20 +1512,22 @@ builtin_ord(PyObject *self, PyObject *args) 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", |