diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-07-17 12:50:43 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-07-17 23:40:42 -0400 |
commit | 1070f974f7a1b6ba012e352b9d635d3902eca244 (patch) | |
tree | a405ab0a9c536da53b8b09e2425d9c63b86bca21 | |
parent | ce39bb6909578017aa10031638e724e038f0b859 (diff) |
systemd-python: fix iteration
Back in 6a58bf4135 raising stop iteration was removed from the C
code, but wasn't added in the Python counterpart.
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | src/python-systemd/journal.py | 24 |
2 files changed, 12 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac index 1cffbbb7e8..9095be7ca6 100644 --- a/configure.ac +++ b/configure.ac @@ -1005,7 +1005,6 @@ AC_MSG_RESULT([ nss-myhostname: ${have_myhostname} gudev: ${enable_gudev} gintrospection: ${enable_introspection} - keymap: ${enable_keymap} Python: ${have_python} Python Headers: ${have_python_devel} man pages: ${have_manpages} diff --git a/src/python-systemd/journal.py b/src/python-systemd/journal.py index 8fd1bb357c..adcc844f46 100644 --- a/src/python-systemd/journal.py +++ b/src/python-systemd/journal.py @@ -191,18 +191,18 @@ class Reader(_Reader): """ return self - if _sys.version_info >= (3,): - def __next__(self): - """Part of iterator protocol. - Returns self.get_next(). - """ - return self.get_next() - else: - def next(self): - """Part of iterator protocol. - Returns self.get_next(). - """ - return self.get_next() + def __next__(self): + """Part of iterator protocol. + Returns self.get_next() or raises StopIteration. + """ + ans = self.get_next() + if ans: + return ans + else: + raise StopIteration() + + if _sys.version_info < (3,): + next = __next__ def add_match(self, *args, **kwargs): """Add one or more matches to the filter journal log entries. |