diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 664a22a..1802b34 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.1.0 + rev: v2.4.1 hooks: - id: pyupgrade args: ["--py3-plus"] @@ -15,13 +15,13 @@ repos: types: [] - repo: https://gitlab.com/pycqa/flake8 - rev: 3.7.9 + rev: 3.8.0a2 hooks: - id: flake8 additional_dependencies: [flake8-2020, flake8-implicit-str-concat] - repo: https://github.com/asottile/seed-isort-config - rev: v2.1.0 + rev: v2.1.1 hooks: - id: seed-isort-config diff --git a/RELEASING.md b/RELEASING.md index 068ef1e..6842e8f 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -4,7 +4,8 @@ [Travis CI](https://travis-ci.org/pylast/pylast) should be running cleanly for all merges to master. -* [ ] Edit release draft, adjust text if needed: https://github.com/pylast/pylast/releases +* [ ] Edit release draft, adjust text if needed: + https://github.com/pylast/pylast/releases * [ ] Check next tag is correct, amend if needed diff --git a/src/pylast/__init__.py b/src/pylast/__init__.py index 8495c58..5ddab60 100644 --- a/src/pylast/__init__.py +++ b/src/pylast/__init__.py @@ -1142,7 +1142,12 @@ class _BaseObject: def _extract_cdata_from_request(self, method_name, tag_name, params): doc = self._request(method_name, True, params) - return doc.getElementsByTagName(tag_name)[0].firstChild.wholeText.strip() + first_child = doc.getElementsByTagName(tag_name)[0].firstChild + + if first_child is None: + return None + + return first_child.wholeText.strip() def _get_things(self, method, thing, thing_type, params=None, cacheable=True): """Returns a list of the most played thing_types by this thing.""" diff --git a/tests/test_artist.py b/tests/test_artist.py index 0e3843f..8837261 100755 --- a/tests/test_artist.py +++ b/tests/test_artist.py @@ -52,6 +52,17 @@ class TestPyLastArtist(TestPyLastWithLastFm): self.assertIsNotNone(bio) self.assertGreaterEqual(len(bio), 1) + def test_bio_content_none(self): + # Arrange + # An artist with no biography, with "" in the API XML + artist = pylast.Artist("Mr Sizef + Unquote", self.network) + + # Act + bio = artist.get_bio_content() + + # Assert + self.assertIsNone(bio) + def test_bio_summary(self): # Arrange artist = pylast.Artist("Test Artist", self.network)