@@ -29,7 +29,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
2929 consts = ((PyCodeObject * )code )-> co_consts ;
3030 if (PyTuple_Size (consts ) >= 1 ) {
3131 doc = PyTuple_GetItem (consts , 0 );
32- if (!PyString_Check ( doc ) && ! PyUnicode_Check (doc ))
32+ if (!PyUnicode_Check (doc ))
3333 doc = Py_None ;
3434 }
3535 else
@@ -44,7 +44,7 @@ PyFunction_New(PyObject *code, PyObject *globals)
4444 Otherwise, use None.
4545 */
4646 if (!__name__ ) {
47- __name__ = PyString_InternFromString ("__name__" );
47+ __name__ = PyUnicode_InternFromString ("__name__" );
4848 if (!__name__ ) {
4949 Py_DECREF (op );
5050 return NULL ;
@@ -297,7 +297,7 @@ func_set_code(PyFunctionObject *op, PyObject *value)
297297 PyErr_Format (PyExc_ValueError ,
298298 "%s() requires a code object with %zd free vars,"
299299 " not %zd" ,
300- PyString_AsString (op -> func_name ),
300+ PyUnicode_AsString (op -> func_name ),
301301 nclosure , nfree );
302302 return -1 ;
303303 }
@@ -322,7 +322,7 @@ func_set_name(PyFunctionObject *op, PyObject *value)
322322
323323 /* Not legal to del f.func_name or to set it to anything
324324 * other than a string object. */
325- if (value == NULL || (! PyString_Check ( value ) && ! PyUnicode_Check (value ) )) {
325+ if (value == NULL || ! PyUnicode_Check (value )) {
326326 PyErr_SetString (PyExc_TypeError ,
327327 "__name__ must be set to a string object" );
328328 return -1 ;
@@ -482,12 +482,7 @@ func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
482482 & PyDict_Type , & globals ,
483483 & name , & defaults , & closure ))
484484 return NULL ;
485- if (PyUnicode_Check (name )) {
486- name = _PyUnicode_AsDefaultEncodedString (name , NULL );
487- if (name == NULL )
488- return NULL ;
489- }
490- if (name != Py_None && !PyString_Check (name )) {
485+ if (name != Py_None && !PyUnicode_Check (name )) {
491486 PyErr_SetString (PyExc_TypeError ,
492487 "arg 3 (name) must be None or string" );
493488 return NULL ;
@@ -573,9 +568,8 @@ func_dealloc(PyFunctionObject *op)
573568static PyObject *
574569func_repr (PyFunctionObject * op )
575570{
576- return PyUnicode_FromFormat ("<function %s at %p>" ,
577- PyString_AsString (op -> func_name ),
578- op );
571+ return PyUnicode_FromFormat ("<function %U at %p>" ,
572+ op -> func_name , op );
579573}
580574
581575static int
0 commit comments