Fake attrs on _Namespace change breaks Neutron tests

Bug #1540959 reported by Davanum Srinivas (DIMS)
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
oslo.config
Fix Released
Undecided
Alexis Lee

Bug Description

Running Neutron with oslo.config from master breaks py27 test

2016-02-02 14:14:53.045 | neutron.tests.unit.db.test_migration.TestCli.test_downgrade_fails
2016-02-02 14:14:53.045 | -----------------------------------------------------------------
2016-02-02 14:14:53.045 |
2016-02-02 14:14:53.045 | Captured traceback:
2016-02-02 14:14:53.045 | ~~~~~~~~~~~~~~~~~~~
2016-02-02 14:14:53.045 | Traceback (most recent call last):
2016-02-02 14:14:53.045 | File "neutron/tests/unit/db/test_migration.py", line 336, in test_downgrade_fails
2016-02-02 14:14:53.045 | self.assert_command_fails(['prog', 'downgrade', '--sql', 'juno'])
2016-02-02 14:14:53.045 | File "neutron/tests/unit/db/test_migration.py", line 333, in assert_command_fails
2016-02-02 14:14:53.045 | self.assertRaises(SystemExit, cli.main)
2016-02-02 14:14:53.046 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/testcase.py", line 434, in assertRaises
2016-02-02 14:14:53.046 | self.assertThat(our_callable, matcher)
2016-02-02 14:14:53.046 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/testcase.py", line 445, in assertThat
2016-02-02 14:14:53.046 | mismatch_error = self._matchHelper(matchee, matcher, message, verbose)
2016-02-02 14:14:53.046 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/testcase.py", line 495, in _matchHelper
2016-02-02 14:14:53.046 | mismatch = matcher.match(matchee)
2016-02-02 14:14:53.046 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/matchers/_exception.py", line 108, in match
2016-02-02 14:14:53.046 | mismatch = self.exception_matcher.match(exc_info)
2016-02-02 14:14:53.046 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/matchers/_higherorder.py", line 62, in match
2016-02-02 14:14:53.046 | mismatch = matcher.match(matchee)
2016-02-02 14:14:53.046 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/testcase.py", line 426, in match
2016-02-02 14:14:53.047 | reraise(*matchee)
2016-02-02 14:14:53.047 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/matchers/_exception.py", line 101, in match
2016-02-02 14:14:53.047 | result = matchee()
2016-02-02 14:14:53.047 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/local/lib/python2.7/site-packages/testtools/testcase.py", line 982, in __call__
2016-02-02 14:14:53.047 | return self._callable_object(*self._args, **self._kwargs)
2016-02-02 14:14:53.047 | File "neutron/db/migration/cli.py", line 739, in main
2016-02-02 14:14:53.047 | CONF(project='neutron')
2016-02-02 14:14:53.047 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/src/oslo.config/oslo_config/cfg.py", line 2166, in __call__
2016-02-02 14:14:53.047 | else sys.argv[1:])
2016-02-02 14:14:53.047 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/src/oslo.config/oslo_config/cfg.py", line 2750, in _parse_cli_opts
2016-02-02 14:14:53.047 | return self._parse_config_files()
2016-02-02 14:14:53.048 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/src/oslo.config/oslo_config/cfg.py", line 2767, in _parse_config_files
2016-02-02 14:14:53.048 | self._oparser.parse_args(self._args, namespace)
2016-02-02 14:14:53.048 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/src/oslo.config/oslo_config/cfg.py", line 2016, in parse_args
2016-02-02 14:14:53.048 | return super(_CachedArgumentParser, self).parse_args(args, namespace)
2016-02-02 14:14:53.048 | File "/usr/lib/python2.7/argparse.py", line 1690, in parse_args
2016-02-02 14:14:53.048 | args, argv = self.parse_known_args(args, namespace)
2016-02-02 14:14:53.048 | File "/usr/lib/python2.7/argparse.py", line 1725, in parse_known_args
2016-02-02 14:14:53.048 | delattr(namespace, _UNRECOGNIZED_ARGS_ATTR)
2016-02-02 14:14:53.048 | File "/home/jenkins/workspace/gate-neutron-python27-constraints/.tox/py27-constraints/src/oslo.config/oslo_config/cfg.py", line 1787, in __delattr__
2016-02-02 14:14:53.048 | "'_Namespace' object has no attribute '%s'" % name)
2016-02-02 14:14:53.048 | AttributeError: '_Namespace' object has no attribute '_unrecognized_args'

Alexis Lee (alexisl)
Changed in oslo.config:
assignee: nobody → Alexis Lee (alexisl)
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to oslo.config (master)

Fix proposed to branch: master
Review: https://review.openstack.org/275307

Changed in oslo.config:
assignee: Alexis Lee (alexisl) → Davanum Srinivas (DIMS) (dims-v)
Changed in oslo.config:
assignee: Davanum Srinivas (DIMS) (dims-v) → Alexis Lee (alexisl)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to oslo.config (master)

Reviewed: https://review.openstack.org/275307
Committed: https://git.openstack.org/cgit/openstack/oslo.config/commit/?id=068784afab28631b2a8fcd5dbc55a777508f63b6
Submitter: Jenkins
Branch: master

commit 068784afab28631b2a8fcd5dbc55a777508f63b6
Author: Alexis Lee <email address hidden>
Date: Tue Feb 2 16:19:20 2016 +0000

    Fix unrecognized subparser args

    Someone thought a transient attr would be a clever way to smuggle data
    from a _SubParsersAction up to the main ArgumentsParser. Unfortunately
    they use a really weird way to set the attr:

        vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])

    This bypasses __setattr__ so when they try to delattr later,
    __delattr__ can't find it and bombs. Even though the delattr is
    protected by a hasattr, because hasattr uses getattr which checks the
    private object dict first before calling __getattr__.

    Handle this by falling back to super in __getattr__ and __delattr__.

    Change-Id: Id89a0c00fd32b6580d891ccf69d58fa17f11ec49
    Closes-Bug: #1540959

Changed in oslo.config:
status: In Progress → Fix Released
Revision history for this message
Davanum Srinivas (DIMS) (dims-v) wrote : Fix included in openstack/oslo.config 3.5.0

This issue was fixed in the openstack/oslo.config 3.5.0 release.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.