From f972d043c5c04172c730c6177b831b415a676131 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 30 Sep 2015 07:32:36 +0200 Subject: [PATCH] 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 --- qutebrowser/app.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 64a116fc2..a94918eaf 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -428,19 +428,19 @@ def _init_modules(args, crash_handler): def _init_late_modules(args): """Initialize modules which can be inited after the window is shown.""" - try: - log.init.debug("Reading web history...") - reader = objreg.get('web-history').async_read() - with debug.log_time(log.init, 'Reading history'): - while True: - QApplication.processEvents() + log.init.debug("Reading web history...") + reader = objreg.get('web-history').async_read() + with debug.log_time(log.init, 'Reading history'): + while True: + QApplication.processEvents() + try: next(reader) - except StopIteration: - pass - except (OSError, UnicodeDecodeError) as e: - error.handle_fatal_exc(e, args, "Error while initializing!", - pre_text="Error while initializing") - sys.exit(usertypes.Exit.err_init) + except StopIteration: + break + except (OSError, UnicodeDecodeError) as e: + error.handle_fatal_exc(e, args, "Error while initializing!", + pre_text="Error while initializing") + sys.exit(usertypes.Exit.err_init) class Quitter: