Fix StopIteration handling in _init_late_modules.

This caused a PendingDeprecationWarning with Python 3.5:

Traceback (most recent call last):
  File "/home/florian/proj/qutebrowser/git/qutebrowser/utils/debug.py", line 237, in log_time
    yield
  File "/home/florian/proj/qutebrowser/git/qutebrowser/app.py", line 433, in _init_late_modules
    next(reader)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/florian/proj/qutebrowser/git/qutebrowser/app.py", line 433, in _init_late_modules
    next(reader)
  File "/usr/lib64/python3.5/contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
PendingDeprecationWarning: generator 'log_time' raised StopIteration
This commit is contained in:
Florian Bruhin 2015-09-30 07:32:36 +02:00
parent 07c02041fc
commit f972d043c5

View File

@ -428,15 +428,15 @@ def _init_modules(args, crash_handler):
def _init_late_modules(args): def _init_late_modules(args):
"""Initialize modules which can be inited after the window is shown.""" """Initialize modules which can be inited after the window is shown."""
try:
log.init.debug("Reading web history...") log.init.debug("Reading web history...")
reader = objreg.get('web-history').async_read() reader = objreg.get('web-history').async_read()
with debug.log_time(log.init, 'Reading history'): with debug.log_time(log.init, 'Reading history'):
while True: while True:
QApplication.processEvents() QApplication.processEvents()
try:
next(reader) next(reader)
except StopIteration: except StopIteration:
pass break
except (OSError, UnicodeDecodeError) as e: except (OSError, UnicodeDecodeError) as e:
error.handle_fatal_exc(e, args, "Error while initializing!", error.handle_fatal_exc(e, args, "Error while initializing!",
pre_text="Error while initializing") pre_text="Error while initializing")