Mercurial > hgrepos > Python > libs > ConfigMix
diff configmix/_speedups.c @ 637:4499e9b4855d
The ``{{::DEL::}}`` is not subject to interpolation any more.
This fixes the handling of these deletion markers when merging
configurations: sometimes they were tried to be interpolated -- and
this failed.
| author | Franz Glasner <f.glasner@feldmann-mg.com> |
|---|---|
| date | Fri, 04 Mar 2022 17:35:27 +0100 |
| parents | 33264c660fca |
| children | 999cfca55d25 |
line wrap: on
line diff
--- a/configmix/_speedups.c Sun Jan 23 17:34:11 2022 +0100 +++ b/configmix/_speedups.c Fri Mar 04 17:35:27 2022 +0100 @@ -34,6 +34,7 @@ PyObject *STARTTOK; PyObject *ENDTOK; PyObject *REF_NAMESPACE; + PyObject *DEL_VALUE; }; @@ -713,6 +714,7 @@ PyObject *s; PyObject *cache; + int cmp; Py_ssize_t s_len; Py_ssize_t idx; Py_ssize_t i, j; @@ -751,6 +753,14 @@ return NULL; } + cmp = PyUnicode_Compare(s, sstate->DEL_VALUE); + if ((cmp < 0) && PyErr_Occurred()) { + return NULL; + } + if (cmp == 0) { + return Py_NewRef(s); + } + idx = PyUnicode_Find(s, sstate->STARTTOK, 0, s_len, 1); if (idx < 0) { PyErr_Clear(); @@ -957,6 +967,7 @@ PyObject *s; PyObject *cache = NULL; + int cmp; Py_ssize_t s_len; Py_ssize_t start, rest, end; PyObject *tmp; @@ -991,6 +1002,14 @@ return NULL; } + cmp = PyUnicode_Compare(s, sstate->DEL_VALUE); + if ((cmp < 0) && PyErr_Occurred()) { + return NULL; + } + if (cmp == 0) { + return Py_NewRef(s); + } + start = PyUnicode_Find(s, sstate->STARTTOK, 0, s_len, 1); if (start == -2) { return NULL; @@ -1653,6 +1672,12 @@ } PyUnicode_InternInPlace(&(sstate->REF_NAMESPACE)); + sstate->DEL_VALUE = PyUnicode_FromStringAndSize("{{::DEL::}}", 3); + if (sstate->DEL_VALUE == NULL) { + return -1; + } + PyUnicode_InternInPlace(&(sstate->DEL_VALUE)); + return 0; } @@ -1677,6 +1702,7 @@ Py_VISIT(sstate->STARTTOK); Py_VISIT(sstate->ENDTOK); Py_VISIT(sstate->REF_NAMESPACE); + Py_VISIT(sstate->DEL_VALUE); } return 0; } @@ -1702,6 +1728,7 @@ Py_CLEAR(sstate->STARTTOK); Py_CLEAR(sstate->ENDTOK); Py_CLEAR(sstate->REF_NAMESPACE); + Py_CLEAR(sstate->DEL_VALUE); } return 0; }
