changeset 553:9d2bd411f5c5

Do not rstrip() the remaining variable name when parsing out filters from variable names
author Franz Glasner <fzglas.hg@dom66.de>
date Sun, 02 Jan 2022 20:43:24 +0100
parents 39e5d07d8dbc
children 36d7aa000435
files configmix/_speedups.c configmix/config.py tests/test.py
diffstat 3 files changed, 8 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/configmix/_speedups.c	Sun Jan 02 20:40:09 2022 +0100
+++ b/configmix/_speedups.c	Sun Jan 02 20:43:24 2022 +0100
@@ -559,12 +559,6 @@
     if (name == NULL) {
         goto error;
     }
-    tmp = PyObject_CallMethod(name, "rstrip", NULL);
-    if (tmp == NULL) {
-        goto error;
-    }
-    Py_DECREF(name);
-    name = tmp;
 
     filters = PyUnicode_Substring(varname, sep+1, varname_len);
     if (filters == NULL) {
--- a/configmix/config.py	Sun Jan 02 20:40:09 2022 +0100
+++ b/configmix/config.py	Sun Jan 02 20:43:24 2022 +0100
@@ -411,10 +411,9 @@
     if sep:
         filters = filters.strip()
         if filters:
-            return (name.rstrip(),
-                    filters.split(_FILTER_SEPARATOR))
+            return (name, filters.split(_FILTER_SEPARATOR))
         else:
-            return (name.rstrip(), [])
+            return (name, [])
     else:
         return (name, [])
 
--- a/tests/test.py	Sun Jan 02 20:40:09 2022 +0100
+++ b/tests/test.py	Sun Jan 02 20:43:24 2022 +0100
@@ -1906,20 +1906,20 @@
     def test_split_filters_empty(self):
         self.assertEqual((u"", []), self.split_filters(u""))
 
-    def test_split_filters_varname_only(self):
-        self.assertEqual((u"varname ", []), self.split_filters(u"varname "))
+    def test_split_filters_varname_only_no_stripping(self):
+        self.assertEqual((u" varname ", []), self.split_filters(u" varname "))
 
-    def test_split_filters_single_stripping(self):
-        self.assertEqual((u" the-varname", []),
+    def test_split_filters_single_no_stripping(self):
+        self.assertEqual((u" the-varname ", []),
                          self.split_filters(u" the-varname |  "))
 
     def test_split_filters_one(self):
         self.assertEqual((u"the-varname", [u"None"]),
-                         self.split_filters(u"the-varname |None"))
+                         self.split_filters(u"the-varname|None"))
 
     def test_split_filters_many(self):
         self.assertEqual((u"the-varname", [u"Empty", u"None"]),
-                         self.split_filters(u"the-varname |Empty|None"))
+                         self.split_filters(u"the-varname|Empty|None"))
         
 
 class T09Parser(_TParserMixin, unittest.TestCase):