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

Joshua Colp (JIRA) noreply at issues.asterisk.org
Tue Jun 5 04:40:55 CDT 2018


     [ https://issues.asterisk.org/jira/browse/ASTERISK-27894?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Joshua Colp updated ASTERISK-27894:
-----------------------------------

    Status: Open  (was: Triage)

> [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
>            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