pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/56378: audio/py-beets gives a stack trace at startup



>Number:         56378
>Category:       pkg
>Synopsis:       audio/py-beets gives a stack trace at startup
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 28 20:20:00 +0000 2021
>Originator:     Onno van der Linden
>Release:        NetBSD 9.99.80
>Organization:
>Environment:
System: NetBSD sheep 9.99.80 NetBSD 9.99.80 (SHEEPKMS) #1: Thu Mar 4 19:16:39 CET 2021 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEPKMS i386
Architecture: i386
Machine: i386
>Description:
Running /usr/pkg/bin-beets-3.8 gives a stack trace ending in

ValueError: Name node can't be used with 'None' constant
>How-To-Repeat:
Install audio/py-beets with a recent python version
>Fix:

Until 1.5.0 gets imported the appended diff from

https://github.com/beetbox/beets/commit/a3044be81b164e96094db4f196ba9b1886295937

seems to work


--- beets/util/functemplate.py.orig	2019-05-31 01:31:09.000000000 +0200
+++ beets/util/functemplate.py	2021-08-28 20:11:08.566230310 +0200
@@ -73,15 +73,26 @@
     """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):



Home | Main Index | Thread Index | Old Index