# HG changeset patch # User Paul Boddie # Date 1555334020 -7200 # Node ID 37e672f4923f3d045b57741f18c03f17bee00f04 # Parent f3b5a5025b28966ce77bb3fe87032ecf9e312ed5 Handle regions with directives but no content. diff -r f3b5a5025b28 -r 37e672f4923f moinformat/parsers/common.py --- a/moinformat/parsers/common.py Mon Apr 15 15:13:17 2019 +0200 +++ b/moinformat/parsers/common.py Mon Apr 15 15:13:40 2019 +0200 @@ -3,7 +3,7 @@ """ Moin wiki parsing functionality. -Copyright (C) 2017, 2018 Paul Boddie +Copyright (C) 2017, 2018, 2019 Paul Boddie This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -393,22 +393,28 @@ the 'region' object. """ - while True: - preceding = self.read_until(["directive"], False) + try: + while True: + preceding = self.read_until(["directive"], False) - # With an immediately-appearing directive, handle its details. + # With an immediately-appearing directive, handle its details. - if preceding == "": - handler = self.handlers.get(self.matching_pattern()) - if handler: - handler(self, region) + if preceding == "": + handler = self.handlers.get(self.matching_pattern()) + if handler: + handler(self, region) + else: + break + + # Otherwise, with no immediate directive (or none at all), stop. + else: break - # Otherwise, with no immediate directive (or none at all), stop. + # Handle a premature end of region. - else: - break + except StopIteration: + pass # Parsing utilities.