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.
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 @@
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 @@
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 @@
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 @@
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 @@
int retval = 0;
if (__class__ == NULL) {
- __class__ = PyString_FromString("__class__");
+ __class__ = PyUnicode_FromString("__class__");
if (__class__ == NULL)
return -1;
}