@@ -1354,8 +1354,8 @@ z_set(void *ptr, PyObject *value, Py_ssize_t size)
13541354 Py_INCREF (value );
13551355 return value ;
13561356 }
1357- if (PyString_Check (value )) {
1358- * (char * * )ptr = PyString_AS_STRING (value );
1357+ if (PyBytes_Check (value )) {
1358+ * (char * * )ptr = PyBytes_AsString (value );
13591359 Py_INCREF (value );
13601360 return value ;
13611361 } else if (PyUnicode_Check (value )) {
@@ -1410,20 +1410,21 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
14101410 Py_INCREF (value );
14111411 return value ;
14121412 }
1413- if (PyString_Check (value )) {
1414- value = PyUnicode_FromEncodedObject (value ,
1415- conversion_mode_encoding ,
1416- conversion_mode_errors );
1417- if (!value )
1418- return NULL ;
1419- } else if (PyInt_Check (value ) || PyLong_Check (value )) {
1413+ if (PyInt_Check (value ) || PyLong_Check (value )) {
14201414#if SIZEOF_VOID_P == SIZEOF_LONG_LONG
14211415 * (wchar_t * * )ptr = (wchar_t * )PyInt_AsUnsignedLongLongMask (value );
14221416#else
14231417 * (wchar_t * * )ptr = (wchar_t * )PyInt_AsUnsignedLongMask (value );
14241418#endif
14251419 Py_INCREF (Py_None );
14261420 return Py_None ;
1421+ }
1422+ if (PyBytes_Check (value )) {
1423+ value = PyUnicode_FromEncodedObject (value ,
1424+ conversion_mode_encoding ,
1425+ conversion_mode_errors );
1426+ if (!value )
1427+ return NULL ;
14271428 } else if (!PyUnicode_Check (value )) {
14281429 PyErr_Format (PyExc_TypeError ,
14291430 "unicode string or integer address expected instead of %s instance" ,
0 commit comments