Skip to content

Commit 1605d32

Browse files
committed
chore: Further remove Python 2 compat hacks
1 parent 25e841a commit 1605d32

5 files changed

Lines changed: 8 additions & 45 deletions

File tree

COPYING

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,3 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2121
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2222
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
2323
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24-
25-
26-
The license for the file `musicbrainzngs/compat.py` is
27-
28-
Copyright (c) 2012 Kenneth Reitz.
29-
30-
Permission to use, copy, modify, and/or distribute this software for any
31-
purpose with or without fee is hereby granted, provided that the above
32-
copyright notice and this permission notice appear in all copies.
33-
34-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
35-
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
36-
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
37-
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
38-
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
39-
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
40-
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

musicbrainzngs/compat.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,5 @@
1-
# Copyright (c) 2012 Kenneth Reitz.
2-
3-
# Permission to use, copy, modify, and/or distribute this software for any
4-
# purpose with or without fee is hereby granted, provided that the above
5-
# copyright notice and this permission notice appear in all copies.
6-
7-
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8-
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9-
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10-
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11-
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12-
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
13-
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14-
15-
"""pythoncompat"""
16-
import sys
171
from http.client import BadStatusLine, HTTPException
182
from io import StringIO
193
from urllib.error import HTTPError, URLError
204
from urllib.parse import quote_plus, urlencode, urlunparse
215
from urllib.request import HTTPDigestAuthHandler, HTTPHandler, HTTPPasswordMgr, Request, build_opener
22-
23-
unicode = str
24-
bytes = bytes
25-
basestring = (str,bytes)

musicbrainzngs/musicbrainz.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,9 @@ def _check_filter_and_make_params(entity, includes, release_status=[], release_t
253253
the filters can be used with the given includes. Return a params
254254
dict that can be passed to _do_mb_query.
255255
"""
256-
if isinstance(release_status, compat.basestring):
256+
if isinstance(release_status, (str,bytes)):
257257
release_status = [release_status]
258-
if isinstance(release_type, compat.basestring):
258+
if isinstance(release_type, (str,bytes)):
259259
release_type = [release_type]
260260
_check_filter(release_status, VALID_RELEASE_STATUSES)
261261
_check_filter(release_type, VALID_RELEASE_TYPES)
@@ -640,7 +640,7 @@ def _mb_request(path, method='GET', auth_required=AUTH_NO,
640640
# Encode Unicode arguments using UTF-8.
641641
newargs = []
642642
for key, value in sorted(args.items()):
643-
if isinstance(value, compat.unicode):
643+
if isinstance(value, str):
644644
value = value.encode('utf8')
645645
newargs.append((key, value))
646646

musicbrainzngs/util.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,24 @@ def _unicode(string, encoding=None):
1515
This can only be a guess, but this might be better than failing.
1616
It is safe to use this on numbers or strings that are already unicode.
1717
"""
18-
if isinstance(string, compat.unicode):
18+
if isinstance(string, str):
1919
unicode_string = string
20-
elif isinstance(string, compat.bytes):
20+
elif isinstance(string, bytes):
2121
# use given encoding, stdin, preferred until something != None is found
2222
if encoding is None:
2323
encoding = sys.stdin.encoding
2424
if encoding is None:
2525
encoding = locale.getpreferredencoding()
2626
unicode_string = string.decode(encoding, "ignore")
2727
else:
28-
unicode_string = compat.unicode(string)
28+
unicode_string = str(string)
2929
return unicode_string.replace('\x00', '').strip()
3030

3131
def bytes_to_elementtree(bytes_or_file):
3232
"""Given a bytestring or a file-like object that will produce them,
3333
parse and return an ElementTree.
3434
"""
35-
if isinstance(bytes_or_file, compat.basestring):
35+
if isinstance(bytes_or_file, (str,bytes)):
3636
s = bytes_or_file
3737
else:
3838
s = bytes_or_file.read()

test/_common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def open(self, request, body=None):
2727
if self.exception:
2828
raise self.exception
2929

30-
if isinstance(self.response, compat.unicode):
30+
if isinstance(self.response, str):
3131
return StringIO.StringIO(self.response)
3232
else:
3333
return BytesIO(self.response)

0 commit comments

Comments
 (0)