RulesTest.test_rule_from_node in test/test-menu-rules.py fails with Python 3.8.4
[ 12s] + PYTHONPATH=/home/abuild/rpmbuild/BUILDROOT/python-pyxdg-0.26-0.x86_64/usr/lib/python3.8/site-packages
[ 12s] + pytest-3.8 test/test-basedirectory.py test/test-desktop.py test/test-icon.py test/test-inifile.py test/test-locale.py test/test-menu-rules.py test/test-menu.py test/test-mime.py test/test-recentfiles.py -v -k 'not test_get_type'
[ 13s] ============================= test session starts ==============================
[ 13s] platform linux -- Python 3.8.4, pytest-5.4.3, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3
[ 13s] cachedir: .pytest_cache
[ 13s] rootdir: /home/abuild/rpmbuild/BUILD/pyxdg-0.26
[ 13s] collecting ... collected 55 items / 5 deselected / 50 selected
...
[ 17s] =================================== FAILURES ===================================
[ 17s] ________________________ RulesTest.test_rule_from_node _________________________
[ 17s]
[ 17s] self = <test-menu-rules.RulesTest testMethod=test_rule_from_node>
[ 17s]
[ 17s] def test_rule_from_node(self):
[ 17s] parser = XMLMenuBuilder(debug=True)
[ 17s] for i, test in enumerate(_tests):
[ 17s] root = etree.fromstring(test['doc'])
[ 17s] > rule = parser.parse_rule(root)
[ 17s]
[ 17s] test/test-menu-rules.py:166:
[ 17s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 17s] ../../BUILDROOT/python-pyxdg-0.26-0.x86_64/usr/lib/python3.8/site-packages/xdg/Menu.py:759: in parse_rule
[ 17s] return Rule(type, tree)
[ 17s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[ 17s]
[ 17s] self = <xdg.Menu.Rule object at 0x7f4122167610>, type = 0
[ 17s] expression = <_ast.Expression object at 0x7f4122270e20>
[ 17s]
[ 17s] def __init__(self, type, expression):
[ 17s] # Type is TYPE_INCLUDE or TYPE_EXCLUDE
[ 17s] self.Type = type
[ 17s] # expression is ast.Expression
[ 17s] self.expression = expression
[ 17s] > self.code = compile(self.expression, '<compiled-menu-rule>', 'eval')
[ 17s] E ValueError: Name node can't be used with 'False' constant
[ 17s]
[ 17s] ../../BUILDROOT/python-pyxdg-0.26-0.x86_64/usr/lib/python3.8/site-packages/xdg/Menu.py:421: ValueError
Failre happens with this node:
{'doc': '<Include></Include>',
'data': [('app0.desktop', ['Graphics', 'Settings'], False),
('screenreader.desktop', [], False)]}
parser.parse_rule
is:
def parse_rule(self, node):
type = Rule.TYPE_INCLUDE if node.tag == 'Include' else Rule.TYPE_EXCLUDE
tree = ast.Expression(lineno=1, col_offset=0)
expr = self.parse_bool_op(node, ast.Or())
if expr:
tree.body = expr
else:
tree.body = ast.Name('False', ast.Load())
ast.fix_missing_locations(tree)
return Rule(type, tree)
It seems that the rules for compile()
are now stricter than they were in 3.8.3, where this tests passed.
Edited by Thomas Kluyver