summaryrefslogtreecommitdiffstats
path: root/Objects/moduleobject.c
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2008-06-09 04:58:54 (GMT)
commitdd96db63f689e2f0d8ae5a1436b3b3395eec7de5 (patch)
treeb2299acac9ce44fc488fc7b2ae2a44548cd5fbb8 /Objects/moduleobject.c
parente98839a1f48b2915f1cc747884e64f4d6e4c8e7a (diff)
downloadcpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.zip
cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.gz
cpython-dd96db63f689e2f0d8ae5a1436b3b3395eec7de5.tar.bz2
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.
Diffstat (limited to 'Objects/moduleobject.c')
-rw-r--r--Objects/moduleobject.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index fa3daa9..d1aa771 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -22,7 +22,7 @@ PyModule_New(const char *name)
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 @@ PyModule_GetName(PyObject *m)
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 @@ PyModule_GetFilename(PyObject *m)
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 @@ _PyModule_Clear(PyObject *m)
/* 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 @@ _PyModule_Clear(PyObject *m)
/* 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 @@ module_repr(PyModuleObject *m)
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