chiark / gitweb /
systemd-python: fix iteration
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 17 Jul 2013 16:50:43 +0000 (12:50 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 18 Jul 2013 03:40:42 +0000 (23:40 -0400)
Back in 6a58bf4135 raising stop iteration was removed from the C
code, but wasn't added in the Python counterpart.

configure.ac
src/python-systemd/journal.py

index 1cffbbb7e8d40cb01cccee00644db45b3a0c6758..9095be7ca6d839c350b3416e29a42eae86905f21 100644 (file)
@@ -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}
index 8fd1bb357c199bb32e488d17ffef08f204a65011..adcc844f465abbb837b39d7e1e996ffc216bdfce 100644 (file)
@@ -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.