[asterisk-bugs] [JIRA] (ASTERISK-27894) [patch] testsuite: Avoid KeyError when astdatadir not set in asterisk.conf.
Alexander Traud (JIRA)
noreply at issues.asterisk.org
Fri Jun 8 01:22:54 CDT 2018
[ https://issues.asterisk.org/jira/browse/ASTERISK-27894?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alexander Traud closed ASTERISK-27894.
--------------------------------------
Resolution: Fixed
> [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: 13.21.0, 15.4.0
> Environment: configs/basic-pbx
> Reporter: Alexander Traud
> Assignee: Alexander Traud
> Severity: Minor
> Labels: patch
> Attachments: astdatadir.patch
>
>
> 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