From 1070f974f7a1b6ba012e352b9d635d3902eca244 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Wed, 17 Jul 2013 12:50:43 -0400 Subject: systemd-python: fix iteration Back in 6a58bf4135 raising stop iteration was removed from the C code, but wasn't added in the Python counterpart. --- src/python-systemd/journal.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') 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. -- cgit v1.2.3-54-g00ecf