Package: pyxdg
Version: 0.26-3
Followup-For: Bug #964609
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu groovy ubuntu-patch

Dear Maintainer,

While reviewing GCC10 FTBFS with ubuntu 20.10 Groovy, I worked on pyxdg failure.
After reproducing the failure in a sbuild environment I noticed that this wasn't
a ftbfs issue but more likely an issue introduced with python 3.8.4

In Python 3.8.4 rc1, Custom AST constant naming became more strict and raised 
ValueError when True, False and Node are used within a ast.Name node [1]

After some research I found a similar issue reported here [2] and inspired from
it to write a solution for pyxdg

This patch has been submitted for groovy and is in proposed. This test failure
was also blocking nose to migrate from proposed which shoudl now be able to 
migrate to groovy devel

  * Fix compatibility issue with python 3.8.4 (Closes: #964609, #968399)

Thanks for considering the patch.

Matthieu

[1] https://bugs.python.org/issue40870
[2] https://github.com/nestorsalceda/mamba/pull/151

-- System Information:
Debian Release: bullseye/sid
  APT prefers focal-updates
  APT policy: (500, 'focal-updates'), (500, 'focal-security'), (500, 'focal'), 
(100, 'focal-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.4.0-42-generic (SMP w/8 CPU cores)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru pyxdg-0.26/debian/patches/python384compat.diff 
pyxdg-0.26/debian/patches/python384compat.diff
--- pyxdg-0.26/debian/patches/python384compat.diff      1969-12-31 
18:00:00.000000000 -0600
+++ pyxdg-0.26/debian/patches/python384compat.diff      2020-08-12 
17:41:44.000000000 -0500
@@ -0,0 +1,57 @@
+Description: Fix Pytyhon 3.8.4 compatibility Issue
+ Starting with Python 3.8.4 rc1, Custom AST constant naming became more strict 
+ and raised ValueError when True, False and Noe are used within a ast.Name 
node 
+ Solution inspired from https://github.com/nestorsalceda/mamba/pull/151 
+Author: Matthieu Clemenceau <matthieu.clemenc...@canonical.com>
+Origin: vendor
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=964609
+Last-Update: 2020-08-17
+
+--- pyxdg-0.26.orig/xdg/Menu.py
++++ pyxdg-0.26/xdg/Menu.py
+@@ -21,6 +21,8 @@ import os
+ import locale
+ import subprocess
+ import ast
++import sys
++
+ try:
+     import xml.etree.cElementTree as etree
+ except ImportError:
+@@ -34,6 +36,17 @@ from xdg.util import PY3
+ import xdg.Locale
+ import xdg.Config
+ 
++def _ast_const(name):
++    # fixes compat issue with python 3.8.4+
++    # c.f https://github.com/pytest-dev/pytest/issues/7322
++    if sys.version_info >= (3, 4):
++        name = ast.literal_eval(name)
++        if sys.version_info >= (3, 8):
++            return ast.Constant(name)
++        else:
++            return ast.NameConstant(name)
++    else:
++        return ast.Name(id=name, ctx=ast.Load())
+ 
+ def _strxfrm(s):
+     """Wrapper around locale.strxfrm that accepts unicode strings on Python 2.
+@@ -763,7 +776,8 @@ class XMLMenuBuilder(object):
+         if expr:
+             tree.body = expr
+         else:
+-            tree.body = ast.Name('False', ast.Load())
++            #tree.body = ast.Name('False', ast.Load())
++            tree.body = _ast_const('False')
+         ast.fix_missing_locations(tree)
+         return Rule(type, tree)
+ 
+@@ -790,7 +804,7 @@ class XMLMenuBuilder(object):
+             expr = self.parse_bool_op(node, ast.Or())
+             return ast.UnaryOp(ast.Not(), expr) if expr else None
+         elif tag == 'All':
+-            return ast.Name('True', ast.Load())
++            return _ast_const('True')
+         elif tag == 'Category':
+             category = node.text
+             return ast.Compare(
diff -Nru pyxdg-0.26/debian/patches/series pyxdg-0.26/debian/patches/series
--- pyxdg-0.26/debian/patches/series    2020-03-27 09:30:55.000000000 -0500
+++ pyxdg-0.26/debian/patches/series    2020-08-12 17:41:44.000000000 -0500
@@ -2,3 +2,4 @@
 set-default-menu.patch
 gettext-support.patch
 test_mime_skip_symlink.patch
+python384compat.diff

Reply via email to