Mercurial > cpython-lru_cache-weakref
diff Objects/moduleobject.c @ 47527:52294af4b663 legacy-trunk
This reverts r63675 based on the discussion in this thread:
http://mail.python.org/pipermail/python-dev/2008-June/079988.html
Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names
in the spirit of 3.0 are available via a #define only. See the email thread.
| author | Gregory P. Smith <greg@mad-scientist.com> |
|---|---|
| date | Mon, 09 Jun 2008 04:58:54 +0000 |
| parents | 4fe192d48960 |
| children | e38335d4df91 20d09549b82c |
line wrap: on
line diff
--- a/Objects/moduleobject.c Mon Jun 09 01:28:30 2008 +0000 +++ b/Objects/moduleobject.c Mon Jun 09 04:58:54 2008 +0000 @@ -22,7 +22,7 @@ m = PyObject_GC_New(PyModuleObject, &PyModule_Type); if (m == NULL) return NULL; - nameobj = PyBytes_FromString(name); + nameobj = PyString_FromString(name); m->md_dict = PyDict_New(); if (m->md_dict == NULL || nameobj == NULL) goto fail; @@ -68,12 +68,12 @@ d = ((PyModuleObject *)m)->md_dict; if (d == NULL || (nameobj = PyDict_GetItemString(d, "__name__")) == NULL || - !PyBytes_Check(nameobj)) + !PyString_Check(nameobj)) { PyErr_SetString(PyExc_SystemError, "nameless module"); return NULL; } - return PyBytes_AsString(nameobj); + return PyString_AsString(nameobj); } char * @@ -88,12 +88,12 @@ d = ((PyModuleObject *)m)->md_dict; if (d == NULL || (fileobj = PyDict_GetItemString(d, "__file__")) == NULL || - !PyBytes_Check(fileobj)) + !PyString_Check(fileobj)) { PyErr_SetString(PyExc_SystemError, "module filename missing"); return NULL; } - return PyBytes_AsString(fileobj); + return PyString_AsString(fileobj); } void @@ -117,8 +117,8 @@ /* First, clear only names starting with a single underscore */ pos = 0; while (PyDict_Next(d, &pos, &key, &value)) { - if (value != Py_None && PyBytes_Check(key)) { - char *s = PyBytes_AsString(key); + if (value != Py_None && PyString_Check(key)) { + char *s = PyString_AsString(key); if (s[0] == '_' && s[1] != '_') { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[1] %s\n", s); @@ -130,8 +130,8 @@ /* Next, clear all names except for __builtins__ */ pos = 0; while (PyDict_Next(d, &pos, &key, &value)) { - if (value != Py_None && PyBytes_Check(key)) { - char *s = PyBytes_AsString(key); + if (value != Py_None && PyString_Check(key)) { + char *s = PyString_AsString(key); if (s[0] != '_' || strcmp(s, "__builtins__") != 0) { if (Py_VerboseFlag > 1) PySys_WriteStderr("# clear[2] %s\n", s); @@ -195,9 +195,9 @@ filename = PyModule_GetFilename((PyObject *)m); if (filename == NULL) { PyErr_Clear(); - return PyBytes_FromFormat("<module '%s' (built-in)>", name); + return PyString_FromFormat("<module '%s' (built-in)>", name); } - return PyBytes_FromFormat("<module '%s' from '%s'>", name, filename); + return PyString_FromFormat("<module '%s' from '%s'>", name, filename); } /* We only need a traverse function, no clear function: If the module
