@@ -22,7 +22,7 @@ struct arrayobject; /* Forward */
2222 * functions aren't visible yet.
2323 */
2424struct arraydescr {
25- Py_UNICODE typecode ;
25+ char typecode ;
2626 int itemsize ;
2727 PyObject * (* getitem )(struct arrayobject * , Py_ssize_t );
2828 int (* setitem )(struct arrayobject * , Py_ssize_t , PyObject * );
@@ -1510,7 +1510,7 @@ array_fromunicode(arrayobject *self, PyObject *args)
15101510{
15111511 Py_UNICODE * ustr ;
15121512 Py_ssize_t n ;
1513- Py_UNICODE typecode ;
1513+ char typecode ;
15141514
15151515 if (!PyArg_ParseTuple (args , "u#:fromunicode" , & ustr , & n ))
15161516 return NULL ;
@@ -1545,7 +1545,7 @@ append Unicode data to an array of some other type.");
15451545static PyObject *
15461546array_tounicode (arrayobject * self , PyObject * unused )
15471547{
1548- Py_UNICODE typecode ;
1548+ char typecode ;
15491549 typecode = self -> ob_descr -> typecode ;
15501550 if ((typecode != 'u' )) {
15511551 PyErr_SetString (PyExc_ValueError ,
@@ -1642,7 +1642,7 @@ static const struct mformatdescr {
16421642 * be found.
16431643 */
16441644static enum machine_format_code
1645- typecode_to_mformat_code (int typecode )
1645+ typecode_to_mformat_code (char typecode )
16461646{
16471647#ifdef WORDS_BIGENDIAN
16481648 const int is_big_endian = 1 ;
@@ -1721,7 +1721,7 @@ typecode_to_mformat_code(int typecode)
17211721 intsize = sizeof (PY_LONG_LONG );
17221722 is_signed = 0 ;
17231723 break ;
1724- #endif
1724+ #endif
17251725 default :
17261726 return UNKNOWN_FORMAT ;
17271727 }
@@ -1752,7 +1752,7 @@ static PyObject *array_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
17521752 * NULL is returned to indicate a failure.
17531753 */
17541754static PyObject *
1755- make_array (PyTypeObject * arraytype , Py_UNICODE typecode , PyObject * items )
1755+ make_array (PyTypeObject * arraytype , char typecode , PyObject * items )
17561756{
17571757 PyObject * new_args ;
17581758 PyObject * array_obj ;
@@ -1761,7 +1761,7 @@ make_array(PyTypeObject *arraytype, Py_UNICODE typecode, PyObject *items)
17611761 assert (arraytype != NULL );
17621762 assert (items != NULL );
17631763
1764- typecode_obj = PyUnicode_FromUnicode ( & typecode , 1 );
1764+ typecode_obj = PyUnicode_FromOrdinal ( typecode );
17651765 if (typecode_obj == NULL )
17661766 return NULL ;
17671767
@@ -1791,17 +1791,14 @@ array_reconstructor(PyObject *self, PyObject *args)
17911791 PyObject * items ;
17921792 PyObject * converted_items ;
17931793 PyObject * result ;
1794- int typecode_int ;
1795- Py_UNICODE typecode ;
1794+ int typecode ;
17961795 enum machine_format_code mformat_code ;
17971796 struct arraydescr * descr ;
17981797
17991798 if (!PyArg_ParseTuple (args , "OCiO:array._array_reconstructor" ,
1800- & arraytype , & typecode_int , & mformat_code , & items ))
1799+ & arraytype , & typecode , & mformat_code , & items ))
18011800 return NULL ;
18021801
1803- typecode = (Py_UNICODE )typecode_int ;
1804-
18051802 if (!PyType_Check (arraytype )) {
18061803 PyErr_Format (PyExc_TypeError ,
18071804 "first argument must a type object, not %.200s" ,
@@ -1815,7 +1812,7 @@ array_reconstructor(PyObject *self, PyObject *args)
18151812 return NULL ;
18161813 }
18171814 for (descr = descriptors ; descr -> typecode != '\0' ; descr ++ ) {
1818- if (descr -> typecode == typecode )
1815+ if (( int ) descr -> typecode == typecode )
18191816 break ;
18201817 }
18211818 if (descr -> typecode == '\0' ) {
@@ -1837,9 +1834,9 @@ array_reconstructor(PyObject *self, PyObject *args)
18371834 }
18381835
18391836 /* Fast path: No decoding has to be done. */
1840- if (mformat_code == typecode_to_mformat_code (typecode ) ||
1837+ if (mformat_code == typecode_to_mformat_code (( char ) typecode ) ||
18411838 mformat_code == UNKNOWN_FORMAT ) {
1842- return make_array (arraytype , typecode , items );
1839+ return make_array (arraytype , ( char ) typecode , items );
18431840 }
18441841
18451842 /* Slow path: Decode the byte string according to the given machine
@@ -1985,7 +1982,7 @@ array_reconstructor(PyObject *self, PyObject *args)
19851982 return NULL ;
19861983 }
19871984
1988- result = make_array (arraytype , typecode , converted_items );
1985+ result = make_array (arraytype , ( char ) typecode , converted_items );
19891986 Py_DECREF (converted_items );
19901987 return result ;
19911988}
@@ -2074,8 +2071,8 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
20742071static PyObject *
20752072array_get_typecode (arrayobject * a , void * closure )
20762073{
2077- Py_UNICODE tc = a -> ob_descr -> typecode ;
2078- return PyUnicode_FromUnicode ( & tc , 1 );
2074+ char typecode = a -> ob_descr -> typecode ;
2075+ return PyUnicode_FromOrdinal ( typecode );
20792076}
20802077
20812078static PyObject *
@@ -2147,7 +2144,7 @@ static PyMethodDef array_methods[] = {
21472144static PyObject *
21482145array_repr (arrayobject * a )
21492146{
2150- Py_UNICODE typecode ;
2147+ char typecode ;
21512148 PyObject * s , * v = NULL ;
21522149 Py_ssize_t len ;
21532150
0 commit comments