Saturday, August 29, 2020

[fix] audio/beets - breakage from move to python 3.8

Hi,

Currently beets pukes when you try to run it. This is because of changes in the
python ast module that were backported to 3.8:

https://github.com/beetbox/beets/pull/3621

With this diff, I can run beet as expected.

OK?

Cheers,
Aaron

diff --git a/audio/beets/Makefile b/audio/beets/Makefile
index 7cabe18ef67..165afac23e0 100644
--- a/audio/beets/Makefile
+++ b/audio/beets/Makefile
@@ -5,7 +5,7 @@ COMMENT= CLI tools to manage music collections
MODPY_EGG_VERSION= 1.4.9
DISTNAME= beets-${MODPY_EGG_VERSION}
CATEGORIES= audio
-REVISION= 5
+REVISION= 6

HOMEPAGE= http://beets.io/

diff --git a/audio/beets/patches/patch-beets_util_functemplate_py b/audio/beets/patches/patch-beets_util_functemplate_py
new file mode 100644
index 00000000000..3d982a33fdb
--- /dev/null
+++ b/audio/beets/patches/patch-beets_util_functemplate_py
@@ -0,0 +1,44 @@
+$OpenBSD$
+
+Fix for python 3.8:
+ https://github.com/beetbox/beets/pull/3621
+
+Index: beets/util/functemplate.py
+--- beets/util/functemplate.py.orig
++++ beets/util/functemplate.py
+@@ -73,15 +73,26 @@ def ex_literal(val):
+ """An int, float, long, bool, string, or None literal with the given
+ value.
+ """
+- if val is None:
+- return ast.Name('None', ast.Load())
+- elif isinstance(val, six.integer_types):
+- return ast.Num(val)
+- elif isinstance(val, bool):
+- return ast.Name(bytes(val), ast.Load())
+- elif isinstance(val, six.string_types):
+- return ast.Str(val)
+- raise TypeError(u'no literal for {0}'.format(type(val)))
++ if sys.version_info[:2] < (3, 4):
++ if val is None:
++ return ast.Name('None', ast.Load())
++ elif isinstance(val, six.integer_types):
++ return ast.Num(val)
++ elif isinstance(val, bool):
++ return ast.Name(bytes(val), ast.Load())
++ elif isinstance(val, six.string_types):
++ return ast.Str(val)
++ raise TypeError(u'no literal for {0}'.format(type(val)))
++ elif sys.version_info[:2] < (3, 6):
++ if val in [None, True, False]:
++ return ast.NameConstant(val)
++ elif isinstance(val, six.integer_types):
++ return ast.Num(val)
++ elif isinstance(val, six.string_types):
++ return ast.Str(val)
++ raise TypeError(u'no literal for {0}'.format(type(val)))
++ else:
++ return ast.Constant(val)
+
+
+ def ex_varassign(name, expr):

No comments:

Post a Comment