[asterisk-bugs] [JIRA] (ASTERISK-27894) [patch] testsuite: Avoid KeyError when astdatadir not set in asterisk.conf.
Asterisk Team (JIRA)
noreply at issues.asterisk.org
Tue Jun 5 03:34:54 CDT 2018
[ https://issues.asterisk.org/jira/browse/ASTERISK-27894?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=243670#comment-243670 ]
Asterisk Team commented on ASTERISK-27894:
------------------------------------------
Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.
A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.
Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].
> [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
>
> 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