[pypy-svn] r65569 - in pypy/branch/pyjitpl5-experiments/pypy/config: . test

arigo at codespeak.net arigo at codespeak.net
Thu Jun 4 08:51:31 CEST 2009


Author: arigo
Date: Thu Jun  4 08:51:29 2009
New Revision: 65569

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/config/config.py
   pypy/branch/pyjitpl5-experiments/pypy/config/test/test_config.py
Log:
Fix a bug in option parsing.  Shown by "translate.py --gc=boehm --jit"
which would actually select the hybrid gc.


Modified: pypy/branch/pyjitpl5-experiments/pypy/config/config.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/config/config.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/config/config.py	Thu Jun  4 08:51:29 2009
@@ -98,9 +98,9 @@
             raise AttributeError('unknown option %s' % (name,))
         child = getattr(self._cfgimpl_descr, name)
         oldowner = self._cfgimpl_value_owners[child._name]
-        oldvalue = getattr(self, name)
-        if oldvalue != value and oldowner not in ("default", "suggested"):
-            if who in ("default", "suggested"):
+        if oldowner not in ("default", "suggested"):
+            oldvalue = getattr(self, name)
+            if oldvalue == value or who in ("default", "suggested"):
                 return
             raise ConflictConfigError('cannot override value to %s for '
                                       'option %s' % (value, name))

Modified: pypy/branch/pyjitpl5-experiments/pypy/config/test/test_config.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/config/test/test_config.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/config/test/test_config.py	Thu Jun  4 08:51:29 2009
@@ -580,3 +580,19 @@
     assert c.booloption2 is False
     c.booloption2 = False
     assert c.booloption2 is False
+
+def test_suggested_owner_does_not_override():
+    descr = OptionDescription("test", '', [
+        BoolOption("toplevel", "", default=False),
+        BoolOption("opt", "", default=False,
+                   suggests=[("toplevel", False)]),
+        BoolOption("opt2", "", default=False,
+                   suggests=[("toplevel", True)]),
+    ])
+    c = Config(descr)
+    c.toplevel = False
+    c.opt = True      # bug: sets owner of toplevel back to 'suggested'
+    c.opt2 = True     # and this overrides toplevel because it's only suggested
+    assert c.toplevel == False
+    assert c.opt == True
+    assert c.opt2 == True



More information about the Pypy-commit mailing list