!9 Fix compatibility with python 3.8.4
From: @zhang-liang-pengkun Reviewed-by: @Charlie_li Signed-off-by: @Charlie_li
This commit is contained in:
commit
69b7174e99
61
Fix-compatibility-with-python-3.8.4.patch
Normal file
61
Fix-compatibility-with-python-3.8.4.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 9b913229ace838958e51a16cabc41905a2460f7b Mon Sep 17 00:00:00 2001
|
||||
From: Conrad Kostecki <conrad@kostecki.com>
|
||||
Date: Tue, 25 Aug 2020 00:24:53 +0200
|
||||
Subject: [PATCH] Fix compatibility with >=python-3.8.4
|
||||
|
||||
Signed-off-by: Conrad Kostecki <conrad@kostecki.com>
|
||||
---
|
||||
xdg/Menu.py | 16 ++++++++++++++--
|
||||
1 file changed, 14 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/xdg/Menu.py b/xdg/Menu.py
|
||||
index 1d03cad..ee406bd 100644
|
||||
--- a/xdg/Menu.py
|
||||
+++ b/xdg/Menu.py
|
||||
@@ -21,6 +21,7 @@ import os
|
||||
import locale
|
||||
import subprocess
|
||||
import ast
|
||||
+import sys
|
||||
try:
|
||||
import xml.etree.cElementTree as etree
|
||||
except ImportError:
|
||||
@@ -35,6 +36,17 @@ import xdg.Locale
|
||||
import xdg.Config
|
||||
|
||||
|
||||
+def _ast_const(name):
|
||||
+ 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.
|
||||
|
||||
@@ -754,7 +766,7 @@ class XMLMenuBuilder(object):
|
||||
if expr:
|
||||
tree.body = expr
|
||||
else:
|
||||
- tree.body = ast.Name('False', ast.Load())
|
||||
+ tree.body = _ast_const('False')
|
||||
ast.fix_missing_locations(tree)
|
||||
return Rule(type, tree)
|
||||
|
||||
@@ -781,7 +793,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(
|
||||
--
|
||||
2.39.0.windows.2
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
Name: pyxdg
|
||||
Version: 0.26
|
||||
Release: 4
|
||||
Release: 5
|
||||
Summary: Python library to access freedesktop APIs
|
||||
License: LGPLv2
|
||||
URL: http://freedesktop.org/Software/pyxdg
|
||||
Source0: https://pypi.io/packages/source/P/PyXDG/pyxdg-%{version}.tar.gz
|
||||
Patch0: Fix-several-ResourceWarnings-unclosed-file.patch
|
||||
Patch1: Fix-compatibility-with-python-3.8.4.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
@ -47,6 +48,9 @@ nosetests-%{python3_version} || :
|
||||
%{python3_sitelib}/pyxdg-*.egg-info
|
||||
|
||||
%changelog
|
||||
* Tue Jan 17 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.26-5
|
||||
- Fix-compatibility-with-python-3.8.4.patch
|
||||
|
||||
* Fri Jan 13 2023 zhangliangpengkun<zhangliangpengkun@xfusion.com> - 0.26-4
|
||||
- Fix several ResourceWarnings: unclosed file
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user