[asterisk-bugs] [JIRA] (ASTERISK-27894) [patch] testsuite: Avoid KeyError when astdatadir not set in asterisk.conf.

Alexander Traud (JIRA) noreply at issues.asterisk.org
Tue Jun 5 03:34:54 CDT 2018


Alexander Traud created ASTERISK-27894:
------------------------------------------

             Summary: [patch] testsuite: Avoid KeyError when astdatadir not set in asterisk.conf.
                 Key: ASTERISK-27894
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27894
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: Tests/testsuite
    Affects Versions: 15.4.0, 13.21.0
         Environment: configs/basic-pbx
            Reporter: Alexander Traud


Currently, the Asterisk Test Suite requires the parameter {{astdatadir}} to be set in the configuration file {{asterisk.conf}}. Consequently, with {{sudo make basic-pbx}} for example, {{./runtests.py -l}} gives:{code}  File "./runtests.py", line 68, in <module>
    astdatadir = ast_config.directories["astdatadir"] or '/var/lib/asterisk'
KeyError: 'astdatadir'{code}This is because a misunderstanding of the Python code:

The standard Python class [dict|http://docs.python.org/2.7/library/stdtypes.html#typesmapping] raises an exception—here {{KeyError}}—when the key—here {{astdatadir}}—is not present in the directory at all. Consequently, the part after 'or' is not even evaluated. The solution is to go for {{dict.get}} which goes for a default value on a KeyError.

This issue was reported by [Jaco Kroon|http://infobot.rikers.org/%23asterisk-dev/20160427.html.gz] and [Colin Sung|https://github.com/asterisk/testsuite/pull/1/commits/06f196ad9c2b827810bf7cbba41a85cacee8a993]. The attached patch changes from {{dict\[key\]}} to {{dict.get(key, default)}} and originates from Colin Sung, actually.



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list