# HG changeset patch # User Franz Glasner # Date 1646411727 -3600 # Node ID 4499e9b4855d97a2c1395178d55035f5afb2f875 # Parent 301cf2337fdefe30890de568c048cf9e375da8f7 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. diff -r 301cf2337fde -r 4499e9b4855d CHANGES.txt --- a/CHANGES.txt Sun Jan 23 17:34:11 2022 +0100 +++ b/CHANGES.txt Fri Mar 04 17:35:27 2022 +0100 @@ -12,6 +12,16 @@ Pre-1.0 Series -------------- +none (n/a) +~~~~~~~~~~ + +- **[bugfix]** + 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. + + 0.20.4 (2022-01-17) ~~~~~~~~~~~~~~~~~~~ diff -r 301cf2337fde -r 4499e9b4855d configmix/_speedups.c --- 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; } diff -r 301cf2337fde -r 4499e9b4855d configmix/config.py --- a/configmix/config.py Sun Jan 23 17:34:11 2022 +0100 +++ b/configmix/config.py Fri Mar 04 17:35:27 2022 +0100 @@ -29,7 +29,7 @@ from .variables import lookup_varns, lookup_filter from .compat import u, uchr, n, str_and_u, PY2 -from .constants import REF_NAMESPACE, NONE_FILTER, EMPTY_FILTER +from .constants import REF_NAMESPACE, NONE_FILTER, EMPTY_FILTER, DEL_VALUE try: from ._speedups import (fast_unquote, fast_quote, fast_pathstr2path, _fast_split_ns, _fast_split_filters, @@ -931,6 +931,8 @@ len_s = len(s) if len_s < 4: return s + if s == DEL_VALUE: + return s start = s.find(_STARTTOK, 0) if start < 0: return s diff -r 301cf2337fde -r 4499e9b4855d configmix/constants.py --- a/configmix/constants.py Sun Jan 23 17:34:11 2022 +0100 +++ b/configmix/constants.py Fri Mar 04 17:35:27 2022 +0100 @@ -27,7 +27,10 @@ DEL_VALUE = _u("{{::DEL::}}") """Value for configuration items to signal that the corresponding -key-value is to be deleted when configurations are merged +key-value is to be deleted when configurations are merged. + +Despite having "interpolation" syntax this value will **never** be +substituted. """