From b757bc494af5762da0c79f913c721f4e4b72a4e9 Mon Sep 17 00:00:00 2001 From: Greg Kempe Date: Fri, 25 Sep 2020 08:55:17 +0200 Subject: [PATCH] Fix erroneous commit The -1 change was not correctly released. --- README.rst | 7 ++++++- VERSION | 2 +- cobalt/akn.py | 2 +- tests/test_structured_document.py | 5 ++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 36088e1..0cc4182 100644 --- a/README.rst +++ b/README.rst @@ -83,11 +83,16 @@ Cobalt is Copyright 2015-2020 AfricanLII. Change Log ---------- -4.0.1 +4.0.2 ..... - Better error handling when parsing malformed XML. +4.0.1 +..... + +(replaced by 4.0.2) + 4.0.0 ..... diff --git a/VERSION b/VERSION index 1454f6e..4d54dad 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.1 +4.0.2 diff --git a/cobalt/akn.py b/cobalt/akn.py index d1a3be9..d5bcff0 100644 --- a/cobalt/akn.py +++ b/cobalt/akn.py @@ -259,7 +259,7 @@ def parse(self, xml, document_type=None): if root.countchildren() < 1: raise ValueError("XML root element must have at least one child") - name = root.getchildren()[0].tag.split('}', 1)[1] + name = root.getchildren()[0].tag.split('}', 1)[-1] if name != self.document_type: raise ValueError(f"Expected {self.document_type} as first child of root element, but got {name} instead") diff --git a/tests/test_structured_document.py b/tests/test_structured_document.py index 7b0e612..929619b 100644 --- a/tests/test_structured_document.py +++ b/tests/test_structured_document.py @@ -596,7 +596,10 @@ def test_bad_xml(self): Act('no namespace') with self.assertRaises(ValueError): - Act('no namespace') + Act('no first child') + + with self.assertRaises(ValueError): + Act('no namespace') class JudgmentTestCase(TestCase):