@@ -592,24 +592,22 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
592592 return 0 ;
593593}
594594
595- static int obj2ast_stringlike (PyObject * obj , PyObject * * out , PyArena * arena ,
596- const char * name )
595+ static int obj2ast_identifier (PyObject * obj , PyObject * * out , PyArena * arena )
597596{
598- if (!PyUnicode_CheckExact (name ) ) {
599- PyErr_Format (PyExc_TypeError , "AST %s must be of type str" , name );
597+ if (!PyUnicode_CheckExact (obj ) && obj != Py_None ) {
598+ PyErr_SetString (PyExc_TypeError , "AST identifier must be of type str" );
600599 return 1 ;
601600 }
602601 return obj2ast_object (obj , out , arena );
603602}
604603
605- static int obj2ast_identifier (PyObject * obj , PyObject * * out , PyArena * arena )
606- {
607- return obj2ast_stringlike (obj , out , arena , "identifier" );
608- }
609-
610604static int obj2ast_string (PyObject * obj , PyObject * * out , PyArena * arena )
611605{
612- return obj2ast_stringlike (obj , out , arena , "string" );
606+ if (!PyUnicode_CheckExact (obj )) {
607+ PyErr_SetString (PyExc_TypeError , "AST string must be of type str" );
608+ return 1 ;
609+ }
610+ return obj2ast_object (obj , out , arena );
613611}
614612
615613static int obj2ast_int (PyObject * obj , int * out , PyArena * arena )
0 commit comments