summaryrefslogtreecommitdiffstats
path: root/Objects/abstract.c
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 /Objects/abstract.c
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 'Objects/abstract.c')
-rw-r--r--Objects/abstract.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 84b3384..6e63852 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -207,7 +207,7 @@ PyObject_DelItemString(PyObject *o, char *key)
null_error();
return -1;
}
- okey = PyString_FromString(key);
+ okey = PyUnicode_FromString(key);
if (okey == NULL)
return -1;
ret = PyObject_DelItem(o, okey);
@@ -1598,7 +1598,7 @@ PyMapping_GetItemString(PyObject *o, char *key)
if (key == NULL)
return null_error();
- okey = PyString_FromString(key);
+ okey = PyUnicode_FromString(key);
if (okey == NULL)
return NULL;
r = PyObject_GetItem(o, okey);
@@ -1617,7 +1617,7 @@ PyMapping_SetItemString(PyObject *o, char *key, PyObject *value)
return -1;
}
- okey = PyString_FromString(key);
+ okey = PyUnicode_FromString(key);
if (okey == NULL)
return -1;
r = PyObject_SetItem(o, okey, value);
@@ -1989,11 +1989,13 @@ abstract_get_bases(PyObject *cls)
PyObject *bases;
if (__bases__ == NULL) {
- __bases__ = PyString_FromString("__bases__");
+ __bases__ = PyUnicode_FromString("__bases__");
if (__bases__ == NULL)
return NULL;
}
+ Py_ALLOW_RECURSION
bases = PyObject_GetAttr(cls, __bases__);
+ Py_END_ALLOW_RECURSION
if (bases == NULL) {
if (PyErr_ExceptionMatches(PyExc_AttributeError))
PyErr_Clear();
@@ -2067,7 +2069,7 @@ recursive_isinstance(PyObject *inst, PyObject *cls, int recursion_depth)
int retval = 0;
if (__class__ == NULL) {
- __class__ = PyString_FromString("__class__");
+ __class__ = PyUnicode_FromString("__class__");
if (__class__ == NULL)
return -1;
}