summaryrefslogtreecommitdiff
path: root/systemd
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-07-17 12:50:43 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-07-05 14:19:20 -0400
commit2c0317be82aa85911fe7665719d0139ee4330211 (patch)
tree11bb1cc5a90bb794260ca14639cf1bd0dab8dc3e /systemd
parentd9a07b11ea52bb0c9a52b980394bf851fcc8767e (diff)
downloadpython-systemd-2c0317be82aa85911fe7665719d0139ee4330211.tar.gz
systemd-python: fix iteration
Back in 6a58bf4135 raising stop iteration was removed from the C code, but wasn't added in the Python counterpart.
Diffstat (limited to 'systemd')
-rw-r--r--systemd/journal.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/systemd/journal.py b/systemd/journal.py
index 8fd1bb3..adcc844 100644
--- a/systemd/journal.py
+++ b/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.