@@ -453,8 +453,8 @@ PyImport_Cleanup(void)
453453 while (PyDict_Next (modules , & pos , & key , & value )) {
454454 if (value -> ob_refcnt != 1 )
455455 continue ;
456- if (PyString_Check (key ) && PyModule_Check (value )) {
457- name = PyString_AS_STRING (key );
456+ if (PyUnicode_Check (key ) && PyModule_Check (value )) {
457+ name = PyUnicode_AsString (key );
458458 if (strcmp (name , "__builtin__" ) == 0 )
459459 continue ;
460460 if (strcmp (name , "sys" ) == 0 )
@@ -472,8 +472,8 @@ PyImport_Cleanup(void)
472472 /* Next, delete all modules (still skipping __builtin__ and sys) */
473473 pos = 0 ;
474474 while (PyDict_Next (modules , & pos , & key , & value )) {
475- if (PyString_Check (key ) && PyModule_Check (value )) {
476- name = PyString_AS_STRING (key );
475+ if (PyUnicode_Check (key ) && PyModule_Check (value )) {
476+ name = PyUnicode_AsString (key );
477477 if (strcmp (name , "__builtin__" ) == 0 )
478478 continue ;
479479 if (strcmp (name , "sys" ) == 0 )
@@ -2008,30 +2008,21 @@ get_parent(PyObject *globals, char *buf, Py_ssize_t *p_buflen, int level)
20082008 * buf = '\0' ;
20092009 * p_buflen = 0 ;
20102010 modname = PyDict_GetItem (globals , namestr );
2011- if (modname == NULL || (! PyString_Check ( modname ) && ! PyUnicode_Check (modname ) ))
2011+ if (modname == NULL || ! PyUnicode_Check (modname ))
20122012 return Py_None ;
20132013
2014- if (PyUnicode_Check (modname )) {
2015- /* XXX need to support Unicode better */
2016- modname = _PyUnicode_AsDefaultEncodedString (modname , NULL );
2017- if (!modname ) {
2018- PyErr_Clear ();
2019- return NULL ;
2020- }
2021- }
2022-
20232014 modpath = PyDict_GetItem (globals , pathstr );
20242015 if (modpath != NULL ) {
2025- Py_ssize_t len = PyString_GET_SIZE (modname );
2016+ Py_ssize_t len = PyUnicode_GET_SIZE (modname );
20262017 if (len > MAXPATHLEN ) {
20272018 PyErr_SetString (PyExc_ValueError ,
20282019 "Module name too long" );
20292020 return NULL ;
20302021 }
2031- strcpy (buf , PyString_AS_STRING (modname ));
2022+ strcpy (buf , PyUnicode_AsString (modname ));
20322023 }
20332024 else {
2034- char * start = PyString_AS_STRING (modname );
2025+ char * start = PyUnicode_AsString (modname );
20352026 char * lastdot = strrchr (start , '.' );
20362027 size_t len ;
20372028 if (lastdot == NULL && level > 0 ) {
@@ -2174,19 +2165,9 @@ ensure_fromlist(PyObject *mod, PyObject *fromlist, char *buf, Py_ssize_t buflen,
21742165 }
21752166 return 0 ;
21762167 }
2177- if (PyString_Check (item )) {
2178- /* XXX there shouldn't be any str8 objects here */
2179- PyObject * uni = PyUnicode_DecodeASCII (PyString_AsString (item ),
2180- PyString_Size (item ),
2181- "strict" );
2182- Py_DECREF (item );
2183- if (!uni )
2184- return 0 ;
2185- item = uni ;
2186- }
21872168 if (!PyUnicode_Check (item )) {
21882169 PyErr_SetString (PyExc_TypeError ,
2189- "Item in ``from list'' not a unicode string" );
2170+ "Item in ``from list'' not a string" );
21902171 Py_DECREF (item );
21912172 return 0 ;
21922173 }
@@ -2444,7 +2425,7 @@ PyImport_ReloadModule(PyObject *m)
24442425 done using whatever import hooks are installed in the current
24452426 environment, e.g. by "rexec".
24462427 A dummy list ["__doc__"] is passed as the 4th argument so that
2447- e.g. PyImport_Import(PyString_FromString ("win32com.client.gencache"))
2428+ e.g. PyImport_Import(PyUnicode_FromString ("win32com.client.gencache"))
24482429 will return <module "gencache"> instead of <module "win32com">. */
24492430
24502431PyObject *
0 commit comments