Fix running qute:log and qute:plainlog
This failed because dict.get('level') returned None with no level parameter, and the subsequent [0] raised: Traceback (most recent call last): File ".../qutebrowser/utils/utils.py", line 624, in wrapper return func(*args, **kwargs) File ".../qutebrowser/browser/network/networkmanager.py", line 445, in createRequest op, req, outgoing_data) File ".../qutebrowser/browser/network/qutescheme.py", line 107, in createRequest data = handler(self._win_id, request) File ".../qutebrowser/browser/network/qutescheme.py", line 189, in qute_log level = urllib.parse.parse_qs(request.url().query()).get('level')[0] TypeError: 'NoneType' object is not subscriptable
This commit is contained in:
parent
bb31787931
commit
b704c911ae
@ -169,7 +169,10 @@ def qute_plainlog(_win_id, request):
|
||||
if log.ram_handler is None:
|
||||
text = "Log output was disabled."
|
||||
else:
|
||||
level = urllib.parse.parse_qs(request.url().query()).get('level')[0]
|
||||
try:
|
||||
level = urllib.parse.parse_qs(request.url().query())['level'][0]
|
||||
except KeyError:
|
||||
level = 'vdebug'
|
||||
text = log.ram_handler.dump_log(html=False, level=level)
|
||||
html = jinja.render('pre.html', title='log', content=text)
|
||||
return html.encode('UTF-8', errors='xmlcharrefreplace')
|
||||
@ -186,7 +189,10 @@ def qute_log(_win_id, request):
|
||||
if log.ram_handler is None:
|
||||
html_log = None
|
||||
else:
|
||||
level = urllib.parse.parse_qs(request.url().query()).get('level')[0]
|
||||
try:
|
||||
level = urllib.parse.parse_qs(request.url().query())['level'][0]
|
||||
except KeyError:
|
||||
level = 'vdebug'
|
||||
html_log = log.ram_handler.dump_log(html=True, level=level)
|
||||
|
||||
html = jinja.render('log.html', title='log', content=html_log)
|
||||
|
@ -418,3 +418,11 @@ Feature: Various utility commands.
|
||||
Scenario: Showing messages of an invalid level
|
||||
When I run :messages cataclysmic
|
||||
Then the error "Invalid log level cataclysmic!" should be shown
|
||||
|
||||
Scenario: Using qute:log directly
|
||||
When I open qute:log
|
||||
Then no crash should happen
|
||||
|
||||
Scenario: Using qute:plainlog directly
|
||||
When I open qute:plainlog
|
||||
Then no crash should happen
|
||||
|
Loading…
Reference in New Issue
Block a user