summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-06-10 09:51:05 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-06-10 09:51:05 (GMT)
commit5b222135f8d2492713994f2cb003980e87ce6a72 (patch)
tree3ac3a6a1d7805360ed779e884ca6c4b3f000321f /Modules
parent38e43c25eede3fa77d90ac8183cc0335f4861f4a (diff)
downloadcpython-5b222135f8d2492713994f2cb003980e87ce6a72.zip
cpython-5b222135f8d2492713994f2cb003980e87ce6a72.tar.gz
cpython-5b222135f8d2492713994f2cb003980e87ce6a72.tar.bz2
Make identifiers str (not str8) objects throughout.
This affects the parser, various object implementations, and all places that put identifiers into C string literals. In testing, a number of crashes occurred as code would fail when the recursion limit was reached (such as the Unicode interning dictionary having key/value pairs where key is not value). To solve these, I added an overflowed flag, which allows for 50 more recursions after the limit was reached and the exception was raised, and a recursion_critical flag, which indicates that recursion absolutely must be allowed, i.e. that a certain call must not cause a stack overflow exception. There are still some places where both str and str8 are accepted as identifiers; these should eventually be removed.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_codecsmodule.c2
-rw-r--r--Modules/_hotshot.c2
-rw-r--r--Modules/cPickle.c12
-rw-r--r--Modules/gcmodule.c2
-rw-r--r--Modules/unicodedata.c2
5 files changed, 10 insertions, 10 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index cd766c3..de5270d 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -172,7 +172,7 @@ escape_encode(PyObject *self,
&PyString_Type, &str, &errors))
return NULL;
- size = PyUnicode_GET_SIZE(str);
+ size = PyString_GET_SIZE(str);
newsize = 4*size;
if (newsize > PY_SSIZE_T_MAX || newsize / 4 != size) {
PyErr_SetString(PyExc_OverflowError,
diff --git a/Modules/_hotshot.c b/Modules/_hotshot.c
index 21bd383..fc4a1de 100644
--- a/Modules/_hotshot.c
+++ b/Modules/_hotshot.c
@@ -810,7 +810,7 @@ get_fileno(ProfilerObject *self, PyCodeObject *fcode)
PyObject *name = PyDict_GetItem(dict, obj);
if (name == NULL) {
if (pack_define_func(self, fileno, fcode->co_firstlineno,
- PyString_AS_STRING(fcode->co_name)) < 0) {
+ PyUnicode_AsString(fcode->co_name)) < 0) {
Py_DECREF(obj);
return -1;
}
diff --git a/Modules/cPickle.c b/Modules/cPickle.c
index 68990c9..a4dff7b 100644
--- a/Modules/cPickle.c
+++ b/Modules/cPickle.c
@@ -1829,8 +1829,8 @@ save_global(Picklerobject *self, PyObject *args, PyObject *name)
(name_size = PyString_Size(global_name)) < 0)
goto finally;
- module_str = PyString_AS_STRING((PyStringObject *)module);
- name_str = PyString_AS_STRING((PyStringObject *)global_name);
+ module_str = PyUnicode_AsString(module);
+ name_str = PyUnicode_AsString(global_name);
/* XXX This can be doing a relative import. Clearly it shouldn't,
but I don't know how to stop it. :-( */
@@ -1842,7 +1842,7 @@ save_global(Picklerobject *self, PyObject *args, PyObject *name)
"OS", args, module);
goto finally;
}
- klass = PyObject_GetAttrString(mod, name_str);
+ klass = PyObject_GetAttr(mod, global_name);
if (klass == NULL) {
cPickle_ErrFormat(PicklingError,
"Can't pickle %s: attribute lookup %s.%s "
@@ -2223,7 +2223,7 @@ save(Picklerobject *self, PyObject *args, int pers_save)
res = save_string(self, args, 0);
goto finally;
}
- if ((type == &PyUnicode_Type) && (PyString_GET_SIZE(args) < 2)) {
+ if ((type == &PyUnicode_Type) && (PyUnicode_GET_SIZE(args) < 2)) {
res = save_unicode(self, args, 0);
goto finally;
}
@@ -3584,7 +3584,7 @@ load_global(Unpicklerobject *self)
Py_DECREF(module_name);
return bad_readline();
}
- if ((class_name = PyString_FromStringAndSize(s, len - 1))) {
+ if ((class_name = PyUnicode_FromStringAndSize(s, len - 1))) {
class = find_class(module_name, class_name,
self->find_class);
Py_DECREF(class_name);
@@ -5379,7 +5379,7 @@ init_stuff(PyObject *module_dict)
{
PyObject *copy_reg, *t, *r;
-#define INIT_STR(S) if (!( S ## _str=PyString_InternFromString(#S))) return -1;
+#define INIT_STR(S) if (!( S ## _str=PyUnicode_InternFromString(#S))) return -1;
if (PyType_Ready(&Unpicklertype) < 0)
return -1;
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c
index 2dd058e..adcdb5f 100644
--- a/Modules/gcmodule.c
+++ b/Modules/gcmodule.c
@@ -713,7 +713,7 @@ collect(int generation)
double t1 = 0.0;
if (delstr == NULL) {
- delstr = PyString_InternFromString("__del__");
+ delstr = PyUnicode_InternFromString("__del__");
if (delstr == NULL)
Py_FatalError("gc couldn't allocate \"__del__\"");
}
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index da8af34..f660046 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -515,7 +515,7 @@ nfd_nfkd(PyObject *self, PyObject *input, int k)
/* Hangul Decomposition adds three characters in
a single step, so we need atleast that much room. */
if (space < 3) {
- Py_ssize_t newsize = PyString_GET_SIZE(result) + 10;
+ Py_ssize_t newsize = PyUnicode_GET_SIZE(result) + 10;
space += 10;
if (PyUnicode_Resize(&result, newsize) == -1)
return NULL;