Mercurial > cpython-lru_cache-weakref
comparison Python/modsupport.c @ 42013:cd125fe83051
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.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Sun, 10 Jun 2007 09:51:05 +0000 |
| parents | d6aa7edf217a |
| children | ba5d1a3977e9 |
comparison
equal
deleted
inserted
replaced
| 42012:59c6f4cbb326 | 42013:cd125fe83051 |
|---|---|
| 63 } | 63 } |
| 64 if ((m = PyImport_AddModule(name)) == NULL) | 64 if ((m = PyImport_AddModule(name)) == NULL) |
| 65 return NULL; | 65 return NULL; |
| 66 d = PyModule_GetDict(m); | 66 d = PyModule_GetDict(m); |
| 67 if (methods != NULL) { | 67 if (methods != NULL) { |
| 68 n = PyString_FromString(name); | 68 n = PyUnicode_FromString(name); |
| 69 if (n == NULL) | 69 if (n == NULL) |
| 70 return NULL; | 70 return NULL; |
| 71 for (ml = methods; ml->ml_name != NULL; ml++) { | 71 for (ml = methods; ml->ml_name != NULL; ml++) { |
| 72 if ((ml->ml_flags & METH_CLASS) || | 72 if ((ml->ml_flags & METH_CLASS) || |
| 73 (ml->ml_flags & METH_STATIC)) { | 73 (ml->ml_flags & METH_STATIC)) { |
| 687 } | 687 } |
| 688 | 688 |
| 689 int | 689 int |
| 690 PyModule_AddStringConstant(PyObject *m, const char *name, const char *value) | 690 PyModule_AddStringConstant(PyObject *m, const char *name, const char *value) |
| 691 { | 691 { |
| 692 return PyModule_AddObject(m, name, PyString_FromString(value)); | 692 return PyModule_AddObject(m, name, PyUnicode_FromString(value)); |
| 693 } | 693 } |
