File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1-
1+ fo
22/* Built-in functions */
33
44#include "Python.h"
@@ -1512,20 +1512,22 @@ builtin_ord(PyObject *self, PyObject *args)
15121512
15131513 if (PyString_Check (obj )) {
15141514 size = PyString_GET_SIZE (obj );
1515- if (size == 1 )
1515+ if (size == 1 ) {
15161516 ord = (long )((unsigned char )* PyString_AS_STRING (obj ));
1517+ return PyInt_FromLong (ord );
1518+ }
15171519 } else if (PyUnicode_Check (obj )) {
15181520 size = PyUnicode_GET_SIZE (obj );
1519- if (size == 1 )
1521+ if (size == 1 ) {
15201522 ord = (long )* PyUnicode_AS_UNICODE (obj );
1523+ return PyInt_FromLong (ord );
1524+ }
15211525 } else {
15221526 PyErr_Format (PyExc_TypeError ,
15231527 "ord() expected string or Unicode character, " \
15241528 "%.200s found" , obj -> ob_type -> tp_name );
15251529 return NULL ;
15261530 }
1527- if (size == 1 )
1528- return PyInt_FromLong (ord );
15291531
15301532 PyErr_Format (PyExc_TypeError ,
15311533 "ord() expected a character, length-%d string found" ,
You can’t perform that action at this time.
0 commit comments