From b55949536650a66e996a99428fead672c6ac93e7 Mon Sep 17 00:00:00 2001 From: hugovk Date: Fri, 20 Oct 2017 00:51:34 +0300 Subject: [PATCH] Assume no illegal XML and no more skipping broken Last.fm --- pylast/__init__.py | 15 --------------- tests/test_pylast.py | 5 ----- tests/test_pylast_network.py | 14 -------------- tests/test_pylast_user.py | 1 - 4 files changed, 35 deletions(-) diff --git a/pylast/__init__.py b/pylast/__init__.py index df23ad6..3d1a219 100644 --- a/pylast/__init__.py +++ b/pylast/__init__.py @@ -22,7 +22,6 @@ from xml.dom import minidom, Node import collections -import re import hashlib import shelve import six @@ -108,18 +107,6 @@ SCROBBLE_MODE_LOVED = "L" SCROBBLE_MODE_BANNED = "B" SCROBBLE_MODE_SKIPPED = "S" -# From http://boodebr.org/main/python/all-about-python-and-unicode#UNI_XML -RE_XML_ILLEGAL = (u'([\u0000-\u0008\u000b-\u000c\u000e-\u001f\ufffe-\uffff])' + - u'|' + - u'([%s-%s][^%s-%s])|([^%s-%s][%s-%s])|([%s-%s]$)|(^[%s-%s])' - % - (unichr(0xd800), unichr(0xdbff), unichr(0xdc00), - unichr(0xdfff), unichr(0xd800), unichr(0xdbff), - unichr(0xdc00), unichr(0xdfff), unichr(0xd800), - unichr(0xdbff), unichr(0xdc00), unichr(0xdfff))) - -XML_ILLEGAL = re.compile(RE_XML_ILLEGAL) - # Python >3.4 and >2.7.9 has sane defaults SSL_CONTEXT = ssl.create_default_context() @@ -862,8 +849,6 @@ class _Request(object): except Exception as e: raise MalformedResponseError(self.network, e) - response_text = XML_ILLEGAL.sub("?", response_text) - self._check_response_for_errors(response_text) conn.close() return response_text diff --git a/tests/test_pylast.py b/tests/test_pylast.py index 9279112..9ebbcc1 100755 --- a/tests/test_pylast.py +++ b/tests/test_pylast.py @@ -52,11 +52,6 @@ class PyLastTestCase(unittest.TestCase): api_key=API_KEY, api_secret=API_SECRET, username=self.username, password_hash=password_hash) - def skip_if_lastfm_api_broken(self, value): - """Skip things not yet restored in Last.fm's broken API""" - if value is None or len(value) == 0: - pytest.skip("Last.fm API is broken.") - def helper_is_thing_hashable(self, thing): # Arrange things = set() diff --git a/tests/test_pylast_network.py b/tests/test_pylast_network.py index 7ea6432..733a80e 100755 --- a/tests/test_pylast_network.py +++ b/tests/test_pylast_network.py @@ -47,20 +47,6 @@ class TestPyLastNetwork(PyLastTestCase): self.assertEqual(str(current_track.title), "test title") self.assertEqual(str(current_track.artist), "Test Artist") - def test_invalid_xml(self): - # Arrange - # Currently causes PCDATA invalid Char value 25 - artist = "Blind Willie Johnson" - title = "It's nobody's fault but mine" - - # Act - search = self.network.search_for_track(artist, title) - total = search.get_total_result_count() - - # Assert - self.skip_if_lastfm_api_broken(total) - self.assertGreaterEqual(int(total), 0) - def test_enable_rate_limiting(self): # Arrange self.assertFalse(self.network.is_rate_limited()) diff --git a/tests/test_pylast_user.py b/tests/test_pylast_user.py index 53bb1fc..66beb40 100755 --- a/tests/test_pylast_user.py +++ b/tests/test_pylast_user.py @@ -218,7 +218,6 @@ class TestPyLastUser(PyLastTestCase): tags = user.get_top_tags(limit=1) # Assert - self.skip_if_lastfm_api_broken(tags) self.helper_only_one_thing_in_top_list(tags, pylast.Tag) def test_user_top_tracks(self):