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/dictobject.c b/Objects/dictobject.c
index b45a664..639c3c5 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1040,7 +1040,7 @@
static PyObject *missing_str = NULL;
if (missing_str == NULL)
missing_str =
- PyString_InternFromString("__missing__");
+ PyUnicode_InternFromString("__missing__");
missing = _PyType_Lookup(mp->ob_type, missing_str);
if (missing != NULL)
return PyObject_CallFunctionObjArgs(missing,
@@ -2073,7 +2073,7 @@
PyDict_GetItemString(PyObject *v, const char *key)
{
PyObject *kv, *rv;
- kv = PyString_FromString(key);
+ kv = PyUnicode_FromString(key);
if (kv == NULL)
return NULL;
rv = PyDict_GetItem(v, kv);
@@ -2086,10 +2086,10 @@
{
PyObject *kv;
int err;
- kv = PyString_FromString(key);
+ kv = PyUnicode_FromString(key);
if (kv == NULL)
return -1;
- PyString_InternInPlace(&kv); /* XXX Should we really? */
+ PyUnicode_InternInPlace(&kv); /* XXX Should we really? */
err = PyDict_SetItem(v, kv, item);
Py_DECREF(kv);
return err;
@@ -2100,7 +2100,7 @@
{
PyObject *kv;
int err;
- kv = PyString_FromString(key);
+ kv = PyUnicode_FromString(key);
if (kv == NULL)
return -1;
err = PyDict_DelItem(v, kv);