From 73a7723a156d7221d5ac8fee55493051891df837 Mon Sep 17 00:00:00 2001 From: Andrew Simmons Date: Wed, 6 Jan 2021 10:33:50 -0500 Subject: [PATCH 1/2] Add python version check --- beetsplug/mpdstats.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/beetsplug/mpdstats.py b/beetsplug/mpdstats.py index 39b045f9b..599aa7631 100644 --- a/beetsplug/mpdstats.py +++ b/beetsplug/mpdstats.py @@ -18,6 +18,7 @@ from __future__ import division, absolute_import, print_function import mpd import socket import select +import sys import time import os @@ -52,7 +53,13 @@ class MPDClientWrapper(object): self.music_directory = ( mpd_config['music_directory'].as_str()) - self.client = mpd.MPDClient(use_unicode=True) + if sys.version_info < (3, 0): + # On Python 2, use_unicode will enable the utf-8 mode for + # python-mpd2 + self.client = mpd.MPDClient(use_unicode=True) + else: + # On Python 3, python-mpd2 always uses Unicode + self.client = mpd.MPDClient() def connect(self): """Connect to the MPD. From 3117cc0d318428b079c965d62319ed663236e9eb Mon Sep 17 00:00:00 2001 From: Andrew Simmons Date: Wed, 6 Jan 2021 10:52:18 -0500 Subject: [PATCH 2/2] Update changelog --- docs/changelog.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog.rst b/docs/changelog.rst index ce445496e..dd8e08ca2 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -293,6 +293,8 @@ Fixes: :bug:`2242` * :doc:`plugins/replaygain`: Disable parallel analysis on import by default. :bug:`3819` +* :doc:`/plugins/mpdstats`: Fix Python 2/3 compatibility + :bug:`3798` For plugin developers: